I'm trying to use sympy to compute Taylor series, but something seems to be wrong.
I have an expression that looks like this (the first two terms of e^sin(x)):
e**sin(x)*x*log(e)*cos(x) + 1.0
but when I run evalf on it it returns the expression itself:
x=symbols('x')
print(sympify('e**sin(x)*x*log(e)*cos(x) + 1.0').evalf(subs={x:1}))
# returns e**sin(x)*x*log(e)*cos(x) + 1.0
This happens regardless of what value for x I pick
Use E
for the Euler number:
In [18]: x=symbols('x')
...: print(sympify('E**sin(x)*x*log(E)*cos(x) + 1.0').evalf(subs={x:1}))
2.25338076749345
Alternatively use e.g. exp(sin(x))
rather than E**sin(x)
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments