You are on page 1of 48

MATH 3800

MATHEMATICAL MODELS AND NUMERICAL METHODS

NUMERICAL DIFFERENTIATION/INTEGRATION

© 2020 Gary Bazdell (excluding images)


INTRODUCTION
Even in simple applications, there are time we cannot explicitly
evaluate the functions we are using. In this section, methods are
developed to approximate the solution to our problems.

We used algebraic polynomials to approximate an arbitrary set of data


that was given. This was due to the fact that given any continuous
function defined on a closed interval, there exists a polynomial that is
arbitrarily close to the function at every point in the interval.

Derivatives and integrals of polynomials are easily obtained and


evaluated which is why they will be a focus in our methods.
Numerical Differentiation/Integration - Introduction 2
MATH 3800
MATHEMATICAL MODELS AND NUMERICAL METHODS

NUMERICAL DIFFERENTIATION

Numerical Differentiation - Differentiation


NUMERICAL DIFFERENTIATION
The derivative of the function 𝑓 at 𝑥0 is

𝑓 𝑥0 + ℎ − 𝑓 𝑥0
𝑓′ 𝑥0 = lim .
ℎ→0 ℎ

This formula gives an obvious way to generate an approximation to


𝑓 ′ 𝑥0 which is to simply compute for small values of ℎ the following:

𝑓 𝑥0 + ℎ − 𝑓 𝑥0
.

Numerical Differentiation - Differentiation 4
LAGRANGE POLYNOMIAL
To approximate 𝑓 ′ 𝑥0 , suppose that 𝑥0 ∈ 𝑎, 𝑏 where 𝑓 ∈ 𝐶 2 𝑎, 𝑏
and that 𝑥1 = 𝑥0 + ℎ for some ℎ ≠ 0 that is sufficiently small to ensure
that 𝑥1 ∈ 𝑎, 𝑏 .

𝑓 𝑥0 𝑥 − 𝑥0 − ℎ 𝑓 𝑥0 + ℎ 𝑥 − 𝑥0 𝑓 ′′ 𝛼
𝑓 𝑥 = + + 𝑥 − 𝑥0 𝑥 − 𝑥0 − ℎ
−ℎ ℎ 2

for some 𝛼 between 𝑥0 and 𝑥1 .

Numerical Differentiation - Differentiation 5


DERIVATIVE OF LAGRANGE POLYNOMIAL
𝑓 𝑥0 𝑥 − 𝑥0 − ℎ 𝑓 𝑥0 + ℎ 𝑥 − 𝑥0 𝑓 ′′ 𝛼
𝑓 𝑥 = + + 𝑥 − 𝑥0 𝑥 − 𝑥0 − ℎ
−ℎ ℎ 2

𝑓 𝑥0 𝑓 𝑥0 + ℎ 𝑑 𝑓 ′′ 𝛼
𝑓′ 𝑥 =− + + 𝑥 − 𝑥0 𝑥 − 𝑥0 − ℎ
ℎ ℎ 𝑑𝑥 2

𝑓 𝑥0 + ℎ − 𝑓 𝑥0 𝑑 𝑓 ′′ 𝛼
𝑓′ 𝑥
= + 𝑥 − 𝑥0 𝑥 − 𝑥0 − ℎ
ℎ 𝑑𝑥 2

Numerical Differentiation - Differentiation 6


DERIVATIVE OF ERROR TERM
𝑑 𝑓 ′′ 𝛼
𝑥 − 𝑥0 𝑥 − 𝑥0 − ℎ
𝑑𝑥 2

𝑑 ′′ 𝑥 − 𝑥0 𝑥 − 𝑥0 − ℎ ′′
2 𝑥 − 𝑥0 − ℎ
= 𝑓 𝛼 +𝑓 𝛼
𝑑𝑥 2 2

Note: when 𝑥 is 𝑥0 the formula simplifies to

−ℎ ′′
= 𝑓 𝛼
2
Numerical Differentiation - Differentiation 7
FORWARD/BACKWARD DIFFERENCE
For small values of ℎ, the difference quotient

𝑓 𝑥0 + ℎ − 𝑓 𝑥0

𝑀
can be used to approximate 𝑓′
𝑥0 with an error bounded by ℎ
2
where 𝑀 is a bound on 𝑓 ′′ 𝑥 for 𝑥 between 𝑥0 and 𝑥1 = 𝑥0 + ℎ.

This formula is called the forward-difference formula if ℎ > 0 and the


backward-difference formula if ℎ < 0.
Numerical Differentiation - Differentiation 8
EXERCISE 1
Use the forward-difference formula to approximate the derivative of

𝑓 𝑥 = ln 𝑥

at 𝑥0 = 1.8 using ℎ = 0.1 and determine the bound for the error
approximation.

Numerical Differentiation - Differentiation 9


GENERAL FORM
Suppose that 𝑥0 , 𝑥1 , … , 𝑥𝑛 are 𝑛 + 1 distinct numbers in some
interval 𝐼 and that 𝑓 ∈ 𝐶 𝑛+1 𝐼 .
𝑛
𝛼 𝑓 𝑛+1
𝑓 𝑥 = ෍ 𝑓 𝑥𝑘 𝐿𝑘 𝑥 + 𝑥 − 𝑥0 … 𝑥 − 𝑥𝑛
𝑛+1 !
𝑘=0

for some 𝛼 in 𝐼, where 𝐿𝑘 (𝑥) denotes the 𝑘th Lagrange coefficient


polynomial for 𝑓 at 𝑥0 , 𝑥1 , … , 𝑥𝑛 .

Numerical Differentiation - Differentiation 10


DERIVATIVE OF GENERAL FORM
𝑛
𝑑 𝑓 𝑛+1 𝛼
𝑓 ′ 𝑥 = ෍ 𝑓 𝑥𝑘 𝐿′𝑘 𝑥 + 𝑥 − 𝑥0 … 𝑥 − 𝑥𝑛
𝑑𝑥 𝑛 + 1 !
𝑘=0
Error Term

𝑑 𝑥 − 𝑥0 … 𝑥 − 𝑥𝑛 𝑛+1
𝑥 − 𝑥0 … 𝑥 − 𝑥𝑛 d 𝑛+1
𝑓 𝛼 + 𝑓 𝛼
𝑑𝑥 𝑛+1 ! 𝑛+1 ! dx

If 𝑥 is one of the number 𝑥𝑗 we get


𝑛
𝑓 𝑛+1𝛼
ෑ 𝑥𝑗 − 𝑥𝑘
𝑛+1 !
𝑘=0,𝑘≠𝑗

Numerical Differentiation - Differentiation 11


𝒏 + 𝟏 -POINT FORMULA
𝑛 𝑛
𝛼 𝑓 𝑛+1
𝑓′ 𝑥 = ෍ 𝑓 𝑥𝑘 𝐿′𝑘 𝑥 + ෑ 𝑥𝑗 − 𝑥𝑘
𝑛+1 !
𝑘=0 𝑘=0,𝑘≠𝑗

In general, using more evaluation points produces greater accuracy.


Though we need to be careful as the numbers of functional evaluations
grow the more issues with round off error we shall see.

The most common formula is the three-point formula.


Numerical Differentiation - Differentiation 12
THREE-POINT FORMULA
2 2
𝑓 3 𝛼
𝑓′ 𝑥 = ෍ 𝑓 𝑥𝑘 𝐿′𝑘 𝑥 + ෑ 𝑥𝑗 − 𝑥𝑘
6
𝑘=0 𝑘=0,𝑘≠𝑗

𝑥 − 𝑥1 𝑥 − 𝑥2 2𝑥 − 𝑥1 − 𝑥2
𝐿0 𝑥 = 𝐿′0 𝑥 =
𝑥0 − 𝑥1 𝑥0 − 𝑥2 𝑥0 − 𝑥1 𝑥0 − 𝑥2

𝑥 − 𝑥0 𝑥 − 𝑥2 2𝑥 − 𝑥0 − 𝑥2
𝐿1 𝑥 = 𝐿′1 𝑥 =
𝑥1 − 𝑥0 𝑥1 − 𝑥2 𝑥1 − 𝑥0 𝑥1 − 𝑥2

𝑥 − 𝑥0 𝑥 − 𝑥1 2𝑥 − 𝑥0 − 𝑥1
𝐿2 𝑥 = 𝐿′2 𝑥 =
𝑥2 − 𝑥0 𝑥2 − 𝑥1 𝑥2 − 𝑥0 𝑥2 − 𝑥1

Numerical Differentiation - Differentiation 13


THREE-POINT FORMULA
Suppose that each node is equally spaced out.

𝑥0 , 𝑥1 = 𝑥0 + ℎ, 𝑥2 = 𝑥1 + ℎ = 𝑥0 + 2ℎ

2𝑥 − 𝑥1 − 𝑥2 2𝑥 − 2𝑥0 − 3ℎ
𝐿′0 𝑥 = 𝐿′0 𝑥 =
𝑥0 − 𝑥1 𝑥0 − 𝑥2 2ℎ2

2𝑥 − 𝑥0 − 𝑥2 2𝑥 − 2𝑥0 − 2ℎ
𝐿′1 𝑥 = 𝐿′1 𝑥 =
𝑥1 − 𝑥0 𝑥1 − 𝑥2 −ℎ2

2𝑥 − 𝑥0 − 𝑥1 2𝑥 − 2𝑥0 − ℎ
𝐿′2 𝑥 = 𝐿′2 𝑥 =
𝑥2 − 𝑥0 𝑥2 − 𝑥1 2ℎ2

Numerical Differentiation - Differentiation 14


THREE-POINT FORMULA
Using
𝑥0 , 𝑥1 = 𝑥0 + ℎ, 𝑥2 = 𝑥0 + 2ℎ
we get
1 3 1 ℎ2
𝑓 ′ 𝑥0 = − 𝑓 𝑥0 + 2𝑓 𝑥0 + ℎ − 𝑓 𝑥0 + 2ℎ + 𝑓 3
𝛼
ℎ 2 2 3


1 1 1 ℎ2 3
𝑓 𝑥0 + ℎ = − 𝑓 𝑥0 + 𝑓 𝑥0 + 2ℎ − 𝑓 𝛼
ℎ 2 2 6


1 1 3 ℎ2 3
𝑓 𝑥0 + 2ℎ = 𝑓 𝑥0 − 2𝑓 𝑥0 + ℎ + 𝑓 𝑥0 + 2ℎ + 𝑓 𝛼
ℎ 2 2 3
Numerical Differentiation - Differentiation 15
THREE-POINT FORMULA
With a simple change of variables we get the following

1 ℎ2
𝑓 ′ 𝑥0 = −3𝑓 𝑥0 + 4𝑓 𝑥0 + ℎ − 𝑓 𝑥0 + 2ℎ + 𝑓 3 𝛼
2ℎ 3

1 ℎ2
𝑓 ′ 𝑥0 = −𝑓 𝑥0 − ℎ + 𝑓 𝑥0 + ℎ − 𝑓 3
𝛼
2ℎ 6

1 ℎ2
𝑓 ′ 𝑥0 = 𝑓 𝑥0 − 2ℎ − 4𝑓 𝑥0 − ℎ + 3𝑓 𝑥0 + 𝑓 3 𝛼
2ℎ 3
Numerical Differentiation - Differentiation 16
MIDPOINT AND ENDPOINT FORMULA
Three-Point Endpoint Formula


1 ℎ2 3
𝑓 𝑥0 = −3𝑓 𝑥0 + 4𝑓 𝑥0 + ℎ − 𝑓 𝑥0 + 2ℎ + 𝑓 𝛼
2ℎ 3
where 𝛼 lies between 𝑥0 and 𝑥0 + 2ℎ.

Three-Point Midpoint Formula


1 ℎ2 3
𝑓 𝑥0 = −𝑓 𝑥0 − ℎ + 𝑓 𝑥0 + ℎ − 𝑓 𝛼
2ℎ 6
where 𝛼 lies between 𝑥0 − ℎ and 𝑥0 + ℎ.

Numerical Differentiation - Differentiation 17


EXERCISE 2
Use the three-point endpoint and midpoint formula to approximate the
derivative of

𝑓 𝑥 = ln 𝑥

at 𝑥0 = 1.8 using ℎ = 0.1 and determine the bound for the error
approximation.

Numerical Differentiation - Differentiation 18


ROUND-OFF ERROR ON MIDPOINT FORMULA
Suppose that in evaluating

𝑓 𝑥0 − ℎ and 𝑓 𝑥0 + ℎ
we encounter round-off errors

𝑒 𝑥0 − ℎ and 𝑒 𝑥0 + ℎ .

These are related to the true values as follows:

𝑓 𝑥0 − ℎ = 𝑓ሚ 𝑥0 − ℎ + 𝑒 𝑥0 − ℎ
𝑓 𝑥0 + ℎ = 𝑓ሚ 𝑥0 + ℎ + 𝑒 𝑥0 + ℎ

Numerical Differentiation - Differentiation 19


TOTAL ERROR
The total error in the approximation is

𝑓ሚ 𝑥0 + ℎ − 𝑓ሚ 𝑥0 − ℎ 𝑒 𝑥0 + ℎ − 𝑒 𝑥0 − ℎ ℎ2
𝑓 ′ 𝑥0 − = − 𝑓 3 𝛼
2ℎ 2ℎ 6

Assume that the round off errors are bounded by some number 𝜀 > 0
and that the third derivative of 𝑓 is bounded by a number 𝑀 > 0.

𝑓ሚ 𝑥0 + ℎ − 𝑓ሚ 𝑥0 − ℎ 𝜀 ℎ2
𝑓 ′ 𝑥0 − ≤ + 𝑀
2ℎ ℎ 6
Numerical Differentiation - Differentiation 20
MATH 3800
MATHEMATICAL MODELS AND NUMERICAL METHODS

NUMERICAL QUADRATURE

Numerical Quadrature - Integration


NUMERICAL QUADRATURE
The basic method involved in approximating

𝑏
න 𝑓 𝑥 𝑑𝑥
𝑎
is called numerical quadrature.
𝑛 𝑏
෍ 𝑎𝑖 𝑓 𝑥𝑖 ≈ න 𝑓 𝑥 𝑑𝑥
𝑖=0 𝑎

Numerical Quadrature - Integration 22


GENERAL FORM
The basic idea is to select a set of distinct nodes 𝑥0 , 𝑥1 , … , 𝑥𝑛 from
the interval 𝑎, 𝑏 . Then integrate the Lagrange interpolating
polynomial
𝑛

𝑃𝑛 𝑥 = ෍ 𝑓 𝑥𝑖 𝐿𝑖 𝑥
𝑖=0

and its truncation error term over 𝑎, 𝑏 .

Numerical Quadrature - Integration 23


INTEGRATION OF 𝑃𝑛 𝑥
𝑏 𝑏 𝑛 𝑏 𝑛
𝑓 𝑛+1 𝛼
න 𝑓 𝑥 𝑑𝑥 = න ෍ 𝑓 𝑥𝑖 𝐿𝑖 𝑥 𝑑𝑥 + න ෑ 𝑥 − 𝑥𝑖 𝑑𝑥
𝑎 𝑎 𝑎 𝑛+1 !
𝑖=0 𝑖=𝑜

𝑛 𝑏 𝑛
1
= ෍ 𝑎𝑖 𝑓 𝑥𝑖 + න ෑ 𝑥 − 𝑥𝑖 𝑓 𝑛+1 𝛼 𝑑𝑥
𝑛+1 ! 𝑎
𝑖=0 𝑖=𝑜

where 𝛼 is in 𝑎, 𝑏 and
𝑏
𝑎𝑖 = ‫𝑖𝐿 𝑎׬‬ 𝑥 𝑑𝑥, for each 𝑖 = 0, 1, … , 𝑛.
Numerical Quadrature - Integration 24
QUADRATURE FORMULA
The quadrature formula is

𝑏 𝑛

න 𝑓 𝑥 𝑑𝑥 ≈ ෍ 𝑎𝑖 𝑓 𝑥𝑖
𝑎 𝑖=0
with error given by

𝑏 𝑛
1 𝑛+1
𝐸 𝑓 = න ෑ 𝑥 − 𝑥𝑖 𝑓 𝛼 𝑑𝑥
𝑛+1 ! 𝑎
𝑖=0

Numerical Quadrature - Integration 25


THE TRAPEZOIDAL RULE
𝑦

𝑎 = 𝑥0 𝑥1 = 𝑏 𝑥

Numerical Quadrature - Integration 26


THE TRAPEZOIDAL RULE
To derive the Trapezoidal rule, let 𝑥0 = 𝑎, 𝑥1 = 𝑏 and use the linear
Lagrange polynomial.

𝑏 𝑥1
𝑥 − 𝑥1 𝑥 − 𝑥0 1 𝑥1 ′′
න 𝑓 𝑥 𝑑𝑥 = න 𝑓 𝑥𝑜 + 𝑓 𝑥1 𝑑𝑥 + න 𝑓 𝛼 𝑥 − 𝑥0 𝑥 − 𝑥1 𝑑𝑥
𝑎 𝑥0 𝑥0 − 𝑥1 𝑥1 − 𝑥0 2 𝑥0

𝑏 3
𝑥1 − 𝑥0 𝑥1 − 𝑥0
න 𝑓 𝑥 𝑑𝑥 = 𝑓 𝑥0 + 𝑓 𝑥1 − 𝑓 ′′ 𝛼
𝑎 2 12

Numerical Quadrature - Integration 27


SIMPSON’S RULE
𝑦

𝑎 = 𝑥0 𝑥2 = 𝑏 𝑥

Numerical Quadrature - Integration 28


SIMPSON’S RULE
𝑥2 −𝑥0
To derive Simpson’s rule, let 𝑥0 = 𝑎, 𝑥2 = 𝑏, 𝑥1 = 𝑎 + ℎ, ℎ = and use the second Lagrange
2
polynomial.

𝑏
න 𝑓 𝑥 𝑑𝑥 =
𝑎
𝑥2
𝑥 − 𝑥1 𝑥 − 𝑥2 𝑥 − 𝑥0 𝑥 − 𝑥2 𝑥 − 𝑥0 𝑥 − 𝑥1
න 𝑓 𝑥𝑜 + 𝑓 𝑥1 + 𝑓 𝑥2 𝑑𝑥
𝑥0 𝑥0 − 𝑥1 𝑥0 − 𝑥2 𝑥1 − 𝑥0 𝑥1 − 𝑥2 𝑥2 − 𝑥0 𝑥2 − 𝑥1
1 𝑥2 3
+ න 𝑓 𝛼 𝑥 − 𝑥0 𝑥 − 𝑥1 𝑥 − 𝑥2 𝑑𝑥
6 𝑥0

𝑏
ℎ ℎ5 4
න 𝑓 𝑥 𝑑𝑥 = 𝑓 𝑥0 + 4𝑓 𝑥1 + 𝑓 𝑥2 − 𝑓 𝛼
𝑎 3 90

Numerical Quadrature - Integration 29


EXERCISE 3
Compare the Trapezoidal rule and Simpson’s rule approximations to

2
න 𝑥 2 𝑑𝑥 .
0

Numerical Quadrature - Integration 30


THE OPEN MIDPOINT RULE
𝑦

𝑏 3
𝑥1 − 𝑥0
න 𝑓 𝑥 𝑑𝑥 = 𝑥1 − 𝑥0 𝑓 𝑥∗ + 𝑓 ′′ 𝛼
𝑎 24

𝑎 = 𝑥0 𝑎+𝑏 𝑥1 = 𝑏 𝑥
𝑥∗ =
2

Numerical Quadrature - Integration 31


PIECEWISE APPROACH
𝑏−𝑎
We now look at chopping an interval 𝑎, 𝑏 into 𝑛 subintervals with ℎ = .
𝑛
Midpoint Rule
𝑏 𝑛−1 2
∗ ℎ ′′ ∗ ℎ
න 𝑓 𝑥 𝑑𝑥 = ℎ ෍ 𝑓 𝑥𝑖 + 𝑏−𝑎 𝑓 𝛼 , 𝑥𝑖 = 𝑥𝑖 +
𝑎 24 2
𝑖=0
Trapezoidal Rule
𝑏 𝑛−1
ℎ ℎ2
න 𝑓 𝑥 𝑑𝑥 = ෍ 𝑓 𝑥𝑖 + 𝑓 𝑥𝑖+1 − 𝑏 − 𝑎 𝑓 ′′ 𝛼
𝑎 2 12
𝑖=0
Simpson’s Rule (𝑛 must𝑛be even)
𝑏 2 −1
ℎ ℎ4 4
න 𝑓 𝑥 𝑑𝑥 = ෍ 𝑓 𝑥2𝑖 + 4𝑓 𝑥2𝑖+1 + 𝑓 𝑥2𝑖+2 − 𝑏−𝑎 𝑓 𝛼
𝑎 3 180
𝑖=0

Numerical Quadrature - Integration 32


EXERCISE 4
Approximate the following integral using the midpoint, trapezoidal, and
Simpson’s rule for 𝑛 = 8

2
2 −𝑥 2
න 𝑥 𝑒 𝑑𝑥
0

Numerical Quadrature - Integration 33


MATH 3800
MATHEMATICAL MODELS AND NUMERICAL METHODS

GAUSSIAN QUADRATURE

Gaussian Quadrature - Gaussian Quadrature


GAUSSIAN QUADRATURE
In Gaussian quadrature, the nodes for evaluating are chosen in an
optimal way rather than an equally spaced way. The nodes
𝑥1 , 𝑥2 , … , 𝑥𝑛
are in the interval 𝑎, 𝑏 and the coefficients
𝑐1 , 𝑐2 , … , 𝑐𝑛
are chosen to minimize the expected error obtained in the
approximation
𝑏 𝑛

න 𝑓 𝑥 𝑑𝑥 ≈ ෍ 𝑐𝑖 𝑓 𝑥𝑖
𝑎 𝑖=1

Gaussian Quadrature - Gaussian Quadrature 35


APPROXIMATING POLYNOMIAL
We are interested in solving for the 2𝑛 parameters,
𝑐1 , … , 𝑐𝑛 , 𝑥1 , … , 𝑥𝑛
such that the choice of these values produces the greatest degree of
precision for the largest class of polynomials.

If the coefficients of a polynomial are considered parameters, we


should choose a polynomial of degree 2𝑛 − 1 as it has 2𝑛 coefficients.

This is the largest class of polynomials for which it is reasonable to


expect a formula to be exact.

Gaussian Quadrature - Gaussian Quadrature 36


BASIS OF THE GAUSSIAN QUADRATURE RULE
In the two-point Gaussian Quadrature Rule, the integral is
approximated as

𝑏
𝐼 = න 𝑓 𝑥 𝑑𝑥 ≈ 𝑐1 𝑓 𝑥1 + 𝑐2 𝑓 𝑥2
𝑎

Suppose our interval of integration is −1, 1 . The four unknowns


𝑥1 , 𝑥2 , 𝑐1 , 𝑐2 are found by assuming that the formula gives exact results
for integrating a general three order polynomial.

Gaussian Quadrature - Gaussian Quadrature 37


BASIS OF THE GAUSSIAN QUADRATURE
Hence, exact when 𝑓 𝑥 = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 + 𝑎3 𝑥 3 .
Integrating 𝑓 𝑥 directly gives us,

1 1
න 𝑓 𝑥 𝑑𝑥 = න 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 + 𝑎3 𝑥 3 𝑑𝑥
−1 −1
2 3 4 1
𝑎1 𝑥 𝑎2 𝑥 𝑎3 𝑥
= 𝑎0 𝑥 + + +
2 3 4 −1
2
= 𝑎0 2 + 𝑎1 0 + 𝑎2 + 𝑎3 0
3

Gaussian Quadrature - Gaussian Quadrature 38


BASIS OF THE GAUSSIAN QUADRATURE
If we substitute 𝑓 𝑥 into our two point approximation we get

1
න 𝑓 𝑥 𝑑𝑥 = 𝑐1 𝑎0 + 𝑎1 𝑥1 + 𝑎2 𝑥12 + 𝑎3 𝑥13 + 𝑐2 𝑎0 + 𝑎1 𝑥2 + 𝑎2 𝑥22 + 𝑎3 𝑥23
−1

Equating equations, the two previous expressions yield


2
𝑎0 2 + 𝑎1 0 + 𝑎2 + 𝑎3 0
3
= 𝑐1 𝑎0 + 𝑎1 𝑥1 + 𝑎2 𝑥12 + 𝑎3 𝑥13 + 𝑐2 𝑎0 + 𝑎1 𝑥2 + 𝑎2 𝑥22 + 𝑎3 𝑥23
= 𝑎0 𝑐1 + 𝑐2 + 𝑎1 𝑐1 𝑥1 + 𝑐2 𝑥2 + 𝑎2 𝑐1 𝑥12 + 𝑐2 𝑥22 + 𝑎3 𝑐1 𝑥13 + 𝑐2 𝑥23

Gaussian Quadrature - Gaussian Quadrature 39


BASIS OF THE GAUSSIAN QUADRATURE
Since the constants 𝑎0 , 𝑎1 , 𝑎2 , 𝑎3 are arbitrary, we are left with the
following
𝑐1 + 𝑐2 = 2 𝑐1 𝑥1 + 𝑐2 𝑥2 = 0
2
2
𝑐1 𝑥1 + 𝑐2 𝑥2 =2
𝑐1 𝑥13 + 𝑐2 𝑥23 = 0
3

A little algebra show that this system of equations has the unique
solution
𝑐1 = 1 𝑐2 = 1
3 3
𝑥1 = − 𝑥2 =
3 3
Gaussian Quadrature - Gaussian Quadrature 40
BASIS OF THE GAUSSIAN QUADRATURE
The two point Gaussian quadrature rule gives the approximation

1
3 3
න 𝑓 𝑥 𝑑𝑥 ≈ 𝑓 − +𝑓 .
−1 3 3

NOTE This formula produces the exact result for every polynomial of
degree three or less.

Gaussian Quadrature - Gaussian Quadrature 41


LEGENDRE POLYNOMIALS
Legendre polynomials are a system of complete and orthogonal
polynomials that are solutions to Legendre’s differential equation
1 − 𝑥 2 𝑦 ′′ − 2𝑥𝑦 ′ + 𝑛 𝑛 + 1 𝑦 = 0.

The set that is relevant to our problem, 𝑃0 𝑥 , 𝑃1 𝑥 , … , 𝑃𝑛 𝑥 , …


with the following properties:
1. For each 𝑛, 𝑃𝑛 𝑥 is a monic polynomial of degree 𝑛.
1
2. ‫׬‬−1 𝑃 𝑥 𝑃𝑛 𝑥 𝑑𝑥 = 0 whenever 𝑃 𝑥 is a polynomial of degree
less than 𝑛.

Gaussian Quadrature - Gaussian Quadrature 42


LEGENDRE POLYNOMIALS
The first few Legendre polynomials are

1
𝑃0 𝑥 = 1 𝑃1 𝑥 = 𝑥 𝑃2 𝑥 = 𝑥2 −
3
3
3
6 2 3
4
𝑃3 𝑥 = 𝑥 − 𝑥 and 𝑃4 𝑥 = 𝑥 − 𝑥 +
5 7 35

The roots of these polynomials are distinct, lie in the interval −1, 1 ,
have symmetry with respect to the origin, and are the correct choices
for determining the parameters that give us the nodes and coefficients
for our quadrature method.
Gaussian Quadrature - Gaussian Quadrature 43
THEOREM
Suppose that 𝑥1 , … , 𝑥𝑛 are the roots of the 𝑛th Legendre polynomial 𝑃𝑛 𝑥
and for each 𝑖 = 1, … , 𝑛, the numbers 𝑐𝑖 are defined by
1 𝑛
𝑥 − 𝑥𝑗
𝑐𝑖 = න ෑ 𝑑𝑥
𝑥𝑖 − 𝑥𝑗
−1 𝑗=1
𝑗≠𝑖

If 𝑃 𝑥 is any polynomial of degree less than


𝑛
2𝑛, then
1
න 𝑃 𝑥 𝑑𝑥 = ෍ 𝑐𝑖 𝑃 𝑥𝑖
−1 𝑖=1

Gaussian Quadrature - Gaussian Quadrature 44


TABLE
The constants 𝑐𝑖 𝑛 Roots Coefficients
needed for the 2 0.5773502692 1.0000000000
quadrature rule can -0.5773502692 1.0000000000
be generated from
3 0.7745966692 0.5555555556
the equation in the
theorem. The 0.0000000000 0.8888888889
following lists these -0.7745966692 0.5555555556
values for 4 0.8611363116 0.3478548451
0.3399810436 0.6521451549
𝑛 = 2, 3, 4 -0.3399810436 0.6521451549
-0.8611363116 0.3478548451
Gaussian Quadrature - Gaussian Quadrature 45
EXERCISE 5
Approximate

1
න 𝑒 𝑥 cos 𝑥 𝑑𝑥
−1

using Gaussian quadrature with 𝑛 = 3.

Gaussian Quadrature - Gaussian Quadrature 46


OTHER INTERVALS
What if the integral is not posed over the interval −1,1 ?

Apply a change of variable to rewrite any integral over [𝑎, 𝑏] as in


integral over −1,1 .

𝑏
𝑏−𝑎 1 1 1
න 𝑔 𝑥 𝑑𝑥 = න 𝑔 𝑏−𝑎 𝑡+𝑎+𝑏 𝑑𝑡 = න 𝑓 𝑡 𝑑𝑡
𝑎 2 −1 2 −1

Gaussian Quadrature - Gaussian Quadrature 47


EXERCISE 6
Approximate

𝜋
න sin 𝑥 𝑑𝑥
0

using Gaussian quadrature with 𝑛 = 3.

Gaussian Quadrature - Gaussian Quadrature 48

You might also like