From f6d0b85283865affa42a410d0b96884c85550f7f Mon Sep 17 00:00:00 2001 From: Jackie Date: Tue, 12 Sep 2017 14:17:44 -0400 Subject: [PATCH] Taylor Series Update --- TaylorSeries.py | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/TaylorSeries.py b/TaylorSeries.py index 3583fdc..f621b99 100644 --- a/TaylorSeries.py +++ b/TaylorSeries.py @@ -28,27 +28,3 @@ def taylor(function,x0,n): i += 1 return p print(taylor(cos(x),0,5)) -def plot(): - x_lims = [-5,5] - x1 = np.linspace(x_lims[0],x_lims[1],800) - y1 = [] - # Approximate up until 10 starting from 1 and using steps of 2 - for j in range(1,10,2): - func = taylor(f,0,j) - print('Taylor expansion at n='+str(j),func) - for k in x1: - y1.append(func.subs(x,k)) - plt.plot(x1,y1,label='order '+str(j)) - y1 = [] - # Plot the function to approximate (sine, in this case) - plt.plot(x1,np.sin(x1),label='sin of x') - plt.xlim(x_lims) - plt.ylim([-5,5]) - plt.xlabel('x') - plt.ylabel('y') - plt.legend() - plt.grid(True) - plt.title('Taylor series approximation') - plt.show() - -#plot()