1

sympy 中是否有将 sinh(x)+cosh(x) 简化为 exp(x) 的命令?如果我发出

from sympy import *
x = Symbol('x')
(sinh(x)+cosh(x)).simplify()

我只是得到 sinh(x)+cosh(x) 回来,但我想看到 exp(x) 。

4

1 回答 1

3

Even assuming that the simplify function in sympy was very good, what you suggest may not have worked, because what is "simple" is not rigorously defined.

I think what you want is the functionality present in .rewrite:

In [1]: (sinh(x)+cosh(x)).rewrite(exp)
Out[1]: 
 x
e 

You can use .rewrite for many other transformations including gamma <-> combinatorics and inverse trig <-> logarithms.

于 2012-06-18T09:46:44.220 回答