Solutions of Assignment-2
Solutions of Assignment-2
2. Using the bisection method, determine the point of intersection of the curves given by y = 3x and y = ex in
the interval [0, 1] with an accuracy 0.1.
Sol. We consider f (x) = 3x − ex = 0, which is continuous. Root lies in [0, 1] as f (0)f (1) < 0. Thus we take
a = 0, b = 1. We have:
c1 = 0.75
c2 = 0.625
c3 = 0.5625
1 Lecture Notes of Dr. Paramjeet Singh
CONTINUED
–2–
As|c3 − c2 | = 0.0625 < 0.1, so x coordinate of the point with given accuracy is x = 0.625. Thus y = 3x =
1.875. So point of intersection of the curves is (0.625, 1.875).
√
3. Find an approximation to 3
25 correct to within 10−2 using the bisection algorithm.
Sol. Let f (x) = x3 − 25 = 0 which is continuous. Also f (2)f (3) < 0 which implies that root lies in interval
(2, 3).
a+b
Thus we take a = 2, b = 3, c = and bracket the root at each stage. Below are the iterations to get an
2
−3
accuracy of 10 .
4. Find a bound for the number of iterations needed to achieve an approximation by bisection method with
accuracy 10−2 to the solution of x3 − x − 1 = 0 lying in the interval [1, 2]. Find an approximation to the
root with this degree of accuracy.
Sol. Let f (x) = x3 − x − 1 = 0 and f (1)f (2) < 0. Also f is a continuous function.
a+b
Thus we take a = 1, b = 2, and then we calculate the middle points c = by bracketing the root.
2
−2
log(2 − 1) − log(10 )
Number of iterations required are N ≥ ≈ 6.6438.
log 2
Thus seven iterations are required to achieve an accuracy of 10−2 , which are given below in table. So root
5. Sketch the graphs of y = x and y = 2 sin x. Use the bisection method to find an approximation to within
10−2 to the first positive value of x with x = 2 sin x.
Sol. The graphs of y = x and y = 2 sin x has shown in the next Figure. They intersect near 2.
More precisely f (1)f (2) < 0, thus first positive root lies in (1, 2).
Iterations with desired accuracy are given below. So root with given accuracy is 1.8984375.
6. The function defined by f (x) = sin(πx) has zeros at every integer. Show that when −1 < a < 0 and
2 < b < 3, the bisection method converges to
(a) 0, if a + b < 2
(b) 2, if a + b > 2
(c) 1, if a + b = 2.
CONTINUED
–3–
Sol.
Thus
f (a) · f (c) < 0 =⇒ b = c ∈ (1/2, 1).
The algorithm will now search within the interval [a, c] and 0 is the only root within this new interval.
(b) In this case a + b > 2, f (a) = sin(πa) < 0 and
3 > a + b > 2 =⇒ 3/2 > c > 1, =⇒ c ∈ (1, 3/2) =⇒ f (c) = sin(πc) < 0.
Thus
f (a) · f (c) > 0 =⇒ a = c ∈ (1, 3/2).
The algorithm will now search within the interval [c, b] and 2 is the only root within this new interval.
(c) In this case a + b = 2 and f (a) = sin(πa) < 0.
a + b = 2 =⇒ c = 1, f (c) = sin(πc) = 0.
CONTINUED
– 4 –
−x 1
7. Show that g(x) = 2 has a unique fixed point on , 1 . Use fixed-point iteration to find an approximation
3
to the fixed point accurate to within 10−2 .
Sol. The function g(x) = 2−x is continuous. Further
g(1/3) = 0.793700526
g(1) = 0.5
g 0 (x) = −2−x ln 2
|g 0 (1/3)| = 0.550151282
0
|g (1)| = 0.34657
00
g (x) = 2−x ln2 2 6= 0.
1 0 1
Thus g(x) ∈ , 1 and |g (x)| ≤ 0.550151282 < 1. Hence g(x) has a unique fixed point in , 1 . Now with
3 3
x0 = 0.5, we have
x1 = 0.70711
x2 = 0.61255
x3 = 0.65404
x4 = 0.63550
x5 = 0.64372
|x5 − x4 | = 0.00822 < 0.01.
So root is 0.64372.
8. For each of the following equations, use the given interval or determine an interval [a, b] on which fixed-point
iteration will converge. Estimate the number of iterations necessary to obtain approximations accurate to
within 10−2 , and perform the calculations.
5
(a) x = + 2.
x2
(b) 2 + sin x − x = 0 in interval [2, 3].
(c) 3x2 − ex = 0.
Sol.
5 5
(a) Here f (x) = + 2 − x and we take g(x) = 2 + 2.
x2 x
As f (2)f (3) < 0, so root lies in (2, 3). We have
10
g 0 (x) = −
x3
|g 0 (2)| = 1.25 > 1
|g 0 (2.5)| = 0.64 < 1
0
|g (3)| = 0.37037
10
g 00 (x) = − 3 6= 0.
x
As root lies in (2, 3), we have to restrict the interval and need to consider (2.5, 3) in order to |g 0 (x) < 1|.
Also k = max |g 0 (x)| = 0.64. Further
x∈[2.5,3]
g(2.5) = 2.8
g(3) = 2.5556.
CONTINUED
–5–
Thus g(x) ∈ [2.5, 3] for x ∈ [2.5, 3]. Thus the choice of g will work. We start with x0 = 2.5 and get
x1 = g(x0 ) = 2.8. We can estimate the number of iteration from the formula
kn
|α − xn | ≤ |x1 − x0 | < 10−2
1−k
which gives
0.64n
(0.3) < 10−2
0.36
n > 9.9103 ≈ 10.
We have
x1 = 2.8
x2 = 2.63775510204082
x3 = 2.71862291377498
x4 = 2.67650663176068
x5 = 2.69796453650544
x6 = 2.68690634940763
x7 = 2.69257202494715
|x7 − x6 | < 0.01.
We get the root in 7 iterations with given accuracy although theoretical estimate shows that we need
to perform minimum 10 iterations. By starting near root, we can get a more closer estimate.
(b) We consider f (x) = 2 + sin x − x. Root lies in [2, 3] as f (2)f (3) < 0. Let us take initial guess x0 = 2.5.
We take g(x) = 2 + sin x and get
g 0 (x) = cos x
|g 0 (2)| = 0.4161
|g 0 (3)| = 0.9900
00
g (x) = − sin x 6= 0.
So |g 0 (x) < 1| for x ∈ [2, 3]. Also k = max |g 0 (x)| = 0.99. Further
x∈[2,3]
g(2) = 2.9093
g(3) = 2.1411.
Thus g(x) ∈ [2, 3] for x ∈ [2, 3]. Thus the choice of g will work. We start with x0 = 2.5 and get
x1 = g(x0 ) = 2.5985. We can estimate the number of iteration from the formula
kn
|α − xn | ≤ |x1 − x0 | < 10−2
1−k
which gives
0.99n
|2.5985 − 2.5| < 10−2
1 − 0.99
n > 685.81 ≈ 686.
We have
CONTINUED
–6–
(c) The equation 3x2 − ex = 0 have two positive
q roots, one in [0, 1] and other in [3, 4]. There are numerous
1 x
possibilities to write g(x) and for g(x) = 3 e , on [0, 1] with x0 = 1, we have
1
g 0 (x) = √ ex/2
2 3
|g 0 (0)| = 0.28868
|g 0 (1)| = 0.47594
1
g 00 (x) = √ ex/2 6= 0.
4 3
Thus |g 0 (x) < 1|. Also k = max |g 0 (x)| = 0.47594. Further
x∈[0,1]
g(0) = 0.57735
g(1) = 0.95189.
Thus g(x) ∈ [0, 1] for x ∈ [0, 1]. Thus the choice of g will work. We start with x0 = 0.5 and get
x1 = g(x0 ) = 0.74133. We can estimate the number of iteration from the formula
kn
|α − xn | ≤ |x1 − x0 | < 10−2
1−k
which gives
0.47594n
|0.74133 − 0.5| < 10−2
1 − 0.47594
n > 5.1581 ≈ 6.
We have
x1 = 0.74133
x2 = 0.83641
x3 = 0.87713
x4 = 0.89517
x5 = 0.90328
|x5 − x4 | = 0.00811 < 0.01.
Root is 0.90328.
For another root in [3, 4], we take g(x) = ln 3x2 with x0 = 3.5,
2
g 0 (x) =
x
|g 0 (3)| = 0.66667
|g 0 (4)| = 0.5
2
g 00 (x) = − 2 6= 0.
x
Thus |g 0 (x) < 1|. Also k = max |g 0 (x)| = 0.66667. Further
x∈[0,1]
g(3) = 3.2958
g(4) = 3.8712.
Thus g(x) ∈ [3, 4] for x ∈ [3, 4]. We start with x0 = 3.5 and get x1 = g(x0 ) = 3.6041. We can estimate
the number of iteration from the formula
kn
|α − xn | ≤ |x1 − x0 | < 10−2
1−k
CONTINUED
–7–
which gives
0.66667n
|3.6041 − 3.5| < 10−2
1 − 0.66667
n > 8.4876 ≈ 9.
We have
x1 = 3.6041
x2 = 3.6628
x3 = 3.6951
x4 = 3.7126
x5 = 3.7221
|x5 − x4 | < 0.01.
9. Show that g(x) = π + 0.5 sin(x/2) has a unique fixed point on [0, 2π]. Use fixed-point iteration to find an
approximation to the fixed point that is accurate to within 10−2 . Also estimate the number of iterations
required to achieve 10−2 accuracy, and compare this theoretical estimate to the number actually needed.
Sol. Since g 0 (x) = 14 cos(x/2), g is continuous and g 0 exists on [0, 2π].
Further, g 0 (x) = 0 only when x = π, so that g(0) = g(2π) = π and g(π) = π + 1/2 and thus g(x) ∈ [0, 2π].
|g 0 (x)| ≤ 1/4, for 0 ≤ x ≤ 2π.
Thus a unique fixed point exists in [0, 2π]. With k = 1/4 and x0 = π, we have x1 = π + 1/2. Now
kn
|α − xn | ≤ |x1 − x0 | < 10−2 .
1−k
For the bound to be less than 0.01, we need n ≥ 4.
Iterations are given by
x1 = 3.6416
x2 = 3.6260
x3 = 3.6270
|x3 − x2 | < 0.01.
10. Use the fixed-point iteration method to find smallest and second smallest positive roots of the equation
tan x = 4x, correct to 4 decimal places.
Sol. Let f (x) = tan x − 4x = 0. In this case we write
For first positive root, we take n = 0 and thus g(x) = tan−1 (4x). Clearly g(x) is continuous and root lies
before π/2. So we take x0 = 1.5 and we have
x1 = 1.4056476
x2 = 1.3947829
x3 = 1.3934402
x4 = 1.3932729
x5 = 1.3932520.
CONTINUED
–8–
Iterations are given by
x1 = 4.6568904
x2 = 4.6587566
x3 = 4.6587780
11. Find all the zeros of f (x) = x2 + 10 cos x by using the fixed-point iteration method for an appropriate
iteration function g. Find the zeros accurate to within 10−2 .
Sol. A closer look to f (x) = x2 + 10 cos x = 0 or x2 = −10 cos x, shows that this equation has four roots.
Two roots are negative which lies in [−4, −3] and [−2, −1].
By symmetry of both x2 and −10 cos x, two positive roots lies in [1, 2] and [3, 4].
There are many possibilities to write g(x). In particular, we take
f (x) x2 + 10 cos x
g(x) = x − 0
=x− .
f (x) 2x − 10 sin x
Iterations scheme is given by
x2n + 10 cos xn
xn+1 = g(xn ) = xn − .
2xn − 10 sin xn
For root lies in [−4, −3], we take x0 = −3. We have
x1 = −3.1961
x2 = −3.1630
x3 = −3.1620
|x3 − x2 | < 0.01.
Thus root accurate to within 10−2 for the interval [−4, −3] is −3.1620.
Similarly for root lies in [−2, −1], we take initial guess x0 = −1.5. Then iterations are given by
x1 = −1.9240
x2 = −1.9679
x3 = −1.9689
|x3 − x2 | = 0.001 < 0.01.
Thus root accurate to within 10−2 for the interval [−2, −1] is −1.9689.
Just reversing the sign, we get other roots. So positive root in [1, 2] is 1.9689 and second positive root lies
in [3, 4] is 3.1620.
Solving for α gives α = 0, 1/A. Thus if fixed-point iteration converges to a nonzero limit, then the limit
is α = 1/A, so the inverse of a number can be found using only multiplications and subtractions from
g(x) = 2x − Ax2 ..
CONTINUED
–9–
1 3 5
(b) Any subinterval [a, b] of having root α = will work. For example, we take
A , containing 1/A
4A 4A
0
suffices. Now g(x) is continuous and g (x) exists and we have
1
g 0 (x) = 2 − 2Ax = 0 =⇒ x=
A
1 1
g =
A A
3 15
g =
4A 16A
5 15
g =
4A 16A
3 1
g0 =
4A 2
5 1
g0 =− .
4A 2
3 5 3 5 1
Thus if we take x ∈ , , then g(x) ∈ , and |g 0 (x)| ≤ < 1. Thus g satisfy all the
4A 4A 4A 4A 2
condition for fixed point convergence.
13. Consider the root-finding problem f (x) = 0 with root α, with f 0 (x) 6= 0. Convert it to the fixed-point
problem
x = x + cf (x) = g(x)
with c a nonzero constant. How should c be chosen to ensure rapid convergence of
xn+1 = xn + cf (xn )
to α (provided that x0 is chosen sufficiently close to α)? Apply your way of choosing c to the root-finding
problem x3 − 5 = 0.
Sol. In order to ensure convergence of the iterations
|g 0 (x)| < 1,
Any c satisfying the above condition will work and c = −1/f 0 (x0 ) will provide rapid convergence (which is
actually Newton’s method). Now we apply the way to given problem.
We have f (x) = x3 − 5 = 0 and f (1)f (2) < 0. So we can start with any point, say x0 = 1.5. Then
x3 − 5
g(x) = x − .
3x2
Iterations are given by
x1 = 1.740741
x2 = 1.710516
x3 = 1.709976.
CONTINUED
– 10 –
14. Show that if A is any positive number, then the sequence defined by
1 A
xn = xn−1 + , for n ≥ 1,
2 2xn−1
√
converges to A whenever x0 > 0. What happens if x0 < 0?
Sol. Do it yourself.
15. Use secant method to find root accurate to within 10−3 for −x3 − cos x = with initial guesses −1 and 0.
Sol. The secant iterations are defined as
xn − xn−1
xn+1 = xn − f (xn ) n = 1, 2 · · ·
f (xn ) − f (xn−1 )
16. Use secant method to find root of x3 − 0.165x2 + 3.993 × 10−4 = 0 with initial guesses 0.02 and 0.05. Use
the stopping criterion that the relative error is less than 0.5%.
Sol. The secant iterations are given by
xn − xn−1
xn+1 = xn − f (xn ), n = 1, 2 · · ·
f (xn ) − f (xn−1 )
Start with x0 = 0.02 and x1 = 0.05, denote the relative error by εn , we get
x1 − x0
x2 = 0.06461, ε1 = × 100% = 22.62%
x1
x2 − x1
x3 = 0.06241 ε2 = × 100% = 3.525%
x2
x3 − x2
x4 = 0.06238 ε3 = × 100% = 0.0595% < 0.5%.
x3
17. Use Newton’s method to approximate the positive root of 2 cos x = x4 correct to six decimal places.
Sol. Let f (x) = 2 cos x − x4 = 0. Clearly f is continuous differentiable function and f (1)f (2) < 0.
We have f 0 (x) = −2 sin x − 4x3 .
Starting with x0 = 1, we get
f (x0 ) 2 cos(1) − 14
x1 = x0 − = 1 − = 1.014183
f 0 (x0 ) −2 sin(1) − 4(1)3
f (x1 )
x2 = x1 − 0 = 1.013957
f (x1 )
x3 = 1.013957.
CONTINUED
– 11 –
18. Use Newton’s method to approximate, to within 10−4 , the value of x that produces the point on the graph
of y = x2 that is closest to (1, 0).
Sol. Let (x, y = x2 ) be a point on the curve y = x2 .
Let s(x) be the square of the distance of this point from point (1, 0). Then
2
s(x) = (x − 1)2 + (x2 ) = (x − 1)2 + x4 .
Minimizing the square of the distance is equivalent to minimizing the distance.
For finding the minimum, firstly equate first derivate of s(x) to zero, which gives
s0 (x) = 2(x − 1) + 4x3 = 2[(x − 1) + 2x3 ] = 0.
Write the above expression as root finding problem.
f (x) = (x − 1) + 2x3 = 0.
f 0 (x) = 1 + 6x2 .
Newton iteration’s are given by
f (xn ) (xn − 1) + 2x3n 1 + 4x3n
xn+1 = xn − = x n − = .
f 0 (xn ) 1 + 6x2n 1 + 6x2n
Starting with x0 = 1.0, we have
x1 = 0.6
x2 = 0.589873417721519
x3 = 0.589754528506440
x4 = 0.589754512301459.
Therefore root with desired accuracy 10−4 is 0.58975.
Thus the point of minimum distance from (1, 0) is (0.58975, 0.34781).
CONTINUED
– 12 –
Thus in both cases
xn+1 = −xn .
Hence sequence is oscillatory and provide no convergence.
(b) In this case for x > 0, the Newton’s iterations are
2/3
xn
xn+1 = xn − 2
1/3
3xn
3
= xn − xn
2
1
= − xn .
2
Similarly for x < 0, we have
2/3
−xn
xn+1 = xn −
− 21/3
3xn
1
= − xn .
2
Thus in both cases
1
xn+1 = − xn .
2
In this case convergence occurs.
Since α = 0 is the root, so from iterations scheme, we can write
1
|xn+1 − 0| = |xn − 0|
2
1
|xn+1 − α| = |xn − α|
2
1
en+1 = en ,
2
where error en = |xn − α|. Thus by definition of order of convergence, order of convergence is one.
Note that the Newton’s method provides second order convergence (minimum) if f 0 (α) 6= 0. In this example,
the function is not differentiable at x = 0. So method may fail (as in part (a)) or method provide slow
convergence (as in part (b)).
20. Apply the Newton’s method with x0 = 0.8 to the equation f (x) = x3 − x2 − x + 1 = 0, and verify that
the convergence is only of first-order. Further show that root α = 1 has multiplicity 2 and then apply the
modified Newton’s method with m = 2 and verify that the convergence is of second-order.
Sol. Successive iterations in Newton’s method are given by
x3n − x2n − xn + 1
xn+1 = xn − , n = 0, 1, 2, · · ·
3x2n − 2xn − 1
Starting with x0 = 0.8, we obtain
CONTINUED
– 13 –
Now we compute the ratios to find the order of convergence.
x3n − x2n − xn + 1
xn+1 = xn − 2 , n = 0, 1, 2, · · ·
3x2n − 2xn − 1
21. Use Newton’s method and the modified Newton’s method to find a solution of
√ √
cos(x + 2) + x(x/2 + 2) = 0, for − 2 ≤ x ≤ −1
Starting with x0 = −1.5, we get the root in 12 iterations with accuracy 10−3 .
x1 = −1.47855075977922 x2 = −1.46246535074333
x3 = −1.45040193555133 x4 = −1.44135464479384
x5 = −1.43456929092347 x6 = −1.42948032375788
x7 = −1.42566361878740 x8 = −1.42280109901900
x9 = −1.42065421398883 x10 = −1.41904405169404
x11 = −1.41783644052568 x12 = −1.41693074432811.
f (xn )f 0 (xn )
xn+1 = xn − , n = 0, 1, 2, · · ·
f 0 (x 2 00
n ) − f (xn )f (xn )
In this case, we get the answer only in two iterations (with same accuracy)
x1 = −1.41423460337851, x2 = −1.41424162427621.
CONTINUED
– 14 –
f (xn )
22. Given the iterative scheme xn+1 = xn − 0 , n ≥ 0 with f (α) = f 0 (α) = 0 and f 00 (α) 6= 0. Find the
f (xn )
order of convergence for this scheme.
Sol. We write the Newton’s iterations as fixed point iterations with
f (x)
g(x) = x −
f 0 (x)
[f 0 (x)]2 − f (x)f 00 (x) f (x)f 00 (x)
g 0 (x) = 1 − = .
[f 0 (x)]2 [f 0 (x)]2
(0)
Since f (α) = f 0 (α) = 0, so g 0 (0) has form. Thus by using the l’Hop̂ital rule, we have
(0)
f 0 (x)f 00 (x) + f (x)f (3) (x)
lim g 0 (0) = lim
x→0 x→0 2f 0 (x)f 00 (x)
[f 00 (x)]2 + 2f 0 (x)f (3) (x) + f (x)f (4) (x)
lim g 0 (0) = lim
x→0 x→0 2[f 0 (x)]2 + 2f 0 (x)f (3) (x)
1
g 0 (α) =
6= 0.
2
Thus the order of convergence for the given scheme is one.
23. A particle starts at rest on a smooth inclined plane whose angle θ is changing at a constant rate
dθ
= ω < 0.
dt
At the end of t seconds, the position of the object is given by
e − e−ωt
ωt
g
x(t) = − 2 − sin ωt .
2ω 2
Suppose the particle has moved 1.7 ft in 1 s. Find, to within 10−5 , the rate ω at which θ changes. Assume
that g = 32.17 ft/s2 .
24. An object falling vertically through the air is subjected to viscous resistance as well as to the force of gravity.
Assume that an object with mass m is dropped from a height s0 and that the height of the object after t
seconds is
mg m2 g
s(t) = s0 − t + 2 (1 − e−kt/m ),
k k
CONTINUED
– 15 –
where g = 32.17 ft/s2 and k represents the coefficient of air resistance in lb-s/ft. Suppose s0 = 300 ft,
m = 0.25 lb, and k = 0.1 lb-s/ft. Find, to within 0.01 s, the time it takes this quarter-pounder to hit the
ground.
Sol. When the object hit the ground, the height of the object s(t) = 0. This gives
mg m2 g
s0 − t + 2 (1 − e−kt/m ) = 0
k k
300 − 80.425t + 201.0625(1 − e−0.4t ) = 0
t = (501.0625 − 201.0625 e−0.4t )/80.425 = g(t).
Start with t0 = 3, first three iterations of fixed-point are (within accuracy 0.01 s)
25. The circle below has radius 1, and the longer circular arc joining A and B is twice as long as the chord AB.
Find the length of the chord AB, correct to four decimal places. Use Newton’s method.
Sol. Draw a perpendicular from O to AB, meeting AB at M. Let θ = ∠AOM . Standard trigonometry shows
that the length of AB is 2 sin θ. The shorter arc joining A and B has length 2θ, so the longer arc has length
2π − 2θ. The longer arc is twice the chord, and therefore
2π − 2θ = 4 sin θ.
We can use the Newton’s Method to solve this equation as it stands by writing f (θ) = 2 sin θ + θ − π.
Also if we substitute x = π − θ then equation becomes x = 2 sin x. This equation can be solved easily with
initial guess 1.5 and root is 1.895494267.
The length of the chord is 2 sin θ that is, 2 sin x, and that is equal to x.
26. It costs a firm C(q) dollars to produce q grams per day of a certain chemical, where
The firm can sell any amount of the chemical at $4 a gram. Find the break-even point of the firm, that is,
how much it should produce per day in order to have neither a profit nor a loss. Use the Newton’s method
and give the answer to the nearest gram.
Sol. If we sell q grams then the revenue is 4q. The break-even point is when revenue is equal to cost, that
is, when
4q = 1000 + 2q + 3q 2/3 .
Let f (q) = 2q − 3q 2/3 − 1000. We need to solve the equation f (q) = 0.
It is worth asking first whether there is a solution, and whether possibly there might be more than one.
We have f 0 (q) = 2 − q −1/3 . The Newton’s Method yields
2/3 1/3
2qn − 3qn − 1000 qn + 1000qn
qn+1 = qn − −1/3
= −1/3
.
2 − qn 2 − qn
CONTINUED
– 16 –
Let us start with q0 = 600. Note that f (q) < 0 for small values of q, indeed up to 500 and beyond. Also,
f (1000) > 0. Since f is continuous, it is equal to 0 somewhere between 500 and 1000.
Further, iterations are given as
q1 = 607.6089386
q2 = 607.6067886.