MA 214 Lecture 20
MA 214 Lecture 20
(Numerical Integration)
IDEA
∫b ∫b
f (x) dx ≈ Simpler function dx.
a a
MA 214 - NA Spring 2023-24 3 / 40
Interpolating Polynomial (Recall)
Theorem
For a given data set
x x0 x1 x2 x3 · · · xn
,
y y0 y1 y2 y3 · · · yn
Theorem
For a given data set
x x0 x1 x2 x3 · · · xn
,
y y0 y1 y2 y3 · · · yn
Theorem
For a given data set
x x0 x1 x2 x3 · · · xn
,
y y0 y1 y2 y3 · · · yn
f (x1 ) − p0 (x1 )
A1 =
(x1 − x0 )
MA 214 - NA Spring 2023-24 7 / 40
Newton’s Divided Differences
General Data Set
x x0 x1 x2 x3 · · · xn
.
f(x) f(x0 ) f(x1 ) f(x2 ) f(x3 ) · · · f(xn )
Newton form of interpolating polynomial
∏
pn (x) = A0 + A1 (x − x0 ) +A2 (x − x0 )(x − x1 ) + A3 2i=0 (x − xi )
∏
+ · · · + An n−1
i=0 (x − xi ),
A0 = f (x0 )
f (x1 ) − p0 (x1 )
A1 =
(x1 − x0 )
MA 214 - NA Spring 2023-24 7 / 40
Newton’s Divided Differences
x x0 x1 x2 x3 · · · xn
.
f(x) f(x0 ) f(x1 ) f(x2 ) f(x3 ) · · · f(xn )
∑
n ∏
k−1
pn (x) = f [x0 ] + f [x0 , x1 , · · · , xk ] (x − xi )
k=1 i=0
Approximation
Given n + 1 nodes x0 , x1 , · · · , xn
Approximation
Approximation
I(f ) ≈ I(pn )
Approximation
I(f ) ≈ I(pn )
The approximation is written as
( n )
∑
I(f ) ≈ I(pn ) = I f (xi )li (x)
i=0
Approximation
I(f ) ≈ I(pn )
The approximation is written as
( n )
∑ ∑
n
I(f ) ≈ I(pn ) = I f (xi )li (x) = f (xi )I(li )
i=0 i=0
Approximation
I(f ) ≈ I(pn )
The approximation is written as
( n )
∑ ∑
n
I(f ) ≈ I(pn ) = I f (xi )li (x) = f (xi )I(li )
i=0 i=0
= f (x0 )w0 + f (x1 )w1 + · · · + f (xn )wn ,
MA 214 - NA Spring 2023-24 11 / 40
Numerical Integration
Approximation
I(f ) ≈ I(pn )
The approximation is written as
( n )
∑ ∑
n
I(f ) ≈ I(pn ) = I f (xi )li (x) = f (xi )I(li )
i=0 i=0
= f (x0 )w0 + f (x1 )w1 + · · · + f (xn )wn , wi = I(li )
MA 214 - NA Spring 2023-24 11 / 40
Quadrature Rule 1: Rectangle Rule
I(f ) ≈ I(pn ) = f (x0 )w0 +f (x1 )w1 + · · · + f (xn )wn , i.e. TAKE n = 0.
I(f ) ≈ I(pn ) = f (x0 )w0 +f (x1 )w1 + · · · + f (xn )wn , i.e. TAKE n = 0.
Then p0 (x) = f (x0 ), and therefore
I(p0 ) = (b − a)f (x0 ).
I(f ) ≈ I(pn ) = f (x0 )w0 +f (x1 )w1 + · · · + f (xn )wn , i.e. TAKE n = 0.
Then p0 (x) = f (x0 ), and therefore
I(p0 ) = (b − a)f (x0 ).
If x0 = a, then this approximation becomes
I(f ) ≈ IR (f ) := (b − a)f (a)
and is called rectangle rule.
I(f ) ≈ I(pn ) = f (x0 )w0 +f (x1 )w1 + · · · + f (xn )wn , i.e. TAKE n = 0.
Then p0 (x) = f (x0 ), and therefore
I(p0 ) = (b − a)f (x0 ).
If x0 = a, then this approximation becomes
I(f ) ≈ IR (f ) := (b − a)f (a)
y f (x)
and is called rectangle rule.
I(f)
a b x
MA 214 - NA Spring 2023-24 13 / 40
Numerical Integration: Rectangle Rule
I(f ) ≈ I(pn ) = f (x0 )w0 +f (x1 )w1 + · · · + f (xn )wn , i.e. TAKE n = 0.
Then p0 (x) = f (x0 ), and therefore
I(p0 ) = (b − a)f (x0 ).
If x0 = a, then this approximation becomes
I(f ) ≈ IR (f ) := (b − a)f (a)
y f (x)
and is called rectangle rule.
IRI(f)
(f )
a b x
MA 214 - NA Spring 2023-24 14 / 40
Numerical Integration: Rectangle Rule (contd.)
Mathematical Error
Mathematical Error
Mathematical Error
Proof
For each x ∈ (a, b], from the linear interpolating polynomial for f at the
nodes a and x, we can write
Proof
For each x ∈ (a, b], from the linear interpolating polynomial for f at the
nodes a and x, we can write
If x0 = (a + b)/2, we get
( )
a+b
I(f ) ≈ IM (f ) := (b − a)f
2
and is called the mid-point rule.
If x0 = (a + b)/2, we get
( )
a+b
I(f ) ≈ IM (f ) := (b − a)f
2
and is called the mid-point rule.
I(f) ≈ I(pn ) = f (x0 )w0 + f (x1 )w1 + · · · + f (xn )wn , i.e. TAKE n = 1.
I(f) ≈ I(pn ) = f (x0 )w0 + f (x1 )w1 + · · · + f (xn )wn , i.e. TAKE n = 1.
Then
p1 (x) = f (x0 ) + f [x0 , x1 ](x − x0 ),
I(f) ≈ I(pn ) = f (x0 )w0 + f (x1 )w1 + · · · + f (xn )wn , i.e. TAKE n = 1.
Then
p1 (x) = f (x0 ) + f [x0 , x1 ](x − x0 ),
and therefore
∫ b
I(f) ≈ IT (f) := (f (x0 ) + f [x0 , x1 ](x − x0 )) dx.
a
I(f) ≈ I(pn ) = f (x0 )w0 + f (x1 )w1 + · · · + f (xn )wn , i.e. TAKE n = 1.
Then
p1 (x) = f (x0 ) + f [x0 , x1 ](x − x0 ),
and therefore
∫ b
I(f) ≈ IT (f) := (f (x0 ) + f [x0 , x1 ](x − x0 )) dx.
a
Taking x0 = a and x1 = b, we get
( )
f (a) + f (b)
IT (f) = (b − a)
2
I(f) ≈ I(pn ) = f (x0 )w0 + f (x1 )w1 + · · · + f (xn )wn , i.e. TAKE n = 1.
Then
p1 (x) = f (x0 ) + f [x0 , x1 ](x − x0 ),
and therefore
∫ b
I(f) ≈ IT (f) := (f (x0 ) + f [x0 , x1 ](x − x0 )) dx.
a
Taking x0 = a and x1 = b, we get
( )
f (a) + f (b)
IT (f) = (b − a)
2
and is called the Trapezoidal Rule.
MA 214 - NA Spring 2023-24 25 / 40
Numerical Integration: Trapezoidal Rule (contd.)
y f (x)
I(f)
a b x
y
f (x)
IT (f)
a b x
Mathematical Error
Mathematical Error
Mathematical Error
Proof
We have
f (x) = f (a) + f [a, b](x − a) + f [a, b, x](x − a)(x − b)
Proof
We have
f (x) = f (a) + f [a, b](x − a) + f [a, b, x](x − a)(x − b)
= p1 (x) + f [a, b, x](x − a)(x − b)
Proof
We have
f (x) = f (a) + f [a, b](x − a) + f [a, b, x](x − a)(x − b)
= p1 (x) + f [a, b, x](x − a)(x − b)
Integrating over the interval [a, b], we get
∫b
I(f) = IT (f) + f [a, b, x](x − a)(x − b)dx.
a
Proof
The function
The function
∫b
MET (f) = f [a, b, η] (x − a)(x − b)dx,
a
f (n+1) (ξx )
f [x0 , x1 , · · · , xn , x] =
(n + 1)!
f (n+1) (ξx )
f [x0 , x1 , · · · , xn , x] =
(n + 1)!
⇒ MET (f ) ≈ −0.0569.
⇒ MET (f ) ≈ −0.0569.
Recall
f 00 (η)(b − a)3
MET (f) = − ,
12
⇒ MET (f ) ≈ −0.0569.
Recall
f 00 (η)(b − a)3
MET (f) = − ,
12
Using the error formula, we get the bounds for MET (f) as
1 1
− ≈ −0.1667 < MET (f) < − ≈ −0.02083
6 48
which clearly holds in the present case.
MA 214 - NA Spring 2023-24 34 / 40
Quadrature Rule 2(a): Composite Trapezoidal Rule
Then, we get
∫ b n−1 ∫
∑ xj+1
I(f) = f (x)dx = f (x)dx.
a j=0 xj