Bisection Method (11 Files Merged)
Bisection Method (11 Files Merged)
The first technique to solve equations like above, based on the Intermediate Value
Theorem, is called the Bisection, or Binary-search, method.
Suppose f(x)=0 is a continuous function defined on [a, b], with f (a) and f (b) of
opposite sign. The Intermediate Value Theorem implies that a number p exists in
(a, b) with f (p) = 0.
The bisection method calls for 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, 𝑝1 =
2
Let 𝑓(𝑎1) and 𝑓(𝑝1) have different signs but 𝑓(𝑝1) and 𝑓(𝑏1) have same signs, then
𝑎 +𝑏
the root lies in the interval [𝑎1, 𝑝1]. Set 𝑎1 = 𝑎2 and 𝑝1 = 𝑏2, and let 𝑝2 = 2 2
2
If 𝑓(𝑎2) and 𝑓(𝑝2) have same signs but 𝑓(𝑝2) and 𝑓(𝑏2) have different signs, then
𝑎 +𝑏
the root lies in the interval [𝑝2, b2]. Then find 𝑝3 = 3 3 on the same lines
2
n 𝒂𝒏 𝒃𝒏 𝒑𝒏 𝒇(𝒑𝒏 )
1 0 1 0.5 -0.625
n 𝒂𝒏 𝒃𝒏 𝒑𝒏 𝒇(𝒑𝒏 )
1 0 1 0.5 -0.2071
Disadvantage
The Bisection method, though conceptually clear, has significant drawbacks. It is
relatively slow to converge (that is, N may become quite large before | 𝑝 − 𝑝𝑁 | is
sufficiently small), and a good intermediate approximation might be inadvertently
discarded.
Advantage
The method has the important property that it always converges to a solution.
TASK 1
You are designing a spherical tank to hold water for a small village in a developing
country. The volume of liquid it can hold can be
computed as
𝝅 𝒉𝟐
𝑽= (𝟑𝑹 − 𝒉)
𝟑
where V = volume (m3), h = depth of water in
tank (m), and R = the tank radius (m). If R = 3
m, what depth must the tank be filled to so that
it holds 30 m3? Determine your answer using some suitable initial guess.
TASK 2
PRACTICE
Newton Divided-Difference Formula
A practical difficulty with Lagrange interpolation is that the work done in calculating
the approximation by the lower degree polynomial does not lessen the work needed to
calculate the higher degree polynomial approximation.
Newton Divided-Difference Table
x f(x) First divided Second divided Third divided Fourth divided
differences differences differences difference
𝑥0 𝑓[𝑥0 ]
𝑓[𝑥0 , 𝑥1 ] = 𝐴
𝑓(𝑥1 ) − 𝑓(𝑥0 )
=
𝑥1 − 𝑥0
𝑥1 𝑓[𝑥1 ] 𝑓[𝑥0 , 𝑥1 , 𝑥2 ]
𝐵 −𝐴
= =𝐸
𝑥2 − 𝑥0
𝑓[𝑥1 , 𝑥2 ] = 𝐵 𝑓[𝑥0 , 𝑥1 , 𝑥2 , 𝑥3 ]
𝑓(𝑥2 ) − 𝑓(𝑥1 ) 𝐹−𝐸
= = =𝐻
𝑥2 − 𝑥1 𝑥3 − 𝑥0
𝑥2 𝑓[𝑥2 ] 𝑓[𝑥1 , 𝑥2 , 𝑥3 ] 𝑓[𝑥0 , 𝑥1 , … , 𝑥4 ]
𝐶 −𝐵 𝐼 −𝐻
= =𝐹 = =𝐽
𝑥3 − 𝑥1 𝑥4 − 𝑥0
𝑓[𝑥2 , 𝑥3 ] = 𝐶 𝑓[𝑥1 , 𝑥2 , 𝑥3 , 𝑥4 ]
𝑓(𝑥3 ) − 𝑓(𝑥2 ) 𝐺−𝐹
= = =𝐼
𝑥3 − 𝑥2 𝑥4 − 𝑥1
𝑥3 𝑓[𝑥3 ] 𝑓[𝑥2 , 𝑥3 , 𝑥4 ]
𝐷 −𝐶
= =𝐺
𝑥4 − 𝑥2
𝑓[𝑥3 , 𝑥4 ] = 𝐷
𝑓(𝑥4 ) − 𝑓(𝑥3 )
=
𝑥4 − 𝑥3
𝑥4 𝑓[𝑥4 ]
𝑓[𝑥2 , 𝑥3 ] = 3.1576
Theorem: (i) If g ∈ C[a, b] and g(x) ∈ [a, b] for all x ∈ [a, b], then g has at least
one fixed point in [a, b].
(ii) If, in addition, 𝑔′ (𝑥) exists on (a, b) and a positive constant k < 1 exists with
|𝑔′ (𝑥)| ≤ k, for all x ∈ (a, b), then there is exactly one fixed point in [a, b].
To approximate the fixed point of a function g, we choose an initial approximation
𝑝0 and generate the sequence {𝑝𝑛 }∞
𝑛=0 by letting 𝑝𝑛 = 𝑔(𝑝𝑛−1 ), for each n ≥ 1.
1
4𝑥 2 = 10 − 𝑥 3 ⇒ (𝑏) 𝑥 = √10 − 𝑥 3
2
10
𝑥 2 (𝑥 + 4) = 10 ⇒ (𝑐) 𝑥 = √
4+𝑥
𝑥 3 +4𝑥 2 −10
and by some other means (𝑑) 𝑥 = 𝑥 −
3𝑥 2 +8𝑥
To start the sequence for each function, let us take 𝑝0 = 1.5 from [1, 2].
We have summarized these four sequences in the form of a table as:
6 1.36785 1.36523
7 1.36389
8 1.36592
9 1.36488
10 1.36541
11 1.36514
12 1.36528
Some of the methods you have learned in Calculus, LA, DE as exact methods, will be
solved numerically (using computer) here. These methods are not exact but help us in
solving difficult problems with the help of computer algorithms with good accuracy.
Computer is a very powerful tool which is now used in almost every field of our world:
organizing a super store, launching a rocket in space, building missiles systems,
constructing a building of 100 floors, bringing the world online, shopping, gaming, for
business, and much more. Most of the world population is using computer in one form
or other. As a computer science student, one has to learn how all this work is being done,
what are the difficulties behind it and what the limitations are. The issues discussed in
this course of numerical computing are:
How computer performs calculations?
How Mathematics is the base of computer?
What issues you have to deal while implementing an Algorithm on computer
(error, resources, accuracy, stability, computer compatibility)?
Which Algorithms are better and how to improve Algorithms?
How a real life problem is digitalized (making algorithms to implement on
computer, explaining the solution in terms of real world)?
Applications in CS
We can also understand the importance of mathematics by following examples:
GAMING
An angry bird user is only concerned about the quality of the game and how much fun it
provides while playing. But for a CS student, it is important to learn the basics of the
different features of this game which are based on the concepts of numerical computing.
First thing is what the inputs of this game are
1. Angle with which bird is fired
2. Power or Force
Here comes the difficult part that how from these inputs computer will get the output
i.e. the trajectory of the bird, its impact on wood and on other things. What kind of
mathematics and physics is involved? Just try to get the ideas like the trajectory of the
bird is a projectile motion and from input, first differential equation for projectile
motion is made and its solution give us the exact trajectory and impact of the bird. So
in this game Calculus, Differential equation, Linear Algebra, and of course numerical
computing (still to be learned) are used. Students can try to visualize different
phases in making this game and broaden their vision for more innovations.
Similarly, in Racing games like Need for speed, speed is like 1st derivative,
acceleration and brakes are 2nd derivative. In handling movement graphics,
Mathematics is used.
ANIMATION
Look at different options in Corel draw and other graphic and animation soft wares.
Features like zoom in, zoom out, rotation, drawing different shapes, coloring and
spraying are all executed using the algorithms based on Mathematics (Linear Algebra,
coordinate system, geometry, Statistics, Calculus). There may be designers who have
used these soft wares for ages and still questioning ‘where Mathematics is being
used’. Of course principles of numerical computing are very important to
understand in solving any kind of problem. A beautifully written book “Fundamentals
of Computer Graphics Third Edition” can increase your knowledge of how
Mathematics is being used in Computer Science.
Applications in Real life Problems
Now a day, usually for mega projects, we use digital models and test different
possibilities in them before actually manufacturing them.
Flying Jet Simulation for Pilots
Commercial Jet is a very costly thing with the huge responsibility of the safety of
passengers. For these reasons, simulation of the actual jet is made, on which Pilots can
practice many scenarios: flying in snow, rain, bad weather, different emergency
situations. Many things from numerical computing are used in making these
simulations possible, like aero dynamics, graphics, and fluid mechanics.
Engineering
A 100 story building cannot be built without planning. When there is so much at stake,
we have to be sure, like is the base enough powerful to handle the weight of the
building, does the design work, how much weather conditions the building can
handle, and many other different scenarios are to be tested.
On June 4, 1996 Ariane 5 rocket launched by the European Space Agency exploded
just forty seconds after its lift-off from Kourou, French Guiana.
The rocket was on its first voyage, after a decade of development costing $7 billion,
and its cargo were valued at $500 million.
A board of inquiry investigated the causes of the explosion and in two weeks issued a
report. It turned out that the cause of the failure was a software error based on rounding
off at some 24th decimal place and thus the conversion failed.
The Patriot Missile Failure
In 1991 Gulf War, an American Patriot Missile in Saudi Arabia, failed to track and
intercept an incoming Iraqi Scud missile. The Scud struck an American Army barracks,
killing 28 soldiers and injuring around 100 other people.
The report of the General Accounting office, reported on the cause of the failure. It
turned out that the cause was an inaccurate calculation of the time since boot due to
computer arithmetic errors. Specifically, the time in tenths of second as measured by
the system's internal clock was multiplied by 1/10 to produce the time in seconds. The
small chopping error, when multiplied by the large number giving the time in tenths of
a second, led to a significant error which was about 0.34 seconds.
Nowadays, in era of smart phones and fast internet, we talk about Nanoseconds not
even microseconds.
So in each scenario, we should know our limitations and effects of failures in
calculations which we will learn in this course.
Analysis of the error involved in calculations is an important topic in numerical
analysis.
*In this course, scientific calculators should be with you in all the lectures.
Reference Material:
Numerical Analysis by Burden and Fairies 10th Edition
Numerical Analysis: Mathematics of Scientific Computing 6 th Edition by David
Ronald Kincaid, Elliott Ward Cheney
Applied Numerical Analysis 7th Edition by Curtis F. Gerald
Numerical Analysis 2nd Edition by Tim Sauer
Review of Calculus (Why in CS and in NM?)
A solid knowledge of calculus is essential for an understanding of the analysis of
numerical techniques, and more thorough review might be needed if you have been away
from this subject for a while.
And f is continuous at 𝑥0 if
lim 𝑓(𝑥) = 𝑓(𝑥0 )
𝑥→𝑥0
Differentiability
Let f be a function defined in an open interval containing 𝑥0 . The function f is
differentiable at 𝑥0 if
𝑓(𝑥)−𝑓(𝑥0 )
𝑓 ′ (𝑥0 ) = lim𝑥→𝑥0 exists, called the derivative of 𝑓 at 𝑥0 .
𝑥−𝑥0
Interpolation and Polynomial Approximation
Applications
In chapter 1 we found polynomial approximation of a function using Taylor’s
formula about a point 𝑥0 . What if we have a data set of two or more points? Like
population of a country taken every 10 years as:
Geometric Meaning
Algorithm
Lagrange Interpolating Polynomials
A polynomial of degree one passing through points (𝑥0 , 𝑦0 ) and (𝑥1 , 𝑦1 ) is same as
approximating a function 𝑓 with 𝑦0 = 𝑓(𝑥0 ) and 𝑦1 = 𝑓(𝑥1 ).
Lagrange polynomial for it is
𝑃1 (𝑥) = 𝐿0 (𝑥)𝑓(𝑥0 ) + 𝐿1 (𝑥)𝑓(𝑥1 ) with
𝑥−𝑥1 𝑥−𝑥0
𝐿0 (𝑥) = and 𝐿1 (𝑥) = .
𝑥0 −𝑥1 𝑥1 −𝑥0
Similarly for three points (𝑥0 , 𝑦0 ), (𝑥1 , 𝑦1 ) and (𝑥2 , 𝑦2 ), we have to calculate three
coefficient polynomials 𝐿0 (𝑥), 𝐿1 (𝑥), 𝐿2 (𝑥) and Lagrange polynomial for it is
𝑃2 (𝑥) = 𝐿0 (𝑥)𝑓(𝑥0 ) + 𝐿1 (𝑥)𝑓(𝑥1 ) + 𝐿2 (𝑥)𝑓(𝑥2 ) with
(𝑥−𝑥1 )(𝑥−𝑥2 ) (𝑥−𝑥0 )(𝑥−𝑥2 ) (𝑥−𝑥0 )(𝑥−𝑥1 )
𝐿0 (𝑥) = , 𝐿1 (𝑥) = and 𝐿2 (𝑥) =
(𝑥0 −𝑥1 )(𝑥0 −𝑥2 ) (𝑥1 −𝑥0 )(𝑥1 −𝑥2 ) (𝑥2 −𝑥0 )(𝑥2 −𝑥1 )
Yes…
For (𝑥0 , 𝑦0 ), (𝑥1 , 𝑦1 ), (𝑥2 , 𝑦2 ) and (𝑥3 , 𝑦3 ), Lagrange polynomial will be
𝑃3 (𝑥) = 𝐿0 (𝑥)𝑓(𝑥0 ) + 𝐿1 (𝑥)𝑓(𝑥1 ) + 𝐿2 (𝑥)𝑓(𝑥2 ) + 𝐿3 (𝑥)𝑓(𝑥3 ) with
(𝑥−𝑥1 )(𝑥−𝑥2 )(𝑥−𝑥3 ) (𝑥−𝑥0 )(𝑥−𝑥2 )(𝑥−𝑥3 )
𝐿0 (𝑥) = , 𝐿1 (𝑥) = ,
(𝑥0 −𝑥1 )(𝑥0 −𝑥2 )(𝑥0 −𝑥3 ) (𝑥1 −𝑥0 )(𝑥1 −𝑥2 )(𝑥1 −𝑥3 )
Example 1
Determine the linear Lagrange interpolating polynomial that passes through the points
(2, 4) and (5, 1).
Hence,
1 1
𝑃1 (𝑥) = − (𝑥 − 5)4 + (𝑥 − 2)1 = −𝑥 + 6 .
3 3
*You can see that it is the same linear equation, you have derived in calculus from
the point slope form of the equation using two points. The advantage is that the
Lagrange polynomial is not only for polynomials of degree one but can be
extended to polynomials of degree n using n+1 points of any given data.
Example 2
1
Use 𝑥0 = 2, 𝑥1 = 2.75 and 𝑥2 = 4 to find Lagrange polynomial for 𝑓(𝑥) = .
𝑥
Use this polynomial to approximate 𝑓(3).
Solution: First determine coefficient polynomials 𝐿0 (𝑥), 𝐿1 (𝑥), and 𝐿2 (𝑥) as
(𝑥 − 𝑥1 )(𝑥 − 𝑥2 ) (𝑥 − 2.75)(𝑥 − 4) 2
𝐿0 (𝑥) = = = (𝑥 − 2.75)(𝑥 − 4),
(𝑥0 − 𝑥1 )(𝑥0 − 𝑥2 ) (2 − 2.75)(2 − 4) 3
(𝑥 − 𝑥0 )(𝑥 − 𝑥2 ) (𝑥 − 2)(𝑥 − 4) 16
𝐿1 (𝑥) = = = − (𝑥 − 2)(𝑥 − 4),
(𝑥1 − 𝑥0 )(𝑥1 − 𝑥2 ) (2.75 − 2)(2.75 − 4) 15
(𝑥 − 𝑥0 )(𝑥 − 𝑥1 ) (𝑥 − 2)(𝑥 − 2.75) 2
and 𝐿2 (𝑥) = = = (𝑥 − 2)(𝑥 − 2.75).
(𝑥2 − 𝑥0 )(𝑥2 − 𝑥1 ) (4 − 2)(4 − 2.75) 5
Therefore, polynomial for it is
𝑃2 (𝑥) = 𝐿0 (𝑥)𝑓(𝑥0 ) + 𝐿1 (𝑥)𝑓(𝑥1 ) + 𝐿2 (𝑥)𝑓(𝑥2 )
2 1 16 1 2 1
= (𝑥 − 2.75)(𝑥 − 4) − (𝑥 − 2)(𝑥 − 4) + (𝑥 − 2)(𝑥 − 2.75)
3 2 15 2.75 5 4
1 35 49
⟹ 𝑃2 (𝑥) = 𝑥2 − 𝑥+
22 88 44
1
So, 𝑃2 (3) = 0.32955 while 𝑓(3) = = 0.33333.
3
Practice
Exercise 3.1
Q. For 𝑥0 = 0, 𝑥1 = 0.6, 𝑥2 = 0.9 and 𝑓(𝑥) = √1 + 𝑥 , construct
Lagrange interpolation polynomial of degree 1 & 2 to approximate 𝑓(0.45) and
find error.
Solution: (i) Lagrange polynomial of degree 1
For 𝑥0 = 0, 𝑥1 = 0.6, 𝑓(𝑥0 ) = 1, 𝑓(𝑥1 ) = √1.6
𝑥 − 𝑥1 𝑥 − 0.6 5
𝐿0 (𝑥) = = = − (𝑥 − 0.6)
𝑥0 − 𝑥1 −0.6 3
𝑥 − 𝑥0 𝑥−0 5
and 𝐿1 (𝑥) = = = 𝑥.
𝑥1 − 𝑥0 0.6 3
5 5
Hence, 𝑃1 (𝑥) = 𝐿0 (𝑥)𝑓(𝑥0 ) + 𝐿1 (𝑥)𝑓(𝑥1 ) = − (𝑥 − 0.6) 1 + 𝑥√1.6
3 3
⟹ 𝑃(0.45) = 1.19868,
while f(0.45) = 1.20416
So, Absolute Error =0.00548
(ii) Lagrange polynomial of degree 2
For 𝑥0 = 0, 𝑥1 = 0.6, 𝑥2 = 0.9, 𝑓(𝑥0 ) = 1, 𝑓(𝑥1 ) = √1.6, 𝑓(𝑥2 ) = √1.9
(𝑥 − 𝑥1 )(𝑥 − 𝑥2 ) (𝑥 − 0.6)(𝑥 − 0.9)
𝐿0 (𝑥) = = ,
(𝑥0 − 𝑥1 )(𝑥0 − 𝑥2 ) (−0.6)(−0.9)
(𝑥 − 𝑥0 )(𝑥 − 𝑥2 ) 𝑥(𝑥 − 0.9)
𝐿1 (𝑥) = = ,
(𝑥1 − 𝑥0 )(𝑥1 − 𝑥2 ) (0.6)(−0.3)
(𝑥 − 𝑥0 )(𝑥 − 𝑥1 ) 𝑥(𝑥 − 0.6)
𝑎𝑛𝑑 𝐿2 (𝑥) = = .
(𝑥2 − 𝑥0 )(𝑥2 − 𝑥1 ) (0.9)(0.3)
Therefore, 𝑃2 (𝑥) = 𝐿0 (𝑥)𝑓(𝑥0 ) + 𝐿1 (𝑥)𝑓(𝑥1 ) + 𝐿2 (𝑥)𝑓(𝑥2 )
(𝑥 − 0.6)(𝑥 − 0.9) 𝑥(𝑥 − 0.9) 𝑥(𝑥 − 0.6)
= 1− √1.6 + √1.9
0.54 0.18 0.27
⟹ 𝑃(0.45) = 1.20342
So, Absolute Error = 0.00074
NEWTON’S (OR NEWTON-RAPHSON) METHOD
Newton’s (or the Newton-Raphson) method is one of the most powerful and well-
known numerical methods for solving a root-finding problem. There are many
ways of introducing Newton’s method.
If we only want an algorithm, we can consider the technique graphically, as is
often done in calculus. Another possibility is to derive Newton’s method as a
technique to obtain faster convergence than offered by other types of functional
iterations. A third means of introducing Newton’s method, which is discussed next,
is based on Taylor polynomials. We will see there that this particular derivation
produces not only the method, but also a bound for the error of the approximation.
Algorithm
Example
Use Newton’s method to approximate a root of
𝑓(𝑥) = cos 𝑥 − 𝑥 = 0 with 𝑝0 = 𝜋⁄4.
𝑓(𝑝1 )
For n =2, 𝑝2 = 𝑝1 − =0.739085
𝑓′ (𝑝1 )
𝑓(𝑝2 )
and 𝑝3 = 𝑝2 − =0.739085.
𝑓′ (𝑝2 )
Advantage/Disadvantage
In a practical application, an initial approximation is selected and successive
approximations are generated by Newton’s method. These will generally either
converge quickly to the root, or it will be clear that convergence is unlikely.
Word Problem 1
The sum of two numbers is 20. If each number is added to its square root, the
product of the two sums is 155.55. Determine the two numbers to within 10−4 .
Word Problem 2
The accumulated value of a savings account based on regular periodic payments
can be determined from the annuity due equation,
Practice
Q2. Let 𝑓(𝑥) = −𝑥 3 − cos 𝑥 and 𝑝0 = −1. Use Newton’s method to find 𝑝2 .
Could 𝑝0 = 0 be used?
Solution: Putting 𝑓(𝑥) = −𝑥 3 − cos 𝑥 and 𝑓 ′ (𝑥) = −3𝑥 2 + sin 𝑥
𝑓(𝑝𝑛−1 )
in Newton’s formula 𝑝𝑛 = 𝑝𝑛−1 −
𝑓′ (𝑝𝑛−1 )
𝑓(𝑝0 )
for n=1, we get 𝑝1 = 𝑝0 − = −0.88033
𝑓′ (𝑝0 )
𝑓(𝑝1 )
For n=2, 𝑝2 = 𝑝1 − = −0.86568.
𝑓′ (𝑝1 )
PROGRAM (S) TO BE
BSCS
EVALUATED
Course Description
1 NCEAC.FORM.001.C
Course Goals Students should be:
1) able to assess the approximation techniques to formulate and
apply appropriate strategy to solve real world problems.
2) aware of the use of numerical computing in modern scientific
computing.
3) familiar with numerical solution of integration, differentiation,
linear equations, ordinary differential equations,
interpolations.
Topics Covered in the Attached
Course
Programming Assignments No
Done in the Course
Class Time Spent on (in Theory Problem Solution Social and Ethical Issues
credit hours) Analysis Design
0.5 1.5 0.5 0.5
Oral and Written At least 4 assignments will be submitted by each student.
Communications
2 NCEAC.FORM.001.C
2 Discussion of main problems of Numerical Computing and how Class
Mathematics can solve these problems Assignment
Taylor’s polynomials as solution to 1st main problem of Numerical
Computing. Theory of Taylor’s polynomials and its uses.
Truncation error.
MID TERM
9 Concept of Differentiation, its uses in Real Life and Computer Science.
Numerical Differentiation, its Purpose and Applications. 3
3 NCEAC.FORM.001.C
Drawbacks, Error Analysis, Comparison of both Formulae.
10 Concept of Integration, its uses in Real Life and Computer Science. Quiz 4
Numerical Integration, its Purpose and Applications.
15 REVISION
16 REVISION
FINAL TERM
4 NCEAC.FORM.001.C
Review of Calculus
This lecture contains a short review of those topics from single-variable calculus that
will be needed in later topics. A solid knowledge of calculus is essential for an
understanding of the analysis of numerical techniques, and more thorough review
might be needed if you have been away from this subject for a while.
And f is continuous at 𝑥0 if
lim 𝑓(𝑥) = 𝑓(𝑥0 )
𝑥→𝑥0
Differentiability
Let f be a function defined in an open
interval containing 𝑥0 . The function f
is differentiable at 𝑥0 if
𝑓(𝑥) − 𝑓(𝑥0 )
𝑓 ′ (𝑥0 ) = lim
𝑥→𝑥0 𝑥 − 𝑥0
exists, called the derivative of f at 𝑥0 .
Rolle’s Theorem
Suppose f ∈ C[a, b] and f is
differentiable on (a, b). If f (a) = f (b),
then a number c in (a, b) exists with
𝑓 ′ (𝑐) = 0.
* Learn the use of calculator, write a function and calculate its values at different
points.
Example
Show that 𝑥 5 − 2𝑥 3 + 3𝑥 2 − 1 = 0 has a solution in the interval [0, 1].
Solution:
Consider the function defined by
𝑓 (𝑥) = 𝑥 5 − 2𝑥 3 + 3𝑥 2 − 1
The function f is continuous on [0, 1]. In addition, f (0) = −1 < 0 and 0 < 1 = f (1).
The Intermediate Value Theorem implies that a number 𝑥 exists, with 0 < 𝑥 < 1, for
which 𝑥 5 − 2𝑥 3 + 3𝑥 2 − 1 = 0.
Work to do
Exercise 1.1
Q1: Show that following equations have at least one solution in the given intervals.
a. 𝑥 cos 𝑥 − 2𝑥 2 + 3𝑥 − 1 = 0, [0.2, 0.3] and [1.2, 1.3]
b. (𝑥 − 2)2 − ln 𝑥 = 0, [1, 2] and [𝑒, 4]
c. 𝑥 − (ln 𝑥)𝑥 = 0, [4, 5]
Geometric Meaning
Example
Use Secant method to find solution accurate to within 10−5 for 𝑓(𝑥 ) =
𝑥 3 − 2𝑥 2 − 5 in [1, 4].
Solution: For Secant method, let us take 𝑝0 = 2 and 𝑝1 = 3, from [1, 4].
Formula for Secant method is
𝑓(𝑝𝑛−1 )(𝑝𝑛−1 − 𝑝𝑛−2 )
𝑝𝑛 = 𝑝𝑛−1 −
𝑓 (𝑝𝑛−1 ) − 𝑓(𝑝𝑛−2 )
* For calculator take 𝑝0 = 𝑥 and 𝑝1 = 𝑦 and write function as
(𝑦 3 − 2𝑦 2 − 5)(𝑦 − 𝑥)
𝑦−
((𝑦 3 − 2𝑦 2 − 5) − (𝑥 3 − 2𝑥 2 − 5))
and for 𝑝2 𝑡𝑎𝑘𝑒 𝑥 = 2 and 𝑦 = 3.
For 𝑝3 𝑡𝑎𝑘𝑒 𝑥 = 3 and 𝑦 = 2.55556 and so on.
So for n=2, we have
𝑓(𝑝1 )(𝑝1 − 𝑝0 )
𝑝2 = 𝑝1 − = 2.55556
𝑓 (𝑝1 ) − 𝑓(𝑝0 )
𝑓(𝑝2 )(𝑝2 − 𝑝1 )
𝑝3 = 𝑝2 − = 2.66905
𝑓(𝑝2 ) − 𝑓(𝑝1 )
𝑝4 = 2.69237
𝑝5 = 2.69063
𝑝6 = 2.69065 = 𝑝7 is the solution of f(x).
Advantage/Disadvantage
The convergence of the Secant method is much faster than functional iteration but
slightly slower than Newton’s method. This is generally the case. Newton’s
method or the Secant method is often used to refine an answer obtained by another
technique, such as the Bisection method, since these methods require good first
approximations but generally give rapid convergence.
Word Problem 1
Word Problem 2
The accumulated value of a savings account based on regular periodic payments
can be determined from the annuity due equation,
Q8(c) Use Secant method to find solution accurate within 10−3 for the equation:
2𝑥 cos(2𝑥) − (𝑥 − 2)2 = 0 𝑓𝑜𝑟 2 ≤ 𝑥 ≤ 3.
TAYLOR SERIES AND POLYNOMIALS
Taylor series and polynomials are of basic importance and used extensively in numerical
analysis, in approximating a differentiable function and its integral etc.
Taylor Series
Let f and its higher order derivatives be continuous on [a, b] and x0 be a fixed point in [a, b].
Then, for x ∈ [a, b], 𝑓(𝑥) can be expressed as the infinite series (called Taylor’s Series)
𝑓 ′′ (𝑥0 ) 𝑓 (𝑛) (𝑥0 ) 𝑓 (𝑛+1) (𝑥0 )
𝑓(𝑥) = 𝑓(𝑥0 ) + 𝑓 ′ (𝑥0 )(𝑥 − 𝑥0 ) + (𝑥 − 𝑥0 )2 + ⋯ + (𝑥 − 𝑥0 )𝑛 + (𝑥 − 𝑥0 )𝑛+1 + ⋯
2! 𝑛! (𝑛 + 1)!
Taylor Polynomial
𝑓(𝑛) (𝑥0 )
If the Taylor’s series is truncated to the term (𝑥 − 𝑥0 )𝑛 , then the polynomial
𝑛!
obtained is called the Taylor’s polynomial
′′ 𝑛 ( )
𝑓 (𝑥0 )
′ 2 𝑓 (𝑥0 )
𝑓(𝑥) ≈ 𝑃𝑛 𝑥 = 𝑓 𝑥0 + 𝑓 𝑥0 𝑥 − 𝑥0 +
( ) ( ) ( )( ) ( 𝑥 − 𝑥0 + ⋯ +
) (𝑥 − 𝑥0 )𝑛
2! 𝑛!
Theorem (Taylor’s Theorem)
Suppose f ∈ Cn [a, b], that f (n+1) exists on [a, b], and x0 ∈ [a, b]. For every x ∈ [a, b],there
exists a number ξ(x) between x0 and x with
𝑓(𝑥) = 𝑃𝑛 (𝑥) + 𝑅𝑛 (𝑥)
Where
𝑓 ′′ (𝑥0 ) 𝑓 (𝑛) (𝑥0 )
𝑃𝑛 (𝑥) = 𝑓 (𝑥0 ) + 𝑓 ′ (𝑥0 )(𝑥 − 𝑥0 ) + (𝑥 − 𝑥0 )2 + ⋯ + (𝑥 − 𝑥0 )𝑛
2! 𝑛!
and
𝑓 (𝑛+1) (𝜉(𝑥))
𝑅𝑛 (𝑥) = (𝑥 − 𝑥0 )𝑛+1 .
(𝑛 + 1)!
Here 𝑃𝑛 (𝑥) is the nth Taylor polynomial for f about x0, and 𝑅𝑛 (𝑥) is the remainder term
(or truncation error) associated with 𝑃𝑛 (𝑥). Since the number ξ(x) in the truncation error
𝑅𝑛 (𝑥) depends on the value of x at which the polynomial 𝑃𝑛 (𝑥) is being evaluated, it is a
function of the variable x. However, we should not expect to be able to explicitly determine
the function ξ(x). Taylor’s Theorem simply ensures that such a function exists, and that its
value lies between x and x0.
In the case x0 = 0, the Taylor polynomial is often called a Maclaurin polynomial, and the
Taylor series is often called a Maclaurin series.
The term truncation error in the Taylor polynomial refers to the error involved in using a
truncated, or finite, summation to approximate the sum of an infinite series.
Example. Let f (x) = cos x and x0 = 0. Determine
(a) the second, third and fourth Taylor polynomial for f about x0; and use these polynomials
to approximate f (0.02) by finding the actual error.
(b) an upper bound for |f (0.02) − 𝑃𝑛 (0.02)| using the error formula 𝑅2 (𝑥), compare it to the
actual error.
Solution. Since f ∈ C∞(R), Taylor’s Theorem can be applied for any n ≥ 0. Also,
𝑓 ′ (𝑥) = − sin 𝑥 , 𝑓 ′′ (𝑥) = − cos 𝑥 , 𝑓 ′′′ (𝑥) = sin 𝑥 , and 𝑓 (4) (𝑥) = cos 𝑥,
So
𝑓 (0) = 1, 𝑓 ′ (0) = 0, 𝑓 ′′ (0) = −1, 𝑓 ′′′ (0) = 0, 𝑎𝑛𝑑 𝑓 (4) (0) = 1.
⟹ 𝑃4 (0.02) =0.99980001
(b) To find upper bound of error we use formula
𝑓 (𝑛+1) (𝜉(𝑥))
𝑅𝑛 (𝑥) = (𝑥 − 𝑥0 )𝑛+1 .
(𝑛 + 1)!
where ξ(x) is some (generally unknown) number between 0 and x.
Therefore, the upper bound of error for 𝑃2 (𝑥) will be
𝑓 ′′′ (𝜉 (𝑥)) 3 sin 𝜉 (𝑥) 3
𝑅2 (𝑥) = 𝑥 = 𝑥
3! 6
The error bound is much larger than the actual error. This is due to the poor bound we used
for | sin ξ(x)|.
As from calculus, we have | sin x| ≤ |x|. Since 0 ≤ ξ < 0.02, we could have used the fact that
| sin ξ(x)| ≤ 0.02 in the error formula, producing the bound 𝑅2 (0.02) =2.67 × 10−8.
Similarly, the upper bound of error for 𝑃3 (𝑥) will be
𝑓 (4) (𝜉(𝑥)) 4 cos 𝜉 (𝑥) 4
𝑅3 (𝑥) = 𝑥 = 𝑥
4! 24
Since, | cos ξ(x)| ≤ 1, so 𝑅3 (0.02) ≤ 6.67 × 10−9 .
′
𝑓′′ (0) 𝑓′′′ (0) 𝑓(4) (0)
𝑓(𝑥) = 𝑓(0) + 𝑓 (0)𝑥 + 𝑥 + 2 3
𝑥 ++ 𝑥4 + ⋯
2! 3! 4!
𝑥3 𝑥5 𝑥7
sin 𝑥 = 𝑥 − + − +⋯
3! 5! 7!
𝑥3 𝑥3 𝑥5
or sin 𝑥 ≈ 𝑃4 (𝑥) = 𝑥 − and sin 𝑥 ≈ 𝑃5 (𝑥) = 𝑥 − +
3! 3! 5!
Therefore, 𝐀𝐜𝐭𝐮𝐚𝐥 𝐞𝐫𝐫𝐨𝐫 for 𝑃4 (0.1) = 8.7 × 10−8 and for 𝑃5 (0.1) = 2 × 10−11 , resp.
* But if we check error at 𝑥 = 0.5, with 𝑃5 (0.5) = 0.4794271
≤ 0.103 taking 𝜉 (𝑥) = 0.5, cos 𝜉 (𝑥) = 1 and sin 𝜉 (𝑥) = 𝜉 (𝑥) .
(c) To find upper bound of error for 𝑃2 (𝑥) on the interval [0,1]
1 1
∫0 𝑃2 (𝑥) 𝑑𝑥 = ∫0 (1 + 𝑥) 𝑑𝑥 = 1.5
1
While exact value is ∫0 𝑒 𝑥 cos 𝑥 𝑑𝑥 = 1.378.
𝑃3 (0.2) = 0.8945
While exact value is 𝑓(0.2) = √1 − 0.2 = 0.8944272
So, 𝐀𝐜𝐭𝐮𝐚𝐥 𝐞𝐫𝐫𝐨𝐫 = 7 × 10−5 .
For n = 4 and 𝑥0 = 0, we have
′
𝑓′′ (0) 𝑓′′′ (0) 𝑓(4) (0)
𝑃4 (𝑥) = 𝑓(0) + 𝑓 (0)𝑥 + 2
𝑥 + 3
𝑥 + 𝑥4
2! 3! 4!
1 1 1 5
= 1 − 𝑥 − 𝑥2 − 𝑥3 − 𝑥4
2 8 16 128
⟹ 𝑃4 (0.2) = 0.8944375.
Therefore, 𝐀𝐜𝐭𝐮𝐚𝐥 𝐞𝐫𝐫𝐨𝐫 = 1.03 × 10−5 .
(b) To find upper bound of error for 𝑃3 (𝑥) will be
𝑓 (4) (𝜉(𝑥)) 4 5
𝑅3 (𝑥) = 𝑥 =− (1 − 𝜉 (𝑥))−7/2 𝑥 4
4! 128
so 𝑅3 (0.2) ≤ 1.365 × 10−4 taking 𝜉(𝑥) = 0.2.
0.5
(c) To approximate ∫0 𝑓(𝑥)𝑑𝑥 , we use
0.5 0.5 1 1 1
∫0 𝑃3 (𝑥) 𝑑𝑥 = ∫0 (1 − 2 𝑥 − 8 𝑥 2 − 16 𝑥 3 ) 𝑑𝑥 = 0.431315
0.5
While exact value is ∫0 √1 − 𝑥 𝑑𝑥 = 0.430964.
Therefore, 𝐀𝐜𝐭𝐮𝐚𝐥 𝐞𝐫𝐫𝐨𝐫 = 3.51 × 10−4 .