MTH 201 Lecture Notes
MTH 201 Lecture Notes
March 8, 2021
ii
Let f be a function that has values of opposite sign at the two ends of an interval.
Suppose also that f is continuous on that interval. To fix the notation, let a < b and
f (a)f (b) < 0. It then follows that f has a root in the interval (a, b). In other words, there
must exist a number p that satisfies the two conditions a < p < b and f (p) = 0. How
is this conclusion reached? One must recall the Intermediate Value Theorem. ”If x
traverses an interval [a, b], then the values of f (x) completely fill out the interval between
f (a) and f (b).” No intermediate values can be skipped. Hence, a specific function f must
0.1. SOLUTION OF EQUATIONS IN ONE VARIABLE iii
Figure 1:
take on the value zero somewhere in the interval (a, b) because f (a) and f (b) are of opposite
signs.
The Bisection method calls for a repeated halving (or bisecting) of subintervals of [a, b]
and, at each step, locating the half containing p.
To begin, set a1 = a and b1 = b and let p1 be the midpoint of [a, b]; that is,
b1 − a1 a1 + b1
p1 = a1 + = .
2 2
• If f (p1 ) = 0, then p = p1 , and we are done.
• If f (p1 ) 6= 0, then f (p1 ) has the same sign as either f (a1 ) or f (b1 ).
• If f (p1 ) and f (a1 ) have the same sign, p ∈ (p1 , b1 ). Set a2 = p1 and b2 = b1 .
• If f (p1 ) and f (a1 ) have opposite signs, p ∈ (a1 , p1 ). Set a2 = a1 and b2 = p1 .
Then reapply the process to the interval [a2 , b2 ].
iv
Example 1. Show that f (x) = x3 + 4x2 − 10 = 0 has a root in [1, 2], and use the Bisection
method to determine an approximation to the root that is accurate to at least within 10−4 .
Solution: Because f (1) = −5 and f (2) = 14, the Intermediate Value Theorem ensures
that this is continuous in [1, 2].
For the first iteration, we use the fact that at the midpoint of [1, 2] we have f (1.5) =
2.375 > 0. This indicates that we should select the interval [1, 1.5] for our second iteration.
Then we find that f (1.25) = −1.796875, so our new interval becomes [1.25, 1.5], whose
midpoint is 1.375. Continuing in this manner gives the values in Table 1.
After 13 iterations, p13 = 1.365112305 approximates the root p with an error
so the approximation is correct to at least within 10−4 . The correct value of p to nine
decimal places is p = 1.365230013.
0.1. SOLUTION OF EQUATIONS IN ONE VARIABLE v
Theorem 2. Suppose that f ∈ C[a, b] and f (a) · f (b) < 0. The Bisection method generates
a sequence {pn }∞
n=1 approximating a zero p of f with
b−a
pn − p ≤ , when n ≥ 1. (2)
2n
Example 2. Determine the number of iterations necessary to solve f (x) = x3 +4x2 −10 = 0
with accuracy 10−3 using a1 = 1 and b1 = 2.
Solution: From equation (2), we have
We will use base-10 logarithms because the tolerance is given as a power of 10.
Thus
2−n < 10−3
implies that
log10 2−n < log10 10−3 = −3.
We then have
−n log10 2 < −3
from which we obtain
3
n> ≈ 9.96.
log10 2
Hence, ten iterations will ensure an approximation accurate to within 10−3 .
i. Provided the function is continuous on an interval [a, b] with f (a) · f (b) < 0, bisection
method is guaranteed to work.
ii. The number of iterations needed to achieve a specific accuracy is known in advance.
EXERCISE 1
√
(a) Use the Bisection method to find p3 for f (x) = x − cos(x) on [0, 1]
(b) Use the Bisection method to find solutions accurate to within 10−5 for the following
problems:
i. x − 2−x = 0 f or 0≤x≤1
ii. ex − x2 + 3x − 2 = 0 f or 0≤x≤1
iii. 2x cos(2x) − (x + 1)2 = 0 f or − 3 ≤ x ≤ −2
(c) If a = 0.1 and b = 1.0, how many steps of the bisection method are needed to
determine the root with an error of at most 12 × 10−8 ?
(d) Use Theorem 2 to find a bound for the number of iterations needed to achieve an
approximation with accuracy 10−4 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.
(e) Consider the bisection method with the initial interval [a0 , b0 ]. Show that after ten
steps with this method,
1 1
a9 + b9 = 2−11 b0 − a0 .
a10 + b10 −
2 2
(f) The function f (x) = sin(x) satisfies f (−π/2) = −1 and f (π/2) = 1. Using bisection
method, how many iterations are needed to find an interval of length at most 10−4
which contains a root of the function?
The procedure known as Newton’s method is also called the Newton-Raphson iteration.
The Newton-Raphson method is one of the most useful and best known algorithms that
relies on the continuity of f 0 (x) and f 00 (x).
At a certain point (x0 , f (x0 )) on the graph of f, there is a tangent, which is a rather good
approximation to the curve in the vicinity of that point. Analytically, it means that the
linear function
l(x) = f 0 (x0 )(x − x0 ) + f (x0 )
is close to the given function f near x0 . At x0 , the two functions l and f agree. We take
the zero of l as an approximation to the zero of f. The zero of l is easily found:
f (x0 )
x1 = x0 − .
f 0 (x0 )
Thus, starting with point x0 (which we may interpret as an approximation to the root
sought), we pass to a new point x1 obtained from the preceding formula. Naturally, the
process can be repeated (iterated) to produce a sequence of points:
f (x1 ) f (x2 )
x2 = x1 − , x3 = x2 − ,
f 0 (x1 ) f 0 (x2 )
etc. Under favourable conditions, the sequence of points will approach a zero of f.
The geometry of Newton’s method is shown in Figure 1. The line y = l(x) is tangent to
the curve y = f (x). It intersects the x- axis at a point x1 . The slope of l(x) is f 0 (x0 ).
0.1. SOLUTION OF EQUATIONS IN ONE VARIABLE ix
Figure 2:
x
There are other ways of interpreting Newton’s method. Suppose again that x0
is an initial approximation to a root of f and let x1 = x0 + h be the correct root
so that f (x1 ) = 0.
Expanding f (x0 + h) by Taylor series, we obtain
h2 00
f (x0 ) + hf 0 (x0 ) + f (x0 ) + · · · = 0
2
Neglecting the second and higher order derivatives, we have
f (x0 ) + hf 0 (x0 ) = 0,
which gives
f (x0 )
h=− .
f 0 (x0 )
A better approximation than x0 is therefore, given by x1 , where
f (x0 )
x1 = x0 − .
f 0 (x0 )
f (xn )
xn+1 = xn − , (3)
f 0 (xn )
Example 3. Perform four iterations of the Newton’s method to find the smallest positive
root of the equation f (x) = x3 − 5x + 1 = 0.
Solution:
Since, f (0) · f (1) < 0, the smallest positive root lies in the interval (0, 1).
Applying the Newton’s method, we obtain
2x31 − 1 2(0.176471)3 − 1
x2 = 2 = = 0.201568,
3x1 − 5 3(0.176471)2 − 5
2x32 − 1 2(0.201568)3 − 1
x3 = = = 0.201640,
3x22 − 5 3(0.201568)2 − 5
2x33 − 1 2(0.201640)3 − 1
x4 = = = 0.201640.
3x23 − 5 3(0.201640)2 − 5
Therefore, the root correct to six decimal places is x = 0.201640.
has one root in the interval (−1, 0) and one in (0, 1). Calculate the negative root correct to
4 decimal places.
Solution: From the given function, we have
Hence, one root lies in the interval (−1, 0) and one root in the interval (0, 1).
Using the formula
f (xn )
xn+1 = xn − 0 , n = 0, 1, · · ·
f (xn )
where ! !
π π(x + 1)
f 0 (x) = − sin + 0.148.
8 8
(i) It is fast
(ii) It can be extended to multidimensional problems.
xii
(c) Establish Newton’s iterative scheme in simplified form, not involving the
reciprocal of x for the function f (x) = xR − x−1 . Carry out three steps of
this procedure using R = 4 and x0 = −1.
(d) Use Newton’s method to find all roots of the following equations, correct
to six decimal places
√
(i) 3 cos(x) = x + 1 (ii) cos(x) = x (iii) sin(x) = x2 − 2 (iv) cos(x2 − x) =
x4 .
(e) Find all positive roots to the equation
Z x
2
10 e−x dt = 1,
0
Let the interval [a, b] be divided into n equal subintervals such that a = x0 <
x1 < x2 < · · · < xn = b. Clearly, xn = x0 + nh. Hence the integral becomes
Z xn
I= ydx
x0
Substituting n = 1 in (4) and taking the curve through (x0 , y0 ) and (x1 , y1 ) as a
polynomial of degree one so that differences of an order higher than one vanish,
we get
Z x0 +h !
1 hh i h
ydx = h y0 + ∆y0 = 2y0 + (y1 − y0 ) = (y0 + y1 ).
x0 2 2 2
Putting n = 2 in formula (4) and taking the curve through (x0 , y0 ), (x1 , y1 ) and
(x2 , y2 ) as a polynomial of degree two so that differences of order higher than
two vanish, we get
Z x0 +2h !
1 2
ydx = 2h y0 + ∆y0 + ∆ y0
x0 6
2h
= 6y0 + 6 y1 − y0 + y2 − 2y1 + y0
6
h
= y0 + 4y1 + y2
3
Similarly,
Z x0 +4h
h
ydx = y2 + 4y3 + y4 , · · · ,
x0 +2h 3
Z x0 +nh
h
f (x)dx = yn−2 + 4yn−1 + yn .
x0 +(n−2)h 3
0.2. NUMERICAL INTEGRATION xv
Substituting n = 3 in formula (4) and taking the curve through (x0 , y0 ), (x1 , y1 ),
(x2 , y2 ) and (x3 , y3 ) as a polynomial of degree three so that differences of order
higher than three vanish, we get
Z x0 +3h
3 3 2 1 3
ydx = 3h y0 + ∆y0 + ∆ y0 + ∆ y0
x0 2 4 8
" #
3h
= 8y0 + 12 y1 − y0 + 6 y2 − 2y1 + y0 + y3 − 3y2 + 3y1 − y0
8
3h h i
= y0 + 3y1 + 3y2 + y3 .
8
Similarly,
Z x0 +6h
3h h i
ydx = y3 + 3y4 + 3y5 + y6 , · · ·
x0 +3h 8
Z x0 +6h
3h h i
ydx = yn−3 + 3yn−2 + 3yn−1 + yn .
x0 +(n−3)h 8
Adding the above integrals, we get
Z x0 +nh
3h
ydx = (y0 +yn )+3(y1 +y2 +y4 +y5 +· · ·+yn−2 +yn−1 )+2(y3 +y6 +· · ·+yn−3 )
x0 8
(7)
which is known as Simpson’s three-eighth rule.
Note: This rule also requires that the number of subintervals should be taken
as multiples of 3.
Example 5. Evaluate Z 1
1
dx
0 1+x
using trapezoidal and Simpson’s rules with h = 0.5, 0.25, and 0.125, correct to three decimal
places.
Solution: (i) h = 0.5 : The values of x and y are tabulated below (Table 2)
xvi
1
(b) Simpson’s 3 rule gives
1h i
I= 1.0000 + 4(0.6667) + 0.5000 = 0.6945.
6
(ii) h = 0.25 : The tabulated values of x and y are given below (Table 3)
xviii
1
(b) Simpson’s 3rule gives
1h i
I= 1.0000 + 4(0.8000 + 0.5714) + 2(0.6667) + 0.5000 = 0.6932.
12
(iii) h = 0.125 : The tabulated values of x and y are given below (Table 4)
(a) Trapezoidal rule gives
1h i
I= 1.0+2(0.8889+0.80+0.7273+0.6667+0.6154+0.5714+0.5333)+0.50 = 0.6941.
16
Hence the value of I may be taken to be 0.693, correct to three decimal places.
The exact value of I is loge 2, which is 0.693147 · · · .
This example demonstrates that, in general, Simpson’s rule yields more accu-
rate results than the trapezoidal rule.
EXERCISE 3
(a) Evaluate
Z π Z 2
x
(i) x sin(x)dx and (ii) dx
0 −2 5 + 2x
using the trapezoidal rule with five ordinates.
1
(b) Using Simpson’s 3 rule with h = 1, evaluate the integral
Z 7
I= x2 log xdx.
3
(d) Evaluate
Z 2
dx
0 x3 +x+1
1
by using Simpson’s 3 rule with h = 0.25.
(e) Suppose that f (0) = 1, f (0.5) = 2.5, f (1) = 2, and f (0.25) = f (0.75)
R 1 = α. Find
α if the Trapezoidal rule with n = 4 gives the value 1.75 for 0 f (x)dx.
0.2. NUMERICAL INTEGRATION xxi