Skip to content

Instantly share code, notes, and snippets.

@anthonymorast
Created October 3, 2021 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonymorast/298b43ad65a412afa620af7cb83c81d1 to your computer and use it in GitHub Desktop.
Save anthonymorast/298b43ad65a412afa620af7cb83c81d1 to your computer and use it in GitHub Desktop.
def approximate_derivative(self, x):
"""
Estimates the derivative of a function f(x) from its Taylor series.
Useless since we need the derivative of the actual function to find the series
"""
value = 0
for i in range(1, len(self.coefficients)): # skip the first value (constant) as the derivative is 0
value += self.coefficients[i] * i * ((x - self.center)**(i-1)) # differentiate each term: x^n => n*x^(n-1)
return value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment