[ Home ] | Integration I | Numerical Methods. Note « 6 » |
One can choose the weights wi (for open formulae) such that the formula integrates precisely diverging integrals, say, 1/√(x).
Due to round-off errors n cannot be too large, say n<10 for single and n<20 for double precision. Therefore if the accuracy is not good enough the interval is subdivided into smaller intervals and the formulae are applied to subintervals thus reducing the error.
The error can be estimated by comparing the results from formulae of different precision, e.g., open-2 and open-4.
Gaussian quadratures seek to obtain the best approximation to the integral ∫ab w(x)f(x)dx ≈ ∑i=1..n wi f(xi) with optimally chosen abscissas xi and weights wi. The optimal abscissas happen to be the roots of polynomials which are orthogonal on (a,b) with the weight-function w(x). For w(x) ≡ 1 these are the Legendre polynomials. Because the number of free parameters is 2n (n abscissas and n weights) the Gaussian quadratures are accurate up to 2n-1 order compared to only n-1 order for equally spaced abscissas. Unfortunately the optimal points can not be reused at the next iteration in an adaptive algorithm.
function [J,ERR] = OPEN24(f,a,b)
calculate J2 and J4; J=J4 ; ERR=abs(J4-J2)
function [J,err] = DUMBINT (f,a,b,N) subdivide (a,b) into N sub-intervals (ai,bi) for each sub-interval calculate the sub-integral and sub-error [Si,ei] = OPEN24("f",ai,bi) calculate the global-integral J=∑iSi and global-error err=√(∑iei2)
∫-100100 [1/1+x2] dx |