New Quadratic Integration
|
05-30-2018, 01:39 PM
Post: #1
|
|||
|
|||
New Quadratic Integration
If you are familiar with the basic Simpson's rule, you know that it integrates f(x) in an interval (a, b). This algorithm calculates f(x) at a, b, and (a+b)/2. In other words, the Simpson's rule samples f(x) at midpoint of (a, b). Typically, we use the chained version of Simpson's rule, where we use multiple equidistant values of x to calculate the integral.
I decided to develop a similar algorithm that calculates the integral of f(x) for the interval (a, b). Instead of calculating f((a + b)/2), I decided to determine the value of x=m where f(m) = (f(a) + f(b)) / 2. In other words, I seek the value of x where f(x) is the average of f(a) and f(b). The first step is to perform a simple inverse Lagrangian interpolation to calculate m. Then perform an analytical integration for the Lagrangian polynomial that passes through (a, f(a), (m, f(m), and (b, f(b)). Here is the pseudo-code for the algorithm: Quote:Given a, b, and function f(x). Here is an implementation of the function Area in Excel VBA: Quote:Function f(ByVal X As Double) As Double The parameters for function Area are: 1) A and B that define the integration interval. 2) N is the number of divisions within the integration intervl. Can be any positive value. I tested the above code with f(x)=x and f(x)=1/x and obtained good results. My rational behind this algorithm is the integration of function that experience steep changes. That i why I seek the value of x=m instead of x+(a+b)/2. Enjoy! Namir |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
New Quadratic Integration - Namir - 05-30-2018 01:39 PM
RE: New Quadratic Integration - Dieter - 05-30-2018, 05:53 PM
RE: New Quadratic Integration - Namir - 05-30-2018, 08:17 PM
RE: New Quadratic Integration - Dieter - 05-30-2018, 09:24 PM
RE: New Quadratic Integration - ttw - 05-31-2018, 02:27 AM
RE: New Quadratic Integration - Namir - 05-31-2018, 03:46 AM
RE: New Quadratic Integration - Namir - 05-31-2018, 03:51 AM
RE: New Quadratic Integration - ttw - 05-31-2018, 03:56 AM
|
User(s) browsing this thread: 1 Guest(s)