0% found this document useful (0 votes)
5 views

MA 214 Lecture 20

Uploaded by

mugdha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

MA 214 Lecture 20

Uploaded by

mugdha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 106

Introduction to Numerical Analysis

(Numerical Integration)

MA 214, Spring 2023-24.

MA 214 - NA Spring 2023-24 1 / 40


Numerical Integration

MA 214 - NA Spring 2023-24 2 / 40


Numerical Integration

The problem is to evaluate the number


∫ b
I(f ) = f (x)dx.
a

MA 214 - NA Spring 2023-24 3 / 40


Numerical Integration

The problem is to evaluate the number


∫ b
I(f ) = f (x)dx.
a

The process of approximating the value of I(f ) is usually referred to as


numerical integration or quadrature rule.

MA 214 - NA Spring 2023-24 3 / 40


Numerical Integration

The problem is to evaluate the number


∫ b
I(f ) = f (x)dx.
a

The process of approximating the value of I(f ) is usually referred to as


numerical integration or quadrature rule.

IDEA

f (x) ≈ Simpler function.

MA 214 - NA Spring 2023-24 3 / 40


Numerical Integration
The problem is to evaluate the number
∫ b
I(f ) = f (x)dx.
a

The process of approximating the value of I(f ) is usually referred to as


numerical integration or quadrature rule.
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

MA 214 - NA Spring 2023-24 4 / 40


Interpolating Polynomial (Recall)

Theorem
For a given data set
x x0 x1 x2 x3 · · · xn
,
y y0 y1 y2 y3 · · · yn

there ALWAYS exists an interpolating polynomial

MA 214 - NA Spring 2023-24 4 / 40


Interpolating Polynomial (Recall)

Theorem
For a given data set
x x0 x1 x2 x3 · · · xn
,
y y0 y1 y2 y3 · · · yn

there ALWAYS exists an interpolating polynomial


and

this interpolating polynomial is UNIQUE


MA 214 - NA Spring 2023-24 4 / 40
Lagrange form of Interpolating Polynomial
Formula 1: Lagrange Form
Theorem (Lagrange form of Interpolating Polynomial)
Given data set
x x0 x1 x2 x3 · · · xn
,
y y0 y1 y2 y3 · · · yn

Lagrange form of interpolating polynomial is given by



n ∏
n
(x − xi )
pn (x) = yk lk (x), lk (x) = .
(xk − xi )
k=0 i=0
i6=k
MA 214 - NA Spring 2023-24 5 / 40
Newton form of Interpolating Polynomial (contd.)
Theorem (Newton form of Interpolating Polynomial)
Given data set
x x0 x1 x2 x3 · · · xn
,
y y0 y1 y2 y3 · · · yn

MA 214 - NA Spring 2023-24 6 / 40


Newton form of Interpolating Polynomial (contd.)
Theorem (Newton form of Interpolating Polynomial)
Given data set
x x0 x1 x2 x3 · · · xn
,
y y0 y1 y2 y3 · · · yn

The Newton form of interpolating polynomial pn (x) can be written


as

pn (x) = A0 + A1 (x − x0 ) +A2 (x − x0 )(x − x1 ) + A3 2i=0 (x − xi )

+ · · · + An n−1i=0 (x − xi )

MA 214 - NA Spring 2023-24 6 / 40


Newton form of Interpolating Polynomial (contd.)
Theorem (Newton form of Interpolating Polynomial)
Given data set
x x0 x1 x2 x3 · · · xn
,
y y0 y1 y2 y3 · · · yn

The Newton form of interpolating polynomial pn (x) can be written


as

pn (x) = A0 + A1 (x − x0 ) +A2 (x − x0 )(x − x1 ) + A3 2i=0 (x − xi )

+ · · · + An n−1i=0 (x − xi )

where A0 , A1 , · · · , An are constants obtained to satisfy interpolation


conditions.
MA 214 - NA Spring 2023-24 6 / 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 )

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 )

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
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

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

In new notation, we write the interpolating polynomial as :


n ∏
k−1
pn (x) = f [x0 ] + f [x0 , x1 , · · · , xk ] (x − xi )
k=1 i=0

MA 214 - NA Spring 2023-24 8 / 40


We then showed that :
f [x1 , x2 , · · · , xn ] − f [x0 , x1 , · · · , xn−1 ]
f [x0 , x1 , · · · , xn ] =
xn − x0

MA 214 - NA Spring 2023-24 9 / 40


We then showed that :
f [x1 , x2 , · · · , xn ] − f [x0 , x1 , · · · , xn−1 ]
f [x0 , x1 , · · · , xn ] =
xn − x0

This ratio is called nth -order divided difference.


Definition (Divided Differences)
Let x0 , x1 , · · · , xn be distinct nodes.

MA 214 - NA Spring 2023-24 9 / 40


We then showed that :
f [x1 , x2 , · · · , xn ] − f [x0 , x1 , · · · , xn−1 ]
f [x0 , x1 , · · · , xn ] =
xn − x0

This ratio is called nth -order divided difference.


Definition (Divided Differences)
Let x0 , x1 , · · · , xn be distinct nodes.
Let pn (x) be the polynomial interpolating a function f at the nodes
x0 , x1 , · · · , xn .

MA 214 - NA Spring 2023-24 9 / 40


We then showed that :
f [x1 , x2 , · · · , xn ] − f [x0 , x1 , · · · , xn−1 ]
f [x0 , x1 , · · · , xn ] =
xn − x0

This ratio is called nth -order divided difference.


Definition (Divided Differences)
Let x0 , x1 , · · · , xn be distinct nodes.
Let pn (x) be the polynomial interpolating a function f at the nodes
x0 , x1 , · · · , xn .
The coefficient of xn in the polynomial pn (x)

MA 214 - NA Spring 2023-24 9 / 40


We then showed that :
f [x1 , x2 , · · · , xn ] − f [x0 , x1 , · · · , xn−1 ]
f [x0 , x1 , · · · , xn ] =
xn − x0

This ratio is called nth -order divided difference.


Definition (Divided Differences)
Let x0 , x1 , · · · , xn be distinct nodes.
Let pn (x) be the polynomial interpolating a function f at the nodes
x0 , x1 , · · · , xn .
The coefficient of xn in the polynomial pn (x), is denoted by
f [x0 , x1 , · · · , xn ]

MA 214 - NA Spring 2023-24 9 / 40


We then showed that :
f [x1 , x2 , · · · , xn ] − f [x0 , x1 , · · · , xn−1 ]
f [x0 , x1 , · · · , xn ] =
xn − x0

This ratio is called nth -order divided difference.


Definition (Divided Differences)
Let x0 , x1 , · · · , xn be distinct nodes.
Let pn (x) be the polynomial interpolating a function f at the nodes
x0 , x1 , · · · , xn .
The coefficient of xn in the polynomial pn (x), is denoted by
f [x0 , x1 , · · · , xn ], is called an nth divided difference of f.

MA 214 - NA Spring 2023-24 9 / 40


Numerical Integration

The problem is to evaluate the number


∫ b
I(f ) = f (x)dx.
a

Approximation

Given n + 1 nodes x0 , x1 , · · · , xn

MA 214 - NA Spring 2023-24 10 / 40


Numerical Integration

The problem is to evaluate the number


∫ b
I(f ) = f (x)dx.
a

Approximation

Given n + 1 nodes x0 , x1 , · · · , xn Construct pn (x)

MA 214 - NA Spring 2023-24 10 / 40


Numerical Integration

The problem is to evaluate the number


∫ b
I(f ) = f (x)dx.
a

Approximation

Given n + 1 nodes x0 , x1 , · · · , xn Construct pn (x)

I(f ) ≈ I(pn )

MA 214 - NA Spring 2023-24 10 / 40


Numerical Integration

Approximation

Given n + 1 nodes x0 , x1 , · · · , xn Construct pn (x)

I(f ) ≈ I(pn )
The approximation is written as
( n )

I(f ) ≈ I(pn ) = I f (xi )li (x)
i=0

MA 214 - NA Spring 2023-24 11 / 40


Numerical Integration

Approximation

Given n + 1 nodes x0 , x1 , · · · , xn Construct pn (x)

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

MA 214 - NA Spring 2023-24 11 / 40


Numerical Integration

Approximation

Given n + 1 nodes x0 , x1 , · · · , xn Construct pn (x)

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

Given n + 1 nodes x0 , x1 , · · · , xn Construct pn (x)

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

MA 214 - NA Spring 2023-24 12 / 40


Numerical Integration: Rectangle Rule

I(f ) ≈ I(pn ) = f (x0 )w0 +f (x1 )w1 + · · · + f (xn )wn ,

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.

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 ).

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)
and is called rectangle rule.

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.

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

MER (f ) := I(f ) − I(p0 ).

MA 214 - NA Spring 2023-24 15 / 40


Numerical Integration: Rectangle Rule (contd.)

Mathematical Error

MER (f ) := I(f ) − I(p0 ).

Theorem (Error in Rectangle Rule)


Let f ∈ C1 [a, b].

MA 214 - NA Spring 2023-24 15 / 40


Numerical Integration: Rectangle Rule (contd.)

Mathematical Error

MER (f ) := I(f ) − I(p0 ).

Theorem (Error in Rectangle Rule)


Let f ∈ C1 [a, b].The mathematical error MER (f ) of the rectangle rule
takes the form
f 0 (η)(b − a)2
MER (f ) = ,
2
for some η ∈ (a, b).
MA 214 - NA Spring 2023-24 15 / 40
Numerical Integration: Rectangle Rule (contd.)

Proof

For each x ∈ (a, b], from the linear interpolating polynomial for f at the
nodes a and x, we can write

f (x) = p0 (x) + f [a, x](x − a).

MA 214 - NA Spring 2023-24 16 / 40


Numerical Integration: Rectangle Rule (contd.)

Proof

For each x ∈ (a, b], from the linear interpolating polynomial for f at the
nodes a and x, we can write

f (x) = p0 (x) + f [a, x](x − a).

Therefore, the mathematical error in the rectangle rule is given by


∫b
MER (f ) = I(f ) − IR (f ) = f [a, x](x − a) dx.
a

MA 214 - NA Spring 2023-24 16 / 40


Numerical Integration: Rectangle Rule (contd.)
Proof

Therefore, the mathematical error in the rectangle rule is given by


∫b
MER (f ) = I(f ) − IR (f ) = f [a, x](x − a) dx.
a

Using mean-value theorem for integrals, we get


∫b
MER (f ) = f [a, ξ] (x − a) dx,
a

for some ξ ∈ (a, b).


MA 214 - NA Spring 2023-24 17 / 40
Numerical Integration: Rectangle Rule (contd.)
Proof

Using mean-value theorem for integrals, we get


∫b
MER (f ) = f [a, ξ] (x − a) dx,
a

for some ξ ∈ (a, b).


By mean value theorem for derivatives, f [a, ξ] = f 0 (η) for some
η ∈ (a, ξ). Thus, we get (for some η ∈ (a, b))
f 0 (η)(b − a)2
MER (f ) = .
2
MA 214 - NA Spring 2023-24 18 / 40
Quadrature Rule 1(a): Mid-Point Rule

MA 214 - NA Spring 2023-24 19 / 40


Numerical Integration: 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.

MA 214 - NA Spring 2023-24 20 / 40


Numerical Integration: 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.

Mathematical error is left as an exercise

MA 214 - NA Spring 2023-24 20 / 40


Numerical Integration: Composite Rectangle Rule

To improve on the approximation

MA 214 - NA Spring 2023-24 21 / 40


Numerical Integration: Composite Rectangle Rule

To improve on the approximation


break the interval [a, b] into smaller subintervals and

MA 214 - NA Spring 2023-24 21 / 40


Numerical Integration: Composite Rectangle Rule

To improve on the approximation


break the interval [a, b] into smaller subintervals and
apply the rectangle rule on each subinterval.

MA 214 - NA Spring 2023-24 21 / 40


Numerical Integration: Composite Rectangle Rule

To improve on the approximation


break the interval [a, b] into smaller subintervals and
apply the rectangle rule on each subinterval.
We will derive a general formula for this.

MA 214 - NA Spring 2023-24 21 / 40


Numerical Integration: Composite Rectangle Rule (contd.)
Let us subdivide the interval [a, b] into n equal subintervals of length
b−a
h=
n

MA 214 - NA Spring 2023-24 22 / 40


Numerical Integration: Composite Rectangle Rule (contd.)
Let us subdivide the interval [a, b] into n equal subintervals of length
b−a
h=
n
with endpoints of the subintervals as
xj = a + jh, j = 0, 1, · · · , n.

MA 214 - NA Spring 2023-24 22 / 40


Numerical Integration: Composite Rectangle Rule (contd.)
Let us subdivide the interval [a, b] into n equal subintervals of length
b−a
h=
n
with endpoints of the subintervals as
xj = a + jh, j = 0, 1, · · · , n.
Then, we get ∫ b
I(f ) = f (x)dx
a

MA 214 - NA Spring 2023-24 22 / 40


Numerical Integration: Composite Rectangle Rule (contd.)
Let us subdivide the interval [a, b] into n equal subintervals of length
b−a
h=
n
with endpoints of the subintervals as
xj = a + jh, j = 0, 1, · · · , n.
Then, we get ∫ b
I(f ) = f (x)dx
a
∫ xn
= f (x)dx
x0
MA 214 - NA Spring 2023-24 22 / 40
Numerical Integration: Composite Rectangle Rule (contd.)
Let us subdivide the interval [a, b] into n equal subintervals of length
b−a
h=
n
with endpoints of the subintervals as
xj = a + jh, j = 0, 1, · · · , n.
Then, we get ∫ b
I(f ) = f (x)dx
a
∫ xn n−1 ∫
∑ xj+1
= f (x)dx = f (x)dx.
x0 j=0 xj
MA 214 - NA Spring 2023-24 22 / 40
Numerical Integration: Composite Rectangle Rule (contd.)
∫ b
I(f ) = f (x)dx
a
∫ xn n−1 ∫
∑ xj+1
= f (x)dx = f (x)dx.
x0 j=0 xj

Using Rectangle rule on the subinterval [xj , xj+1 ], we get

MA 214 - NA Spring 2023-24 23 / 40


Numerical Integration: Composite Rectangle Rule (contd.)
∫ b
I(f ) = f (x)dx
a
∫ xn n−1 ∫
∑ xj+1
= f (x)dx = f (x)dx.
x0 j=0 xj

Using Rectangle rule on the subinterval [xj , xj+1 ], we get


∫ xj+1
f (x)dx ≈ hf (xj ), j = 0, 1, · · · , n.
xj

MA 214 - NA Spring 2023-24 23 / 40


Numerical Integration: Composite Rectangle Rule (contd.)
∫ b
I(f ) = f (x)dx
a
∫ xn n−1 ∫
∑ xj+1
= f (x)dx = f (x)dx.
x0 j=0 xj

Using Rectangle rule on the subinterval [xj , xj+1 ], we get


∫ xj+1
f (x)dx ≈ hf (xj ), j = 0, 1, · · · , n.
xj

Substituting this in the above equation, we get


I(f ) ≈ hf (x0 ) + hf (x1 ) + · · · + hf (xn ).

MA 214 - NA Spring 2023-24 23 / 40


Numerical Integration: Composite Rectangle Rule (contd.)
∫ b
I(f ) = f (x)dx
a
∫ xn n−1 ∫
∑ xj+1
= f (x)dx = f (x)dx.
x0 j=0 xj

Using Rectangle rule on the subinterval [xj , xj+1 ], we get


∫ xj+1
f (x)dx ≈ hf (xj ), j = 0, 1, · · · , n.
xj

Substituting this in the above equation, we get


I(f ) ≈ hf (x0 ) + hf (x1 ) + · · · + hf (xn ).
This rule is called the Composite Rectangle rule.
MA 214 - NA Spring 2023-24 23 / 40
Quadrature Rule 2: Trapezoidal Rule

MA 214 - NA Spring 2023-24 24 / 40


Numerical Integration: Trapezoidal Rule

I(f) ≈ I(pn ) = f (x0 )w0 + f (x1 )w1 + · · · + f (xn )wn ,

MA 214 - NA Spring 2023-24 25 / 40


Numerical Integration: Trapezoidal Rule

I(f) ≈ I(pn ) = f (x0 )w0 + f (x1 )w1 + · · · + f (xn )wn , i.e. TAKE n = 1.

MA 214 - NA Spring 2023-24 25 / 40


Numerical Integration: Trapezoidal Rule

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 ),

MA 214 - NA Spring 2023-24 25 / 40


Numerical Integration: Trapezoidal Rule

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

MA 214 - NA Spring 2023-24 25 / 40


Numerical Integration: Trapezoidal Rule

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

MA 214 - NA Spring 2023-24 25 / 40


Numerical Integration: Trapezoidal Rule

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

MA 214 - NA Spring 2023-24 26 / 40


Numerical Integration: Trapezoidal Rule (contd.)

y
f (x)

IT (f)

a b x

MA 214 - NA Spring 2023-24 27 / 40


Numerical Integration: Trapezoidal Rule (contd.)

Mathematical Error

MET (f) := I(f) − I(p1 ).

MA 214 - NA Spring 2023-24 28 / 40


Numerical Integration: Trapezoidal Rule (contd.)

Mathematical Error

MET (f) := I(f) − I(p1 ).

Theorem (Error in Trapezoidal Rule)


Let f ∈ C2 [a, b].

MA 214 - NA Spring 2023-24 28 / 40


Numerical Integration: Trapezoidal Rule (contd.)

Mathematical Error

MET (f) := I(f) − I(p1 ).

Theorem (Error in Trapezoidal Rule)


Let f ∈ C2 [a, b].The mathematical error MET (f) of the trapezoidal rule
takes the form
f 00 (η)(b − a)3
MET (f) = − ,
12
for some η ∈ (a, b).
MA 214 - NA Spring 2023-24 28 / 40
Numerical Integration: Trapezoidal Rule (contd.)

Proof

We have
f (x) = f (a) + f [a, b](x − a) + f [a, b, x](x − a)(x − b)

MA 214 - NA Spring 2023-24 29 / 40


Numerical Integration: Trapezoidal Rule (contd.)

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)

MA 214 - NA Spring 2023-24 29 / 40


Numerical Integration: Trapezoidal Rule (contd.)

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

MA 214 - NA Spring 2023-24 29 / 40


Numerical Integration: Trapezoidal Rule (contd.)

Proof

f (x) = 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
Therefore the mathematical error is given by
∫b
MET (f) = I(f) − IT (f) = f [a, b, x](x − a)(x − b)dx.
a
MA 214 - NA Spring 2023-24 30 / 40
Numerical Integration: Trapezoidal Rule (contd.)

The function

x 7−→ f [a, b, x] is continuous and we have (x − a)(x − b) < 0, x ∈ (a, b)

MA 214 - NA Spring 2023-24 31 / 40


Numerical Integration: Trapezoidal Rule (contd.)

The function

x 7−→ f [a, b, x] is continuous and we have (x − a)(x − b) < 0, x ∈ (a, b)

Mean-value theorem for integrals then gives

∫b
MET (f) = f [a, b, η] (x − a)(x − b)dx,
a

for some η ∈ (a, b).

MA 214 - NA Spring 2023-24 31 / 40


Numerical Integration: Trapezoidal Rule (contd.)

We use the formula

f (n+1) (ξx )
f [x0 , x1 , · · · , xn , x] =
(n + 1)!

for some ξx ∈ (a, b).

MA 214 - NA Spring 2023-24 32 / 40


Numerical Integration: Trapezoidal Rule (contd.)

We use the formula

f (n+1) (ξx )
f [x0 , x1 , · · · , xn , x] =
(n + 1)!

for some ξx ∈ (a, b).


Using this formula in the mathematical error
∫b
MET (f) = f [a, b, η] (x − a)(x − b)dx,
a
we get the desired formula after a simple integration.
MA 214 - NA Spring 2023-24 32 / 40
Numerical Integration: Trapezoidal Rule (contd.)
Example: Approximate the integral
∫ 1
1
I= dx,
0 1 + x

MA 214 - NA Spring 2023-24 33 / 40


Numerical Integration: Trapezoidal Rule (contd.)
Example: Approximate the integral
∫ 1
1
I= dx,
0 1 + x

The true value is I = log(2) ≈ 0.693147.

MA 214 - NA Spring 2023-24 33 / 40


Numerical Integration: Trapezoidal Rule (contd.)
Example: Approximate the integral
∫ 1
1
I= dx,
0 1 + x

The true value is I = log(2) ≈ 0.693147.


Using the trapezoidal rule, we get
( )
1 1 3
IT (f) = 1+ = = 0.75.
2 2 4

MA 214 - NA Spring 2023-24 33 / 40


Numerical Integration: Trapezoidal Rule (contd.)
Example: Approximate the integral
∫ 1
1
I= dx,
0 1 + x

The true value is I = log(2) ≈ 0.693147.


Using the trapezoidal rule, we get
( )
1 1 3
IT (f) = 1+ = = 0.75.
2 2 4

⇒ MET (f ) ≈ −0.0569.

MA 214 - NA Spring 2023-24 33 / 40


Numerical Integration: Trapezoidal Rule (contd.)

⇒ MET (f ) ≈ −0.0569.
Recall
f 00 (η)(b − a)3
MET (f) = − ,
12

MA 214 - NA Spring 2023-24 34 / 40


Numerical Integration: Trapezoidal Rule (contd.)

⇒ 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

MA 214 - NA Spring 2023-24 35 / 40


Numerical Integration: Composite Trapezoidal Rule

To improve on the approximation, especially, when f (x) is not a nearly


linear function on [a, b],

MA 214 - NA Spring 2023-24 36 / 40


Numerical Integration: Composite Trapezoidal Rule

To improve on the approximation, especially, when f (x) is not a nearly


linear function on [a, b],
break the interval [a, b] into smaller subintervals and

MA 214 - NA Spring 2023-24 36 / 40


Numerical Integration: Composite Trapezoidal Rule

To improve on the approximation, especially, when f (x) is not a nearly


linear function on [a, b],
break the interval [a, b] into smaller subintervals and
apply the Trepezoidal rule on each subinterval.

MA 214 - NA Spring 2023-24 36 / 40


Numerical Integration: Composite Trapezoidal Rule

To improve on the approximation, especially, when f (x) is not a nearly


linear function on [a, b],
break the interval [a, b] into smaller subintervals and
apply the Trepezoidal rule on each subinterval.
We will derive a general formula for this.

MA 214 - NA Spring 2023-24 36 / 40


Numerical Integration: Composite Trapezoidal Rule (contd.)
Let us subdivide the interval [a, b] into n equal subintervals of length
b−a
h=
n

MA 214 - NA Spring 2023-24 37 / 40


Numerical Integration: Composite Trapezoidal Rule (contd.)
Let us subdivide the interval [a, b] into n equal subintervals of length
b−a
h=
n
with endpoints of the subintervals as
xj = a + jh, j = 0, 1, · · · , n.

MA 214 - NA Spring 2023-24 37 / 40


Numerical Integration: Composite Trapezoidal Rule (contd.)
Let us subdivide the interval [a, b] into n equal subintervals of length
b−a
h=
n
with endpoints of the subintervals as
xj = a + jh, j = 0, 1, · · · , n.
Then, we get ∫ ∫
b xn
I(f) = f (x)dx = f (x)dx
a x0

MA 214 - NA Spring 2023-24 37 / 40


Numerical Integration: Composite Trapezoidal Rule (contd.)
Let us subdivide the interval [a, b] into n equal subintervals of length
b−a
h=
n
with endpoints of the subintervals as
xj = a + jh, j = 0, 1, · · · , n.
Then, we get ∫ ∫
b xn
I(f) = f (x)dx = f (x)dx
a x0
∑ ∫ xj+1
n−1
= f (x)dx.
j=0 xj
MA 214 - NA Spring 2023-24 37 / 40
Numerical Integration: Composite Trapezoidal Rule (contd.)
Then, we get
∫ b n−1 ∫ xj+1

I(f ) = f (x)dx = f (x)dx.
a j=0 xj

Using Trapezoidal rule on the subinterval [xj , xj+1 ], we get

MA 214 - NA Spring 2023-24 38 / 40


Numerical Integration: Composite Trapezoidal Rule (contd.)
Then, we get
∫ b n−1 ∫ xj+1

I(f ) = f (x)dx = f (x)dx.
a j=0 xj

Using Trapezoidal rule on the subinterval [xj , xj+1 ], we get


∫ xj+1 ( )
f (xj ) + f (xj+1 )
f (x)dx ≈ h , j = 0, 1, · · · , n.
xj 2

MA 214 - NA Spring 2023-24 38 / 40


Numerical Integration: Composite Trapezoidal Rule (contd.)
Then, we get
∫ b n−1 ∫ xj+1

I(f ) = f (x)dx = f (x)dx.
a j=0 xj

Using Trapezoidal rule on the subinterval [xj , xj+1 ], we get


∫ xj+1 ( )
f (xj ) + f (xj+1 )
f (x)dx ≈ h , j = 0, 1, · · · , n.
xj 2
Substituting this in the above equation, we get
[ ] [ ] [ ]
f (x0 ) + f (x1 ) f (x1 ) + f (x2 ) f (xn−1 ) + f (xn )
I(f ) ≈ h +h +· · ·+h .
2 2 2
MA 214 - NA Spring 2023-24 38 / 40
Numerical Integration: Composite Trapezoidal Rule (contd.)

Then, we get
∫ b n−1 ∫
∑ xj+1
I(f) = f (x)dx = f (x)dx.
a j=0 xj

Using Trapezoidal rule on the subinterval [xj , xj+1 ], we get


[ ]
n 1 1
IT (f ) := h f (x0 ) + f (x1 ) + f (x2 ) + · · · + f (xn−1 ) + f (xn ) .
2 2

This rule is called the Composite Trapezoidal rule.

MA 214 - NA Spring 2023-24 39 / 40


Numerical Integration: Composite Trapezoidal Rule (contd.)
Example: Using composite trapezoidal rule with n = 2,

MA 214 - NA Spring 2023-24 40 / 40


Numerical Integration: Composite Trapezoidal Rule (contd.)
Example: Using composite trapezoidal rule with n = 2, let us
approximate the integral
∫ 1
1
I= dx.
0 1 + x

MA 214 - NA Spring 2023-24 40 / 40


Numerical Integration: Composite Trapezoidal Rule (contd.)
Example: Using composite trapezoidal rule with n = 2, let us
approximate the integral
∫ 1
1
I= dx.
0 1 + x

The true value is I = log(2) ≈ 0.693147.

MA 214 - NA Spring 2023-24 40 / 40


Numerical Integration: Composite Trapezoidal Rule (contd.)
Example: Using composite trapezoidal rule with n = 2, let us
approximate the integral
∫ 1
1
I= dx.
0 1 + x

The true value is I = log(2) ≈ 0.693147.


Now, the composite trapezoidal rule with x0 = 0, x1 = 1/2 and x2 = 1
gives
IT2 (f) ≈ 0.70833.

MA 214 - NA Spring 2023-24 40 / 40


Numerical Integration: Composite Trapezoidal Rule (contd.)
Example: Using composite trapezoidal rule with n = 2, let us
approximate the integral
∫ 1
1
I= dx.
0 1 + x

The true value is I = log(2) ≈ 0.693147.


Now, the composite trapezoidal rule with x0 = 0, x1 = 1/2 and x2 = 1
gives
IT2 (f) ≈ 0.70833.
Thus the error is −0.0152.
MA 214 - NA Spring 2023-24 40 / 40
Numerical Integration: Composite Trapezoidal Rule (contd.)
Example: Using composite trapezoidal rule with n = 2, let us
approximate the integral
∫ 1
1
I= dx.
0 1 + x

The true value is I = log(2) ≈ 0.693147.


Now, the composite trapezoidal rule with x0 = 0, x1 = 1/2 and x2 = 1
gives
IT2 (f) ≈ 0.70833.
Thus the error is −0.0152. Recall trapezoidal rule gave −0.0569.
MA 214 - NA Spring 2023-24 40 / 40

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy