0% found this document useful (0 votes)
34 views13 pages

Numerical Methods

This document provides an overview of numerical methods topics for a Maths 2 course. It covers Simpson's rule for approximating definite integrals, the Newton-Raphson method for finding roots of functions, and Lagrange interpolation. Simpson's rule is demonstrated through an example. The Newton-Raphson method is explained and an example is worked through to find the coordinates of a point where two curves intersect. Exercises are provided to apply Simpson's rule and Newton-Raphson method. Lagrange interpolation is introduced but not explained in detail.

Uploaded by

nombusonndlovu
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)
34 views13 pages

Numerical Methods

This document provides an overview of numerical methods topics for a Maths 2 course. It covers Simpson's rule for approximating definite integrals, the Newton-Raphson method for finding roots of functions, and Lagrange interpolation. Simpson's rule is demonstrated through an example. The Newton-Raphson method is explained and an example is worked through to find the coordinates of a point where two curves intersect. Exercises are provided to apply Simpson's rule and Newton-Raphson method. Lagrange interpolation is introduced but not explained in detail.

Uploaded by

nombusonndlovu
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/ 13

NUMERICAL METHODS

Tutorial Manual

MUT
Maths 2
Introduction
This handout reviews the topics on numerical methods as required by the Maths
2 course requirements. The topics covered are the Simpson’s rule, Newton-
Raphson method, and the Lagrange interpolation.

Intended learning outcomes:


After engaging with this material, the student should be able to
 Apply the Simpson’s rule to evaluate the definite integral for a function
whose integral cannot be evaluated analytically
 Use the Newton-Raphson technique to determine the roots (or zeros) of
a function
 Use Lagrange interpolation to interpolate (or estimate) unknown values
inside the given range of values

Simpson’s rule
To determine the indefinite integral  f  x  dx, we simply use a function whose
derivative is f  x  . In practice, this is not always possible as the derivative of
some functions do not exist. But you already know that the definite integral
 f  x  dx is a number which represents the area between the curve y  f  x  , the
b

x  axis, and the ordinates x  a and x  b.

Therefore, even though it is not possible to evaluate  f  x  dx, we can still by the
 f  x  dx
b
approximate value for a
by evaluating the area using an appropriate
estimation method. One common method to evaluate the area under the curve is
known as the Simpson’s rule.

The Simpson’s rule, with  2n  1 ordinates is given by

1
 f  x  dx  3 d  y  4  y1  y3  y5   y4 n 1   2  y2  y4  y6   y4 n 4   y2 n 
b

a 0

 d 1st  4   yodd   2   yeven   last 


1
3

1
ba
where d 
number of intervals

y0  f  x0  , y1  f  x1  ,

Example

Find the shaded area under the curve y  3e x  5x2  4cos x shown in the sketch by
using Simpson’s rule with 6 intervals.

Solution
Since there are 6 intervals, it means there are 7 x-ordinates. Therefore,
ba 1.5  0.3
d   0.2
number of intervals 6

This gives 7 ordinates from x0  0.3 to x6  1.5. Therefore

2
y  3e x  5 x 2  4 cos 3 x
y0  3e0.3  5  0.3  4 cos  3  0.3  5.1589
2

y1  3e0.5  5  0.5   4 cos  3  0.5   3.3525


2

y2  3e0.7  5  0.7   4 cos  3  0.7   1.9204


2

y3  3e0.9  5  0.9   4 cos  3  0.9   1.6534


2

y4  3e1.1  5 1.1  4 cos  3 1.1  3.0987


2

y5  3e1.3  5 1.3  4cos  3 1.3  6.3639


2

y6  3e1.5  5 1.5  4cos  3 1.5  11.0762


2

y0  5.1589

y odd  y1  y3  y5
 3.3525  1.6534  6.3639
 11.3698

y even  y2  y4
 1.9204  3.0987
 5.0191

y6  11.0762

From the Simpson’s rule


1
A  0.2   y0  4 yodd  2 yeven  y6 
3
1
  0.2  5.1589  4  11.3698  2  5.0191  11.0762
3
 4.7835

There are other ways of constructing the answer like constructing a table but these
will not discussed in this handout for now.

NB: You may have noticed that we could have evaluated the area by using direct
integration. Out of interest, let us go ahead and see what we get and how this
compares with the solution from the Simpson’s rule.

3
A  3e  5 x 2  4 cos 3 x  dx
1.5
x
0.3
1.5
 5 3 4
 3e  x  x  sin 3x

 3 3 
0.3

 5 4   5 4 
  3e1.5  1.5   sin  3 1.5     3e0.3   0.3  sin  3  0.3 
3 3

 3 3   3 3 
 4.7853

The difference is minor and thus the Simpson’s rule is a decent approximation of
the definite integral. Details of the derivation of the Simpson’s rule are beyond
the scope of this course.

Exercises
Use the Simpson’s rule with 6 coordinates to find an approximate value for

1

2.4
a) dx
0 1  x2

 x

3.4
b)  tanh 2 x  cos  dx
1
 2

In both cases, leave your answer to 4 decimal places.

Solutions
a) 1.1756

b) 3.4313

Newton-Raphson method
The Newton-Raphson method is an iterative technique used to approximate the
roots (or zeros) of a function. It becomes particularly useful for those functions
for which the analytical solution is difficult or impossible to obtain. The

4
derivation of the Newton-Raphson method is not too difficult to understand.
However, it is not required for this course. You can read more of this in the study
or in calculus textbooks. The Newton-Raphson technique is formally stated as
follows:

If xn is the current estimate of the root of the equation f  x   0, then the next
estimate is given by
𝒇(𝒙𝒏 )
𝒙𝒏+𝟏 = 𝒙𝒏 −
𝒇′ (𝒙𝒏 )
The more the iterations, the closer you should get to the exact solution.

Example

5
The graphs of y  e x and y  sin 2 x intersect at A and B as shown in the figure
above. Find, accurate to 5 decimal places, the coordinates of point B only by using
the Newton-Raphson iteration method.

Solution
We want to find the value of x such that
sin 2 x  e  x
OR sin 2 x  e  x  0

Let f  x   sin 2 x  e x This means f '  x   2cos 2 x  e x .

From the figure, f  x   0 at two points, near x  0.5 and x  1.5. The question has
requested root B, therefore, we let x0  1.5
From the Newton-Raphson method, we have
f  x0  sin  2 1.5   e 1.5
x1  x0   1.5 
f '  x0  2 cos  2 1.5   e 1.5
 1.453319904

Make sure your calculator is in radian mode. It is helpful to use the memory
function of a calculator to store progressive values of xn1.

sin  2 x0   e x0
x1  x0 
2 cos 2 x0  e x0
 1.45273805

sin  2 x1   e x1
x2  x1 
2 cos 2 x1  e x1
 1.452737935

sin  2 x2   e x2
x3  x2 
2 cos 2 x2  e x2
 1.452737935

At this point, the values of xn1 are no longer changing hence we have reached the
answer. Rounding off to 5 decimal places, we have the solution is x  1.452737935.

6
Exercise
a) Use the Newton-Raphson method to find the solution of x  sin 2 x correct
to 5 decimal places. Use x0  1.5.

b) Find the solution to e2 x  x  6 correct to 5 decimal places.

Solution
a) x  1.89549

b) x  0.97087

Lagrange interpolation
So far, we have assumed that the relationship between a function and its variables
can always be expressed in the form of a function. In practice, we will know the
value of a function for particular values of x. If we only know distinct values
f  x0  , f  x1  , , f  xn  , we can use extrapolation techniques to find the values
of f  x  for other values of f  x  in between the given values. One of the
common techniques is the Lagrange interpolation technique.

A detailed explanation of the Lagrange interpolation will not be carried out in this
handout and the reader is encouraged to consult numerical technique textbooks.
We will use means of examples to outline the construction of Lagrange functions
before giving a general formula.

Lagrange Linear Interpolation

In a Lagrange linear interpolation, we have 2 points,  x , f  x 


0 0 and
 x , f  x   . The Lagrange linear interpolation function is given by
1 1

f  x f  x0  f  x1 
 
 x  x0   x  x1   x  x0  x0  x1   x1  x0   x  x1 

7
Example
Find f  3  from the table below, using Lagrange interpolation:

x f  x

2 1,5

5 4,0

Give the answer to 4 decimal places accurately.

Solution
Clearly, x0  2; x1  5;

f  x0   1,5; f  x1   4,0.

There are two points given from point 0 to point 1 so we use the Lagrange linear
interpolation formula given by:
f  x f  x0  f  x1 
 
 x  x0   x  x1   x  x0  x0  x1   x1  x0   x  x1 
f  3 1,5 4,0
 
 3  2  3  5   3  2  2  5   5  2  3  5 
 1,5 4 
 f  3    2    
 3 6 
 f  3   2,3333.

Lagrange Quadratic Interpolation


The case is similar in analogy to the one for the linear interpolation. In this case,
we are given three points:  x0 ; f  x0   ,  x1; f  x1   and  x2 ; f  x2   .
The corresponding Lagrange interpolation function is given by

8
f  x f  x0  f  x1 
  
 x  x0   x  x1  x  x2   x  x0  x0  x1  x0  x2   x1  x0   x  x1  x1  x2 
f  x2 
 x2  x0   x2  x1  x  x2 

Example
Given the table of values

x f  x
3 1
4 2
5 4

Use Lagrangian interpolation to find the value of f  4, 3  to 4 decimal places


accurately.

Solution
There are 3 points from point 0 to 2 and therefore we use the Lagrange quadratic
interpolation (excess details omitted from now on):

f  x f  x0  f  x1 
  
 x  x0   x  x1  x  x2   x  x0  x0  x1  x0  x2   x1  x0   x  x1  x1  x2 
f  x2 
 x2  x0   x2  x1  x  x2 

f  4,3  1 2
 
 4,3  3  4,3  4  4,3  5   4,3  3  3  4  3  5   4  3  4,3  4  4  5 
4

 5  3  5  4  4,3  5 

9
 
39  1 2 4 
 f  4,3     13  3  7 
100    
 5 10 5

 f  4,3   3,5643

Lagrange Cubic Interpolation


An example would suffice since all background material is assumed understood
by now.

Example
Given the table of values

x f  x
6 0,801153
7,2 -0,82236
9 -0,73922
13 0,994808

Use the Lagrangian interpolation to find the values of


a) f  8

b) f  10  .

10
Solution
There are 4 points given. Therefore, we have the corresponding Lagrange
interpolation function:
f  x
 x  x0   x  x1  x  x2   x  x3 
f  x0  f  x1 
 
 x  x0  x0  x1  x0  x2  x0  x3   x1  x0   x  x1  x1  x2   x1  x3 
f  x2  f  x3 
 
 x2  x0   x2  x1  x  x2   x2  x3   x3  x0  x3  x1  x3  x2  x  x3 

a) f  8   1,0671

b) f  10   0,0265

Exercise
Given the table of values:

x -2 -1 0 1 2 3
f  x -65 -30 25 14 36 51

Use Lagrangian interpolation to find the values of

a) f  3 

b) f  4

11
Solutions
a) f  3   515

b) f  4   444

________________________________________________________________

12

You might also like