Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import *
- from numpy import *
- from matplotlib.pylab import *
- def g(x, n):
- s = 0
- for j in range(n+1):
- s += ((-1)**j *x**(2*j+1.0))/factorial(2*j + 1)
- return s
- x = linspace(0, 4*pi, 20)
- n_list = (1, 2, 3, 6, 12)
- for n in n_list:
- plot(x, g(x, n))
- plot (x,sin(x))
- ylabel ("f(x, n)")
- xlabel ("x")
- ylim(-5,5)
- legend (["((-1)**j *x**(2*j+1))/factorial(2*j + 1)", "sin(x)"])
- show()
Add Comment
Please, Sign In to add comment