Professional Documents
Culture Documents
Basic idea: Calculate both nodes x1 , . . . , xn and coefficients The Legendre polynomials Pn (x) have the properties
c1 , . . . , cn such that 1 For each n, Pn (x) is a monic polynomial of degree n (leading
Z coefficient 1)
b n
X R1
2 P (x)Pn (x) dx = 0 when P (x) is a polynomial of degree
f (x) dx ≈ ci f (xi ) −1
a
less than n
i=1
The roots of Pn (x) are distinct, in the interval (−1, 1), and
Since there are 2n parameters, we might expect a degree of symmetric with respect to the origin.
precision of 2n − 1 Examples:
Example: n = 2 gives the rule
Z √ ! √ ! P0 (x) = 1, P1 (x) = x
1
− 3 3 1 3
f (x) dx ≈ f +f 2
P2 (x) = x − P3 (x) = x3 − x
−1 3 3 3 5
6 3
with degree of precision 3 P4 (x) = x4 − x2 +
7 35
Gaussian Quadrature Computing Gaussian Quadrature Coefficients
MATLAB Implementation
function [x,c]=gaussquad(n)
Theorem %GAUSSQUAD Gaussian quadrature
Suppose x1 , . . . , xn are roots of Pn (x) and
P=zeros(n+1,n+1);
Z
n
Y 1 P([1,2],1)=1;
x − xj
ci = dx for k=1:n-1
−1 x i − xj P(k+2,1:k+2)=((2*k+1)*[P(k+1,1:k+1) 0]- ...
j6=i
k*[0 0 P(k,1:k)])/(k+1);
If P (x) is any polynomial of degree less than 2n, then end
x=sort(roots(P(n+1,1:n+1)));
Z 1 n
X
P (x) dx = ci P (xi ) A=zeros(n,n);
−1 i=1 for i=1:n
A(i,:)=polyval(P(i,1:i),x)’;
end
c=A\[2;zeros(n-1,1)];
4 16 8 16 4
c 1 4 2 4 1
a b
Gaussian Double Integration Improper Integrals with a Singularity
Similar techniques can be used for non-rectangular regions construct the fourth Taylor polynomial P4 (x) for g about a:
g 00 (a)
P4 (x) = g(a) + g 0 (a)(x − a) + (x − a)2
2!
g 000 (a) g (4) (a)
+ (x − a)3 + (x − a)4
3! 4!
and write
Z b Z b Z b For the first integral, use the Composite Simpson’s rule to
g(x) − P4 (x) P4 (x)
f (x) dx = dx + dx compute the integral of G on [a, b], where
a a (x − a)p a (x − a)p
( g(x)−P (x)
4
The second integral can be computed exactly: (x−a)p , if a < x ≤ b
g(x) =
Z 4 Z 0, if x = a
b
P4 (x) X b
g (k) (a)
dx = (x − a)k−p dx
a (x − a)p k! (k)
Note that 0 < p < 1 and P4 (a) agrees with g (k) (a) for each
k=0 a
X4 k = 0, 1, 2, 3, 4, so G ∈ C 4 [a, b] and Simpson’s rule can be applied.
g (k) (a)
= (b − a)k+1−p
k!(k + 1 − p)
k=0
R∞
For an improper integral with a singularity at the right An integral of the form a x1p dx, with p > 1, can be converted to
endpoint b, make the substitution z = −x, dz = −dx to an integral with left endpoint singularity at 0 by the substitution
obtain
t = x−1 , dt = −x−2 dx, so dx = −x2 dt = −t−2 dt
Z b Z −a
f (x) dx = f (−z) dz which gives
a −b
Z ∞ Z 0 Z 1/a
which has its singularity at the left endpoint 1 tp 1
dx = − dt = dt
For an improper integral with a singularity at c, where a xp 1/a t2 0 t2−p
a < c < b, split into two improper integrals R∞
More generally, this variable change converts a f (x) dx into
Z b Z c Z b
Z ∞ Z 1/a
f (x) dx = f (x) dx + f (x) dx 1
a a c f (x) dx = t−2 f dt
a 0 t