Numerical Methods Test 1 Page 1 of 5
Numerical Methods Test 1 Page 1 of 5
Numerical Methods Test 1 Page 1 of 5
Question: 1 2 3 4 5 Total
Points: 4 5 17 12 12 50
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 ]
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.000 · · · 0δk |
≤ × 10−k
|0.d1 d2 d3 · · · dk dk+1 dk+2 · · · |
0.5
< × 10−k
0.1
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.]
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−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
k + log(b − a)
n≥ ,
log 2
we have
4 + log(2)
n≥ ≥ 14.28771238 ≈ 15 iterations.
log 2
Thus,
c5 = 1.187500.
Question 4
√
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 )
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.
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 )
[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.
Hence we have
x3 = 1.838531.