Found an interesting simple approximation for the integral of a function
|
06-15-2021, 09:16 PM
(This post was last modified: 06-18-2021 03:13 AM by Namir.)
Post: #1
|
|||
|
|||
Found an interesting simple approximation for the integral of a function
Hi,
I found in the 9th edition of "Numerical Analysis" by Burden & Faires, a question (number 16) on page 202 about estimating an integral using: Integral of f(x) from a to b = 9/4*h*f(x1) + 3/4*h*f(x2) Where h = (b-a)/3, x1 = a + h, and x2 = b. You can divide your interval (A, B) into a series of small (a, b) and reuse the above equation. Here is a Python implementation that uses the above equation is a series of small intervals: Code: from math import * The output is: Code: Area= 4.605170176738395 Does anyone know about this rather unusual algorithm? Namir |
|||
06-18-2021, 12:01 AM
Post: #2
|
|||
|
|||
RE: Found an interesting simple approximation for the integral of a function
The geometry seems to fit a trapezoid so I'd guess the rule is quadratic. I did plug in various values for general polynomials (X^k is sufficient) and used (the interval 0 to 1 is sufficient) and tried various values of k. If I did it correctly (not guaranteed, of course), X^2 would be integrated correctly but not X^3. The midpoint rule and composite trapezoidal rules do the same for fewer function evaluations.
|
|||
06-18-2021, 12:52 AM
(This post was last modified: 06-18-2021 11:53 AM by Albert Chan.)
Post: #3
|
|||
|
|||
RE: Found an interesting simple approximation for the integral of a function
(06-15-2021 09:16 PM)Namir Wrote: Integral of f(x) from a to b = 9/4*h*f(x1) + 3/4*h*f(x2) If we extend for more intervals, we have weight of 0301301301301 ... Flip the limits, integrating from right to left, weight also flipped 1031031031031 ... ∫(f(x), x=a .. b) = ∫(f(x) + f(a+b-x), x=a .. b)/2 RHS folded integral, we add the weights: 1332332332332 ... Folded integral is Simpson's 3/8 rule |
|||
06-18-2021, 05:13 AM
(This post was last modified: 06-18-2021 05:15 AM by Namir.)
Post: #4
|
|||
|
|||
RE: Found an interesting simple approximation for the integral of a function
I was curious about the name of the algorithm, since the book authors just tossed the equation in one of their questions without giving it a name. I do recognize that it is a variant of teh trapezoidal integration. I was curious that it calculated fx(x) at the end of the interval b and at x= a +(b-a)/3, giving that point more weight.
In the absence of a name, I am calling this type of algorithm, the Quasi Trapezoidal method. I reversed the weights calculating fx(x) at a and at b-(b-a)/3. Here is the updated Micro Python code, for bother versions, that I ran on a TI NSpire emulator: Code: from math import * The output is: Code:
Shows that both versions, as expected, give close results. |
|||
06-18-2021, 12:08 PM
Post: #5
|
|||
|
|||
RE: Found an interesting simple approximation for the integral of a function | |||
06-18-2021, 01:29 PM
(This post was last modified: 06-18-2021 05:12 PM by Namir.)
Post: #6
|
|||
|
|||
RE: Found an interesting simple approximation for the integral of a function
(06-18-2021 12:08 PM)Albert Chan Wrote:(06-18-2021 05:13 AM)Namir Wrote: In the absence of a name, I am calling this type of algorithm, the Quasi Trapezoidal method. Sounds like you are talking about combining the two versions of the Quasi-Trapezoidal method to end up with a four-point Quasi Simpson 3/8 method[. I went ahead and combined the two versions Quasi Trapezoidal methods and indeed came out with something that looks like SImpsin's 3/8 rule. Here is the Mini Python code for the whole thing: Code: from math import * The output is: Code:
Showing that the Quasi Simpson 3/8 does better than the other two methods, as expected. Namir |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)