如何将5*3**n/6重写为5/2*3**(n-1):我想要字符串ok



我想使用序列

我想要字符串ok

5*3**n/6 ---> 5/2*3**(n-1)

我尝试

from sympy import *
var('n')
f=5  *3**n/6
g=5/2*3**(n-1)
print("#",f,simplify(f))
print("#",g,simplify(g))
# 5*3**n/6       5*3**n/6
# 2.5*3**(n - 1) 0.833333333333333*3**n

(2022-02-11(

https://docs.sympy.org/latest/tutorial/simplification.html#powsimp

>>> from sympy import powsimp
>>> powsimp(5*3**n/6)
5*3**(n - 1)/2

最新更新