Math : Numerical Methods

◙ EP-Program
17
- Strisuksa School - Roi-et
Math : Numerical Methods
► Dr.Wattana Toutip - Department of Mathematics – Khon Kaen University
© 2010 :Wattana Toutip
◙ [email protected]
◙ http://home.kku.ac.th/wattou
17 Numerical methods
If a value cannot be found exactly, then an approximate value can often be obtained
by numerical methods.
17.1
Solution of equations
Suppose we want to solve an equation f  x   0. A sequence of numbers
x0 , x1 , x2 ,
, xn ,
which gets closer to the solution converges to the solution . If the
sequence does not get closer to a fixed value, then it diverges. Three methods to find a
convergent sequence are as follow.
1. LINEAR INTERPOLATION METHOD
Linear interpolation estimates the rot of the equation f  x   0 by drawing a straight line
between two known values of the function, and calculating where that straight line crosses
the x-axis
If a and b are near the root  , then draw the straight line between
 a, f  a  
and
 b, f  b   . If this line crosses the x-axis at A, the by similar triangles:
Aa b A

,
 f  a  f b 
where
A
af  b   bf  a 
f b  f  a 
y
y
f  ba
x

y

a
a A
Fig 17.1
f a


a
a
b
y

a
x
y

a
xn 1

a
xFig17.2
n
x
xn 1


a
y
a
2. NEWTON-RAPHSON METHOD
The Newton-Raphson method obtains approximations to the root of f  x   0 by drawing a
tangent to the curve of y  f  x  , and calculating where that tangent crosses the x-axis.
Pick a first approximation x0 , and successive approximations are given by:
xn 1  xn 
f  xn 
f '  xn 
(fig 17.2)
3. PICARD’S METHOD
Picard’s method rearranges the equation f  x   0 in the form x  g  x  . It then obtains a
sequence of approximations to the root of x  g  x  by the following: Pick a first
approximation x0 , Successive approximations are given by:
xn 1  g  xn 
There are often several ways to arrange an equation in the form x  g  x  . If the iteration
diverges, try another arrangement.
17.1.1 Examples
y

3
a
2
1
- 1 Fig 17.3
1
 1
a
a
x
y

a
1.
Show that there is a root of x3  3x  1  0 between 0 and 1 . Obtain an
approximation for this root by linear interpolation.
Solution
Let f  x   x3  3x  1 Then f  0   1 and f 1  3 . Hence the graph of y  x3  3x  1
must cross the x-axis at some point  between 0 and 1. To find an approximation for 
apply the formula above, using a  0 and b  1 .
0  3  1 1 1


3   1
4
2.
Use the Newton-Raphson formula to find a solution to x3  3x  1  0 accurate
to 6 decimal places.
Solution
1
as the starting point . the iteration is
4
x3  3x  1
xn 1  xn  n 2 n
giving:
3 xn  3
Take x0 
x1  0.3235294
x2  0.3221859
x3  0.3221854
x4  0.3221854
The last two values agree to 6 decimal places
The solution is   0.322185
1. Show that the equation x 2  3x  1  0 can be arranged in the following ways:
1
(a) x  3 1  3x 
(b)
x  1  x3 
3
Apply Picard’s method to both these arrangements, and hence find the solution to
3 decimal places.
Solution
(a) Rewrite the equation as x3  1  3x . Take the cube root of both sides.
x  3 1  x3 
(b) Rewrite the equation as 3x  1  x3 . Divide both sides by 3
1
x  1  x3 
3
1
In both cases let x0 
4
For arrangement (a)
The next terms are:
x1  0.62296, x2  0.96186, x3  0.32225
The last two agree to 3 decimal places
The solutions is   0.322
17.1.2 Exercises
1.
Show that there is a root of x 4  6 x  1  0 between -1 and 0, and use linear
interpolation to find an approximation to that root
2.
Use Newton-Raphson’s iteration to find the solution to the equation in
Question 1, accurate to 6 decimal places.
3.
Find a pair of integers between which there is a root of x3  2 x 2  3  0 . Use
linear interpolation to find an approximation to that root
4.
Find the solution to the equation of Question 3, accurate to 5 decimal places,
by means of Newton-Raphson’s iteration
5.
Find the solution to the equation e x  2  x, accurate to 6 decimal places.
6.
Solve to 6 decimal places the equation sin     1(  is measured in radians)
Solve the equation tan     1 , accurate to 6 decimal places.
Use Picard’s iteration to solve the equation cos x  x to 3 decimal places
Show that the equation x3  x  1  0 can be written either as
7.
8.
9.
(a)
x  1  x3 or as
(b)
3 1  x 
Apply Picard’s iteration to the equation , using both of the forms (a) and (b).
Which one works? Find the solution of the equation, given to 3 decimal places.
10.
Show that there is a root of the equation x 4  x  20 between x  2 and x  3 .
Show that the equation can be written in the following forms:
20
x  20  x 4
(a)
(b)
(c)
x  4  20  x 
x
1  x3
Apply Picard’s iteration to each of these . Hence solve the equation to 3 decimal
places.
11.
Show that there is a root of the equation e x  x  2 between x  0 and x  1 .
(Here x is measured in radians.) Rearrange the equation in two forms, and hence use Picard’s
method to solve the equation to 3 decimal places.
17.2 Numerical integration
In many cases a function cannot be exactly integrated. There is a method for
finding the definite integral of f  x  from x  a to x  b .
Divide the interval  a, b  into n equal intervals of length h. h 
a  x0  x1 
 xn  b .
ba
.
n
Fig 17.4
y

a
1
a  x0
x1
1
x2
x3
xn  b
x
y
x1
x2
x3

TRAPEZIUM RULE
a
a
1
x1
x2 x1
The trapezium rule approximates the integral
by
dividing
the
area
into
trapezia.
n
a
a
1
1
The formula is:
a
1
a f  x dx  2 h  f  a   f b   2  f  x1   f  x2    f  xn1  
If the graph of f  x  is concave, as shown in the figure , then the Trapezium rule will
b
overestimate the true value. If the graph is convex then the rule will underestimate the value
17.2.1 Examples
1.
Evaluate

2
1
sin xdx, using the trapezium rule with 4 intervals
Solution
1
Here a  1, b  2, h  . Apply the formula:
4
2
1
3
 7 
sin
xdx

sin
1

sin
2

2sin

sin



 
12
8 
2
 4  

2
1
sin xdx  0.9313
2.
y is a function of x : the table below gives six values for x and y :
x
0
10
20
30
40
50
y
1.3
1.7
2.3
3.0
3.9
4.9
y

5a
1
30
4
120
10
330
x2
120
10
30
x21
1x2
20
1
10
a1x30
1
1x20
2
110
30
ax1
1 20
x2
-1 110
x
1 ax12
30 1x
a
20 1
1
10 a
x2
x1
1
a
10
20 30
40 50 x
10
20 30 30 y
x2
10
20
20 
x2
Fig 17.5
x1
a
10 10
x2
x1
1
x
x
xrule
a trapezium
Use the
to 2find an2 approximation for
1
1
x1
x1
a
1
underestimate
a
1
1
Solution
a
a
Apply the trapezium rule with a  0, b  50,, h  10.

50

50
0
0

50
0
ydx Is your answer an over or
1
ydx  10  1.3  4.9  2 1.7  2.3  3.0  3.9  
2
ydx  140
A sketch of the graph is shown. Note that it is concave The answer is an overestimate
17.2.2 Exercise
1.
Evaluate
 x
2.
Evaluate
  sin x dx , using the trapezium rule with 6 intervals
2
1
1
0
3
 1dx , using the trapezium rule with four intervals.
3.
Evaluate
4.
Evaluate
 x
3
 1dx, , using the trapezium rule with 8 intervals
2
1


2
0
cos xdx,
(a)
by exact integration,
(b)
by the trapezium rule with 4 intervals.
What conclusion do you make about the accuracy of the rule?
5. y is a function of x, with values given by the following table:
x
2
3
4
5
6
7
y
85
74
66
59
51
47
Use the trapezium rule to approximate
6.
7
2
ydx
y is given in terms of x, by the following table:
x
0
0.2
0.4
0.6
0.8
1.0
y
0.35 0.47 0.57 0.65 0.79 0.86
Approximate
7.


1.2
0
1.2
1.03
ydx ,using the trapezium rule.
y is given in terms of x, by the table:
x
10
13
16
19
22
y
0.35 0.8
1.4
2.1
3.0
Find an approximation for

25
10
25
4.2
ydx , using the trapezium rule. Write out an

extra row for the values of y 2 , and hence find an approximation for
25
10
ydx ,
using the trapezium rule
8. By considering the shape of the graph, show that your answer to Question 3 is
an overestimate of the true value.
9. By considering the shape of the graph, show that any evaluation of


2
0
cosxdx
by the trapezium rule will be an underestimate. Is this confirmed in your
answer to Question 4 ?
17.3
Examination question
1.
The equation of a curve is y  x 2  3x  5 . A region is bounded by the curve,
the axes and the ordinate at x  4 .
(i)
By using the trapezium rule with four strips of equal width, find an
approximate value of the area of the region.
(ii)
Use a sketch to show why the approximate value of the area of the
region is greater than the actual value
2.
(a)
Rearrang the cubic equation x3  6 x  2  0 into the form
b
x
State the values of the constants a and b .
x  a
(b)
Use the iterative formula
xn 1 
a
b
xn
With x0  2 and your values of a and b to find the approximate positive
solution x4 of the equation , to an appropriate degree of accuracy . Show all your
intermediate answers.
3.
Show that the cubic equation x3  2 x  11  0 has only one real root and
further that the root lies between x  1 and x  2 .
Two possible iterative schemes for finding the root are
1
1/3
xn 1  11  2 xn 
(i)
(ii)
xn1  11  xn3  and
2
Show that only one of these schemes converges from an initial estimate of
x  2 and hence find the root correct to 4 d.p., justifying the accuracy of your
answer.
2. Draw a diagram to show why , if x0 is an approximate solution of the equation
f  x   0, then x0 
f  x0 
is, in general , a better one.
f '  x0 
Prove that the cubic equation x3  6 x  2  0 has a root lying between 0 and 1, and
find it correct to two decimal places.
3. Show that

1
0
x 2e x dx  e  2
Show that use of the trapezium rule with 5 strips(6 ordinates) gives an estimate
that is about 3.8% to high.
Explain why approximate evaluation of this integral using the trapezium rule will
always result in an overestimate , however many strips are used.
4. (a) By sketching the curves with equation y  4  x 2 and y  e x , show that the
equation x 2  e x  4  0 has one negative root and one positive root

(b) Use the iteration formula xn1   4  e xn

1/2
with x0  2 to find in turn
x1 , x2 , x3 and x4 and hence write down an approximate to the negative root of the
equation , giving your answer to 4 decimal places.
(c) Describe the result of such an attempt.
Common errors
1. Index notation
Do not be confused by the notation xn , For example , do not confuse x2 with
x 2 , x2 is the second approximation in the sequence which started with x0
2. Solution of equations
In all the methods be very careful with arithmetic. It is very easy to make mistake,
especially with the negative signs in the linear interpolation and Newton-Raphson
formulae.
When doing several successive approximations, It is a good idea to keep xn in the
memory of your calculator, and the replace it with xn 1 after each approximation
is completed.
3. Numerical integration
(a) Make sure that your intervals are correct . They must be equal in length.
(b) When approximating something like
 y dx, make sure that you square the
2
values before you use the formula . Be careful of the followings:
2
 y dx 
  ydx 
Solution (to exercise)
17.1.2
1. 0.2
2. 0.166796
1
3. 2,3, 2
3
4. 2.48558
5. 0.442854
6. 0.510973
7. 1.132268
8. 0.739
9. 0.682
10. 2.058
11. 0.443
12. 0.382
17.2.2
1. 2.135
2. 0.6295
3. 10.6875
4. (a) 1
5. 316
6. 0.806
7. 28.65, 74.625
2
(b) 0.987
===========================================================
References:
Solomon, R.C. (1997), A Level: Mathematics (4th Edition) , Great Britain, Hillman
Printers(Frome) Ltd.
y