Professional Documents
Culture Documents
J. Chaudhry
Degree of Precision
If the integration rule has zero error when integrating any polynomial of
degree 6 r
and
If the error is nonzero for some polynomial of degree r + 1,
then
the rule has degree of precision equal to r.
!
These quadrature rules have one thing in common: they’re restrictive
e.g. Simpson:
Zb
b−a 2(b − a) a+b b−a
f (x) dx ≈ f (a) + f + f (b)
a 6 3 2 6
Gaussian Quadrature
Choose the nodes and coefficients optimally to maximize the degree of
precision of the quadrature rule:
Zb X
n
f (x) dx ≈ wj f (xj )
a j=0
Goal
Seek wj and xj so that the quadrature rule is exact for really high polynomials
is as accurate as possible...
Consider Z2
x3 + 1 dx = 4.75
1
f (x) = c0 + c1 x + c2 x2 + c3 x3
Z1 Z1
c0 + c1 x + c2 x2 + c3 x3 dx
f (x) dx =
−1 −1
c0 + c1 x1 + c2 x21 + c3 x31 +
= w0
c0 + c1 x2 + c2 x22 + c3 x32
w1
Rearrange:
Z1 ! Z1 !
c0 w0 + w1 − dx + c1 w0 x 0 + w1 x 1 − x dx +
−1 −1
Z1 ! Z1 !
c2 w0 x20 + w1 x21 − x dx 2
+ c3 w0 x30 + w1 x31 − 3
x dx =0
−1 −1
Since c0 , c1 , c2 and c3 are arbitrary, then their coefficients must all be zero.
J. Chaudhry (UNM) Math/CS 375 10 / 31
Derive...
This implies:
Z1 Z1
w0 + w1 = dx = 2 w0 x0 + w1 x1 = x dx = 0
−1 −1
Z1 Z1
2
w0 x20 + w1 x21 = x2 dx = w0 x30 + w1 x31 = x3 dx = 0
−1 3 −1
Z1 √ ! √ !
3 3
f (x) dx ≈ f − +f
−1 3 3
Zb
f (x) dx ≈?
a
Zb
f (x) dx ≈?
a
b−a b+a
let x = 2 t+ 2
then dx = b−a
2 dt
Zb Z1
(b − a)t + b + a b−a
f (x) dx = f dt
a −1 2 2
we need more to make this work for more than two points
A sensible quadrature rule for the interval [−1, 1] based on 1 node would
use the node x = 0. This is a root of φ(x) = x
Notice: ± √1 3 are the roots of φ(x) = 3x2 − 1
general φ(x)?
Pused the fact that since r(x) is (at most) a degree n polynomial,
Here we
r(x) = ni=0 r(xi )`i (x).
Orthogonality of Functions
Two functions g(x) and h(x) are orthogonal on [a, b] if
Zb
g(x)h(x) dx = 0
a
φ0 = 1
φ1 = x
3x2 − 1
φ2 =
2
5x3 − 3x
φ3 =
2
..
.
In general:
2n − 1 n−1
φn (x) = xφn−1 (x) − φn−2 (x)
n n
0.75
0.5
0.25
-0.25
-0.5
-0.75
-1
Order 2
1.0000 1.0000
Order 3
0.5556 0.8889 0.5556
Order 4
0.3479 0.6521 0.6521 0.3479
Order 5
0.2369 0.4786 0.5689 0.4786 0.2369
Order 6
0.1713 0.3608 0.4679 0.4679 0.3608 0.1713
-1 -0.5 0 0.5 1
The connection between the roots of the Legendre polynomials and exact
integration of polynomials is established by the following theorem.
Theorem
Suppose that x0 , x1 , . . . , xn are roots of the nth Legendre polynomial Pn (x) and
that for each i = 0, 1, . . . , n the numbers wi are defined by
Z1 Y
n Z1
x − xj
wi = dx = `i (x) dx
−1 xi − xj −1
j=0
j,i
Then Z1 X
n
f (x)dx = wi f (xi ),
−1 i=0
!!!
When evaluating a quadrature rule
Z1 X
n
f (x)dx = wi f (xi ).
−1 i=0
do not generate the nodes and weights each time. Use a lookup table...
Z1
Approximate x2 e−x dx using Gaussian quadrature with n = 1.
0
Solution We again want to convert our limits of integration to -1 to 1. Using the
same process as the earlier example, we get:
Z1 Z1 2
1 t+1
x2 e−x dx = e−(t+1)/2 dt.
0 2 −1 2
Z1 √ √
!2 !2
3 √ 3 √
1 − + 1 3 +1 3
x2 e−x dx ≈ 3
e−(− 3 +1)/2 + 3
e−( 3 +1)/2 = 0.159410
0 2 2 2
Example
int gauss.m: base routine for Gauss quadrature
Example
R5
int gauss test.m: integrate 0 xe−x dx with
1 1 subinterval, increasing number of nodes
2 3 nodes, increases number of intervals (panels)
Result: GL quadrature with 1 subinterval and many nodes more accurate
compared 3 nodes and many subpanels (for same number of function
evaluations)
Example
R5
int compare gauss trapezoid simpson.m: integrate 0 xe−x dx with
1 trapezoid
2 Simpson
3 Gauss
Result: Gauss more accurate for same number of function evals.
J. Chaudhry (UNM) Math/CS 375 27 / 31
Something interesting...
40K tetrahedrons.
J. Chaudhry (UNM) Math/CS 375 30 / 31
Quadrature
40K tetrahedrons.
R
need to integrate a function f (x) over each tet Ωi : Ωi f (x) dx
needs quadrature
map the integration to a reference tetrahedron
perform Gauss Quadrature using (n + 1)(n + 2)(n + 3)/6 quadrature
points (where n is the 1-D number of points).
f (x) is often a product of degree m Lagrange interpolating polynomials
...needs large n
results in # of tetrahedrons × n3 /6 function evaluations
J. Chaudhry (UNM) Math/CS 375 31 / 31