Num Analysis
Num Analysis
f (x )
xn+1 = xn − f 0(xn )
n
[Link]
Department of Mathematics
Makerere University
1 Introduction 5
1.1 What is Numerical Analysis? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2 Two issues of Numerical Analysis: . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3 Advantages and Disadvantages of Numerical Analysis: . . . . . . . . . . . . . . . 7
1.3.1 Hard or impossible classical solutions . . . . . . . . . . . . . . . . . . . . 7
1.3.2 Tabulated data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4 Important Notes: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.5 Numerical Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.5.1 Sources of Errors: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.5.2 Types of Errors: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2 Numerical Integration 11
2.1 Manual Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.2 Trapezoidal/Trapezium rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2.1 Composite Trapezoidal Rule . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3 Simpson’s rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3.1 Composite Simpson’s rule . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3.2 Program-FORTRAN (an alternative to MAPLE) . . . . . . . . . . . . . 21
2.4 Mid-Point Rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.4.1 Error in midpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3
CONTENTS
4 Interpolation 83
4.1 Review- Linear interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
4.2 Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
4.3 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
4.4 Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
4.5 Lagrange interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
4.5.1 Alternatively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
4.5.2 Examples of interpolating polynomials . . . . . . . . . . . . . . . . . . . 88
4.5.3 Error analysis in Lagrange’s interpolation . . . . . . . . . . . . . . . . . 92
4.5.4 Rounding errors in Lagrange polynomials . . . . . . . . . . . . . . . . . . 94
Introduction
Most real mathematical problems do not have analytical solutions. However, they do have
real solutions. In order to obtain these solutions we must use other methods such as graphical
representations, or numerical analysis. Numerical analysis is the mathematical method that
uses numerical approximations to obtain numerical answers to the problem. Numerical analysis
also considers the accuracy of an approximation, and when the approximation is good enough.
Numerical answers are useful because we use numbers to build our world, not with the exact
π
analytical solution, such as √e27
The ever-increasing advances in computer technology has enabled many in science and engi-
neering to apply numerical methods to simulate physical phenomena. Numerical methods are
often divided into elementary ones such as finding the root of an equation, integrating a func-
tion or solving a linear system of equations to intensive ones like the finite element method.
Intensive methods are often needed for the solution of practical problems and they often re-
quire the systematic application of a range of elementary methods, often thousands or millions
of times over. In the development of numerical methods, simplifications need to be made to
progress towards a solution: for example general functions may need to be approximated by
polynomials and computers cannot generally represent numbers exactly anyway. As a result,
numerical methods do not usually give the exact answer to a given problem, or they can only
tend towards a solution getting closer and closer with each iteration. Numerical methods are
generally only useful when they are implemented on computer using a computer program-
ming language .
The study of the behavior of numerical methods is called numerical analysis. This is a mathe-
matical subject that considers the modeling of the error in the processing of numerical methods
and the subsequent re-design of methods.
Numerical analysis involves the study of methods of computing numerical data. In many prob-
lems this implies producing a sequence of approximations; thus the questions involve the rate
of convergence, the accuracy (or even validity) of the answer, and the completeness of the re-
sponse. (With many problems it is difficult to decide from a program’s termination whether
other solutions exist.) Since many problems across mathematics can be reduced to linear alge-
bra, this too is studied numerically; here there are significant problems with the amount of time
necessary to process the initial data. Numerical solutions to differential equations require the
determination not of a few numbers but of an entire function; in particular, convergence must
be judged by some global criterion. Other topics include numerical simulation, optimization,
and graphical analysis, and the development of robust working code.
Numerical linear algebra topics: Solutions of linear systems AX = B, eigenvalues and eigenvec-
tors, matrix factorizations. Calculus topics: numerical differentiation and integration, interpo-
5
lation, solutions of nonlinear equations f (x) = 0. Statistical topics: polynomial approximation,
curve fitting.
Further information on the elementary methods can be found in books on numerical methods
or books on numerical analysis. Dedicated text books can be found on each of the intensive
methods. Details of available books can be accessed through [Link] .
(3) Fixed Point Iteration, Linear Interpolation and Newton-Raphson Method, what are the
differences to their uses?
Best Answer
1. um, everywhere? From a cash machine, to calculating how much chemicals to put to
produce laundry detergent, to construction of buildings and bridges.
2. The ever-increasing advances in computer technology has enabled many in science and
engineering to apply numerical methods to simulate physical phenomena. Numerical
methods are often divided into elementary ones such as finding the root of an equation,
integrating a function or solving a linear system of equations to intensive ones like the
finite element method. Intensive methods are often needed for the solution of practical
problems and they often require the systematic application of a range of elementary
methods, often thousands or millions of times over. In the development of numerical
methods, simplifications need to be made to progress towards a solution: for example
general functions may need to be approximated by polynomials and computers cannot
generally represent numbers exactly anyway. As a result, numerical methods do not
usually give the exact answer to a given problem, or they can only tend towards a solution
getting closer and closer with each iteration. Numerical methods are generally only useful
when they are implemented on computer using a computer programming language .
Other answers
2. Numerical Methods refers to procedures to find approximate solutions when exact solu-
tions cannot be found in a straightforward manner.
3. Linear interpolation assumes that if two points on a graph are given, any point in between
them can be found by connecting the original two points by a straight line.
Newton Raphson is a method to find approximate solutions to an equation through an
iterative process where each calculated value is used as the starting point for the next
calculated value. NRM requires that you can evaluate the first derivative of that equation.
- it is also known as a technique widely used by scientists and engineers to solve their
problems.
Other than the truncation errors involved in numerical methods, numerical algorithms are
computationally involved, calling for powerful computing abilities and machines. The schemes
are usually multi steps and multi terms.
However, numerical techniques are widely applied in solving real world problem.
Example 1.3.2 Solving a simple looking first order ordinary differential equation
dy
= x2 + y 2
dx
analytically is not easy at all.
Example 1.3.3 To compute the area under the curve defined by the table below
x 1 3 5 7
f (x) -3 5 21 45
will be analytically impossible since we do not know the explicit definition of f (x) that was
used to generate the table above. To compute
ˆ 7
f (x)dx
1
- Numerical methods bridge the precision gap by putting errors under firm control.
the truncation error in a result. It is possible for any purely numerical algorithm, including
the algorithms used by numerical functions in Mathematica, to produce incorrect results,
and to do so without warning. The only way to be certain that results from functions
like NIntegrate and NDSolve are correct is to do some independent analysis, possibly
including detailed investigation of the algorithm that was used to do the calculation.
Such investigations are an important part of the field of numerical analysis.
For example, after using Taylor expansion
x x2 x3
ex = 1 + + + + ···
1! 2! 3!
x2 x4 x6 x8
cos x = 1 + + + + + ···
2! 4! 6! 8!
x3 x5 x7 x9
sin x = x − + − + + ···
3! 5! 7! 9!
You could realize that there are many terms you have truncated off in the expansion,
thats why · · ·
Although the ability to reduce the effects of roundoff error by raising the precision of a
calculation is certainly very useful, it is far from a universal solution to all problems with
numerical error.
1.8625 to three decimal places, it becomes 1.863
1.8625 to two decimal places, it becomes 1.86
1.8625 to one decimal place, it become 1.9
Numerical Integration
There are two main reasons for you to need to do numerical integration: analytical integration
may be impossible or infeasible, or you may wish to integrate tabulated data rather than known
functions. In this section we outline the main approaches to numerical integration. Which is
preferable depends in part on the results required, and in part on the function or data to be
integrated.
That is
This will be useful when we cannot find an elementary antiderivative for f (x) or if the function
is defined using data obtained from some experiment.
Numerical integration is the numerical approximation of the integral of a function. For a
function of one variable, it amounts to finding the area under the graph of the function. That
is finding I where ˆ b
I= f (x) dx
a
Methods generally replace the integral by a weighted sum of n weights and n function evalua-
tions, so that
n
X
I= Wi f (xi ) dx
i=1
For a function of two variables it is equivalent to finding an approximation to the volume under
the surface. Numerical integration is often also referred to as quadrature or sometimes cubature
for functions of two or more variables. Returning to the one variable case, numerical integration
involves finding the approximation to an integral of a function f(x) through its evaluation at
a set of discrete points. There are two distinct approaches to this. Firstly methods like the
trapezium rule or Simpson’s rule determine the integral through evaluating f(x) at regularly
spaced points. These are generally referred to as Newton-Cotes formulae.
Alternative methods termed Gaussian Quadrature methods have arisen that select irregularly-
placed evaluation points, chosen to determine the integral as accurately as possible with a given
set of points.
Gaussian Quadrature methods are important as they often lead to very efficient methods. In
numerical integration the efficiency of the method relates to the accuracy obtained with respect
to the number of evaluations of the function f (x). In intensive methods such as the boundary
element method integrations may need to be performed millions of times so the efficiency of
the methods needs to be considered sometimes.
In general, care must be taken to match the numerical integration method to the expected
11
2.1. MANUAL METHOD
nature of the function f (x). For example it may be known that f (x) is regular. On the other
hand f (x) may be singular or oscillatory and will then need special treatment. Often a special
method called a product integration method can be developed for the integration of functions
of the form f (x) = w(x)g(x) where w(x) is a pre-set function and the function and g(x) is
known to be a relatively nice function.
There are books devoted to numerical integration. Numerical integration is a basic numerical
method and the subject is generally covered in books on numerical methods or numerical
analysis (see below). Numerical methods for carrying out numerical integration can often be
easily programmed and can also be found in general numerical libraries.
h3 00
Etrunc = − [f (c1 ) + f 00 (c2 ) + . . . + f 00 (cn )]
12
M h3
|Etrunc | ≤
12n2
such that the second derivative f 00 is continuous on [a, b] and that |f 00 (x)| < M for all x in [a, b].
Solution
Since
ˆ 1
h
I= f (x)dx ' {f0 + 2f1 + 2f2 + 2f3 + 2f4 + f5 }
0 2
Partitioning the interval [0, 1], we get,
f0 = f (x0 ) = f (0) = 02 = 0
f1 = f (x1 ) = f (0.2) = (0.2)2 = 0.04
f2 = f (x2 ) = f (0.4) = (0.4)2 = 0.16
f3 = f (x3 ) = f (0.6) = (0.6)2 = 0.36
f4 = f (x4 ) = f (0.8) = (0.8)2 = 0.64
f5 = f (x5 ) = f (1) = 12 = 1
Therefore
0.2
I' {0 + 2[0.04 + 0.16 + 0.36 + 0.64] + 1}
2
= 0.1{0 + 2[1.2] + 1} = 0.340.
Absolute error committed is
0.340 − 0.333 ' 0.00667
We have noted that the error obtained is much smaller than that obtained with the pure
trapezoidal rule in the previous example. In fact the smaller the error, i.e the better the ap-
proximation.
Example 2.2.2 Compute the numerical value of the definite the integral
ˆ 2
x2
I= e− 2 dx
−2
by the composite trapezoidal rule with h = 1.0. The exact value of the integral I to 4 decimal
places is 2.3925.
Solution
Since h = 1.0, then ,
−(1)2
1.0 − (−2)2 (−1)2
− 2
(0)2
− 2 + 12 e− 2
−(2)2
− 2
I = e 2 + 2e + 2e +e
2
= 0.5(0.13534 + 2 × 0.60653 + 2 × 1.00000 + 2 × 0.60653 + 0.73534)
= 2.3484
h
' {f (1.0) + 2f (1.2) + 2f (1.4) + 2f (1.6) + 2f (1.8) + f (2.0)}
2
0.2
' {0.5 + 2(0.45) + 2(0.42) + 2(0.38) + 2(0.36) + 0.33}
2
' 0.4057
h
' {f (0) + 2f (0.75) + 2f (1.5) + 2f (2.25) + f (3.0)}
2
0.75
' {3 + 2(4.5) + 2(6) + 2(7.5) + 9}
2
' 18
by the Trapezium rule with 100 points, it gives the answer as 1.5302437923
But can you think of a way of programme this easily??
with h = 0.25
(iii) Compute the analytical, classical, or exact solution to the definite integral above
Exercise 2.1
´1
1. Compute the approximate value of 0 (x2 + 1)−1 dx by using the trapezoidal rule with
ten subintervals. Then compare with the actual value of the integral. Determine the
truncation error bound and compare with the actual error.
´5
2. If the trapezoidal rule is used to compute 2 sin xdx with h = 0.01, obtain an upper
bound error.
´2
3. How large must n be if the trapezoidal rule is to estimate 0 exp{−x2 }dx with an error
not exceeding 10−6 ?
´1 2
4. Consider the integral 0 sin(π x2 )dx. Suppose that we wish to integrate numerically with
error < 10−5 . What interval width h is needed if the trapezoidal rule is to be used?
´3
5. Approximate 1 x1 dx by the trapezoidal rule with an error of utmost 0.1.
So ˆ ˆ ˆ
x2 x2 x2
f (x)dx = P2 (x)dx + Etrunc (x)dx (2.1)
x0 x0 x0
Results
Summing up all the three cases, equation (2.1) becomes
ˆ x2
h
P2 (x)dx = [f0 + 4f1 + f2 ] + Etrunc (x) Thus
x0 3
ˆ x2
h
P2 (x)dx = [f0 + 4f1 + f2 ] (2.2)
x0 3
Relation equation (2.2) is the Simpson’s rule for approximating the integral. The integral for
the error in equation (2.1), becomes
ˆ x2 ˆ x2
(x − x0 )(x − x1 )(x − x2 ) (4)
Etrunc (x)dx = f (c(x))dx
x0 x0 3!
M h5
(2.3)
180n4
That the fourth derivative f 4 is continuous on [a, b] and that |f 4 (x)| < M for all x in [a, b].
´Example
1 2
2.3.1 Use Simpson’s method (or with n = 1) to approximate the integral I =
0
x dx
Solution ˆ 1
h
Since I = f (x )dx ' [f (x0 ) + 4f (x1 ) + f (x2 )]
0 3
1 (1 − 0 ) 1 (b − a)
But x0 = 0 , x1 = , x2 = 1 , h = = = and n = 1.
2 (2 )(1 ) 2 2n
Therefore
1 1 1 1 1
I ' [f (0) + 4f ( ) + f (1)] = [02 + 4.( )2 + 12 ] = = 0.33
6 2 6 2 3
But the exact value of the integral is 13 = 0.33. It should not surprise you that the Simpson”
rule has generated the exact value of the integral. In fact the general result is that for f (x) a
polynomial of degree two or less, the Simpson” rule will always generate the exact value of the
integral. This will later be stated as a theorem.
becomes,
ˆ b ˆ x2 ˆ x4 ˆ 2n
I= f (x)dx = f (x)dx + f (x)dx + . . . + f (x)dx
a a x2 x2n−2
h
= {[f0 + 4f1 + f2 ] + [f2 + 4f3 + f4 ]+
3
[f4 + 4f5 + f6 ] + . . . + [f2n−2 + 4f2n−1 + f2n ]}
h
= [f0 + 4(f1 + f3 + . . . + f2n−1 ) + 2(f2 + f4 + . . . + f2n−2 ) + fn ] + Etrunc
3
Where the truncation error,
h5 (4)
Etrunc = − [f (c1 ) + f (4) (c2 ) + . . . + f (4) (cn )]
90
h5 (4)
=− f (c2 ) × n
90
(b − a)h4 (4)
=− f (cf )
180
where a ≤ cf ≤ b.
Using step size h = 1.0. Recall the exact value of I to 4 decimal places is 2.3925.
Solution
Using the Simpson’s rule, we have,
1.0 − (−2)2 −
(−1)2
−
(0)2
−
(1)2
−
(−2)2
I' e 2 + 4e 2 + 2e 2 + 4e 2 + e 2 = 2.3743
3
The error committed is 0.0182.
Note 2.3.1 We note that is error is much smaller than that obtained when using Trapezoidal
rule in the previous lecture though same step size is used.
Note 2.3.2 Simpson’s rule only work for even number of subintervals.
Note 2.3.3 For f (x) a trignometric function, we use (Your calculator should be in) Radians.
Example 2.3.3 Determine the fairly accurate solution to the definite integral
ˆ 2
1
dx
1 x
(i) Compute its exact value and hence the absolute error committed by the Simpson’s tech-
nique with n = 4.
ˆ 3
dx
dx = [ln(x + 1)]32 = 0.287682
2 x + 1
⇒ error = 0.287682 − 0.2876831
≈ 0.00036
(iv) Compute the inexact value of the problem using the Trapezoidal rule.
(v) Which of the two numerical techniques (the Trapezoidal or the Simpson) is more accurate
and superior?
Solution
Since the error term is
(b − a) 4 (4)
− h f (cf )
180
But
2
f (x) = ex
therefore
2
f 0 (x) = 2xex
2 2 2 2
f 00 (x) = 2(ex + 2xex ) = 2ex (1 + 2x2 ) = ex (2 + 4x2 )
2 2
therefore, f 000 (x) = 2xex (2 + 4x2 ) + 8xex
2 2
= ex (4x + 8x3 + 8x) = ex (12x + 8x3 )
2
and f (iv) (x) = 8ex (2x4 + 5x2 + 1) < 424e4
2h4
So h! · 424e4 < (0.5)10−4 = 0.057
180
Say choose h = 0.05.
(i) h = 0.1,
(ii) h = 0.5.
Compare with the actual value of the integral in each case. Next, determine the truncation
error bound and compare with the actual error.
Exercise 2.4 Establish the composite Simpson’s rule over (n − 1) even subintervals
ˆ b 2
(n−1)
2
(n−3)
h X X
f (x)dx = [(f (a) + f (b)) + 4 f (a + (2i − 1)h) + 2 f (a + 2ih)] + Etrunc
a 3 i=1 i=1
(b−a)
where, h = (n−1)
and
(b − a) 4 (4)
Etrunc = − h f (c)
180
for some c ∈ [a, b]
Suppose that we wish to integrate numerically with error < 10−5 . What interval width h is
needed if the Simpson’s rule is to be used?
Example 2.3.6 Using Maple; use Simpson’s Rule with n = 100 to approximate the integral
ˆ 1
1
2
dx
0 1+x
> with(student);
1
> simpson( 1+x 2 , x = 0..1, 100);
50
! 49
!
1 1 X 1 1 X 1
+ +
200 75 1 1 2 150 1+ 1 2
i
i=1 1+ 50
i − 100 i=1 2500
> evalf(”);
.7853981634
> evalf(Pi/4);
.7853981635
When trying for the trapezium rule, instead of ”simpson”, you replace it with ”trapezoid”
in step II
INTEGER*4 nx
REAL*8 x0,x1
C=====functions
REAL*8 f
C=====local variables
INTEGER*4 i
REAL*8 dx,xa,xb,fa,fb,Sum
dx = (x1 - x0)/DFLOAT(nx)
Sum = 0.0
DO i=0,nx-1
xa = x0 + DFLOAT(i)*dx
xb = x0 + DFLOAT(i+1)*dx
fa = f(xa)
fb = f(xb)
Sum = Sum + fa + fb
ENDDO
Sum = Sum * dx / 2.0
TrapeziumRule = Sum
RETURN
END
Example 2.3.7
(b) Derive Trapezium’s rule for the integration of a function f (x) between a and b,
h
IT = [f0 + 2f1 + 2f2 + . . . + 2fn−1 + fn ] + Etrunc
2
State its truncation error.
(b−a)
We divide [a, b] into n equal intervals of width h = n
Let
ˆ b ˆ x1
I= f (x)dx = f (x)dx+
a a
ˆ x2 ˆ xi+1 ˆ xn
f (x)dx + . . . + f (x)dx + . . . + f (x)dx.
x1 xi xn−1
h3 00
Etrunc = − [f (c1 ) + f 00 (c2 ) + . . . + f 00 (cn )]
12
M h3
|Etrunc | ≤
12n2
such that the second derivative f is continuous on [a, b] and that |f 00 (x)| < M for all x
00
in [a, b].
(c) Numerically approximate ˆ 2 √
2 + cos(2 x ) dx
0
by using the Trapezium rule with
1
(i) n = 4 ⇒ h = 2
h
I ≈ [f0 + 2f1 + 2f2 + . . . + 2fn−1 + fn ]
2
1 h √ √ h √ √ √ ii
2 + cos(2 0) + 2 + cos(2 2) + 2 2 + cos(2 0.5) + 2 + cos(2 1) + 2 + cos(2 1.5)
4
1h √ h √ √ ii
≈ 3 + 2 + cos(2 2) + 2 (2 + cos 2) + (2 + cos 2) + (2 + cos 6)
4
1h √ h √ √ ii
≈ 5 + cos(2 2) + 2 (2 + cos 2) + (2 + cos 2) + (2 + cos 6)
4
1
= [13.98841913]
4
≈ 3.4971
1
(ii) n = 8 ⇒ h = 4
h
I = [f0 + 2f1 + 2f2 + . . . + 2fn−1 + fn ]
2 √ √ √ √
= 2 + cos(2 0) + 2 + cos(2 2) + 2 2 + cos(2 0.25) + 2 2 + 2 cos(2 0.5)
√ √ √ √
+ 2 2 + cos(2 0.75) + 2 2 + cos(2 1) + 2 2 + cos(2 1.25) + 2 2 + cos(2 1.5) +
≈ 3.46928
(d) Considering your results in part (c) above, state any two reasons on how to reduce the
errors in numerical integration.
(e) (i) Solve the integral in part (c) above using the Simpson’s rule with n = 4.
h
I = [f0 + 4(f1 + f3 + . . . + f2n−1 ) + 2(f2 + f4 + . . . + f2n−2 ) + fn ] + Etrunc
3
1 h √ √ h √ √ i
≈ 2 + cos(2 0) + 2 + cos(2 2) + 2 2 + cos(2 0.5) + 2 + cos(2 1.5)
6
√ i
+ 4 2 + cos(2 1)
1h √ h √ √ i i
≈ 3 + 2 + cos(2 2) + 2 (2 + cos 2) + (2 + cos 6) + 4(2 + cos 2)
6
1h √ h √ √ ii
≈ 5 + cos(2 2) + 2 (2 + cos 2) + (2 + cos 6) + 4(2 + cos 2)
6
≈ 3.46008250981
(ii) Show that using the Simpson’s rule with n = 8, the integral in part (c) above is
I ≈ 3.460002979.
h
I = [f0 + 4(f1 + f3 + . . . + f2n−1 ) + 2(f2 + f4 + . . . + f2n−2 ) + fn ] + Etrunc
3
1 h √ √ n √ √
≈ 2 + cos(2 0) + 2 + cos(2 2) + 2 2 + cos(2 0.5) + 2 + cos(2 1)
12
√ o n √ √
+ 2 + cos(2 1.5) + 4 2 + cos(2 0.25) + 2 + cos(2 0.75)
√ √ oi
+ 2 + cos(2 1.25) + 2 + cos(2 1.75)
≈ 3.460002979
3.14159
´2 1
Exercise 2.9 Show that the error (absolute error ) in the trapezium rule to compute 1 x
dx is
2
' 0.0017
600
´2 1
Example 2.4.1 Find the integral using the midpoint rule. 1 x
dx with n = 10
2−1 1
∆x = 10
= 10
Sometimes called step width.
1 1
f (x) = x
⇒ f (mi ) = mi
ˆ 2 n
1 X 1 1 1 1 1 1 1
⇒ dx = ∆x f (mi ) = + + + + + ........... + = 0.69264
1 x i=1
10 1.15 1.25 1.35 1.45 1.55 1.95
Motivation
Given a second degree polynomial, we can accurately compute it’s root, that is
√
2 −b ± b2 − 4ac
ax + bx + c = 0 ⇒ x =
2a
But what if ax5 + bx4 + cx3 + dx2 + ex + f = 0 ⇒ x =?, sin x + x = 0 ⇒ x =?
Problem Description
• Given a non-linear equation f (x) = 0, find a x? such that f (x? ) = 0. Thus, x? is a root
of f (x) = 0.
• Galois theory in math tells us that only polynomials of degree ≤ 4 can be solved with
close forms using +, −, ×, ÷ and taking roots.
• Unfortunately, this process can go wrong, leading to another root or even diverge.
Methods to be discussed
• There are two types of methods, bracketing and open. The bracketing methods require
an interval that is known to contain a root, while the open method does not.
• Commonly seen bracketing methods include the bisection method and the regula falsi
method, and the open methods are Newtons method, the secant method, and the successive
substitution.
27
3.1. NEWTON RAPHSON’S METHOD
The equation of the line with slope p and passing through the point (x0 , f0 ) is
y − f0
=p (3.1)
x − x0
However, we know that p is the slope of the tangent to y = f (x) at (x0 , f0 ). This is given by;
y − f0
= f00
x − x0
y − f0 = (x − x0 )f00 (3.3)
From figure 3.1, line of equation 13.3 cuts the x-axis at the point (x1 , 0) i.e when x = x1 and
y = 0.
Substituting in equation (3.3) we get,
0 − f0 = (x1 − x0 )f00
equation (3.4) is actually the Newton’s method for obtaining the next iterate x1 from the
previous iterate x0 . The equation (3.4) is generalized and written;
f (xn )
xn+1 = xn − (3.5)
f 0 (xn )
since the linear approximation of the curve is done at each of the iterates xn , xn+1 , xn+1 , . . . as
reflected in figure above.
x2 − 3 = 0 on [1, 2]
f (xn ) = x2n − 3
therefore f 0 (xn ) = 2xn
f (xn )
But Raphson’s formula is xn+1 = xn − 0
f (xn )
(x2n − 3)
xn+1 = xn −
2xn
2xn − x2n + 3
2
=
2x
2 n
xn + 3
=
2xn
Taking the initial guess/approximation as x0 = 2, but you could also consider x0 = 1 you come
up with the same answer.
x20 + 3 22 + 3
⇒ x1 = = = 1.7500000
2x0 2(2)
2
x +3 (1.75)2 + 3
x2 = 1 = = 1.7321000
2x1 2(1.75)
2
x +3 (1.7321)2 + 3
x3 = 2 = = 1.7320508
2x2 2(1.7321)
x2 + 3 (1.7320508)2 + 3
x4 = 3 = = 1.7320508
2x3 2(1.7320508)
Example 3.1.2 Use Newton-Raphson Method to find the only real root of the equation
x3 − x − 1 = 0
correct to 9 decimal places.
Since f (1) = −1 and f (2) = 5, the function has a root in the interval [1, 2] since the function
changes sign between [1, 2]. Let us make an initial guess x0 = 1.5.
f (x) = x3 − x − 1 ⇒ f (xn ) = x3n − xn − 1
f 0 (x) = 3x2 − 1 ⇒ f 0 (xn ) = 3x2n − 1
f (xn )
xn+1 = xn −
f 0 (xn )
(x3 − xn − 1)
xn+1 = xn − n 2
(3xn − 1)
3
2xn + 1
xn+1 =
3x2n − 1
2x30 + 1 2(1.5)3 + 1
x1 = = = 1.347826087
3x20 − 1 3(1.5)2 − 1
2x31 + 1 2(1.347826087)3 + 1
x2 = = = 1.325200399
3x21 − 1 3(1.347826087)2 − 1
2x32 + 1 2(1.325200399)3 + 1
x3 = = = 1.324718174
3x22 − 1 3(1.325200399)2 − 1
2x33 + 1 2(1.324718174)3 + 1
x4 = = = 1.324717957
3x23 − 1 3(1.324718174)2 − 1
2x34 + 1 2(1.324717957)3 + 1
x5 = = = 1.324717957
3x24 − 1 3(1.324717957)2 − 1
The approximated root of
x3 − x − 1 = 0
to 9 decimal places is 1.324717957
Remark 3.1.1 The more the decimal places the better the approximation.
x3 − x − 1 = 0
Remark 3.1.2 The fewer the decimal places the faster the iteration scheme converges.
y = e−x − x
f (xn )
xn+1 = xn −
f 0 (xn )
(e−xn − xn ) −xn e−xn − xn − e−xn + xn (xn + 1) e−xn
xn+1 = xn − = =
(−e−xn − 1) (−e−xn − 1) 1 + e−xn
(x0 + 1) e−x0 ([0.5] + 1) e−0.5
x1 = = = 0.5663
1 + e−x0 1 + e−0.5
(x1 + 1) e−x1 ([0.5663] + 1) e−0.5663
x2 = = = 0.5671
1 + e−x1 1 + e−0.5663
(x2 + 1) e−x2 ([0.5671] + 1) e−0.5671
x3 = = = 0.5671
1 + e−x2 1 + e−0.5671
The approximated root of
e−x − x = 0
to 4 decimal places is 0.5671
f (x) = x2 − 4x + 5 = 0
f (x) = 3x + sin x − ex = 0
Solution
Since f (0) = −1 < 0 and f (1) = 3 + sin(1) − e > 0, so there is a real root in [0, 1]. Using
f (x) = ex − 2x = 0
Its an alternating solutions, the solutions oscillate near the local maxima or local minima.
In other words, Newton’s Method fails to produce a solution. Why is this? Because there is no
solution to be found!
Mathematicians are often very happy when, after a great deal of work, they are just able to
say that a solution to a problem exists. This is because once they know it exists, there might
be some nice method, such as Newton’s Method, to actually compute the solution.
f (x) = xe−x
with x0 = 2, it produces
n xn f (xn )
.. .. ..
. . .
◦ However, f (xn ) goes to zero rapidly as xn gets larger in a finite precision environment,
and could be mistaken as a zero of f .
f (x) = x3 − x − 3
f (xn ) x3n − xn − 3
xn+1 = xn − = x n −
f 0 (xn ) 3x2n − 1
2x3n + 3
xn+1 =
3x2n − 1
with x0 = 0, it produces
x1 = −3.00000
x2 = −1.96154
x3 = −1.14718
x4 = −0.00658
x5 = −3.00039
x6 = −1.96182
x7 = −1.14743
The sequence will not converge. But if the algorithm starts with x0 = 2, then it produces
x1 = 1.7272727
x2 = 1.6736912
x3 = 1.6717026
x4 = 1.6716999
x5 = 1.6716999
The sequence converges to the root 1.6716999 correct to seven decimal places.
This examples illustrates again that the starting point x0 must be close enough to the zero of
f.
x = 2 sin x (3.6)
Let f (x) = x − 2 sin x. Then f 0 (x) = 1 − 2 cos x, and the Newton-Raphson iteration is
Things dont look good, and they get worse. It turns out that x35 < −64000000. We could be
stubborn and soldier on. Miracles happen-but not often. (One happens here, around n = 212.)
The trouble was caused by the choice of x0 , let us consider x0 = 1.5. Here are the next six
estimates, to 19 decimal places - to indicate how fast the convergence is
x1 = 2.0765582006304348291 x4 = 1.8954942764727706570
x2 = 1.9105066156590806258 x5 = 1.8954942670339809987
x3 = 1.8956220029878460925 x6 = 1.8954942670339809471
The next iterate x7 agrees with x6 in the first 19 decimal places, indeed in the first 32, and the
true root is equal to x6 to 32 decimal places.
Comment 3.1.1 The remedy to this is to rewrite the Equation (3.6) into other forms say
2 1 sin x 1
− = 0 or =
x sin x x 2
works nicely - to have f 0 (x) harder to be too small or almost zero for ∀ x ∈ (0, π) - as we shall
see in the section of successive substitution, Section 3.5
Example 3.1.12 Consider the problem of finding the positive number x with cos x = x3 We
can rephrase that as finding the zero of
Since cos x ≤ 1 for all x and x3 > 1 for x > 1, we know that our zero lies in [0, 1]. We try a
starting value of x0 = 0.5.
Exercise 3.1 Let f (x) = x2 − a. Show that the Newton Method leads to the recurrence
1 a
xn+1 = xn +
2 xn
x2 + x − 1 = 0
in the interval [0, 1], giving your answer correct to 4 decimal places.
2x3 + 3x2 − 3x − 5 = 0
has a real root in the interval [1, 2]. Approximate this root correct to five decimal places using
Newton Raphson’s method.
Exercise 3.5 Use Newton’s method to approximate the root of the equation
g(x) = x3 − 2 sin x
on [0.5, 2].
f (xn )
xn+1 = xn −
f 0 (xn )
(xr − A)
xn+1 = xn − n r−1
rxn
rxn − xrn + A
r
=
rxr−1
n
(r − 1)xrn + A
=
rxr−1
n
1 A
xn+1 = (r − 1)xn + r−1 (3.7)
r xn
Equation (3.7) is a general formula from which we can obtain quadratically convergent iterative
processes for finding approximations to arbitrary roots of numbers.
Note 3.1.1 The root, or answer interested in is the x. And also what is f (x) is the function
f (x) = 0
Which is the Newton’s square root algorithm for extracting roots of positive numbers.
Example 3.1.15 Use Newton’s square root algorithm to find the square root of 5 correct to
six decimal places.
1
5 2 = x ⇒ x2 − 5 = 0 ⇒ f (x) = x2 − 5 = 0
Or substituting in the general formula r = 2 and A = 5 we get,
1 A
xn+1 = xn +
2 xn
The value of x2 = 2.236111 is correct only to one decimal place since it agrees with the previous
iterate x1 = 2.250000 only in one decimal place.
However, x3 = 2.236068 is correct to three decimal places since it is in agreement with the
previous iterate x2 in exactly three places of decimal.
But x4 = 2.236068 is exactly the same as x3 . In fact they are exactly the same up to nine
decimal places.
This means that x4 = 2.236068 is the value of the root correct to nine decimal places. Thus
x4 , must also be correct up to six decimal places.
Hence, the value of the root that you state as being correct to six decimal places or nine decimal
places is x4 = 2.236068. Compare with the value obtained from calculator.
A−1 = x ⇒ x−1 = A
1
⇒ =A
x
⇒ f (x) = Ax − 1 = 0 wrong choice, f 0 (x) = c
1 1
⇒ f (x) = − A = 0 ⇒ f 0 (x) = − 2
x x
1
f (xn ) −A
xn+1 = xn − 0 ⇒ xn+1 = xn − xn 1
f (xn ) − x2
n
⇒ xn+1 = xn (2 − Axn )
xn+1 = xn (2 − Axn )
This formula is quadratically convergent and can suitably be applied to calculate the reciprocal
of numbers.
Let x0 = 0.5.
Exercise 3.6 Use the Newton Raphson method to estimate the reciprocal of 18 correct to 8
decimal places.
• Because the convergence rate is high, no worry for initial guess, interval size, and number
of decimal places required.
? The Newton Raphson’s method may also fail if f (x) has a point of inflection in the neigh-
borhood of the root.
? Newtons method is an extremely powerful technique, but it has a major weakness: the
need to know the value of the derivative of f at each approximation.
? Frequently, f 0 (x) is far more difficult and needs more arithmetic operations to calculate
than f (x).
? If in the immediate neighborhood of a root of f (x), f 0 (x) vanishes or is very small, the
Newton Raphson’s method will not converge. The reason for this failure is; since f 0 (x) is
very small, the quantity, − ff0(x n)
(xn )
becomes very large. In case it is zero - the denominator,
then function is not defined. The consequence is that we are thrown away from the root
we are approximating.
Exercise 3.7 Use Newton’s square root algorithm to find the square root of 2 correct to 6
decimal places.
Exercise 3.8 Use cube root Newton’s algorithm to find the cube root of 7 correct to four
decimal places.
Exercise 3.10 State the advantages and disadvantages of the Newton’s method for nonlinear
equations.
Exercise 3.11
(a) Define the Newton-Raphson method formula for finding the root of a non-linear equation
f (x) = 0
f (xn )
xn+1 = xn −
f 0 (xn )
(b) The convergence of the Newton-Raphson method technique highly depends on the initial
guess. Discuss.
Yes, when the initial guess is in the interval given, the iterations converge faster than
otherwise.
(c) Use Newton Raphson method to estimate one of the solutions of x2 − 4 = 0 using x0 = 6
to 2 decimal places.
xn xn+1
x0 = 6 x1 = 3.33
x1 = 3.33 x2 = 2.27
x2 = 2.27 x3 = 2.01
x3 = 2.01 x4 = 2.00
x4 = 2.00 x5 = 2.00
(d) Newton’s Raphson’s method is one of the popular schemes for solving a non-linear equation
f (x) = 0. Prove that the Newton Raphson’s method for finding the square root of a positive
number A is given by,
1 A
xn+1 = xn +
2 xn
√
Use the scheme above to approximate the square root of 5( 5) to three decimal places
with x0 = 2.
xn xn+1
x0 = 2 x1 = 2.25
x1 = 2.25 x2 = 2.236
x2 = 2.236 x3 = 2.2.236
x3 = 2.236 x4 = 2.236
Exercise 3.12 With any simple example, write short notes on the ”NRM” for solving non-
linear equations.
3.2.2 Implementation
Given a function f(x) and an interval which might contain a root, perform a predetermined
number of iterations using the bisection method.
3.2.3 Limitations
Investigate the result of applying the bisection method over an interval where there is a discon-
tinuity. Apply the bisection method for a function using an interval where there are distinct
roots. Apply the bisection method over a ”large” interval.
Masenge (1989) called this method a trivial simplification of the regula falsi.
In mathematics, the bisection method is a root-finding algorithm which works by repeatedly
dividing an interval in half and then selecting the subinterval in which the root exists.
x0 = 1 ⇒ f0 = −2.000 < 0
x1 = 2 ⇒ f1 = 1.000 > 0
Since f11 = 0.000, then x11 = 1.732 it is the root or zero of the function x2 − 3 = 0, that is the
approximated square root of 3 correct to three decimal places.
3x + sin x − ex = 0
using the Bisection method on the interval [0, 0.5] correct to 4 decimal places.
Let
x0 = 0 ⇒ f0 = −1.0000 < 0
x1 = 0.5 ⇒ f1 = 0.3307 > 0
• The convergence of interval halving is very slow (slow at converging to the root x? ). For
example, a simple non linear equation
x3 − x − 2
• The method fails in case of approximating a double root or a root of even multiplicity.
cos x − xex = 0
f (x) = x3 − 5x2 − 2x + 10
using numerical Bisection method, if the graphical methods found the real root between x = 1
and x = 3:
Let
x0 = 1 ⇒ f0 = 4.0000 > 0
x1 = 3 ⇒ f1 = −14.0000 < 0
By interval halving,
xn + xn−1
xn+1 =
2
x1 + x0 3+1
x2 = = = 2.0000 ⇒ f2 = −6.0000 < 0
2 2
x2 + x0 2.0000 + 1.0000
x3 = = = 1.5000 ⇒ f3 = −0.8750 < 0
2 2
x3 + x0 1.5000 + 1.0000
x4 = = = 1.2500 ⇒ f4 = 1.6406 > 0
2 2
x4 + x3 1.2500 + 1.5000
x5 = = = 1.3750 ⇒ f5 = 0.3965 > 0
2 2
x5 + x3 1.3750 + 1.5000
x6 = = = 1.4375 ⇒ f6 = −0.2366 < 0
2 2
x6 + x5 1.4375 + 1.3750
x7 = = = 1.4063 ⇒ f7 = 0.0802 > 0
2 2
....
..
It is evident that the functional values f (xi ) are approaching zero as the number of iterations
is increased.
After more
√ six iteration the approximated root of 1.40625 compares favorably with the exact
value of 2
Example 3.2.5 The following polynomial has a root within the interval 3.75 ≤ x ≤ 5.00
f (x) = x3 − x2 − 10x − 8 = 0
Iteration
i xs xm xe f (xs ) f (xm ) f (xe ) f (xs )f (xm ) f (xm )f (xe ) error d
on the interval [3, 4], this time with step = 0.001, abs = 0.001.
Iteration
i xs xe f (xs ) f (xe ) xm f (xm ) abs
Remark 3.2.2 Thus, after the 11th iteration, we note that the final interval, [3.2958, 3.2968]
has a width less than 0.001 and |f (3.2968)| = 0.000025 < 0.001 and therefore we chose xe =
3.2968 to be our approximation of the root.
Although it is xm = 3.2963 in the last interval, but it is not the better approximation, since
scheme has not yet converged and yet |f (3.2963)| = 0.000035 a much more deviation from the
exact value 0.00000 compared to f (3.2968)
Remark 3.2.3 The Bisection scheme has not yet converged, but iteration terminated because
of the required error achieved.
Iteration
i xs xm xe f (xs ) f (xe ) f (xm )
Exercise 3.13 Will the Bisection Method applied to f (x) = tan x and initial interval [a, b] =
[1, 2] converge to a root? Why or why not? To which value, if any, will the Bisection Method
converge?
Exercise 3.14 If g(x) = cos x − 2x, and [a1 , b1 ] = [0, 1], use the Bisection Method to compute
x3 . Show your work.
Exercise 3.15 Consider the equations
(a) x5 + x = 1
(b) sin x = 6x + 5
(c) ln x + x2 = 3
Apply two steps of the Bisection Method to find an approximate root within 1/8 of the true
root.
Exercise 3.16 Approximate to 2 decimal places the roots of the following equations using
the bisection method.
(a) x2 = 3
(b) x3 = 2
(c) x4 = 2
Exercise 3.17 The function h(x) = x sin x occurs in the study of damped forced oscillation.
Find the value of x that lies in the interval [0, 2] where the function takes on the value h(x) = 1.
Use interval bisection.
Exercise 3.18 If a = 0.1 and b = 1.0, how many steps of the bisection method are needed to
determine a root in this interval with an error of at most 21 × 10−8 ?
Exercise 3.19 Consider obtaining the root of:
ex + 1 + sin x
f (x) = .
(x − 2)
Show that f (1.9) < 0, f (2.1) > 0 and use the bisection method to obtain the root.
x3 − x2 − x + 1 = 0
Exercise 3.21 The bisection method generates intervals [a0 , b0 ], [a1 , b1 ], and so on, which of
these inequalities are true for the root r that is being calculated?
(a) |r − an | ≤ 2|r − bn |
Example 3.2.8 Find all the real solutions to the cubic equation
x3 + 4x2 − 10 = 0
Example 3.2.9 Use Newton’s method to find the roots of the cubic polynomial x3 −3x+2 = 0
in the interval
(a) [0, 2]
f (x1 )(x1 − x0 )
giving, x2 = x1 −
f (x1 ) − f (x0 )
or in general we have that, xn+1 = g(xn , xn−1 )
That is
f (xn ) [xn − xn−1 ]
xn+1 = xn −
f (xn ) − f (xn−1 )
xn [f (xn ) − f (xn−1 )] − f (xn ) [xn − xn−1 ]
xn+1 =
f (xn ) − f (xn−1 )
xn f (xn ) − xn f (xn−1 ) − xn f (xn ) + xn−1 f (xn )
xn+1 =
f (xn ) − f (xn−1 )
xn−1 f (xn ) − xn f (xn−1 )
xn+1 =
f (xn ) − f (xn−1 )
Example 3.3.1 Use the Secant method to find the root near 2 of the equation
x3 − 2x − 5 = 0
Start the iteration with x0 = 1.9, ⇒ f (x0 ) = −1.941 and x1 = 2.0 ⇒ f (x1 ) = −1.000.
xn−1 f (xn ) − xn f (xn−1 )
xn+1 =
f (xn ) − f (xn−1 )
x0 f (x1 ) − x1 f (x0 ) (1.9)(−1.000) − (2.0)(−1.941)
x2 = = = 2.10627, f2 = 0.13166
f (x1 ) − f (x0 ) −1.000 −− 1.941
x1 f (x2 ) − x2 f (x1 ) (2.0)(0.13166) − (2.10627)(−1.000)
x3 = = = 2.09391, f3 = −0.00716
f (x2 ) − f (x1 ) 0.13166 −− 1.000
x2 f (x3 ) − x3 f (x2 ) (2.10627)(−0.00716) − (2.09391)(0.13166)
x4 = = = 2.09455, f4 = −0.00002
f (x3 ) − f (x2 ) −0.00716 − 0.13166
x3 f (x4 ) − x4 f (x3 ) (2.09391)(−0.00002) − (2.09455)(−0.00716)
x5 = = = 2.09455
f (x4 ) − f (x3 ) −0.00002 −− 0.00716
Thus since x4 and x5 are identical to 5 decimal places, so x5 = 2.09455 is the value of the root
correct to five decimal places.
Example 3.3.2 Estimate the root of
x4 − x − 10 = 0
with the initial guess as 1.0 and 2.0 using the numerical Secant scheme. Take solutions to 5
decimal places.
Let
x0 = 1.0 ⇒ f0 = −10.0
x1 = 2.0 ⇒ f1 = 4.0
For the Secant rule
xn−1 f (xn ) − xn f (xn−1 )
xn+1 =
f (xn ) − f (xn−1 )
x0 f (x1 ) − x1 f (x0 ) (1.0)(4.0) − (2.0)(−10.0)
x2 = = = 1.71429
f (x1 ) − f (x0 ) 4.0 −− 10.0
⇒ f2 = −3.07780
x1 f (x2 ) − x2 f (x1 ) (2.0)(−3.07780) − (1.71429)(4.0)
x3 = = = 1.83853
f (x2 ) − f (x1 ) −3.07780 − 4.0
⇒ f3 = −0.41283
x2 f (x3 ) − x3 f (x2 ) (1.71429)(−0.41283) − (1.83853)(−3.07780)
x4 = = = 1.85778
f (x3 ) − f (x2 ) −0.41283 −− 3.07780
⇒ f4 = 0.05401
x3 f (x4 ) − x4 f (x3 ) (1.83853)(0.05401) − (1.85778)(−0.41283)
x5 = = = 1.85555
f (x4 ) − f (x3 ) 0.05401 −− 0.41283
⇒ f5 = −0.00085
x4 f (x5 ) − x5 f (x4 ) (1.85778)(−0.00085) − (1.85555)(0.05401)
x6 = = = 1.85558
f (x5 ) − f (x4 ) −0.00085 − 0.05401
⇒ f6 = −0.00011
x5 f (x6 ) − x6 f (x5 ) (1.85555)(−0.00011) − (1.85558)(−0.00085)
x7 = = = 1.85558
f (x6 ) − f (x5 ) −0.00011 −− 0.00085
So the iterative process converges at 1.85558
Note 3.3.1 If the function f (x) has a trigonometric term, the calculators better be in radians.
1
x − sin x − =0
2
Let the initial guess be 1.0 and 2.0 using the Secant algorithm.
Let x0 = 1.0 ⇒ f0 = −0.34147 and x1 = 2.0 ⇒ f1 = 0.59070
Example 3.3.4 Let the initial guess be −2.0 and −1.0, find the root of
(x2 + 5x + 2)e−x + 1 = 0
Example 3.3.5 Apply the Secant method to show that for the non linear equation
cos x − xex = 0
Example 3.3.6 With initial conditions as x0 = 1.0 and x1 = 2.0, iterate with Secant method
to show that for
x − e−x = 0
e−x = 3 log10 x
by the Secant method to 5 decimal places with the initial guess as 1.0 and 2.0
x0 x1 x2 x3 x4 x5 x6 x7
Example 3.3.8 Use the Secant method to find a solution to x = cos x , and compare the
approximations with those given by Newtons method with x0 = π/4.
For the Secant method we need two initial approximations. Suppose we use x0 = 0.5 and
x1 = π/4.
Observations:
• Comparing results, we see that the Secant Method approximation x4 is accurate to the
tenth decimal place, whereas Newtons method obtained this accuracy by x2 .
• Here, the convergence of the Secant method is much faster than functional iteration but
slightly slower than Newtons method.
The above are advantages or disadvantages depending on the comparison technique in question.
Remark 3.3.1 The Secant method and Newtons method are often used to refine an answer
obtained by another technique (such as the Bisection Method).
f (x) = x3 + x2 − 3x − 3 = 0
f (x) = 3x − sin x − ex = 0
in the interval (0, 1). Estimate this root to 2 decimal places using the Secant method.
Exercise 3.24 Find the roots of the following equations, using the methods of Secant.
(a) ex = cos x
(b) x3 − 2x + 1 = 0
(c) sin 2x − ex − 1 = 0
(d) ln(x − 1) = x2
Exercise 3.25 Use the Secant method to find the real root of the equation
x3 + 2x2 − x + 5 = 0.
Show that f (1.9) < 0, f (2.1) > 0 and use the Secant method to obtain the root.
at each stage of the algorithm. This is termed as root bracketing, like in the Bisection method.
Thus to start the method, you need two points x0 = a0 and x1 = b0 near the root such that
That is f (a0 ) and f (b0 ) are of opposite signs, which implies by the intermediate value theorem
that the function f has a root in the interval [a0 , b0 ], assuming continuity of the function f .
The method proceeds by producing a sequence of shrinking intervals [ak , bk ] that all contain a
root of f .
Figure 3.2: The first two iterations of the false position method
From Figure (3.2) above, we note that the produce f (x0 )(f (x1 ) < 0, which is in conformity
with the regula falsi. The equation of the Chord CD is,
[f (x0 ) − f (x1 )](x − x1 )
y = f (x1 ) =
x0 − x1
This Chord cuts the x-axis at x2 i.e.
f (x0 ) − f (x1 )
−f (x1 ) = (x2 − x1 )
(x0 − x1 )
f (x1 )(x1 − x0 )
giving, x2 = x1 −
f (x1 ) − f (x0 )
Example 3.4.1 Find the root between (2, 3) of x3 − 2x − 5 = 0, by using regula falsi method.
Approximate values to 3 decimal places.
Let us take x0 = 2 and x1 = 3.
f (x) = x3 − 2x − 5
f (x0 ) = f (2) = 23 − 2(2) − 5 = −1 < 0 (negative)
f (x1 ) = f (3) = 33 − 2(3) − 5 = 16 > 0 (positive)
3x + sin x − ex = 0
using the regula falsi scheme of solving non linear equations f (x) = 0 to 3 decimal places on
the interval [0, 0.5].
If we sketch the function f (x) it’s clear that there is a root between 0 and 0.5 and also another
root between 1.5 and 2.0. Now let us consider the function f (x) in the interval [0, 0.5] where
f (0) × f (0.5) is less than zero and use the regula-falsi scheme to obtain the zero of f (x) = 0.
Let x0 = 0.0 ⇒ f0 = −1.000 < 0 and x1 = −0.5 ⇒ f1 = 0.331 > 0
with the initial guess of x0 = 1 and x1 = 1.5 to 3 decimal places using the popular regula falsi
technique.
Let
Example 3.4.4 Use the Regula-Falsi method to compute a real root of the equation
x3 − 9x + 1 = 0,
Let x0 = 2.0 ⇒ f0 = −9 < 0 and x1 = 3.0 ⇒ f1 = 1 > 0, For the regula falsi
x0 f (x1 ) − x1 f (x0 )
x2 = = 2.90000, ⇒ f2 = −0.7110 < 0
f (x1 ) − f (x0 )
x1 f (x2 ) − x2 f (x1 )
x3 = = 2.94156, ⇒ f3 = −0.0207 < 0
f (x2 ) − f (x1 )
x1 f (x3 ) − x3 f (x1 )
x4 = = 2.94275, ⇒ f4 = −0.0011896 < 0
f (x3 ) − f (x1 )
..
.
We observe that the value of the root as a third approximation is evidently different in both
the cases, while the value of x4 , when the interval considered is (2, 3), is closer to the root.
Important observation: The initial interval (x0 , x1 ) in which the root of the equation lies should
be sufficiently small.
Example 3.4.5 Use Regula-Falsi method to find a real root of the equation
ln x − cos x = 0
Note 3.4.1 The iterations have not converged, but we were interested in up to the third
iteration.
Note 3.4.2 For Matlab program for the non linear equation, we write ln x as log x, where as
log x as log10 x
So the root of
ex + 2−x + 2 cos x − 6 = 0
is approximately 1.8294 to 4 decimal places. Analytically, the exact value would be 1.82938.
Remark 3.4.1 Look back at how x8 was computed, how and why it was x6 and x7 paired
together, and not x7 with x1 .
Remark 3.4.2 The scheme converges after the fourth iteration and converges to 2.3707.
In fact, one of the classical root of the non linear equation
2x cos 2x − (x − 2)2 = 0
is
2.37069
Remark 3.4.3 In every next iteration, the previous point must be part of it.
f (x) = x3 − 2x − 2 = 0
Now since, f (1) = −3 < 0 and f (2) = 2 > 0 and f (x) is continuous for all real x, there exists
x? ∈ (1, 2) such that f (x? ) = 0 (the intermediate value theorem).
Let x0 = 1.0 ⇒ f0 = −3.00000 < 0 and x1 = 2.0 ⇒ f1 = 2.00000 > 0,
Example 3.4.9 Use the method of False Position to find a solution to x = cos x, and compare
the approximations with those given by the Newtons method and the Secant Method. Let the
initial approximations be x0 = 0.5 and x1 = π4
Note 3.4.3 Note that the False Position and Secant approximations agree through x3 and
that the method of False Position requires an additional iteration to obtain the same accuracy
as the Secant method.
Remark 3.4.4
• The added insurance of the method of False Position commonly requires more calculation
than the Secant method, . . .
• just as the simplification that the Secant method provides over Newtons method usually
comes at the expense of additional iterations.
Example 3.4.10 The function
f (x) = x2 ex − 1
has a root in the interval [0, 1] since f (0)f (1) < 0. The results from the false position and
secant methods, both started with x0 = 0 and x1 = 1, are shown in the table
Iterates False position Secant
x2 0.3679 0.3679
x3 0.5695 0.5695
x4 0.6551 0.7974
x5 0.6868 0.6855
x6 0.6978 0.7012
x7 0.7016 0.7035
It appears from these results that the secant method gives the correct result x = 0.7035 a little
more quickly.
x log10 x = 1.2
Exercise 3.30 Use the regula false algorithm to find the root of
f (x) = x2 − 4x + 2 = 0
that lies in the interval (0, 1) and state your answer correct to three decimal places.
Exercise 3.33 Approximate to three decimal places the roots of the following equations using
the regula false algorithm.
(a) x3 = 2 (c) x4 = 2
(b) x2 = 3 (d) x5 = 3
Exercise 3.34
(a) Derive the regula falsi algorithm by clearly giving its geometrical illustration.
(b) What advantages and disadvantages does the Secant method enjoy over other methods so
far considered for solving nonlinear equations.
Exercise 3.35 Use both the Falsi Position and Bisection to solve the same equation
and see if there is a difference in the number of steps falsi Position takes to converge versus
Bisection.
Exercise 3.36
Find the solution of x3 + x − 4 = 0 in the interval [1, 4] with accuracy 10−3 . Apply
Exercise 3.37 Approximate the solution of x3 − x − 1 = 0 in the interval [1, 2] with accuracy
10−4 with the Bisection method.
has two real zeros, one in [−1, 0] and the other in [0, 1]. Attempt to approximate these zeros
to within 10−6 using the Regular Falsi method.
Summary 3.1 Increased number of decimal points and/or increased size of interval given
both increase the number of iterations as they increase.
However, increased number of decimal points and/or increased size of interval given both im-
prove on the accuracy of the scheme.
xn+1 = g(xn ), n = 0, 1, 2, . . . ,
if the next iterate depends on the previous two i.e. xn and xn−1 .
x1 = g(x0 )
x2 = g(x1 )
x3 = g(x2 )
x4 = g(x3 )
..
.
xn+1 = g(xn )
..
.
..
.
x2 − 2x − 3 = 0
According to the behavior of the iterates, there is no hope for convergence in the interval
[2, 4]. Hence such a rearrangement-choice of g(x)- is not good.
(b) Splitting f (x) = 0 in the form,
x2 − 3
x = g2 (x) =
2
giving the iterative scheme,
x2n − 3
xn+1 =
2
x20 − 3
x1 = = 6.500000
2
x21 − 3
x2 = = 19.625000
2
x2 − 3
x3 = 2 = 191.070312
2
..
.
This shows that the iterates are obviously diverging. Hence such a rearrangement of g2 (x)
is not good too.
(c) Splitting f (x) = 0 in the form,
p
x = g3 (x) = (2x + 3)
In fact this is an arrangement which is giving a sequence of iterates which are converging
to the root α. The sequence is converging to the root x = 3.000000.
Note 3.5.1
One would actually wonder as to whether you have to keep trying the splitting until you get
one which converges to the root. We can test and know the splitting which gives a convergence
sequence of approximations before starting to compute the iterates. This wonderful criterion
is called the convergence criterion for the iterative scheme of the form
xn+1 = g(xn ).
However, before stating the criterion, lets first formerly state what is meant by an iterative
scheme
xn+1 = g(xn )
being convergent.
Definition 3.5.1
An iterative scheme/process. xn+1 = g(xn ) is convergent if,
lim |xn+1 − xn | = 0,
r→∞
(ii) Let also g(x) be differentiable in the open interval (a, b).
• 0 ≤ |g 0 (x)| ≤ L ≤ 1 ∀ x ∈ (a, b)
• a ≤ g(x) ≤ b ∀ x ∈ (a, b)
then for an arbitrary starting value x0 taken from (a, b) the iteration formula xn+1 = g(xn ) will
converge.
The rate of convergence of the iteration will depend on the smallness of the constant L relative
to unity.
Example 3.5.2
(i) Given the function f (x) = x3 − sin x = 0, [0, 1], using successive substitution technique,
we can generate
1 sin xn
xn+1 = (sin xn ) 3 & xn+1 =
x2n
Which of the two methods converge? Why?
Since for
1 1 −2
g(x) = (sin x) 3 , g 0 (x) = (sin) 3 cos x ⇒ 0 < g 0 (x) < 1
3
1
which implies, g(x) = (sin x) 3 is the converging formula.
(ii) Use the converging formula in (ii) above, to approximate the root of
f (x) = x3 − sin x = 0
1
n (sin x) 3
1 1.0
2 0.944
3 0.932
4 0.929
5 0.929
Note 3.5.2
Sometimes this method is known as the fixed point method, i.e. a fixed point is a number x?
such that x? = g(x? ). Thus a root of f (x) = 0 is a fixed point of the scheme x = g(x).
1 3 3
g(x) = (x3 + 2) ⇒ g 0 (x) = x2 < < 1 ∀ x ∈ [0, 1]
7 7 7
Hence by the convergence criterion, the sequence {xn } defined by
1 3
xn+1 = (x + 2)
7 n
converges to a root of x3 − 7x + 2 = 0
f (x) = e−x − x = 0
Remark 3.5.1 Correct to one decimal place is too much an approximation, but for faster
convergence - not to have more than 14 iterations - it is the pay-off between accuracy and
computational difficulties.
The correct solution is x = 0.56714329. We realise that even at 10th iteration, the fixed point
method has not yet converged.
Exercise 3.40 Verify for the following example that x = 3 is a solution of x = g(x).
18x
(a) g(x) = (x2 +9)
(b) g(x) = x3 − 24
2x3
(c) g(x) = (3x2 −9)
81
(d) g(x) = (x2 +18)
Starting with x0 = 3.1, calculate the first few iteration and justify theoretically the apparent
behavior.
1
Exercise 3.41 Consider the fixed iteration xk = (xk−1 ) for g(x) = 2(x − 1) 2 for x ≥ 1. Show
that only one fixed point exists (at x = 2) and that g 0 (2) = 1. Compute iterations starting
from
Exercise 3.42 By splitting f (x) = x3 − x − 1 = 0 in the form f (x) = x − g(x) = 0 for finding
the root α ∈ [1, 2],
(i) get three different splitting and with their corresponding iterative formulae.
(ii) Test using the convergence criterion which of the splitting lead to a convergent sequence.
(iii) For the scheme leading to a convergent sequence, start with a suitable initial approxima-
tion and find the root correct to 3 decimal places.
Interpolation
Linear interpolation is often used to approximate a value of some function f using two known
values of that function at other points.
thus
(b − a)
f (b) = f (a) + [f (c) − f (a)] (4.1)
(c − a)
and
f (b) − f (a)
b = a+ (c − a) (4.2)
f (c) − f (a)
Example 4.1.1 Given the data below
Time 0 1 2 3 4
Distance 0 6 39 67 100
83
4.1. REVIEW- LINEAR INTERPOLATION
Example 4.1.2 The bus stages along Kampala-Jinja are 10 km apart. An express bus trav-
eling between the two towns only stops at these stages except in case of an emergency when its
permitted to stop at a point between the two stages.
The fares (fee) between the first, second, third and fourth stages from Jinja are Sh 110, Sh 150, Sh 185
and Sh 200 respectively. On a certain day, a passenger paid to travel from Jinja in the bus
upto the fourth stage, but he fell sick and had to be left on a health center 33 km from Jinja.
(a) Given that he was refunded money for the distance he had not traveled, find the approxi-
mate amount of money he received.
Distance (x) 10 20 30 40
(b) Another person who had only Sh.165 was allowed to board a bus but would be left at a
point worth his money, how far from Jinja would he be left.
Then a = 20, c = 30, & b =?
f (a) = 150, f (c) = 185, & f (b) = 165
f (b) − f (a) (165 − 150)
b=a+ (c − a) = 20 + (30 − 20) = 24.286 km
f (c) − f (a) (185 − 150)
Example 4.1.4 Use Linear interpolation to find the root of the equation x3 − x − 1 = 0 which
lies between (1, 2)
x 1 2
f (x) −1 5
Recall that a value x is a root or a solution to an equation f (x) if x satisfy it, i.e if f (x) = 0.
The question is to find the value of x at f (x) = 0.
Then a = 1, c = 2, & b =?
f (a) = −1, f (c) = 5, & f (b) = 0
(0 −− 1)
f (b) − f (a)
b=a+ (c − a) = 1 + (2 − 1) = 1.16667
f (c) − f (a) (5 −− 1)
Example 4.1.5 Use linear interpolation to estimate the root of the equation
x3 − 2x − 5 = 0
x2 − 2 = 0
Distance(m) 0 5 7
Estimate the time taken by a particle to cover a distance of 6 m. 1.0833 s
4.2 Application
Linear interpolation is often used to fill the gaps in a table. Suppose you have a table listing
the population of some country in 1970, 1980, 1990 and 2000, and that you want to estimate
the population in 1994. Linear interpolation gives you an easy way to do this.
The basic operation of linear interpolation between two values is so commonly used in computer
graphics that it is sometimes called a lerp in the jargon of computer graphics. The term can
be used as a verb or noun for the operation. e.g. ”Bresenham’s algorithm lerps incrementally
between the two endpoints of the line.”
Lerp operations are built into the hardware of all modern computer graphics processors. They
are often used as building blocks for more complex operations: for example, a bilinear interpo-
lation can be accomplished in three lerps. Because this operation is cheap, it’s also a good way
to implement accurate lookup tables with quick lookup for smooth functions without having
too many table entries.
4.3 History
Linear interpolation has been used since antiquity for filling the gaps in tables, often with
astronomical data. It is believed that it was used in the Seleucid Empire (last three centuries
BC) and by the Greek astronomer and mathematician Hipparchus (second century BC). A
description of linear interpolation can be found in the Almagest (second century AD) of Ptolemy.
4.4 Extensions
In demanding situations, linear interpolation is often not accurate enough (since not all points
can be approximated to be on a straight line). In that case, it can be replaced by polynomial
interpolation or spline interpolation.
Linear interpolation can also be extended to bilinear interpolation for interpolating functions
of two variables. Bilinear interpolation is often used as a crude anti-aliasing filter. Similarly,
trilinear interpolation is used to interpolate functions of three variables. Other extensions of
linear interpolation can be applied to other kinds of mesh such as triangular and tetrahedral
meshes.
such that Pk (xk ) = 1 and Pk (xj ) = 0, for j different from k. In terms of Lagrange’s polynomials
the polynomial interpolation through the points (x1 , y1 ), (x2 , y2 ), . . . , (xN , yN ) could be defined
simply as
4.5.1 Alternatively
Let f (x) be a continuous function on [a, b], such that
with xk ∈ [a, b]. We call the set of points {xk } tabular points (or interpolating points), while
the set of values {f (xk )} are called the tabular values of f (x). We seek for a polynomial of
degree n, such that
Pn (xk ) = f (xk ), for k = 0 , 1 , 2 , . . . n. (4.3)
Definition 4.5.2
Let {Dk : k = 0, 1, ..., n} be any set of numbers. We define the products;
n
Y
Dk = D0 .D1 ...Dn
k=0
n
Y
and Dk = D0 .D1 ...Dj −1 .Dj +1 ...Dn .
k =0 ,k 6=j
This definition is important in the following defining equation for Lagrange’s interpolating
polynomial.
Theorem 4.5.1
The Lagrange’s interpolation polynomial Pn (x) is given by,
n
X
Pn (x) = Lk (x)f (xk ) (4.4)
k=0
n
Y x − xj
where Lk (x ) =
j =0 ,j 6=k
xk − xj
αk constant.
For Pn (x) to satisfy equation (4.3) we must have,
with
1, j = k
δkj = (4.5)
0, j 6= k
1
αk = n
Q
(xk − xj )
j=0,j6=k
Thus,
x − x1 x − x0
P1 (x) = f (x0 ) + f (x1 ) (4.6)
x0 − x1 x 1 − x0
Which is known as Lagrange’s interpolating polynomial of degree one, popularly known
as Linear interpolating polynomial.
x 0 1
f(x) 1.0000 2.7183
In fact the data in this particular example describes the graph of f (x) = ex on [0, 1].
The geometrical interpretation of the linear interpolation on [0, 1] .
2
X
P2 (x) = Lk (x)f (xk )
k=0
= L0 (x)f (x0 ) + L1 (x)f (x1 ) + L2 (x)f (x2 )
n
Y (x − xj )
with Lk (x) =
j=0,6=k
(xk − xj )
(x − x1 )(x − x2 )
then L0 (x) =
(x0 − x1 )(x0 − x2 )
(x − x0 )(x − x2 )
L1 (x) =
(x1 − x0 )(x1 − x2 )
(x − x0 )(x − x1 )
L2 (x) =
(x2 − x0 )(x2 − x1 )
Thus, we have,
(x − x1 )(x − x2 )
P2 (x) = f (x0 )
(x0 − x1 )(x0 − x2 )
(x − x0 )(x − x2 ) (x − x0 )(x − x1 )
+ f (x1 ) + f (x2 )
(x1 − x0 )(x1 − x2 ) (x2 − x0 )(x2 − x1 )
Which is called a quadratic interpolating polynomial. Generally they are better interpo-
lating polynomials than the linear ones.
Example 4.5.2 You are given that, f (0) = −2, f (2) = 4, and f (3) = 10. Find a
Lagrange polynomial of degree 2 that fits the data.
Solution
Since x0 = 0, x1 = 2 and x2 = 3 therefore f (x0 ) = −2, f (x1 ) = 4, f (x2 ) = 10.
But
Thus P2 (x) can be used to interpolate f (x) at any of the non tabular points.
Thus,
(x − x1 )(x − x2 )(x − x3 ) (x − x0 )(x − x2 )(x − x3 )
P3 = f (x0 ) + f (x1 )
(x0 − x1 )(x0 − x2 )(x0 − x3 ) (x1 − x0 )(x1 − x2 )(x1 − x3 )
(x − x0 )(x − x1 )(x − x3 ) (x − x0 )(x − x1 )(x − x2 )
+ f (x2 ) + f (x3 )
(x2 − x0 )(x2 − x1 )(x2 − x3 ) (x3 − x0 )(x3 − x1 )(x3 − x2 )
Construction of the cubic polynomials from available data will be tested in the text
questions at the end of this lecture. Note that the higher degree Lagrange polynomials
can be constructed with ease.
Theorem 4.5.2
Lagrange’s interpolation polynomial Pn (x) is unique.
Note 4.5.1
The uniqueness means that you cannot find any other polynomial of the same degree
which can interpolate the data.
Proof
The proof proceeds by contradiction. Let Pn (x) and Qn (x) be two different polynomials
which interpolate f (x) over the set of points {xk : k = 0, 1, ..., n} which belong to the
interval [a, b], then
Lets define,
r(x) = P (x) − Q(x) ∀ x ∈ [a, b],
then r(x) has at most degree n. Since r(xk ) = 0, for k = 0, 1, 2, ..., n, it has n + 1 distinct
zeros in [a, b]. This contradicts the fundamental law of algebra which states that a non-
zero polynomial of degree n cannot have more than n zeros and so Pn (x) and Qn (x) are
the same polynomials.
Exercise 4.1
1
1. Construct a linear interpolating polynomial P1 (x) for the function f (x) = x
on the interval
[1, 2]. Use your polynomial to interpolate f (x) at x = 1.2 .
3. Find a third degree Lagrange polynomial that goes through the points (0, 0), (1, 1), (8, 2)
and (27, 3).
Use the polynomial to find q for (20, q). Also construct a linear interpolating polynomial
using only (8, 2) and (27, 3), then use the linear polynomial to estimate q. Compare the
1
estimated q s and comment on your results given that the data is of the function y = x 3 .
5. Given the table below, use Lagrange’s interpolation polynomials of degree one, two and
three to find f (2.5)
Solution
(x − x0 )(x − x2 ) (x − x0 )(x − x1 )
= f (x1 ) + f (x2 )
(x1 − x0 )(x1 − x2 ) (x2 − x0 )(x2 − x1 )
= 0.53814
Apart from the fact that e(xk ) = 0, for k = 0, 1, 2, . . . , n with xk ∈ [a, b], we can say nothing
more about e(x) for any x 6= xk .
In addition we have that f (x) has at least n+1 continuous derivatives on [a, b], then it is possible
to express e(x) in terms of f n+1 (x). We now state without proof two necessary Lemmas.
Lemma 4.5.1
Given
n
Y
qn+1 (x) = (x − xk ), x ∈ [a, b]
k=0
of degree (n + 1),
0
qn+1 (x) is of degree n such that
n
X
0
qn+1 (xj ) = (xj − xk )
k=0,k6=j
Lemma 4.5.2
Let a function g(x) be defined on [a, b]. Let {Sk : k = 0, 1, . . . , n} be a set of distinct points
each belonging to [a, b], with S0 < S1 < S2 < . . . < Sn . Suppose that:
(ii) g(Sk ) = 0, k = 0, 1, . . . , n.
Lemma 4.5.3
The expression in the truncation error e(x) is given by:
n
Y f (n+1) (ξ)
e(x) = (x − xk )
k=0
(n + 1)!
and
q(t)
g(t) = f (t) − Pn (t) − (f (x) − Pn (x)) for t, x ∈ [a, b].
q(x)
Now g(xk ) = 0, k = 0, 1, 2, . . . n Also g(x) = 0 (x 6= xk ). So for each fixed x 6= xk , g(t) has
n + 2 distinct zeros.
Since g(t) satisfies all the conditions of Lemma 1.2, we deduce that there is a number ξ such
that g (n+1) (ξ) = 0 where
min(x, xk) < ξ < max(x, xk ).
k k
Now
(f (x) − Pn )q (n+1) (t)
g (n+1) (t) = f (n+1) (t) − Pn(n+1) (t) −
q(x)
(f (x) − Pn (x))
= f (n+1) (t) − (n + 1)!
q(x)
Since
P n+1 (t) = 0
and
qn+1 (t) = (n + 1)!
The result of the theorem follows when t = ξ.
Example 4.5.3 Using two point linear interpolation of ex on [0, 1] therefore
x(x − 1) ξ
ex = e , ξ ∈ (0, 1).
2
But x(x − 1) is maximum or minimum at x = 21 with maximum absolute value equal to 1. So
e(x) has a maximum value equal to 8e = 0.3398 (4dp)
Which is the rounding error bound. If data was rounded to m decimal places, then the absolute
maximum error is |Ek | ≤ 21 × 10−m for each k = 0, 1, . . . , n.
Example 4.5.4 Find the rounding error bound in linear interpolation, of ex for x ∈ [0, 1],
when data were rounded to four digits.
Solution
1 −4
|P1 (x) − P1 ∗ (x)| ≤ 10 (|L0 (x)| + |L1 (x)|)
2
Now, L0 (x) = 1 − x
and L1 (x) = x
and so on [0, 1], |L0 (x)| + |L1 (x)| = 1 − x + x = 1.
1 −4
Thus, |P1 (x ) − P1? (x )| ≤ 10 ,
2
which says that the effect of rounding errors in the data, on P1 (x) maintains the same maximum
magnitude.
Example 4.5.5 The table below gives the tabulated values of the probability integral,
r ˆ x
2 −t2
I= e 2 dt
π 0
Use linear interpolation to find the value of I when x = 1.125. Estimate also the error bound
on the truncation error over [1, 1.25]
x 1.00 1.05 1.10 1.15 1.20 1.25
I 0.683 0.705 0.729 0.750 0.770 0.789
Solution
Note 4.5.2
At the tabular points x0 , x1 , ..., xn , the truncation error is zero, hence we can write
n
Y
f (x) = Pn (x) + R (x − xi ) (R constant depending on x)
i=0
Let,
n
Q
(t − xi )
i=0
F (x) = f (t) − Pn (t) − {f (x) − Pn (x)} Qn (∗)
(x − xi )
i=0
then
F (xi ) = f (xi ) − Pn (xi ) = 0, i = 0, 1, 2, . . . n
Further
F (x) = f (x) − Pn (x) − f (x) + Pn (x) = 0, ∀ x ∈ (a, b), x 6= xi ,
necessarily and i = 0, 1, 2, . . . n.
Thus, F (t) vanishes in (a, b) at n + 2 distinct points. On applying Rolle’s theorem repeatedly
we conclude that there exists c ∈ (a, b) such that, F (n+1) (c) = 0.
Differentiating equation (∗) (n + 1) times and putting t = c, gives,
n
Y f (n+1) (c)
f (x) = Pn (x) + (x − xi )
i=0
(n + 1)!
Truncation error
1
Y f (2) (c)
(x − xi )
i=0
2!
2
Now (x − x0 )(x − x1 ) is minimum at x = x0 +x 2
1
and is equal to (x1 −x
4
0)
in magnitude.
r √
2 −x2 2 − x2
f 0 (x) = e 2 , f 00 (x) = − xe 2
π π
√ √
2 −x2 2 2 −x2
f 000 (x) = − e 2 + xe 2
π π
and is 0 if x = ±1. Thus , √
00 2
|f (x)| ≤ √
π e
A bound on the truncation error is given by,
r
(0.05)2 2
' 0.00009
8π e
Exercise 4.2
1. Compute a bound on the truncation error for ex on [1, 1.4] when fourth degree polynomial
is used to interpolate ex .
2. Obtain error bounds for both linear and quadratic interpolation for sin hx over the interval
[1.90, 2.10]
4
3. A table of values for x 12−x is constructed for 0 ≤ x ≤ 1 in such a way that the error in
linear interpolation does not exceed if rounding errors
√ were neglected. Show that for
uniform spacing h, then h does not exceed the value 2 2.
4. Find the rounding error bound when quadratic interpolation, of ex for x ∈ [0, 1], when
data were rounded to four digits.
Note 4.5.3 Use Lagrange interpolation to find an appropriate function passing through the
given points. Sketch a graph of this function based only on the given points and what you
think the curve must be. Compare your sketch with the graph created by graphing technology.
(a) A linear function passing through the points (−1, 3) and (2, 1).
(b) A quadratic function passing through the points (−1, 3), (0, 2), and (2, 1).
(c) A cubic function passing through the points (−1, 3), (0, 2), (1, 5), and (2, 1).
(d) A quartic (fourth degree) polynomial function passing through (−2, 4), (−1, 3), (0, 2), (1, 5),
and (2, 1).
Note 4.5.4 Finding a quadratic function that resembles other functions: By choosing three
noncolinear points on any curve we can use Lagrange’s interpolation to find a parabola that
passes through those points. For each of the following functions find a parabola that passes
through the graphs of the functions when at points with the indicated first coordinates. Use
graphing technology to draw a sketch of the function and the quadratic function you find.
Discuss how you might use the function you find to estimate the value of the given function.
(a) f (x) = x5 − 4x3 + 2; x = 0, 1, 2.
√
(b) f (x) = x; x = 0, 1, 4.
Describe a general procedure for finding a polynomial function of degree n that passes through
n + 1 given points with distinct first coordinates.
Note 4.5.5 Lagrange’s interpolation formula has the disadvantage that the degree of the
approximating polynomial must be chosen at the outset; an alternative approach is discussed in
the next Step. Thus, Lagrange’s formula is mainly of theoretical interest for us here; in passing,
we mention that there are some important applications of this formula beyond the scope of this
book - for example, the construction of basis functions to solve differential equations using a
spectral (discrete ordinate) method.
Note 4.5.6 Given the data below,
x -3 1 4 5 7
f(x) -28 4 28 36 52
Use linear interpolation to approximate
(a) f (3).
(b) f (x) if x = 5.
(c) x if f (x) = 12.
(d) the root/solution of f (x). f (x) = 8x − 4
Example 4.5.7 The Lagrange basis polynomials (n=N-1) on the data to approximate f (3.5)
x0 x1 x2
x 1 2 4
f(x) 3 2 1
(x − x1 )(x − x2 ) 1
L0 (x) = = (x − 2)(x − 4)
(x0 − x1 )(x0 − x2 ) 3
(x − x0 )(x − x2 ) 1
L1 (x) = = − (x − 1)(x − 4)
(x1 − x0 )(x1 − x2 ) 2
(x − x0 )(x − x1 ) 1
L2 (x) = = (x − 1)(x − 2)
(x2 − x0 )(x2 − x1 ) 6
f (3) (ξ)
f (x) = P2 (x) + (x − x0 )(x − x1 )(x − x2 ), ξ ∈ [a, b], where {x0 , x1 , x2 } ⊆ [a, b]
3!
(established by setting f (x) = 1) may be used as a check. Note also that with n = 1 we recover
the linear interpolation formula:
Example 4.5.8 Use Lagrange’s interpolation formula to find the interpolating polynomial
P3 (x) through the points (0, 3), (1, 2), (2, 7), and (4, 59) and then find the approximate value of
P3 (3).
x0 x1 x2 x3
x 0 1 2 4
f(x) 3 2 7 59
Here n = 3 = 4 − 1
The Lagrange coefficients are:
(The student should verify that [L0 (x) + L1 (x) + L2 (x) + L3 (x) = 1]
Hence, the required polynomial is
3 2
P3 (x) = − (x3 − 7x2 + 14x − 8) + (x3 − 6x2 + 8x)
8 3
7 3 59
− (x − 5x2 + 4x) + (x3 − 3x2 + 2x)
4 24
1
−9x3 + 63x2 − 126x + 72 + 16x3 − 96x2 + 128x − 42x3 + 210x2 − 168x + 59x3 − 177x2 + 118x
= 24
1
−9x3 + 63x2 − 126x + 72 + 16x3 − 96x2 + 128x − 42x3 + 210x2 − 168x + 59x3 − 177x2 + 118x
=
24
1
24x3 + 0x2 − 48x + 72
=
24
= x3 − 2x + 3
Consequently f (3) ≈ P (3) = 33 − 2(3) + 3 = 24, However, note that, if the explicit form of
the interpolating polynomial were not required, one would proceed to evaluate P3 (x) for some
value of x directly from the factored forms of Lk (x). Thus, in order to evaluate P3 (3), one has
Exercise 4.3 Given that f (−2) = 46, f (−1) = 4, f (1) = 4, f (3) = 156, and f (4) = 484, use
Lagrange’s interpolation formula to estimate the value of f (0).
Example 4.5.9 Use Lagrange interpolation polynomial for the data below
x0 x1 x2 x3
x 1 2 4 5
f(x) 3 8 54 107
(The student should verify that [L0 (x) + L1 (x) + L2 (x) + L3 (x) = 1] Hence, the required
polynomial is
1 3 1
P3 (x) = − (x − 11x2 + 38x − 40)[3] + (x3 − 10x2 + 29x − 20)[8]
12 6
1 3 1
+ (x − 8x2 + 17x − 10)[54] + (x3 − 7x2 + 14x − 8)[107]
6 12
1
= 12 −3x3 + 33x2 − 114x + 120 + 16x3 − 160x2 + 464x − 320 − 108x3 + 864x2 − 1836x + 1080 + 107x3 − 749x2 + 1498x −
1
= −3x3 + 33x2 − 114x + 120 + 16x3 − 160x2 + 464x − 320 − 108x3 + 864x2 − 1836x + 1080 + 107x
12
1
12x3 − 12x2 + 12x + 24
=
12
= x3 − x2 + x + 2
Numerical Differentiation
101
5.3. FORWARD DIFFERENCE APPROXIMATION
Example 5.3.1
For the function f (x) = x2 , approximate f 0 (2) with step length
(i) h = 0.1
(ii) h = 0.01
(iii) h = 0.001.
Compare your results with the analytic/exact value of f 0 (2).
Solution
(i) Since
f (x + h) − f (x)
f (x) '
h
But f (x) = x2 and x = 2, h = 0.1
and
f (x) = 22 = 4
therefore
4.41 − 4 0.41
f 0 (2) ' = = 4.1
0.1 0.1
However, the exact value of
f 0 (2) = (2)(2) = 4
Since f 0 (x) = 2x. This yields an error of 0.1.
(x + h) − f (x) h 00
f 0 (x) = − f (c1 ) (5.1)
h 2
Equation (5.1) is the forward difference form which we can write in better notation as:
f (x + h) − f (x)
f 0 (x) ' + Truncation Error
h
Note 5.3.1
(i) Error 0(h) means that the error → 0 (goes to zero) near x = a at the rate of Ah where
A is a constant (i.e. halving h, halves the error).
h
Etruc = − f 0 (c1 ).
2
Indeed | − h2 f 0 (c1 ) is the bound on the truncation error.
f (x) − f (x − h) h 00
f 0 (x) = + f (c2 )
h 2
The formula can be geometrically represented as in Figure (5.3)
Example 5.4.1 For the function f (x) = x2 , approximate f 0 (2) using the backward difference
approximation with step length
(i) h = 0.1,
(ii) h = 0.01,
(iii) h = 0.001.
Solution
f (x) − f (x − h)
f 0 (x) '
h
But f (x) = x2 , x = 2 and h = 0.1, therefore
f (x) = f (2) = 22 = 4
therefore
4 − 3.6100 0.3900
f 0 (2) '= = = 3.900
0.1 0.1
Since the exact value of
f 0 (2) = (2)(2) = 4,
therefore the absolute error committed by using the numerical formula is 0.1. This is not
very bad.
therefore
4 − 3.996001 0.003999
f 0 (2) ' = = 3.999
0.001 0.001
Error committed is 0.00001. This error is smaller than any of the previous two. Infact the zero
error means the exact value of the derivative is generated.
Note 5.4.1 We note that the smaller h is the better is the numerical approximate to the
derivative.
h2 00
f (x − h) = f (x) − hf 0 (x) + f (c2 ),
2
we get,
f (x) − f (x − h) h 00
f 0 (x) = + f (c2 )
h 2
with x − h ≤ c2 ≤ x
Which is the backward difference approximation. The approximation could also be written
as,
f (x) − f (x − h)
f 0 (x) = + Etrunc
h
or
f (x) − f (x − h)
f 0 (x) = + 0(h)
h
0 f (x + h) − f (x − h) h2 3
f (x) = + f (c)
2h 3!
The formula is geometrically represented as seen in the Figure (figure:central)
f (x + h) − f (x − h)
f 0 (x) ' .
2h
From Figure 5.4, it is clear that the gradient of AB is closer to the gradient of the tangent at
x = a. That is, the two lines are almost parallel. This is expected to be a better approximation
than the forward and the backward. Indeed it is as we shall see in the following example.
Example 5.5.1
Approximate f 0 (2) for f (x) = x2 using the central difference approximation with step size
(i) h = 0.1
(ii) h = 0.01
(iii) h = 0.001
Solution
(2.01)2 − (1.99)2
= = 4.000000000.
0.02
This also generates a zero error.
(2.001)2 − (1.999)2
= = 4.00000000
0.002
h2 00
0 h3 (3)
f (x + h) = f (x) + hf (x) + f (x) + f (c1 ) (5.2)
2 6
and
h2 00 h3
f (x − h) = f (x) − hf 0 (x) + f (x) − f (3) (c2 ) (5.3)
2 6
h3 (3)
f (x + h) = f (x − h) = 2f 0 (x)h + (f (c1 ) − f (3) (c2 )) (5.4)
6
Now,
f (3) (c1 ) + f (3) (2)
= f (3) (c3 ), c1 ≤ c3 ≤ c2
2
This is derived from the intermediate value theorem.
So
f (x + h) − f (x − h) h2 (3)
f 0 (x) = + f (c3 )
2h 3!
i.e, the error is of order 0(h2 ).
Exercise 5.2
1. For f (x) = ex , approximate f 0 (1) using forward, backward and central difference formulae
with,
(i) h = 0.1
(ii) h = 0.01
(iii) h = 0.001
Compare the results with the analytic/exact value of f 0 (1). Comment on your results.
2. Let f (x) be given by the table below. The inherent round off error has the bound
|ek | ≤ 5 × 10−5
(a) Find approximation for f 0 (1.2) using the central difference formula with h = 0.01,
and h = 0.001.
(b) Compare with f 0 (1.2) = − sin(1.2) = −0.932.
(c) Find the total error bound for the three cases in part (a).
3. For f (x) = cos x, Use the forward, backward and central difference formulae to approxi-
mate f 0 (0.8) using h = 0.001. Compare your results with the analytic values.[Hint: either
all in radians or all in degrees, Ans= -0.717]
5.6 Comparision
It is clear that the central difference gives a much more accurate approximation of the derivative
compared to the forward and backward differences. Central differences are useful in solving
partial differential equations. If the data values are available both in the past and in the future,
the numerical derivative should be approximated by the central difference.
h2 00
0 h3 (3) h4 (4)
f (x + h) = f (x) + hf (x) + f (x) + f (x) + f (c)) (5.7)
2 6 24
and
h2 00 h3 h4
f (x − h) = f (x) − hf 0 (x) + f (x) − f (3) (x) + f (4) (c2 ) (5.8)
2 6 24
addition of equations (5.7) and (5.8) gives,
h4 (4)
2 00 4
f (x + h) + f (x − h) = 2f (x) + h f (x) + f (c1 ) + f (c2 ) (5.9)
12
and using,
f (4) (c1 ) + f (4) (c2 )
= f (4) (c3 )
2
with c1 ≤ c3 ≤ c2 . This is derived from the intermediate value theorem and making f 00 (x) the
subject in equation (5.9), we get,
00 f (x − h) − 2f (x) + f (x + h) h2 (4)
f (x) = + f (c3 ) (5.10)
h2 6
or
f (x − h) − 2f (x) + f (x + h)
f 00 (x) = + 0(h2 ) (5.11)
h2
Equation (5.11) is a second order approximation for the second order derivative. The formula
is handy for approximating second order derivatives.
(i) h = 0.100
(ii) h = 0.010
(iii) h = 0.001.
Solution
(i) Since,
f (x − h) − 2f (x) + f (x + h)
f 00 (x) '
h2
But x = 1, h = 0.1, therefore
f (0.9) − 2f (1) + f (1.1)
f 00 (1) '
(0.1)2
(0.9)3 − 2(1)3 + (1.1)3
=
0.01
= 6.00000000000005
However, the exact value is f 00 (x) = 6x, therefore f 00 (1) = 6. Hence error committed is
just 5.0 × 10−14 . This is really small.
(ii) With h = 0.01
f (0.99) − 2f (1) + f (1.01)
f 00 (1) '
(0.01)2
(0.99)3 − 2 + (1.01)3
=
0.0001
= 6.00000000000000
Since the exact value is 6, the error committed is zero to 14 decimal places.
(iii) This also generates a zero error, since,
f (0.999) − 2f (1) + f (1.001)
f 00 (1) '
(0.001)2
(0.999)3 − 2 + (1.001)3
=
0.000001
= 6.00000000000000
f (x + h) − f (x)
f 0 (x) '
h
Solution
For the approximation,
f (x + h) − f (x)
f 0 (x) '
h
Maximum absolute error in f (x + h) is e and that in f (x) is also e. So
e+e 2e
|Eround | < =
h h
Now
h 00 h
|Etrunc | =
|f (c1 )| ≤ M2
2 2
00
say, where M2 = max |f (x)|, a ≤ x ≤ a + h Thus,
2e h
|Total error| ≤ + M2 .
h 2
D.W-Ddumba numerical analysis i Page 113 of 133
5.7. THE SECOND DERIVATIVE APPROXIMATION
Exercise 5.3
(i) h = 0.4
(ii) h = 0.04
(iii) h = 0.004
2. Given the function f (x) = ex , approximate f 00 (x) at x = 2 using step length h of magni-
tude.
(i) 0.1
(ii) 0.01
(iii) 0.001
3. Let f (x) = cosx. Use the formula considered in this Lecture for approximating f 00 (x),
with h = 0.01 to calculate approximations for f 0 (0.8). Compare with the true value.
4. Given that
−f2 + 16f1 − 30f0 + 16f−1 − f−2
f 00 (x0 ) '
12h2
Use the formula to approximate f 00 (1) for f (x) = ex using h = 0.5. Compare your answer
with the analytic answer and the answer obtained when using formula equation (5.11).
What do you notice and suggest?
6.1 Introduction
The lecture defines and inter-relates the most common finite difference operators i.e. forward,
backward, shift, central and the averaging operator. Use of the operators to prove finite differ-
ence identities is also done.
x = x0 + rh, r = 0, 1, . . . , n
x0 f (x0 )
x1 f (x1 )
x2 f (x2 )
· ·
· ·
· ·
xr f (xr )
We can form differences between consecutive pivotal values i.e. fr+1 − fr where
The differences fr+1 − fr are called the first differences. We similarly define higher order
differences.
Example 6.2.1
Masenge (1989) used in his book the example of tabulating the function f (x) = ln(1 + x)
in the interval [2.00, 2.10]. This was tabulated as,
115
6.3. FINITE DIFFERENCE OPERATORS
Differences
xr fr 1st 2nd 3rd
2.00 1.098612
0.006645
2.02 1.105257 −0.000044
0.00601 0.00000
2.04 1.111858 −0.000044
0.006557 0.000002
2.06 1.118415 −0.000042
0.006515 −0.000001
2.08 1.124930 −0.000043
0.006472
2.10 1.31402
Definition 6.2.1
We say that differences are converging if elements of higher order differences decrease rapidly in
magnitude. Such a behavior is common from tables of well-behaved functions like polynomials.
4fr = fr+1 − fr
Thus, the 1st difference column in a difference table consists of the elements,
The second differences are got by differentiating the first differences i.e
4(αfr + βgr ) = α 4 fr + β 4 gr
If we write 42 fr for 4(4fr ), then the second differences are the quantities,
42 f 0 , 42 f 1 , 42 f 2 , . . . . . .
4(42 fr ) = 43 fr , r = 0, 1, 2, . . .
= 4(4n−1 fr )
Thus 4k fr involves information at the pivoted points xr , xr+1 , . . . , xr+k . Thus,
4fr = fr+1 − fr
42 fr = 4fr+1 − 4fr
= (fr+2 − fr+1 ) − (fr+1 − fr )
= fr+2 − 2fr+1 + fr
43 fr = 42 fr+1 − 42 fr
= (fr+3 − 2fr+2 + fr+1 ) − (fr+2 − 2fr+1 + fr )
= fr+3 − 3fr+2 + 3fr+1 − fr .
Similarly we can show that,
5fr = fr − fr+1 .
Efr = fr+1 .
Hence, by this definition we can define higher order shift operators as,
For k negative, we get what is known as the backward shift. For example E −1 fr is a
backward shift defined by,
E −1 fr = fr−1
We also note that k can be fractional.
1
Example 6.3.1 Find E 2 fr and E −5 fr .
Solution
By definitions of the forward and backward shifts i.e.
Efr = fr+1
and
E −1 fr = fr−1
we have,
1
E 2 fr = fr+ 1
2
and
E −5 fr = fr−5 .
= (E − 1)fr
where 1 is the identity operator I, that is,
Ifr = fr .
Thus 4 = E − 1 and E = 4 + 1.
Solution
Since
E 5 fr = E(5fr ) = E(fr − fr−1 )
= Efr − Efr−1 (because of linearity of E)
= fr+1 − fr (By definition of E).
And 4 fr = fr+1 − fr (By definition of 4)
Hence shown.
Solution
Since
k k k k
4 fr = fr+k − fr+k−1 + fr+k−2 + . . .
0 1 2
3 3 3 3 3
therefore 4 f0 = f3+0 − f3+0−1 + f3+0−2 − f3+0−3
0 1 2 3
3 3 3 3
= f3 − f2 + f1 − f0
0 1 2 3
= f3 − 3f2 + 3f1 − f0
And
δ 2 fr = δfr+ 1 − δfr− 1
2 2
Try to find the expressions for δ 3 fr and δ 4 fr before you continue reading.
and
1
E 2 fr = fr+ 1
2
and
1
E − 2 fr = fr− 1 ,
2
we get
1 1
δfr = (E 2 − E − 2 )fr
and hence conclude that,
1 1 1
δ = E 2 − E − 2 = E 2 (1 − E −1 ).
4k fr = (E − 1)k fr .
Hence show that the forward difference can be written in terms of pivotal values by the formula,
k k k k
4 fr = fr+k − fr+k−1 + fr+k−2 + . . .
0 1 2
(ii) 4 − 5 = 45 = δ 2
1 − 4 fr
4( )=
f −r fr fr+1
4r fk = 5r fk+r = δ r fk+ r2 ,
f−3
5f−2
f−2 52 f−1
5f−1 53 f 0
f−1 52 f 0 54 f1
3
5f0 5 f1 55 f 2
f0 52 f 1 54 f2 56 f 3
5f1 53 f 2 55 f 3
2 4
f1 5 f2 5 f3
3
5f2 5 f3
2
f2 5 f3
5f3
f3
f−3
δf−2 12
f−2 δ 2 f−2
δf−1 1 δ 3 f−1 1
2 2
f−1 δ 2 f−1 δ 4 f−1
δf−1 1 δ 3 f− 1 δ 5 f− 1
2 2 2
f0 δ 2 f0 δ 4 f0 δ 6 f0
3 5
δf 1 δ f1 δ f1
2 2 2
f1 δ 2 f1 δ 4 f1
δf1 1 δ 3 f1 1
2 2
f2 δ 2 f2
δf2 21
f3
Example 6.4.1
Given f (x) = x4 , form a table of finite differences, for x from x = −2 in steps of one to 5.
Solution
xr f r 4fr 42 f r 43 fr 44 fr 45 fr
−2 16
-15
−1 1 14
−1 −12
0 0 2 24
1 12 0
1 1 14 24
15 36 0
2 16 50 24
65 60 0
3 81 110 24
175 84
4 256 194
369
5 625
We note that the fourth differences are constants and fifth differences are all zeros. We state
the following theorem to support this observation.
Theorem 6.4.1
Let Pn (x) be a polynomial of degree n(n ≥ 1 integer). Then
Thus, parts (ii) and (iii) of the theorem confirm the validity of the results of the difference table
(4.4) in which fourth order differences are all constants equal to 24 and fifth differences are all
zero.
In fact the theorem can help us check the behaviour of a function (not polynomial) on an
interval. If the nth order differences are fairly constant on an interval for a particular function,
then such a function more or less behaves like a polynomial of degree n in that interval.
P6 (x) = x6 − 6x2 + 1,
Construct a table of forward differences on the interval [4, −4] with step size 1.
Exercise 6.7 Construct a table of backward differences for the polynomial in Exer6.6.
Exercise 6.8 Construct a table of differences for the function f (x) = ex on the interval [−2, 2]
with step size 0.5.
From your results what polynomial function fairly approximate ex on this interval?
Exercise 6.9 What do you think are the uses of finite difference tables
Sample Questions
Question 1
125
Question 2
(a) state one advantage and one disadvantage of the following iterative methods used in the
solution of a non-linear equation f (x) = 0 :
(i) Bisection
(ii) Regular falsi
(iii) Newton Raphson’s
(b) (i) Prove that the general Newton-Raphson iterative method for finding the rth root of
a number, A > 0 is given by,
1 A
xn+1 = {(p − 1)xn + r−1 }
p xn
(ii) From 2b(i) deduce the corresponding iteration formula when p = −2, and use it to
find an approximate value of √12 correct to two decimal places.
√
(iii) Use 2b(ii) to deduce the approximate√ value of 2. Give reasons why this approach
to finding the approximate value of 2 is better than using the iterative formula
1 A
xn+1 = xn +
2 xn
Question 3
(a) The derivative of a function f (x) at a point x0 is defined by the limiting process,
f (x0 + h) − f (x0 )
f 0 (x0 ) = lim ,
h→0 h
provided the limit exists. However, a numerical approximation to f 0 (x0 ) involves differ-
ences such as the forward difference approximation
f (x0 + h) − f (x0 )
f 0 (x0 ) ≈ (3.1)
h
2
(i) Using (3.1), approximate f 0 (1) for f (x) = ex using a step size h = 0.1. Compare
your answer with the exact value of the derivative. Account for the difference in the
results. Suggest one way of improving on your result so obtained.
(ii) Geometrically represent the difference approximation (3.1).
(iii) Derive the difference approximation (3.1) together with its truncation error term.
State the order of the approximation
Question 4
Question 5
(a) (i) State the general Runge-Kutta four stage method of fourth order popular for solving
initial value problems of the form, y 0 = f (x, y), y(xn ) = yn .
(ii) State the order of the local truncation error for the scheme in part (i).
(b) Given the initial value problem y 0 = x − y, y(0) = 0 with classical solution given by, y =
e−x + x − 1. Using h = 0.1, with Runge-Kutta fourth order method, find
(i) y(0.1)
(ii) y(0.2)
(ii) y(0.3)
(iii) y(0.4)
Make a table of comparison of the classical solutions and numerical solutions with the absolute
errors committed at each of the points 0.1, 0.2, 0.3 and 0.4. Account for the errors in the
numerical solutions obtained.
Question 6
(a) One of the oldest numerical techniques for solving a differential equation
dy
= f (x, y) (7.1)
dx
with the initial condition y0 = y(x0 ) where x0 and y0 are given constants and x0 not a singular
point of the function, is by Taylor series. Develop the Taylor series method for equation (7.1).
(b) Using the Taylor series method find an expression for the solution y(x) given that,
dy
= x3 − y
dx
and the initial condition y = 1 when x = 0. Use this expression to find values of y for
(i) x = x0 + h
(ii) x = x0 + 2h with h = 0.1
Question 7
(a) Runge-Kutta methods are popular Numerical techniques for solving ordinary differential
equations. Given the equation,
dy
= f (x, y) with y(a) = c,
dx
y 0 = x + y, y(0) = 1, with h = 1
(iii) Compare the solution y(1) with the exact/analytic solution at that point.
(iv) Suggest anyway of increasing the accuracy in the numerical solution y(1).
(v) Explain the origin of the error in the numerical solution y(1).
(b) The oldest technique for obtaining a numerical solution of an ordinary differential equation
is the Euler’s method. Derive the Euler’s method together with its truncation error for
the equation,
dy
= f (x, y) with y(a) = c
dx
Question 8
(a) Given
y 0 = f (x, y) with y(x0 ) = y0 , (7.2)
derive the Euler’s method for solving equation (2)
(ii) State one advantage and one disadvantage of Euler’s method as compared to Runge-
Kutta.
Question 9
(a) State the defining equations for the following finite difference operators on a function f (x).
(b) Prove that E = ehD ; where D is a differential operator and E is a shift operator acting
on a function y(x).
(c) Let (x0 , y0 ), (x1 , y1 ) · · · , (xn , yn ) be a given set of (n + 1) points. Define the divided
differences
(d) Using Newton’s divided difference formula, fit a cubic polynomial y(x) on the data :
x 0 1 2 3
y(x) 1 0 1 10
Question 10
(i)
42 y0 43 y0 44 y0
dy 1
= 4y0 − + − + ···
dx x=x0 h 2 3 4
(ii)
d2 y
1 2 3 11 4
= 2 4 y0 − 4 y0 + 4 y0 − · · · .
dx2 x=x0 h 12
x 0 2 4 6 8
y 7 13 43 145 367
d2 y
compute dx2
.
x=0
Question 11
´ xn
(a) (i) State the Trapezoidal rule for approximating the integral x0
y(x) dx on [x0 , xn ].
Write down the expression for the truncation error term.
(ii) Derive the rule in part 3(a)(i).
´ 1 dx
(b) Approximate I = 0 1+x 2 using Trapezoidal rule with stepsize h = 0.2. Hence approxi-
mate the value of π . Compare the numerical value of I with it’s analytic value. Explain
how the accuracy of I is affected by the value of h.
(a) (i) With a relevant sketch, describe the Bisection method for approximating the root α
of a non-linear equation f (x) = 0 on [x0 , xn ].
(ii) Use the bisection method to find an approximation to the root of x3 − x − 1 = 0 on
the interval [1, 2] correct to one decimal place.
(b) Newton’s Raphson’s method is one of the popular schemes for solving a non-linear equa-
tion f (x) = 0. Prove that the general Newton Raphson’s iterative method for finding the
pth root of a positive number B is given by
1 B
xn+1 = (p − 1)xn + p−1 .
p xn
Using this scheme, approximate √1 correct to 4 decimal places. Take initial guess as 0.6.
2
Q13.(a) Common iterative schemes for solving non linear equations f (x) = 0 are of the form,
xr+1 = g(xr ) for r = 0, 1, . . .
(b)(i) Prove that the general Newton Raphson’s method for finding the rth root of a number
(N > 0) is given by
1 N
xn+1 = {(r − 1)xn + r−1 }
r xn
(ii) From b(i), deduce the corresponding iterative formula when r = −2, and use it to find an
approximate value of √12 correct to 3 decimal places. Use initial approximation x0 = 0.7.
(ii) A function f (x) passes through the points (0, 1.0000) and (1, 2.7183). Construct La-
grange’s interpolating polynomial satisfying the above data. Use the polynomial to com-
pute the approximate value of f (0.5).
(b)(i) Prove that the bound on the rounding error when using Lagrange’s polynomial Pn (x)
does not blow beyond Σnk=0 |ξk ||Lk (x)| where ξ is the rounding error in fk and Lk (x) are
the Lagrange coefficients.
(ii) Given that f (x) = ex for part a(ii) and data were rounded to four digits, show that the
effect of rounding errors in the on P1 (x) maintains the same maximum magnitude of
1
2
× 10−4
(c) Give the defining equations for the finite difference operators, µ, σ and E. Hence prove
1
the finite difference identity µσ + 12 σ 2 = E 2 σ.
´x
Q15(a) x0 f (x)dx ' h3 [f0 + 4f1 + f2 ] is the popular Simpson’s rule for approximating
an integral.
(i) State two major sources of error when the Simpson’s rule is used to approximate a definite
integral.
Q16(a) The second order central difference approximation for f 0 (x) is given as
f (x + h) − f (x − h)
f 0 (x) ' .
2h
(ii) By the help of appropriate Taylor series, derive the central difference approximation with
its truncation error.
(iii) Using the central difference approximation, approximate f 0 (2) with h = 1.0 and h = 0.1
for f (x) = x2 . What do you notice from your results?
(b) Given that |e0 | and |e1 | are the maximum absolute errors committed when evaluating
f (x + h) and f (x − h) respectively, and |e0 |, |e1 | < e, show that for the central difference
approximation,
e M h2
(i) |Total error| ≤ h
+ 6
1
) where M =max|f 000 (x)| for a − h ≤ c ≤ a + h.
3e 3
(ii) Optimal h = ( M
Further Reading
1. Curtis F. G and Patrick O.W. (1994). Applied Numerical Analysis. Addison - Wesley
Publishing Company.
3. Maron M.J. and Robert J.L. (1991). Numerical Analysis. Wadsworth Publishing Com-
pany.
4. Samuel D. Coute (1980). Elementary Numerical Analysis. Mcgraw hill Kogakusha, Ltd.
133