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

Numerical Differentiation and Integration: Lecture Series On " Numerical Techniques and Programming in Matlab"

The document describes numerical techniques for differentiation and integration. It discusses approximating derivatives of functions using Taylor series expansions and finite differences. Specific methods covered include forward, backward and central difference formulas for approximating the first and second derivatives of functions. The document also describes using interpolating polynomials to estimate derivatives from discrete data points. Examples are provided to demonstrate computing derivatives numerically.

Uploaded by

ahmed
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)
102 views

Numerical Differentiation and Integration: Lecture Series On " Numerical Techniques and Programming in Matlab"

The document describes numerical techniques for differentiation and integration. It discusses approximating derivatives of functions using Taylor series expansions and finite differences. Specific methods covered include forward, backward and central difference formulas for approximating the first and second derivatives of functions. The document also describes using interpolating polynomials to estimate derivatives from discrete data points. Examples are provided to demonstrate computing derivatives numerically.

Uploaded by

ahmed
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/ 55

NUMERICAL DIFFERENTIATION AND INTEGRATION

Lecture series on “ Numerical Techniques and Programming in

MATLAB”

VBS Purvanchal University, Jaunpur

July 22-28, 2016

by

Dr. Sarvesh Kumar,

IIST Trivandrum

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 1
Numerical Differentiation

Basic problems

• Derive a formula that approximates the derivative of a function in

terms of linear combination of function values ( Function may be

known )

• Approximate the value of a derivative of a function defined by discrete

data.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 2
Solution Approaches ..

• Use Taylor Series Expansion.

• Pass a polynomial through the given data and differentiate the

interpolating polynomial.

Applications

To solve Ordinary and Partial Differential Equations.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 3
First Derivative..

Let f : [a, b] −→ R, then the derivative of f is another function say


0
f : [a, b] −→ R and defined by

f (c + h) − f (c)
f 0(c) = lim , ∀c ∈ (a, b).
h→0 h

Geometrically Speaking f 0(c) is the slope of tangent to the curve f (x)

at x = c.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 4
Taylor Series

Derivative of a function at x = x0

Suppose f has two continuous derivatives. Then, by Taylor’s Theorem

h2 00 0
f (x0 + h) = f (x0) + hf (x0) + f (θ)
2

where θ ∈ (x0, x0 + h). Now,

f (x0 + h) − f (x0)
f 0(x0) ≈
h

Called Forward Formula

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 5
Error

Error = |true value − approximate value|

h ”
|ED (f )| ≤ max |f (θ)|
θ∈[a,b] 2

Example

Example1. Using Taylor series find the derivative of f (x) = x2 at x=1,

with h = .1. Also compute the error.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 6
Other formulae

Backward Formula

f (x0) − f (x0 − h)
f 0(x0) ≈
h

Central Formula

f (x0 + h) − f (x0 − h)
f 0(x0) ≈
2h

Similarly, we can drive (Second Derivative )

00 f (x0 + h) − 2f (x0) + f (x0 − h)


f (x0) ≈
h2

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 7
Derivative for discrete data using interpolating

polynomial

x x0 x1 x2 ... xn

f (x) f (x0) f (x1) f (x3) ... f (xn)

Assumption: x0, x1 · · · xn are equispaced i.e., xi − xi−1 = h. Where

the explicit nature of the function f is not known.

Remark 1: We can used Newton’s Forward or Backward formula

depends the location of the point

Remark 2: If data is not equispaced then Lagrange interpolating

polynomial can be used.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 8
Using Newton’s forward difference formula

s(s − 1) 2 s(s − 1)(s − 2) 3


f (x) ≈ Pn(x) = f (x0)+s∆f (x0)+ ∆ f (x0)+ ∆ f (x0)
2! 3!
s(s − 1)(s − 2) · · · (s − n + 1) n
··· ∆ f (x0)
n!

where

x = x0 + sh

We use pn(x) to calculate the derivatives of f.

That is f 0(x) ' p0n(x) for all x ∈ [x0, xn].

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 9
For a given x,

f 0(x) ' p0n(x)


dpn ds
=
ds dx
1 dpn
=
h ds

Similarly,
2
00 d pn
f (x) '
dx2
d dpn
( )
dx dx
d dpn ds
= ( )
dx ds dx
1 d dpn
= ( )
h dx ds
Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 10
1 d2 p n 1
= ( 2 )
h ds h
1 d2 p n
= 2 2
h ds

Thus in general,
k
(k) 1 d pn
f (x) = k k
h ds

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 11
Example 1

Using Taylor series expansion (forward formula) and Newton forward

divided difference, compute first and second derivative at x = 2 for the

following tabulated function

x 1 2 3 4

f (x) 2 5 7 10

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 12
Solution

x f (x) ∆ ∆2 ∆3

1 2

2 5 -1

2 2

3 7 1

4 10

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 13
Here h = 1 Using Taylor series

f (2 + h) − f (2) f (3) − f (2)


f 0(2) = = =2
h 1

00 f (2 + h) − 2f (2) + f (2 − h) f (3) − 2f (2) + f (1)


f (2) = 2
= = −1
h 1

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 14
Using Newton forward divided difference formula

s(s − 1) 2 s(s − 1)(s − 2) 3


f (x) ≈ Pn(x) = f (x0)+s∆f (x0)+ ∆ f (x0)+ ∆ f (x0)
2! 3!
2
 
1 dpn 1 2s − 1 2 3s − 6s + 2 3
f 0(x) ≈ = ∆f (x0) + ∆ f (x0) + ∆ f (x0)
h ds h 2! 3!
Here x = 2, x0 = 1 , s = 1 and h = 1

0 1 1
f (2) = 3 − − = 13/6
2 3

00 1 d2 p n 1  2 3

f (x) ≈ 2 2 = 2 ∆ f (x0) + (s − 1)∆ f (x0)
h ds h
f 00(2) = −1

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 15
Example 2

Calculate f (4)(0.15)

x 0.1 0.2 0.3 0.4 0.5 0.6

f (X) 0.425 0.475 0.400 0.450 0.525 0.575

Solution:

Newton’s forward difference formula:

2 3 2
1 s − s 2 s − 3s + 2s 3
p5(x) = f (x0) + s4 f (x0) + 4 f (x0) + 4 f (x0)+
2 6

s4 − 6s3 + 11s2 − 6s 4 s5 − 10s4 + 35s3 − 50s2 + 24s 5


+ 4 f (x0) + 4 f (x0)
24 120
Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 16
Differentiating this 4-times we get,

d4f dp45 1 4 1 5
' = [4 f (x 0 ) + (5s − 10)4 f (x0)
dx4 dx4 h4 5

1 4
= 4 [4 f (x0) + (s − 2)45f (x0)]
h

1 2
= [−035 + (0.5 − 2)(0.4)] = −95.00 × 10
(0.1)4

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 17
x f (x) 41 f 42 f 43 f 44 f 45 f

0.1 0.425

0.050

0.2 0.475 -0.125

-0.075 0.25

0.3 0.400 0.125 -0.35

‘ 0.050 -0.100 0.4

0.4 0.450 0.025 0.05

0.075 -0.05

0.5 0.525 -0.025

0.050

0.6 0.575
Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 18
Numerical Integration

If f : [a, b] −→ R is differentiable then, we obtain a new function f 0 :

[a, b] −→ R, called the derivative of f . Likewise, if f : [a, b] −→ R is

integrable, then we obtain a new function F : [a, b] −→ R defined by

Z x
F (x) = f (t)dt ∀x ∈ [a, b].
a

Z b
Observation: If f is nonnegative function, then f (x)dx is represent
a
the area under the curve f (x).

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 19
Antiderivative

Antiderivative: Let F : [a, b] −→ R be such that f = F 0, then F is called

an antiderivative of f .

Recall

Fundamental Theorem of Calculus: Let f : [a, b] −→ R is integrable

and has an antiderivative F , then


Z b
f (x)dx = F (b) − F (a).
a

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 20
Basic Problems

• Difficult to find an antiderivative of the function (for example f (x) =


2
e−x )

• Function is given in the tabular form.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 21
Newton-Cotes Methods/Formulae

The derivation of Newton-Cotes formula is based on Polynomial

Interpolation.

x x0 x1 x2 ... xn

f (x) f (x0) f (x1) f (x3) ... f (xn)

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 22
The idea is:

Rb
Replace f by pn(x) and evaluate a
pn(x)dx

That is,
Z b Z b n
Z bX
f (x)dx ' pn(x)dx = li(x)f (xi)dx
a a a i=0
n
X Z b
= f (xi) li(x)dx
i=0 a

Xn
= Aif (xi)
i=0
Rb
Where Ai = l (x)dx
a i
called weights.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 23
Types of Newton-Cotes Formulae

• Trapezoidal Rule (Two pint formula)

• Simpson’s 1/3 Rule (Three Point formula)

• Simpson’s 3/8 Rule (Four point formula)

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 24
Trapezoidal Rule

Since it is two point formula, it uses the first order interpolation

polynomial P1(x).

Z b Z x1
f (x) ≈ P1(x)dx
a x0

P1(x) = f (x0) + s∆f (x0)


x − x0
s=
h
Now, dx = h ds at x = x0, s = 0 and at x = x1, s = 1.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 25
Hence,

Z b Z 1
h
f (x)dx ≈ (f (x0) + s∆f (x0))hds = [f (x0) + f (x1)]
a 0 2

OR
b
b−a
Z
f (x)dx ≈ [f (a) + f (b)]
a 2
Error
T (b − a)3 00
E =− f (ξ),
12
where a < ξ < b

Remark: x0 = a and x1 = b.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 26
1
Basic Simpson’s 3 Rule

Rb
To evaluate a
f (x)dx.

• f will be replaced by a polynomial of degree 2 which interpolates f at


a+b a+b
a, 2 and b. . Here, x0 = a, x1 = 2 , x2 =b

b
b−a
Z
b+a
f (x) dx = [f (a) + 4f ( ) + f (b).]
a 6 2

Error
s−h5f (4)(ξ)
E =
90
for some ξ ∈ (a, b).

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 27
3
Basic Simpson’s 8 Rule

• f is replaced by p3(x) which interpolates f at x0 = a, x1 = a +


b−a
h, x2 = a + 2h, x3 = a + 3h = b. where h = 3 . Thus we get:

Z b
3h
f (x)dx ' [f0 + 3f1 + 3f2 + f3]
a 8

−3h5 (4)
s
Error: E = f (ξ), where a < ξ < b.
80

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 28
Example

1
R2 4
R2
Using Trapezoidal and Simpson 3 rules find 0
x dx and 0
sinxdx and

find the upper bound for the error.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 29
Composite Rules

Note that if the integral [a, b] is large, then the error in the Trapezoidal

rule will be large.

Idea

Error can be reduced by dividing the interval [a, b] into equal subinterval

and apply quadrature rules in each subinterval.

Composite Trapezoidal Rule

b−a
h= , xi = x0 + ih
n
Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 30
Composite Rule

Z b Z xn n Z
X xi
f (x)dx = f (x)dx = f (x)dx
a x0 i=1 xi−1

Now apply Trapezoidal rule on each [xi−1, xi], we have

Z b
h
f (x)dx = [f (x0) + 2 ∗ (f (x1) + f (x2) · · · f (xn−1)) + f (xn)]
a 2

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 31
Error in composite Trapezoidal rule

CT h2 00
E = −(b − a) f (ξ), ξ ∈ [a, b]
12

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 32
1
The Composite Simpson’s 3 Rule

• [a, b] will be will be divided into 2n equal subintervals and we apply


1
basic Simpson’s 3 rule on each of the n intervals [x2i−2, x2i] for i =

1, 2, 3, · · · , n.

b−a
Thus here h = 2n .

Then
Z b Z b=x2n
f (x)dx = f (x)dx
a a=x0
Z x2 Z x4 Z x2i Z x2n
= f (x)dx + f (x)dx + · · · + f (x)dx + · · · + f (x)dx
x0 x2 x2i−2 x2n−2

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 33
h h
= [f (x0) + 4f (x1) + f (x2)] + [f (x2) + 4f (x3) + f (x4)]+
3 3
h
+ · · · + [f (x2n−2) + 4f (x2n−1) + f (x2n)]
3
h
= {f (x0) + 4 × [f (x1) + f (x3) + f (x5) + · · · + f (x2n−1)]+
3
+2 × [f (x2) + f (x4) + f (x6) + · · · + f (x2n−2)] + f (x2n)}

CS h4 (4)
E = −(b − a) f (ξ),
180
where ξ ∈ [a, b]

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 34
Example

R1 1
Evaluate the integral −1
x2 exp(−x)dx by composite Simpson’s 3 rule

with spacing h = 0.25

1
Solution: According to composite Simpson’s 3 rule:

Z 1
h
x2 exp(−x)dx = [f (x0) + 4f (x1) + 2f (x2) + 4f (x3) + 2f (x4)+
−1 3

+4f (x5) + 2f (x6) + 4f (x7) + f (x8)]

Here f (x0) = f (−1) = 2.7183

f (x1) = f (−0.75) = 1.1908

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 35
f (x2) = f (−0.5) = 0.4122

f (x3) = f (−0.25) = 0.0803

f (x4) = f (0) = 0

f (x5) = f (0.25) = 0.0487

f (x6) = f (0.50) = 0.1516

f (x7) = f (0.75) = 0.2657

f (x8) = f (1) = 0.3679

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 36
Substituting these values in the above formula we get:

Z 1
x2 exp(−x)dx ' 0.87965
−1

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 37
Example

Find the minimum no. of subintervals, used in composite Trapezoidal


Z 1
−x4
and Simpson’s 1/3 rule in order to find the integral e dx such that
0
the error can not exceed by .00001.

Sol. For the composite Trapezoidal rule, we have

00
13 max0<ξ<1 |f (ξ)|
≤ .00001
12n2trap
For the composite Simpson 1/3 rule, we have

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 38
14 max0<ξ<1 |f (4)(ξ)|
≤ .00001
180n4simp
Now,

00
max |f (ξ)| ≤ 3.5, max |f (4)(ξ)| ≤ 95
0<ξ<1 0<ξ<1

(Please verify )

Hence

ntrap = 171, nsimp = 16

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 39
3
Composite Simpson’s 8 rule

b−a 3
• [a, b] is divided into 3n equal subintervals. (h = 3n . and we apply 8

rule on each of the n intervals [x3i−3, x3i] for i = 1, 2, 3, · · · , n.)

Hence,

Z b Z x3 Z x6 Z x3n =b
f (x)dx ' f (x)dx + f (x)dx + · · · + f (x)dx
a x0 =a x3 x3n3

3h 3h
= [f0 + 3f1 + 3f2 + f3] + [f3 + 3f4 + 3f5 + f6]+
8 8
3h
+··· + [f3n−3 + 3f3n−2 + 3f3n−1 + f3n]
8
Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 40
3h
= [f0 + 3f1 + 3f2 + 2f3 + 3f4 + 3f5 + 2f6 + 3f7 + · · · + 3f3n−1 + f3n]
8
Remember:

• f with suffices of multiple 3 are multiplied by 2.

• Others by 3, except the end points.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 41
Example

3
Use composite simpson’s 8 rule, find the velocity after 18 seconds, if a

rocket has acceleration as given in the table:


t= 0 2 4 6 8 10 12 14 16 18

a= 40 60 70 75 80 83 85 87 88 88

f0 f1 f2 f3 f4 f5 f6 f7 f8 f9

3h
Sol: Velocity v = 8 [f0 +3f1 +3f2 +2f3 +3f4 +3f5 +2f6 +3f7 +3f8 +f9 ]=
3
4 [40+3×60+3×70+2×75+3×80+383+2×83+2×85+3×87+3×88+88]

= 1389 units.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 42
Method of Undetermined Parameters

The Newton - Cotes integration rules are all of the form

I(f ) ' A0f (x0) + A1f (x1) + A2f (x2) + · · · + Anf (xn)

Also, note that the weights Ai’s do not depend on the given function.

Hence, if the error is of the form

E(I) = Const × f (r+1)(η).

Then the rule must be exact for all polynomials of degree ≤ r

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 43
Therefore

If we wish to construct a rule of the form

I(f ) ' A0f (x0) + A1f (x1) + a2f (x2) + · · · + Anf (xn)

(n-fixed) which is exact for polynomials of degree as high as possible,

i.e., we want

E(I) = Const × f (r+1)(η),

with r as large as possible.

This way of constructing integration rules is called the ” Method of

Undetermined Parameters”.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 44
Example

Suppose we want to derive an integration formula of the form:


Rb
a
f (x)dx = A0 f (a) + A1 f (b) + α f 00(ξ).

We assume that:The rule is exact for the polynomials 1, x, x2.

Now, taking f (x) = 1, we get b − a = A0 + A1

b2 −a2
Taking f (x) = x we get 2 = A0 a + A1 b

b−a
Solving the above two equations we get, A0 = A1 = 2 .
Z b
b−a
Thus, f (x)dx = [f (a) + f (b)] + α f 00(ξ)
a 2

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 45
Now if we take f (x) = x2, we get:

b3 − a3 b−a 2
=( )(a + b2) + 2! α
3 2

(b−a)3
=⇒ α = − 12

Thus
b
b−a (b − a)3 00
Z
f (x)dx = [f (a) + f (b)] − f (ξ)
a 2 12

We see that: This is exactly the trapezoidal rule. Similarly, Simpson’s


1 3
3 and 8 rules can be derived.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 46
Thus in the Method of Undetermined Parameters

• We aim directly for a formula of a preselected type.

Working Method:

• We impose certain conditions on a formula of desired form and use

these conditions to determine the values of the unknown coefficients in

the formula.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 47
The Error term in the Simpson’s 38 -rule, using Method

of Undetermined Parameters

Start with:

Z x3
3h
f (x)dx = [f0 + 3f1 + 3f2 + f3] + α f (4)(ξ)
x0 8

for some suitable ξ ∈ (x0, x3).

Takeing f (x) = x4 in the above integration rule we get:

x53 − x50 3h 4
= [x0 + 3x41 + 3x42 + x43] + α 4!
5 8
Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 48
x53 − x50 3h 4
4!α = − [x0] + 3(x0 + h)4 + 3(x0 + 2h)4 + (x0 + 3h)4
5 8

(x0 + 3h)5 − x50 3h 4


= − [x0] + 3(x0 + h)4 + 3(x0 + 2h)4 + (x0 + 3h)4
5 8

Without loss of generality, we can take: x0 = 0.


243 5 3h5
We have: 4!α = 5 h − 8 [0 + 3 + 3 × 16 + 81] Thus

9 5
4!α = − h
10

That is,

3 5
α=− h
80
Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 49
Therefore the error in the Simpson’s rule is =

3 5 (4)
− h f (ξ)
80

for some suitable ξ ∈ (a, b).

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 50
Recall

The Newton - Cotes integration rules are all of the form

I(f ) ' A0f (x0) + A1f (x1) + A2f (x2) + · · · + Anf (xn)

Also, note that the weights Ai’s do not depend on the given function.

Hence, if the error is of the form E(I) = Const × f (r+1)(η). Then the

rule must be exact for all polynomials of degree ≤ r.

Remark: In these quadrature the points xi are fixed.

Ques: Can we improve the accuracy by choosing some suitable xi

Ans: Using Gaussian Quadrature rule one can improve the accuracy.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 51
Example

Find x0, x1, A0, A1 and α so that the following rule is exact for all

polynomials of degree≤ 3.

Z 1
f (x)dx = A0f (x0) + A1f (x1) + αf (4)(ξ)
−1

(There are 4 unknowns and hence we have chosen the 4-th derivative

in the error term.)

Taking f (x) = 1, x, x2, x3 we get:

A0 + A1 = 2

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 52
A0 x 0 + A1 x 1 = 0

2
A0x20 + A1x21 = 3

A0x30 + A1x31 = 0

On solving these equations we get:

A0 = A1 = 1 x0 = − √13 and x1 = √1 .
3

R1
Thus the integration rule is: −1
f (x)dx = f (− √13 ) + f ( √13 ) + αf (4)(ξ).

Now if we take f (x) = x4 we get

2 2
= + α4!
5 9
Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 53
1 8 1
=⇒ α = ( )=
4! 45 135

Thus the expected integration rule is:

Z 1
1 1 1 (4)
f (x)dx = f (− √ ) + f ( √ ) + f (ξ).
−1 3 3 135

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 54
In general

Giving a positive integer n, we wish to determine 2n + 2 numbers

x0, x1, · · · xn and A0, A1, · · · , An so that the sum

I(f ) ' A0f (x0) + A1f (x1) + A2f (x2) + · · · + Anf (xn),

Z b
provides the exact value of f (x)dx for f (x) = 1, x, x2, · · · x2n+1.
a
Or What we want is that the quadrature rule is exact for all polynomials

of degree ≤ 2n + 1.

Remark: Here we have to solve system of nonlinear equations, which is

some time is not an easy job.

Lecture series on “Numerical techniques and MATLAB”, July 22-28, 2016 Dr. Sarvesh Kumar, IIST Trivandrum. 55

You might also like