You are on page 1of 5

MALAWI UNIVERSITY OF BUSINESS AND APPLIED SCIENCES

Department of Mathematics and Statistics


Bachelor of Engineering & BSc in Mathematical Sciences Education
Test 1 : Error Analysis & Roots of Equations

MTS-NUM-321 : Numerical Methods


DATE: Thursday 15th July, 2021. TIME: 07:50 – 09:20 AM

Question: 1 2 3 4 5 Total
Points: 4 5 17 12 12 50

Instruction(s): Attempt All 5 questions and write clearly and neatly.

Question 1

Find the largest interval in which p∗ must lie to approximate 2 with relative error at most
10−5 for each value of p. [4]

Solution:
The relative error is defined as
|p − p∗ |
.
|p|
This implies that √
| 2 − p∗ |
√ ≤ 10−5 .
| 2|
Solving the inequality yields
√ √ √ √
2 − 2 × 10−5 ≤ p∗ ≤ 2 + 2 × 10−5

or
1.41419942 ≤ p∗ ≤ 1.41422770.

Question 2
Suppose that f l(y) is a k-digit rounding approximation of y where dk+1 ≥ 5. Show that
|f l(y) − y|
≤ 0.5 × 10−k+1 .
|y|
[5]
n n−k
[Hint: If dk+1 ≥ 5, then f l(y) = 0.d1 d2 d3 · · · dk × 10 + 10 ]

Numerical Methods Test 1 Page 1 of 5


Numerical Methods Test 1 Page 2 of 5

Solution:
Let y = 0.d1 d2 d3 · · · dk dk+1 dk+2 · · · × 10n . ⇒ f l(y) = 0.d1 d2 d3 · · · dk × 10n + 10n−k .
Hence
|f l(y) − y| |0.d1 d2 d3 · · · dk × 10n + 10n−k − 0.d1 d2 d3 · · · dk dk+1 dk+2 · · · × 10n |
=
|y| |0.d1 d2 d3 · · · dk dk+1 dk+2 · · · × 10n |

|(0.d1 d2 d3 · · · dk + 10−k ) × 10n − 0.d1 d2 d3 · · · dk dk+1 dk+2 · · · × 10n |


=
|0.d1 d2 d3 · · · dk dk+1 dk+2 · · · × 10n |

|(0.d1 d2 d3 · · · δk × 10n − 0.d1 d2 d3 · · · dk dk+1 dk+2 · · · × 10n |


=
|0.d1 d2 d3 · · · dk dk+1 dk+2 · · · × 10n |

|0.000 · · · 0δk |
≤ × 10−k
|0.d1 d2 d3 · · · dk dk+1 dk+2 · · · |

0.5
< × 10−k
0.1

< 5 × 10−k = 0.5 × 10−k+1


|f l(y) − y|
⇒ < 0.5 × 10−k+1 .
|y|

This is so since d1 6= 0, 1 ≤ d1 ≤ 9 and the minimum value the denominator can take
is 0.1 while the maximum value for the numerator is 0.5 in this case since dk+1 ≥ 5.

Question 3
Consider the equation,
x2 − sin x − 0.5 = 0.
Using Bisection method algorithm,
(a) Show that x2 − sin x − 0.5 = 0 has a root in [0, 2]. [3]
(b) Show that if n is the number of iterations on any interval [a, b], then for some required
accuracy of 10−k , n is given by

k + log(b − a)
n≥ .
log 2

[3]
(c) Find the number of iterative steps required to approximate the root to x2 −sin x−0.5 = 0
accurate to within 10−4 on [0, 2]. [3]
2
(d) Approximate the root to x − sin x − 0.5 = 0 in five iterations i.e find c5 = x5 . [8]
[Hint: Set your calculators to radian mode.]

Numerical Methods Test 1 Page 2 of 5


Numerical Methods Test 1 Page 3 of 5

Solution:
(a) Here we have f (x) = x2 − sin x − 0.5. Thus f (0) = −0.5 and f (2) = 2.590702573
and f (0)f (2) = −1.295351287 < 0. Hence x2 = sin x + 0.5 has a root in [0, 2].

(b) If pn is an approximation to p, then

b−a
|pn − p| ≤ ≤ 10−k .
2n
This implies that
2n
≥ 10k ⇒ 2n ≥ 10k (b − a).
b−a

Taking logarithms on both sides and applying the rules of logarithms yields as
required,
k + log(b − a)
n≥ .
log 2

(c) Now with k = 4, a = 0 and b = 2, and using the formula

k + log(b − a)
n≥ ,
log 2
we have
4 + log(2)
n≥ ≥ 14.28771238 ≈ 15 iterations.
log 2

(d) The following table gives the approximations.

n an bn cn f (cn ) |bn − an |/2


1 0.0000 2.0000 1.000000 -0.341471 1.000000
2 1.0000 2.0000 1.500000 0.752505 0.500000
3 1.0000 1.5000 1.250000 0.113515 0.250000
4 1.0000 1.25000 1.12500 -0.136643 0.125000
5 1.12500 1.1250 1.187500 -0.017281 0.062500
6 1.1875 1.2500 1.218750 0.046682 0.031250
7 1.1875 1.2188 1.203125 0.014343 0.015625

Thus,
c5 = 1.187500.

Question 4

Numerical Methods Test 1 Page 3 of 5


Numerical Methods Test 1 Page 4 of 5


3
(a) Show that when Newton-Raphson’s method is used to approximate λ for some
λ ∈ R, the sequence of iterates is given by
2x3n + λ
xn+1 = .
3x2n
[4]
2
(b) Use Newton-Raphson’s method to compute x2 for f (x) = x cos x − x if x0 = 1. [8]
[Hint: Set your calculators to radian mode.]

Solution:

(a) Here 3 λ ≡ (x3 − λ = 0). This implies that f (xn ) = x3n − λ ⇒ f 0 (xn ) = 3x2n .
Using Newton-Raphson’s algorithmic scheme we have

f (xn )
xn+1 = xn −
f 0 (xn )

x3n − λ 3x3n − x3n + λ


= xn − =
3x2n 3x2n

2x3n + λ
⇒ xn+1 =
3x2n

as required.


(b) With x0 = 1, f (x) = x cos x − x2 , we have f 0 (x) = cos x − x sin x − 2x. The table
below shows the approximations.

n xn f (xn ) f 0 (xn ) |xn+1 − xn |


0 1.000000 -0.459698 -2.301169
1 0.800233 -0.082979 -1.478108 0.199767
2 0.744094 -0.006245 -1.256467 0.056139
3 0.739124 -0.000048 -1.237093 0.004970
4 0.739085 -0.000000 -1.236942 0.000039

Hence we have
x2 = 0.744094.

Question 5
(a) Using Mean Value Theorem (MVT) of Calculus (and Newton-Raphson’s Scheme (?)),
show that the Secant method algorithm approximating the root to f (x) = 0 with x0
and x1 as initial guesses is given by
f (xn )(xn − xn−1 )
xn+1 = xn − .
f (xn ) − f (xn−1 )

Numerical Methods Test 1 Page 4 of 5


Numerical Methods Test 1 Page 5 of 5

[4]
(b) Use Secant method with x0 = 1 and x1 = 2 to solve up to x3 the equation

x4 − x − 10 = 0.

[8]

Solution:
(a) By MVT,
f (xn ) − f (xn−1 )
f 0 (xn ) ≈ .
xn − xn−1
Recall that Newton-Raphson’s method for approximating root x is given by

f (xn )
xn+1 = xn − .
f 0 (xn )

Substitution yields
f (xn )(xn − xn−1 )
xn+1 = xn − .
f (xn ) − f (xn−1 )


(b) With x0 = 1 and x1 = 2 as our initial guesses, we proceed with Secant scheme as
the table below shows.

n xn f (xn ) f (xn ) − f (xn−1 ) |xn − xn−1 |


0 1.000000 -10.000000
1 2.000000 4.000000 14.000000 1.000000
2 1.714286 -3.077884 -7.077884 0.285714
3 1.838531 -0.412799 2.665086 0.124246
4 1.857776 0.053909 0.466708 0.019245
5 1.855553 -0.000778 -0.054687 0.002223
6 1.855584 -0.000001 0.000776 0.000032

Hence we have
x3 = 1.838531.

End of Question Paper.

Numerical Methods Test 1 Page 5 of 5

You might also like