E X P L A N A T I O N S
-----------------------
Method of Weigting Coefficients
to integrate a discrete function
F(x) from x(0) to x(N)
We are looking here for the weigting coefficients A(i), i=0..N,
(N is the number of points), such as the error E given by:
b
E = Sum f(x) dx - [A0 f(x0) + A1 f(x1) + ... + An f(xn)]
a
is null for all distinct points X(i), i=0..N, when f(x) is a polynomial Pn(x)
of degree <= N.
Note that the Xi's are not necessarily equally spaced.
By successively taking as polynomials 1, x, x^2, x^3...x^n as f(x), the in-
tegration leads to a linear equations system:
(a=x(0), b=x(N) )
b
for f(x)=1 ==> Sum 1 dx = A0 + A1 + ... + An = b - a
a
b
for f(x)=x ==> Sum x dx = A0 x0 + A1 x1 + ... + An xn = (b^2 - a^2)/2
a
b
for f(x)=x^2 ==> Sum x^2 dx = A0 x0^2 + A1 x1^2 + ... + An xn^2 = (b^3
a
- a^3)/3
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
b
for f(x)=x^n ==> Sum x^n dx = A0 x0^n + A1 x1^n + ... + An xn^n = (b^n+1
a
- a^n+1)/(n+1)
This linear system, to calculate the weighting coefficients, A(i), i=0..n,
can be written in matrix form as follows:
| 1 1 1 ... 1 | | A0 | | b - a |
| x0 x1 x2 ... xn | | A1 | | (b^2-a^2)/2 |
| x0^2 x1^2 x2^2 ... xn^2 | | A2 | = | (b^3-a^3)/3 |
| ----------------------- | | -- | | ------------------- |
| x0^n x1^n x2^n ... xn^n | | An | | (b^n+1-a^n+1)/(n+1) |
The determinant of the left matrix, of size (n+1)(n+1), never equals zero if
the Xi's are all distinct (determinant of Vandermonde) and the linear system
has always a solution.
Let us see how it works on an example:
Let be the function f(x) = ch(x) = (e^x + e^-x)/2 (hyperbolic cosinus)
and the given points:
x y
-----------------------
0 1
1 1.5431
2 3.7622
2
Let us approximate I = Sum ch(x) dx by: A0 f(0) + A1 f(1) + A2 f(2).
0
We obtain the linear system:
| 1 1 1 | | A0 | | 2-0 |
| 0 1 2 | | A1 | = | (4-0)/2 |
| 0 1 4 | | A2 | | (8-0)/2 |
The roots are: A0 = 1/3, A1 = 4/3 and A2 = 1/3.
So the integral approximation is:
I = 1/3 x 1 + 4/3 x 1.5431 + 1/3 x 3.7612 = 3.6449
======
The exact solution is sh(2) - sh(0) = 3.6269.
The error is 3.6269 - 3.6449 = -0.018
NOTE: When the Xi's are equally spaced, this method is
the same as the formulas of Newton-Cotes.
Reference: "Méthodes de calcul numérique - Tome 1
By Claude Nowakowski, PS1 1981" [BIBLI 07].
Translated by J-P Moreau
Sum is here for the integral sign
^ is here for the power sign.
_________________________________________________________________
End of file dinteg.txt