-
-
Save anthonymorast/8699e1aa1990cfcbf179cb15650514c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def approximate_integral(self, x0, x1): | |
""" | |
Estimates the definite integral of the function using the Taylor series expansion. | |
x0 - lower limit of integration | |
x1 - upper limit of integration | |
""" | |
# integrals can be off by a constant since int(f(x)) = F(x) + C | |
value = 0 | |
for i in range(len(self.coefficients)): | |
value += ((self.coefficients[i] * (1/(i+1)) * ((x1 - self.center)**(i+1))) - | |
(self.coefficients[i] * (1/(i+1)) * ((x0 - self.center)**(i+1)))) # integrate each term: x^n => (1/n+1)*x^(n+1) | |
return value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment