Dddduuu
Dddduuu

Reputation: 13

Having trouble with computing Taylor Series with python Sympy

I want to compute the first 3 Taylor series for the function: f(x) = e^{-x^2} \sin( x - \pi).
I write like this. But got an error message: cannot convert expression to float. How can I fix this?

import sympy
import math
sympy.init_printing(pretty_print=True)
x = sympy.Symbol('x')
f = math.exp(-x**2)*sin(x-(math.pi))
f.series(x0=math.pi, n=3)

Upvotes: 1

Views: 165

Answers (1)

You're using math methods instead of sympy methods. Try:

f = sympy.exp(-x**2)*sympy.sin(x-(sympy.pi))

Upvotes: 1

Related Questions