You are on page 1of 26

MATHEMATICS II

FMA 0126

Mathematics Department
Copyright © 2021 UPNM

P UBLISHED BY UPNM P UBLISHER

WWW. UPNM . EDU . MY / PUBLISH

Licensed under the Creative Commons Attribution-NonCommercial 3.0 Unported


License (the “License”). You may not use this file except in compliance with the
License. You may obtain a copy of the License at http://creativecommons.
org/licenses/by-nc/3.0. Unless required by applicable law or agreed to in
writing, software distributed under the License is distributed on an “AS IS ” BASIS ,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations
under the License.

First printing, December 2021


Contents

1 NUMERICAL METHODS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1 Introduction 5
1.2 Location of Roots in an Interval 5
1.2.1 Graphical Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.2 Change of Sign Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.3 The Newton-Raphson Method . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.3 Euler’s Method 18

Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Books 25
Articles 25
1. NUMERICAL METHODS

Learning Outcomes
Upon completion of this chapter, students will be able to:
1. locate a root of an equation approximately, by graphically or searching
for a sign change.
2. approximate the root of an equation by Newton-Raphson method.
3. approximate the solution of y′ = f (x, y), y(a) = b using Euler’s
method.

1.1 Introduction
Many problems in science and engineering can not be solved analytically, that is, by
a method that uses known rules and logic to get to an exact solution. A numerical
method is used to approximate a solution, or at worst, bound where a solution would
lie.

This chapter we will focus on root finding and solving y′ = f (x, y), y(a) = b.

1.2 Location of Roots in an Interval


Linear and quadratic equations can easily solve algebraically. Sometimes you won’t
be able to algebraically solve non-linear equations such as
6 Chapter 1. NUMERICAL METHODS

1
x3 − 5x + 10 = ln x, sin x + e2x x = 1, 2e−x = .
2−x
So numerical methods will need to be used to give you solutions which are close
to the exact solution. Numerical errors arise during computations due to round-off
errors and truncation errors. One way to reduce these errors is introducing a good
starting interval. This good interval able to speed up the process of finding solutions
and this helps to reduce errors.

The interval for a root of an equation in the form of f (x) = 0 can be determined
by using graphical method or the change of sign method.

1.2.1 Graphical Method


The roots of the equation, f (x) = 0, are the values of x where the graph y = f (x)
cuts the x-axis. Sometimes, a single graph of y = f (x) is difficult to sketch. So, we
rewrite this equation into two simpler (something we able to sketch), y = g(x) and
y = h(x), and sketching these graphs on the same coordinate axes. The intersects of
these graphs will give the roots of the equation y = f (x).

■ Example 1.1 Given the functions y = x3 and y = 3x2 + 2x − 3.


a. Sketch the graphs y = x3 and y = 3x2 + 2x − 3 on the same coordinate axes.
b. Hence, find the intervals where the roots of the equation x3 − 3x2 − 2x + 3 = 0
lie.

Solution 1.1

40
35
30
3x2 + 2x − 3 25
20
15
10 x3
5

−5 −4 −3 −2 −1 1 2 3 4 5
−5
a. −10

b. Graphs of x3 and 3x2 + 2x − 3 are intersect in the interval


i. (−2, −1)
ii. (0, 1)
iii. (3, 4)
Therefore, the roots of equation x3 − 3x2 + 2x − 3 = 0 lie in the interval
(−2, −1), (0, 1) and (3, 4).
1.2 Location of Roots in an Interval 7

■ Example 1.2 Find the interval(s) where the root(s) of the equation ex −x2 +3x = 2
lie by using graphical method.

Solution 1.2

It is quite difficult to sketch graph of ex − x2 + 3x = 2. So, splits the equation


into two simpler equations. g(x) = ex and h(x) = x2 − 3x + 2. Then, sketch
g(x) and h(x) at the same coordinate axes.
10

6
ex
4

2 x2 − 3x + 2

−5 −4 −3 −2 −1 1 2 3 4 5
−2

Graphs of g(x) and h(x) are intersect in the interval (0, 1).

■Example 1.3 Find the interval(s) where the root(s) of the equation x = 2 sin x lie
by using graphical method.

Solution 1.3
Splits the equation into two simpler equations. g(x) = x and h(x) = 2 sin(x).

2
1.5
1
x
0.5
2 sin x
−5 −4 −3 −2 −1 1 2 3 4 5
−0.5
−1
−1.5
−2

Graphs of g(x) and h(x) are intersect in the interval (−2, −1) and (1, 2) and
origin.
8 Chapter 1. NUMERICAL METHODS

f (a) f (b)

a x0 b a x0 b
(x − 3)2
f (b) f (a)

(a) Change of signs from postive to nega- (b) Change of signs from negatie to posi-
tive tive

Figure 1.1: Change of signs

20 20
15
f (x) 15
10
5 10

−5 −4 −3 −2 −1 1 2 3 4 5 5
−5
−10
−15 −2 −1 1 2 3 4 5 6 7
−20 −5
(a) (b)

Figure 1.2: What can go wrong change of sign method

1.2.2 Change of Sign Method


1.2.2.1 Significance of a change of sign between f (a) and f (b)
If f (a) > 0 and f (b) < 0 (Figure 1.1(a)) or f (a) < 0 and f (b) > 0 (Figure 1.1(b))
then there is a solution to the equation f (x) = 0 between the values a and b if the
function is continuous.

1.2.2.2 What can go wrong


a. The interval is too large
Large intervals can hide roots if there is an even number of roots in the in-
terval, this is because the sign would change twice within the interval so it
would appear to have not changed at all.

Figure 1.2a shows the curve cuts the x-axis at 3 different points which in-
dicates that f (x) has 3 different roots. These roots locate in the interval
(−4, −3), (−1, 0) and (0, 1).
1.2 Location of Roots in an Interval 9

If we were trying to find a root for f (x) and chose the interval (−1, 1). It
would appear that there isn’t a root between these values. The signs of f (−1)
and f (1) both be positive. But, from the Figure 1.2 shows that in the interval
(−1, 1) has 2 roots.

b. Change of sign method fails when the graph touches x-axis


Figure 1.2b shows that the graph touches x = 3 which is a root for the function
f (x) = (x − 3)2 . This tells us that if there isn’t a change in sign between two
different values of x, this doesn’t necessarily mean there isn’t a root between
these values, as the graph of f (x) could just touch the x-axis between these
values.
■ Example 1.4 Given f (x) = x3 − 3x2 − 2x + 3, show that f (x) = 0 has a solution
in the interval −1.2 ≤ x ≤ −1.1. ■

Solution 1.4
Substitute x = −1.2 and x = −1.1 into f (x):
f (−1.2) = (−1.2)3 − 3(−1.2)2 − 2(−1.2) + 3 = −0.648
f (−1.1) = (−1.1)3 − 3(−1.1)2 − 2(−1.1) + 3 = 0.239

f (−1.2) and f (−1.1) have different signs and f (x) is a continuous function,
so there is a solution in the interval −1.2 ≤ x ≤ −1.1.

■ Example 1.5 Show that function f (x) = x4 − 5x + 1 has a solution x = 1.64 for
f (x) = 0 correct to 2 decimal places. ■

Solution 1.5
The exact root must lie in the interval [1.635,1.645) because all values in
this interval round to 1.64.
f (1.635) = (1.635)4 − 5(1.635) + 1 = −0.0289
f (1.645) = (1.645)4 − 5(1.645) + 1 = 0.0976

Since f (1.635) and f (1.645) have different signs and all values in this
interval round to 1.64 (correct to 2 decimal places).So, x = 1.64 is the
solution for f (x) = x4 − 5x + 1 = 0.

■ Example 1.6
a. Complete the table below for y = x3 − 7x2 + 14x − 6.

x 0 0.5 1.0 1.5 2.0 2.5 3.0 3.5


i.
y
x 2.8 3.0 3.2 3.4 3.6
ii.
y
10 Chapter 1. NUMERICAL METHODS

b Hence, state the interval in which the roots of the equation x3 − 7x2 + 14x −
6 = 0 lies.

Solution 1.6

x 0 0.5 1.0 1.5 2.0 2.5 3.0 3.5


a. i.
y -6 -0.625 2.0 2.625 2.0 0.875 0 0.125
x 2.8 3.0 3.2 3.4 3.6
ii.
y 0.272 0 -0.112 -0.016 0.336
b. From table (i), sign change happens in the interval (0.5,1.0).
When x = 3.0, f (3.0) = 0, shows that x = 3.0 is a root.
While from table (ii), there is a sign change in the interval (3.4,3.6).

Therefore, the intervals are (0.5,1.0),(3.4,3.6) and (2.8,3.2).

■ Example 1.7 Show that the equation ex − x2 + 3x = 2 has a root close to 0. ■

Solution 1.7

Let f (x) = ex − x2 + 3x − 2
f (−0.5) = e−0.5 − (−0.5)2 + 3(−0.5) − 2 = −3.143
f (0.5) = e0.5 − (0.5)2 + 3(0.5) − 2 = 0.899
Since f (−0.5) < 0 and f (0.5) > 0, the equation ex − x2 + 3x = 2 has a root
between x = −0.5 and x = 0.5, that is close to 0

Remark: x = 0.5 and x = −0.5 are one of the many choices. You
can choose any pairs close to x = 0. For example, x = −0.1 and x = 0.2 or
x = 0.5 and x = −0.2. As long as the pair is bracketing the x = 0.

■ Example 1.8 Given a function f (x) = x − 2 sin x.


a. Find f (1.5) and f (2.0).
b. Show that the equation x = 2 sin x has a root between 1.5 and 2.0.

Solution 1.8
a. f (1.5) = (1.5) − 2 sin(1.5) = −0.495
f (2.0) = (2.0) − 2 sin(2.0) = 0.184
(Remark: calculate trigonometry in radian)

b. Rewrite x = 2 sin x into f (x) = x − 2 sin x. Since f (1.5) < 0 and


f (2.0) > 0, so there is a root between 1.5 and 2.0.
1.2 Location of Roots in an Interval 11

1.2.3 The Newton-Raphson Method


The aim of Newton-Raphson method for estimating a root of an equation f (x) = 0
is to produce a sequence of approximateions that approach the root. Select any
initial number x0 . Idealy, the method moving step by step towards a point where the
graph of f croses the x-axis. (Figure 1.3)

(x1 , f (x1 ))

(x2 , f (x2 ))

(x3 , f (x3 ))

Figure 1.3: Newton-Raphson method

The strategy for the Newton-Raphson method


1. Locate a first approximation to a root of the equation y = f (x), using a sketch
graph of f (x) i.e x-intercept. Or use the provided approximation.

2. Use the Definition 1.2.1 to approximate the second approximation.

Definition 1.2.1 — Newton-Raphson Formula. The fundamental for-


mula for Newton-Raphson is as follows:

f (xn ) ′
xn+1 = xn − , f (x0 ) ̸= 0, n = 1, 2, 3... (1.1)
f ′ (xn )

where f ′ (x0 ) is the derivative of f at xn .

■ Example 1.9 Find the roots of the equation x3 − 3x2 − 2x + 3 = 0 using Newton-
Raphson method correct to 2 decimal places with
12 Chapter 1. NUMERICAL METHODS

a. x = −1
b. x = 1
c. x = 3
d. x = 0
as a first approximation. ■

Solution 1.9
a. x0 = −1
f (x) = x3 − 3x2 − 2x + 3;
f (x0 ) = f (−1) = (−1)3 − 3(−1)2 − 2(−1) + 3 = 1
f ′ (x) = 3x2 − 6x − 2;
f ′ (x0 ) = f ′ (−1) = 3(−1)2 − 6(−1) − 2 = 7
So,
f (x0 )
x1 = x0 −
f ′ (x0 )
1
x1 = −1 − = −1.1429
7
= −1.143(correct to 3 decimal places)
f (x1 )
x2 = x1 − ′
f (x1 )
−0.1257
x2 = −1.1429 − = −1.1286
8.7760
= −1.129(correct to 3 decimal places)
f (x2 )
x3 = x2 − ′
f (x2 )
−0.0016
x3 = −1.1286 − = −1.1288
8.5928
= −1.129(correct to 3 decimal places)

Since, x2 = x3 , the iteration is stop. An approximation to the root is


−1.13 (correct to 2 decimal places)

b. x0 = 1
f (x) = x3 − 3x2 − 2x + 3;
f (x0 ) = f (1) = (1)3 − 3(1)2 − 2(1) + 3 = −1
f ′ (x) = 3x2 − 6x − 2;
f ′ (x0 ) = f ′ (1) = 3(1)2 − 6(1) − 2 = −5
So,
f (x0 )
x1 = x0 −
f ′ (x0 )
1.2 Location of Roots in an Interval 13

−1
x1 = 1 − = 0.8
−5
f (x1 )
x2 = x1 − ′
f (x1 )
−0.008
x2 = 0.8 − = 0.7984
−4.88
= 0.798(correct to 3 decimal places)
f (x2 )
x3 = x2 − ′
f (x2 )
−0.0002
x3 = 0.798 − = 0.7984
−4.8781
= 0.798(correct to 3 decimal places)
Since, x2 = x3 , the iteration is stop. An approximation to the root is
0.80 (correct to 2 decimal places)

c. x0 = 3
f (x) = x3 − 3x2 − 2x + 3;
f (x0 ) = f (3) = (3)3 − 3(3)2 − 2(3) + 3 = −3
f ′ (x) = 3x2 − 6x − 2;
f ′ (x0 ) = f ′ (3) = 3(3)2 − 6(3) − 2 = 7
So,
f (x0 )
x1 = x0 −
f ′ (x0 )
−3
x1 = 3 − = 3.4286
7
= 3.429(correct to 3 decimal places)
f (x1 )
x2 = x1 − ′
f (x1 )
1.1862
x2 = 3.429 − = 3.3356
12.7001
= 3.336(correct to 3 decimal places)
f (x2 )
x3 = x2 − ′
f (x2 )
0.0673
x3 = 3.336 − = 3.3301
11.3707
= 3.330(correct to 3 decimal places)
f (x3 )
x4 = x3 − ′
f (x3 )
14 Chapter 1. NUMERICAL METHODS

−0.0007
x4 = 3.33 − = 3.3301
11.2867
= 3.330(correct to 3 decimal places)

Since, x3 = x4 , the iteration is stop. An approximation to the root is


3.33 (correct to 2 decimal places)

d. x0 = 0
f (x) = x3 − 3x2 − 2x + 3;
f (x0 ) = f (0) = (0)3 − 3(0)2 − 2(0) + 3 = 3
f ′ (x) = 3x2 − 6x − 2;
f ′ (x0 ) = f ′ (0) = 3(0)2 − 6(0) − 2 = −2
So,
f (x0 )
x1 = x0 −
f ′ (x0 )
3
x1 = 0 − = 1.5
−2
f (x1 )
x2 = x1 − ′
f (x1 )
−3.3
x2 = 1.5 − = 0.5222
−3.375
= 0.522(correct to 3 decimal places)
f (x2 )
x3 = x2 − ′
f (x2 )
1.2808
x3 = 0.522 − = 0.8189
−4.3146
= 0.819(correct to 3 decimal places)
f (x3 )
x4 = x3 − ′
f (x3 )
−0.1.009
x4 = 0.819 − = 0.7984
−4.9017
= 0.798(correct to 3 decimal places)
f (x4 )
x5 = x4 − ′
f (x4 )
0.0018
x5 = 0.798 − = 0.7984
−4.8776
= 0.798(correct to 3 decimal places)

Since, x4 = x5 , the iteration is stop. An approximation to the root is


0.80 (correct to 2 decimal places).
1.2 Location of Roots in an Interval 15

Remark: x = 0 is closer to 0.8 (root for (a)) compare to −1.3


(root for (b)). So, x = 0 as the initial value leads to the root 0.8.

■ Example 1.10 By taking 0.5 as a first approximation to the root of the equation
ex − x2 + 3x = 2, using the Newton-Raphson method, find this root correct to 2
decimal places. ■

Solution 1.10

Let f (x) = ex − x2 + 3x − 2, x0 = 0.5


f (x) = ex − x2 + 3x − 2;
f (x0 ) = f (0.5) = e( 0.5) − (0.5)2 + 3(0.5) − 2 = 0.8987
f ′ (x) = ex − 2x + 3;
f ′ (x0 ) = f ′ (0.5) = e( 0.5) − 2(0.5) + 3 = 3.6487
So,
f (x0 )
x1 = x0 −
f ′ (x0 )
0.8987
x1 = 0.5 − = 0.2537
3.6487
= 0.254(correct to 3 decimal places)
f (x1 )
x2 = x1 − ′
f (x1 )
−0.0133
x2 = 0.254 − = 0.2575
3.7812
= 0.258(correct to 3 decimal places)
f (x2 )
x3 = x2 − ′
f (x2 )
0.0018
x3 = 0.258 − = 0.2575
3.7783
= 0.257(correct to 3 decimal places)

Since, x3 = x2 , the iteration is stop. An approximation to the root is 0.26


(correct to 2 decimal places).

■ Example 1.11 Given the function ln(x) + x − 2 = 0.


a. Use graphical method to show that the equation ln(x) + x − 2 = 0 has a root
in the interval (1, 2).
b. Use Newton-Raphson method, find the root of ln(x) + x − 2 = 0 correct to 2
decimal places.

16 Chapter 1. NUMERICAL METHODS

Solution 1.11
a. Let f (x) = ln(x) + x − 2 = 0, g(x) = ln(x) and h(x) = 2 − x.
2
1.5 ln(x)
1
0.5

−0.5 1 2 3 4 5
−1 −x + 2
−1.5
−2

Graphs of g(x) and h(x) are intersect in the interval (1, 2).

b. Choose x0 = 1.5
f (x) = ln(x) + x − 2;
f (x0 ) = f (1.5) = ln(1.5) + (1.5) − 2 = −0.0945
f ′ (x) = 1x + 1;
f ′ (x0 ) = f ′ (1.5) = 1.5
1
+ 1 = 1.6667
So,
f (x0 )
x1 = x0 −
f ′ (x0 )
−0.0945
x1 = 1.5 − = 1.5567
1.6667
= 1.558(correct to 3 decimal places)
f (x1 )
x2 = x1 − ′
f (x1 )
0.0014
x2 = 1.558 − = 1.5571
1.6418
= 1.557(correct to 3 decimal places)
f (x2 )
x3 = x2 − ′
f (x2 )
−0.0002
x3 = 1.557 − = 1.5571
1.6423
= 1.557(correct to 3 decimal places)
Since, x3 = x2 , the iteration is stop. An approximation to the root is
1.56 (correct to 2 decimal places).

Remark: The choice of x0 = 1.5 is the mid-point of the inter-


val. You can use any others value of x0 as long as is the the interval.
For example, x0 = 1.6
1.2 Location of Roots in an Interval 17

■ Example 1.12 Show that the equation x5 − 4x3 + 1 = 0 has a root in the interval
(0, 1). By using Newton-Raphson method to approximate the root correct to 2
decimal places. ■

Solution 1.12

f (x) = x5 − 4x3 + 1
f (0) = (0)5 − 4(0)3 + 1 = 1 > 0
f (1) = (1)5 − 4(1)3 + 1 = −2 < 0

Since f (0) > 0 and f (1) < 0, the equation x5 − 4x3 + 1 has a root in the
interval (0, 1).

Choose x0 = 0.5
f (x) = x5 − 4x3 + 1;
f (x0 ) = f (0.5) = (0.5)5 − 4(0.5)3 + 1 = 0.5313
f ′ (x) = 5x4 − 12x2 ;
f ′ (x0 ) = f ′ (0.5) = 5(0.5)4 − 12(0.5) = −2.6875
So,
f (x0 )
x1 = x0 −
f ′ (x0 )
0.5313
x1 = 0.5 − = 0.6977
−2.6875
= 0.698(correct to 3 decimal places)
f (x1 )
x2 = x1 − ′
f (x1 )
−0.1976
x2 = 0.698 − = 0.6562
−4.6896
= 0.656(correct to 3 decimal places)
f (x2 )
x3 = x2 − ′
f (x2 )
−0.0077
x3 = 0.656 − = 0.6542
−4.2381
= 0.654(correct to 3 decimal places)
f (x3 )
x4 = x3 − ′
f (x3 )
0.0007
x4 = 0.654 − = 0.6542
−4.2179
= 0.654(correct to 3 decimal places)
18 Chapter 1. NUMERICAL METHODS

Since, x4 = x3 , the iteration is stop. An approximation to the root is 0.65


(correct to 2 decimal places).

Exercise 1.1
1. Show equation x7 + 4 = 0 has a root in the interval (−2, 0).

2. Find all the interval(s) contains the root(s) of the equation sin(x) = x2 − 2.

3. Sketch the function y = x2 − 1 and y = x on the same set of axes. Hence,

deduce the interval(s) where the solution of the equation x − x2 + 1 = 0
located.

4. Sketch the function f (x) = x − 3 and g(x) = ln x, x > 0 and find the inter-
val(s) where the root(s) of the equation x − 3 − ln x = 0 lie.

5. Use Newton’s Method to determine x2 correct to 2 decimal places for the


given function with the given initial value, x0 .
a. f (x) = x sin x − x3 + 1, x0 = 1
b. f (x) = x2 − 3 − ln x, x0 = 2.0

6. Newton’s equation y3 − 5y + 1 = 0 has a root near y = 2. Starting with


y0 = 2, compute y1 , y2 , and y3 correct to 2 decimal places, the next three
Newton-Raphson estimates for the root.

7. Use Newton’s Method to find the root of 2 − ex−3 = 0, accurate to 2 deci-


mal places, that lies in interval (3.6, 3.7).

8. Sketch the function f (x) = x3 − x2 + 3 and confirm that there is a simple


root between x = −2 and x = −1. Obtain the value of estimation, correct
to 2 d.p.
Answer

2. (−2, −1) and (1, 2). 6. y1 = 2.1429


3. (1, 2) y2 = 2.1286
4. (0, 1), (4, 5) y3 = 2.1284
5. a.1.35, b. 1.91 7. x = 3.693
8. −1.1746

1.3 Euler’s Method


Majority of first ordinary order differential equations can’t be solved analytically
using the methods you going to learn in Chapter 2 and Chapter 3 of Mathematics 2.
1.3 Euler’s Method 19

Euler’s method solve ordinary differential equations by approximating the func-


tion at different points. Approximations that are close to the analytical solution can
obtain by using Euler’s method. Euler’s method relies on linear approximation as it
uses a few small tangent lines derived based on a given initial value.The formula
behind Euler’s method is based on the formula for linear approximation.

f (x) ≈ f (a) + f ′ (a)(x − a)

Euler’s method is a numerical technique to solve first-order ordinary differential


equations of the form:

dy
= f (x, y), f (x0 ) = y0 .
dx
where f (x, y) is a smooth function on the interval [a, b].

b−a
Subdivide the interval [a, b] into n subintervals and let h = .
n
In summary, Euler’s method for approximating the solution to the initial-value
problem

dy
= f (x, y), f (x0 ) = y0 .
dx
at the points xn+1 = x0 + nh (n = 0, 1, ...) is

yn+1 = yn + h f (xn , yn ), n = 0, 1, ..

■ Example 1.13 Find y(1.0) accurates up to four decimal places using Euler’s

method by solving the y′ = −2xy2 , y(0) = 1 with step size 0.2. ■

Solution 1.13

We have f (x, y) = −2xy2 and h = 0.2, substitute into equation below.

yn+1 = yn + 0.2 f (xn , yn ), n = 0, 1, ..


n = 0, x0 = 0, y0 = 1,
f (x0 , y0 ) = −2(0)(1)2 = 0
x1 = 0.2, y1 = y0 + 0.2 f (x0 , y0 )
= 1 + 0.2(0)
= 1.0
20 Chapter 1. NUMERICAL METHODS

x2 = 0.4, y2 = y1 + 0.2 f (x1 , y1 )


= 1 + 0.2(−2(0.2)(1)2 )
= 0.92
x3 = 0.6, y3 = y2 + 0.2 f (x2 , y2 )
= 0.96 + 0.2(−2(0.4)(0.92)2 )
= 0.78458
x4 = 0.8, y4 = y3 + 0.2 f (x3 , y3 )
= 0.78458 + 0.2(−2(0.6)(0.78458)2 )
= 0.63684
x5 = 1.0, y5 = y4 + 0.2 f (x4 , y4 )
= 0.63684 + 0.2(−2(0.8)(0.63684)2 )
= 0.50706
y(1.0) = 0.5071(correct to 4d.p)
Remark: The actual value for y(1) = 0.5. This solution is a quite good
approximation.

■ Example 1.14 Solve

y′ = x2 − 0.2y, y(−2) = −1

on the interval [−2, 3] using the Euler’s method with the step size h = 1.0. (correct
to three decimal place) ■

Solution 1.14
We have
yn+1 = yn + h f (xn , yn ), n = 0, 1, ..
n = 0, x0 = −2, h = 1.0,
y0 = −1, f (xn , yn ) = xn2 − 0.2yn
x1 = −1.0, y1 = y0 + f (x0 , y0 )
= −1 + 1(−2)2 (−1)
= 3.2
x2 = 0.0, y2 = y1 + f (x1 , y1 )
= 3.2 + 1(−1)2 (3.2)
= 3.56
1.3 Euler’s Method 21

x3 = 1.0, y3 = y2 + f (x2 , y2 )
= 3.56 + 1(0)2 (3.56)
= 2.848
x4 = 2.0, y4 = y3 + f (x3 , y3 )
= 2.848 + 1(1)2 (2.848)
= 3.2784
x5 = 3.0, y5 = y4 + f (x4 , y4 )
= 3.278 + 1(1)2 (3.278)
= 6.6227
y(3.0) = 6.623(correct to 3d.p)

3y − 2x
■ Example 1.15 Solve y′ = , y(3) = 2
x+y

on the interval [3, 6] using the Euler’s method with the step size h = 0.5. (correct to
three decimal place) ■

Solution 1.15

yn+1 = yn + h f (xn , yn ), n = 0, 1, ..
n = 0, x0 = 3, h = 0.5,
3y − 2x
y0 = 2, f (xn , yn ) =
x+y
x1 = 3.5, y1 = y0 + f (x0 , y0 )
 
3(2) − 2(3)
= 2.0 + 0.5
(3) + (2)
=2
x2 = 4.0, y2 = y1 + f (x1 , y1 )
 
3.5(2) − 2(3.5)
= 2.0 + 0.5
(3.5) + (2)
= 1.9091
x3 = 4.5, y3 = y2 + f (x2 , y2 )
 
4(1.9091) − 2(4)
= 1.9091 + 0.5
(4) + (1.9091)
= 1.7168
22 Chapter 1. NUMERICAL METHODS

x4 = 5.0, y4 = y3 + f (x3 , y3 )
 
4(1.7168) − 2(4.5)
= 1.7168 + 0.5
(4.5) + (1.7168)
= 1.4072
x5 = 5.5, y5 = y4 + f (x4 , y4 )
 
4(1.4072) − 2(5.0)
= 1.4072 + 0.5
(5.0) + (1.4072)
= 0.9563
x5 = 6.0, y6 = y5 + f (x5 , y5 )
4(0.9563) − 2(5.5)
= 0.9563 + 0.5( )
(5.5) + (0.9563)
= 0.3266
y(6.0) = 0.327(correct to 3d.p)

Exercise 1.2
1. Find the first two approximations using Euler’s method for the initial value
dy
problem dx = y + 2 cos x, y(1) = 2, starting at x = 1 with step size h = 0.1.
Correct to 3 decimal places.

2. Use Euler’s method with step size 0.2 to estimate y(1.0) , where is the
solution of y′ = y + xy, y(0) = 1. Correct to 3 decimal places.

3. Given the initial value problem dy


dt = 3 − 2t − 0.5y with y(0) = 1, approxi-
mate the value of y(0.5). Use 5 steps. Correct to 3 decimal places.

dy
4. Given the differential equation dx = yt with y(1) = 2 estimate y(1.5) using
Euler’s method with five equal steps. Correct to 3 decimal places.

dy
5. Given the differential equation dx = x + 2 and y(0) = 3. Find an approxi-
mation for y(1) by using Euler’s method with two equal steps. Correct to
2 decimal places.

dy 1
6. Given the differential equation dx = x+2 and y(0) = 1. Find an approxi-
mation of y(1) using Euler’s method with step size, h = 0.5. Correct to 2
decimal places.

dy
7. The curve passing through (2, 0) satifies the differential equation dx =
4x + y. Find an approximation to y(3) using Euler’s method with step size,
h = 0.2. Correct to 3 decimal places.
1.3 Euler’s Method 23

8. Assume that f and f ′ have the values given in the table. Use Euler’s
method with two equal steps to approximate the value of f (4.4). Correct
to 3 decimal places.
x 4 4.2 4.4
f ′ (x) -0.5 -0.3 -0.1
f (x) 2
Answer

1. 2.630 5. 5.25
2. 3.419 6. 1.45
3. 1.941 7. 13.860
4. 2.284 8. 1.90,1.84

REVIEW EXERCISE CHAPTER 1


Instruction: Correct all the answers to three decimal places. Unless stated in the
question

1. By sketching the function f (x) = x − 1 − sin x show that there is a simple root
near x = 2. Use two iterations of the Newton-Raphson method to obtain a
better estimate of the root.

2. Sketch the function f (x) = x3 − x2 + 3 and confirm that there is a simple root
between x = −2 and x = −1. Use x0 = −2 as an initial estimate to obtain the
value to 2 d.p.

3. The forth-degree polynomial

f (x) = 3x4 − 2x3 + 7x2 − x − 5


has two real zeros, one in (−0.7, −0.6) and the other in (0.8, 0.9). Attempt
to approximate these zeros using the Newton-Raphson method.

4. The equation 2x2 − 3 + ex = 0 has two solutions x1 and x2 . Use Newton-


Raphson method to approximate the solution with the following initial exti-
mation.
a. x0 = −1
b. x0 = 1
c. x0 = 0

5. f (x) = x3 + 2x − 1 + 3x − 10.
a. Show that one of the solutions for f (x) = 0 is in the interval (1.5, 1.6).
b. Find f ′ (x)
24 Chapter 1. NUMERICAL METHODS

c. Using x0 = 1.55 as a first approximation, apply the Newton-Raphson


method, to find the root of f (x) = 0 to 3 decimal places.

6. Using Euler’s method with stepsize of h = 0.25, find an approximate value of


dy
y(1), given that dx = x + y and y(0)=1.

7. For the initial condition y(0) = 3, using Euler’s method with a step size
h = 0.1 to estimate the value of y at x = 0.5 for y′ − 2xy = 1.

8. Find the first two approximations using Euler’s method for the differential
dy
equation dx = 2y, y(1) = 2, starting at x = 1 with h = 0.1.

9. Suppose y changes with time t according to the equation y′ = 1 + 2y′ .


a What is the rate of change of y when y = 0?
b Suppose when t = 0, y = 3. Use Euler’s method with step size h = 0.5
to estimate y(1).
Answer

1
1. 1.935 5. b. f ′ (x) = 2x + √ +3
2. -1.17 2x − 1
c. 1.724
3. -0.669,0.882
6. 2.883
4. a.-1.159
7. 4.206
b.0.701
8. 2.88
c.0.701
9. a.1
b.13.5
Bibliography

Books
Articles

You might also like