Gaussian Quadratures

• Newton-Cotes Formulae

– use evenly-spaced functional values
– Did not use the flexibility we have to select the quadrature points

• In fact a quadrature point has several degrees of freedom.
Q(f)=∑i=1m ci f(xi)
A formula with m function evaluations requires specification of
2m numbers ci and xi
• Gaussian Quadratures
– select both these weights and locations so that a higher order
polynomial can be integrated (alternatively the error is proportional
to a higher derivatives)

• Price: functional values must now be evaluated at nonuniformly distributed points to achieve higher accuracy
• Weights are no longer simple numbers
• Usually derived for an interval such as [-1,1]
• Other intervals [a,b] determined by mapping to [-1,1]
Gaussian Quadrature on [-1, 1]
∫

1

−1

n

f ( x )dx ≈ ∑ c i f ( x i ) = c 1 f ( x 1 ) + c 2 f ( x 2 ) + L + c n f ( x n )
i =1

• Two function evaluations:
– Choose (c1, c2, x1, x2) such that the method yields “exact
integral” for f(x) = x0, x1, x2, x3

n=2:

∫

1

−1

f(x)dx

= c 1 f(x 1 ) + c 2 f(x 2 )
-1

x1

x2

1
Finding quadrature nodes and weights
• One way is through the theory of orthogonal
polynomials.
• Here we will do it via brute force
• Set up equations by requiring that the 2m points
guarantee that a polynomial of degree 2m-1 is integrated
exactly.
• In general process is non-linear
– (involves a polynomial function involving the unknown point
and its product with unknown weight)
– Can be solved by using a multidimensional nonlinear solver
– Alternatively can sometimes be done step by step
Gaussian Quadrature on [-1, 1]
n=2:

∫

1

−1

f(x)dx = c 1 f(x 1 ) + c 2 f(x 2 )

Exact integral for f = x0, x1, x2, x3
– Four equations for four unknowns

⎧f
⎪
⎪
⎪f
⎨
⎪f
⎪
⎪f
⎩

1

= 1 ⇒ ∫ 1dx = 2 = c 1 + c 2
−1
1

= x ⇒ ∫ xdx = 0 = c 1 x 1 + c 2 x 2
−1

2
2
2
= x ⇒ ∫ x dx = = c 1 x 1 + c 2 x 2
−1
3
2

1

2

1

3
3
= x ⇒ ∫ x 3 dx = 0 = c 1 x 1 + c 2 x 2
3

−1

1

I = ∫ f ( x )dx = f ( −
−1

⎧c 1 = 1
⎪c = 1
⎪ 2
−1
⎪
⇒ ⎨ x1 =
3
⎪
1
⎪
⎪ x2 = 3
⎩

1
3

)+ f (

1
3

)
Error
• If we approximate a function with a Gaussian quadrature
formula we cause an error proportional to 2n th
derivative
Gaussian Quadrature on [-1, 1]
n=3:

∫

1

−1

f ( x )dx = c 1 f ( x 1 ) + c 2 f ( x 2 ) + c 3 f ( x 3 )

x2
x3
-1 x1
1
• Choose (c1, c2, c3, x1, x2, x3) such that the method
yields “exact integral” for f(x) = x0, x1, x2, x3,x4, x5
Gaussian Quadrature on [-1, 1]
1

f = 1 ⇒ ∫ xdx = 2 = c1 + c2 + c3
−1

1

f = x ⇒ ∫ xdx = 0 = c1 x1 + c2 x2 + c3 x3
−1

1

2
2
2
f = x ⇒ ∫ x dx = = c1 x12 + c2 x2 + c3 x3
3
−1
2

2

1

3
3
f = x 3 ⇒ ∫ x 3dx = 0 = c1 x13 + c2 x2 + c3 x3
−1
1

2
4
4
f = x ⇒ ∫ x dx = = c1 x14 + c2 x2 + c3 x3
5
−1
4

4

1

5
5
f = x 5 ⇒ ∫ x 5 dx = 0 = c1 x15 + c2 x2 + c3 x3
−1

⎧c1 = 5 / 9
⎪c = 8 / 9
⎪ 2
⎪c3 = 5 / 9
⎪
⇒⎨
⎪ x1 = − 3 / 5
⎪ x2 = 0
⎪
⎪ x3 = 3 / 5
⎩
Gaussian Quadrature on [-1, 1]
Exact integral for f = x0, x1, x2, x3, x4, x5

I=∫

1

−1

3
5
3
8
5
)
f ( x )dx = f ( −
)+ f (0 )+ f (
9
5
9
5
9
Gaussian Quadrature on [a, b]
Coordinate transformation from [a,b] to [-1,1]

b−a
b+a
t=
x+
2
2
⎧ x = −1 ⇒ t = a
⎨
⎩x = 1 ⇒ t = b
a

∫

b

a

t1

f ( t )dt = ∫

1

−1

t2

b

1
b−a
b+a b−a
f(
x+
)(
)dx = ∫ g ( x )dx
−1
2
2
2
Example: Gaussian Quadrature
4

I = ∫ te dt = 5216.926477

Evaluate

2t

0

Coordinate transformation

b−a
b+a
t=
x+
= 2 x + 2; dt = 2dx
2
2
4

1

I = ∫ te dt = ∫ (4 x + 4)e
2t

4 x+4

−1

0

1

dx = ∫ f ( x)dx
−1

Two-point formula

1

I = ∫ f ( x )dx = f (
−1

−1

)+ f (

1

)= (4 −

4

)e

3
3
3
= 9.167657324 + 3468.376279 = 3477.543936

4−

4
3

+(4 +

4

)e

3
( ε = 33.34%)

4+

4
3
Example: Gaussian Quadrature
Three-point formula
1
5
8
5
I = ∫ f ( x )dx = f ( − 0.6 ) + f ( 0 ) + f ( 0.6 )
−1
9
9
9
5
8
5
4 − 0 .6
4
= ( 4 − 4 0.6 )e
+ ( 4 )e + ( 4 + 4 0.6 )e 4 + 0.6
9
9
9
5
8
5
= ( 2.221191545 ) + ( 218.3926001 ) + ( 8589.142689 )
9
9
9
= 4967.106689
( ε = 4.79%)
Four-point formula

I = ∫ f ( x )dx = 0.34785[ f ( −0.861136 ) + f ( 0.861136 )]
1

−1

+ 0.652145 [ f ( −0.339981 ) + f ( 0.339981 )]
= 5197.54375
( ε = 0.37%)
Other rules
• Gauss-Lobatto:
– requiring end points be included in the formula

• Gauss-Radau
– Require one end point be in the formula

Gaussian quadratures

  • 1.
    Gaussian Quadratures • Newton-CotesFormulae – use evenly-spaced functional values – Did not use the flexibility we have to select the quadrature points • In fact a quadrature point has several degrees of freedom. Q(f)=∑i=1m ci f(xi) A formula with m function evaluations requires specification of 2m numbers ci and xi • Gaussian Quadratures – select both these weights and locations so that a higher order polynomial can be integrated (alternatively the error is proportional to a higher derivatives) • Price: functional values must now be evaluated at nonuniformly distributed points to achieve higher accuracy • Weights are no longer simple numbers • Usually derived for an interval such as [-1,1] • Other intervals [a,b] determined by mapping to [-1,1]
  • 2.
    Gaussian Quadrature on[-1, 1] ∫ 1 −1 n f ( x )dx ≈ ∑ c i f ( x i ) = c 1 f ( x 1 ) + c 2 f ( x 2 ) + L + c n f ( x n ) i =1 • Two function evaluations: – Choose (c1, c2, x1, x2) such that the method yields “exact integral” for f(x) = x0, x1, x2, x3 n=2: ∫ 1 −1 f(x)dx = c 1 f(x 1 ) + c 2 f(x 2 ) -1 x1 x2 1
  • 3.
    Finding quadrature nodesand weights • One way is through the theory of orthogonal polynomials. • Here we will do it via brute force • Set up equations by requiring that the 2m points guarantee that a polynomial of degree 2m-1 is integrated exactly. • In general process is non-linear – (involves a polynomial function involving the unknown point and its product with unknown weight) – Can be solved by using a multidimensional nonlinear solver – Alternatively can sometimes be done step by step
  • 4.
    Gaussian Quadrature on[-1, 1] n=2: ∫ 1 −1 f(x)dx = c 1 f(x 1 ) + c 2 f(x 2 ) Exact integral for f = x0, x1, x2, x3 – Four equations for four unknowns ⎧f ⎪ ⎪ ⎪f ⎨ ⎪f ⎪ ⎪f ⎩ 1 = 1 ⇒ ∫ 1dx = 2 = c 1 + c 2 −1 1 = x ⇒ ∫ xdx = 0 = c 1 x 1 + c 2 x 2 −1 2 2 2 = x ⇒ ∫ x dx = = c 1 x 1 + c 2 x 2 −1 3 2 1 2 1 3 3 = x ⇒ ∫ x 3 dx = 0 = c 1 x 1 + c 2 x 2 3 −1 1 I = ∫ f ( x )dx = f ( − −1 ⎧c 1 = 1 ⎪c = 1 ⎪ 2 −1 ⎪ ⇒ ⎨ x1 = 3 ⎪ 1 ⎪ ⎪ x2 = 3 ⎩ 1 3 )+ f ( 1 3 )
  • 5.
    Error • If weapproximate a function with a Gaussian quadrature formula we cause an error proportional to 2n th derivative
  • 6.
    Gaussian Quadrature on[-1, 1] n=3: ∫ 1 −1 f ( x )dx = c 1 f ( x 1 ) + c 2 f ( x 2 ) + c 3 f ( x 3 ) x2 x3 -1 x1 1 • Choose (c1, c2, c3, x1, x2, x3) such that the method yields “exact integral” for f(x) = x0, x1, x2, x3,x4, x5
  • 7.
    Gaussian Quadrature on[-1, 1] 1 f = 1 ⇒ ∫ xdx = 2 = c1 + c2 + c3 −1 1 f = x ⇒ ∫ xdx = 0 = c1 x1 + c2 x2 + c3 x3 −1 1 2 2 2 f = x ⇒ ∫ x dx = = c1 x12 + c2 x2 + c3 x3 3 −1 2 2 1 3 3 f = x 3 ⇒ ∫ x 3dx = 0 = c1 x13 + c2 x2 + c3 x3 −1 1 2 4 4 f = x ⇒ ∫ x dx = = c1 x14 + c2 x2 + c3 x3 5 −1 4 4 1 5 5 f = x 5 ⇒ ∫ x 5 dx = 0 = c1 x15 + c2 x2 + c3 x3 −1 ⎧c1 = 5 / 9 ⎪c = 8 / 9 ⎪ 2 ⎪c3 = 5 / 9 ⎪ ⇒⎨ ⎪ x1 = − 3 / 5 ⎪ x2 = 0 ⎪ ⎪ x3 = 3 / 5 ⎩
  • 8.
    Gaussian Quadrature on[-1, 1] Exact integral for f = x0, x1, x2, x3, x4, x5 I=∫ 1 −1 3 5 3 8 5 ) f ( x )dx = f ( − )+ f (0 )+ f ( 9 5 9 5 9
  • 9.
    Gaussian Quadrature on[a, b] Coordinate transformation from [a,b] to [-1,1] b−a b+a t= x+ 2 2 ⎧ x = −1 ⇒ t = a ⎨ ⎩x = 1 ⇒ t = b a ∫ b a t1 f ( t )dt = ∫ 1 −1 t2 b 1 b−a b+a b−a f( x+ )( )dx = ∫ g ( x )dx −1 2 2 2
  • 10.
    Example: Gaussian Quadrature 4 I= ∫ te dt = 5216.926477 Evaluate 2t 0 Coordinate transformation b−a b+a t= x+ = 2 x + 2; dt = 2dx 2 2 4 1 I = ∫ te dt = ∫ (4 x + 4)e 2t 4 x+4 −1 0 1 dx = ∫ f ( x)dx −1 Two-point formula 1 I = ∫ f ( x )dx = f ( −1 −1 )+ f ( 1 )= (4 − 4 )e 3 3 3 = 9.167657324 + 3468.376279 = 3477.543936 4− 4 3 +(4 + 4 )e 3 ( ε = 33.34%) 4+ 4 3
  • 11.
    Example: Gaussian Quadrature Three-pointformula 1 5 8 5 I = ∫ f ( x )dx = f ( − 0.6 ) + f ( 0 ) + f ( 0.6 ) −1 9 9 9 5 8 5 4 − 0 .6 4 = ( 4 − 4 0.6 )e + ( 4 )e + ( 4 + 4 0.6 )e 4 + 0.6 9 9 9 5 8 5 = ( 2.221191545 ) + ( 218.3926001 ) + ( 8589.142689 ) 9 9 9 = 4967.106689 ( ε = 4.79%) Four-point formula I = ∫ f ( x )dx = 0.34785[ f ( −0.861136 ) + f ( 0.861136 )] 1 −1 + 0.652145 [ f ( −0.339981 ) + f ( 0.339981 )] = 5197.54375 ( ε = 0.37%)
  • 12.
    Other rules • Gauss-Lobatto: –requiring end points be included in the formula • Gauss-Radau – Require one end point be in the formula