From 38552bf73966bb2bd610dbb555879dea2e77d36a Mon Sep 17 00:00:00 2001 From: Jackie Date: Tue, 12 Sep 2017 14:14:59 -0400 Subject: [PATCH] Taylor Series Update --- TaylorSeries.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/TaylorSeries.py b/TaylorSeries.py index 1fe5818..3583fdc 100644 --- a/TaylorSeries.py +++ b/TaylorSeries.py @@ -17,6 +17,9 @@ def factorial(n): return n*factorial(n-1) # Taylor approximation at x0 of the function 'function' +# Since I'm still having difficulting getting this to work, I can just create individual functions for each equation (since I don't need the whole thing). +#Make sure you create a function estimating the upper bound error + def taylor(function,x0,n): i = 0 p = 0 @@ -24,6 +27,7 @@ def taylor(function,x0,n): p = p + (function.diff(x,i).subs(x,x0))/(factorial(i))*(x-x0)**i 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) @@ -47,4 +51,4 @@ def plot(): plt.title('Taylor series approximation') plt.show() -plot() +#plot()