0% found this document useful (0 votes)
95 views

Introduction To Numerical Methods-CH-1 YG

This document introduces numerical methods and discusses sources of error in numerical analysis. It can be summarized as follows: I. Numerical methods provide approximate solutions to problems that cannot be solved analytically or that are too complex for hand calculations. They involve representing problems and solutions with numbers. II. Errors in numerical analysis come from rounding errors due to finite precision in computers, and from truncation errors from approximating problems. Round-off errors occur when representing numbers with a limited number of digits, while truncation errors come from simplifying problems. III. It is important to quantify errors in terms of accuracy and precision. Accuracy refers to how close solutions are to the true value, while precision means how consistent repeated calculations

Uploaded by

Aradom Mehari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views

Introduction To Numerical Methods-CH-1 YG

This document introduces numerical methods and discusses sources of error in numerical analysis. It can be summarized as follows: I. Numerical methods provide approximate solutions to problems that cannot be solved analytically or that are too complex for hand calculations. They involve representing problems and solutions with numbers. II. Errors in numerical analysis come from rounding errors due to finite precision in computers, and from truncation errors from approximating problems. Round-off errors occur when representing numbers with a limited number of digits, while truncation errors come from simplifying problems. III. It is important to quantify errors in terms of accuracy and precision. Accuracy refers to how close solutions are to the true value, while precision means how consistent repeated calculations

Uploaded by

Aradom Mehari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

CHAPTER ONE

1.1 INTRODUCTION, APPROXIMATION AND ERRORS

After finishing this chapter, you should be able to:


I. understand the need for numerical methods, and
II. Go through the stages (mathematical modeling, solving and implementation) of solving a
particular physical problem

Introduction to Numerical Methods


Numerical methods are techniques by which mathematical problems are formulated so that they can be
solved with arithmetic operations (multiplication, division, addition, subtraction). Although there are
many kinds of numerical methods, they have one common characteristic: they invariably involve large
numbers of tedious arithmetic calculations.
Mathematics is an elegant and precise subject: however when numerical answers are required one
sometimes needs to rely on approximate methods to obtain useable answers. There are many problems
which simply do not have analytical solutions, or those whose exact solution is beyond our current state
of knowledge. There are also many problems which are too long (tedious) to solve by hand. When such
problems arise we can exploit numerical analysis to reduce the problem to one involving a finite number
of unknowns and use a computer to solve the resulting equations.
There are several additional reasons why you should study numerical methods:
1. Numerical methods are extremely powerful problem-solving tools. They are capable of handling
large systems of equations, nonlinearities, and complicated geometries that are not uncommon
in engineering practice and that are often impossible to solve analytically. As such, they greatly
enhance your problem-solving skills.
2. During your careers, you may often have occasion to use commercially available prepackaged,
or “canned,” computer programs that involve numerical methods. The intelligent use of these
programs is often predicated on knowledge of the basic theory underlying the methods.
3. Many problems cannot be approached using canned (recorded) programs. If you are familiar
with numerical methods and are adept at computer programming, you can design your own
programs to solve problems without having to buy or commission expensive software.
4. Numerical methods are an efficient vehicle for learning to use computers. It is well known that
an effective way to learn programming is to actually write computer programs. Because
numerical methods are for the most part designed for implementation on computers, they are
ideal for this purpose.
5. Numerical methods provide a vehicle for you to reinforce your understanding of mathematics.
Because one function of numerical methods is to reduce higher mathematics to basic arithmetic
operations as stated above.
Finally, the aim of numerical methods is therefore to provide systematic methods for solving problems in
a numerical form. The process of solving problems generally involves starting from an initial data, using
high precision digital computers, following the steps in the algorithms, and finally obtaining the results.
Often the numerical data and the methods used are approximate ones. Hence, the error in a computed
result may be caused by the errors in the data, or the errors in the method or both.

Pre. By. Gebresilassie H. Page 1 of 22


SIGNIFICANT FIGURES
The concept of a significant figure, or digit, has been developed to formally designate the reliability of a
numerical value. The significant digits of a number are those that can be used with confidence. They
correspond to the number of certain digits plus one estimated digit. For example, the speedometer and the
odometer in Fig. below yield readings of three and seven significant figures, respectively. For the
speedometer, the two certain digits are 48. It is conventional to set the estimated digit at one-half of the
smallest scale division on the measurement device. Thus the speedometer reading would consist of the
three significant figures: 48.5. In a similar fashion, the odometer would yield a seven-significant-figure
reading of 87,324.45.

Although it is usually a straightforward procedure to ascertain the significant figures of a number, some
cases can lead to confusion. For example, zeros are not always significant figures because they may be
necessary just to locate a decimal point. The numbers 0.00001845, 0.0001845, and 0.001845 all have four
significant figures. Similarly, when trailing zeros are used in large numbers, it is not clear how many, if
any, of the zeros are significant. For example, at face value the number 45,300 may have three, four, or
five significant digits, depending on whether the zeros are known with confidence. Such uncertainty can
be resolved by using scientific notation, where 4.53 × 104 , 4.530 × 104 , 4.5300 × 104 designate that the
number is known to three, four, and five significant figures, respectively.

The concept of significant figures has two important implications for our study of numerical methods:
1. As we know problem, numerical methods yield approximate results. We must, therefore, develop
criteria to specify how confident we are in our approximate result. One way to do this is in terms
of significant figures. For example, we might decide that our approximation is acceptable if it is
correct to four significant figures.
2. Although quantities such as π, e, or √7 represent specific quantities, they cannot be expressed
exactly by a limited number of digits. For example,
π = 3.141592653589793238462643. . .

ACCURACY AND PRECISION


The errors associated with both calculations and measurements can be characterized with regard to their
accuracy and precision. Accuracy refers to how closely a computed or measured value agrees with the
true value. Precision refers to how closely individual computed or measured values agree with each other.
These concepts can be illustrated graphically using an analogy from target practice. The bullet holes on
each target in Fig. below can be thought of as the predictions of a numerical technique, whereas the
bull’s-eye represents the truth. Inaccuracy (also called bias) is defined as systematic deviation from the

Pre. By. Gebresilassie H. Page 2 of 22


truth. Thus, although the shots in Fig. (c)Are more tightly grouped than those in Fig. (a), the two cases are
equally biased because they are both centered on the upper left quadrant of the target. Imprecision (also
called uncertainty), on the other hand, refers to the magnitude of the scatter. Therefore, although Fig.
(b)and(d)are equally accurate (that is, centered on the bull’s-eye), the latter is more precise because the
shots are tightly grouped.
Therefore, Numerical methods should be sufficiently accurate or unbiased to meet the requirements of a
particular engineering problem. They also should be precise enough for adequateengineering design

1.2 Measuring Errors


After finishing this topic, you should be able to:
A. find the true and relative true error,
B. find the approximate and relative approximate error,
C. relate the absolute relative approximate error to the number of significant digits at
least correct in your answers, and
D. Know the concept of significant digits.
In any numerical analysis, errors will arise during the calculations. To be able to deal with the issue of
errors, we need to
A. Identify where the error is coming from, followed by
B. Quantifying the error, and lastly
C. Minimize the error as per our needs.

A. Identify Where the Error Is Coming From


Error in solving an engineering or science problem can arise due to several factors. First, the error may be
in the modeling technique. A mathematical model may be based on using assumptions that are not
acceptable. For example, one may assume that the drag force on a car is proportional to the velocity of the
car, but actually it is proportional to the square of the velocity of the car. This itself can create huge errors
in determining the performance of the car, no matter how accurate the numerical methods you may use
are. Second, errors may arise from mistakes in programs themselves or in the measurement of physical
quantities. But, in applications of numerical methods itself, the two errors we need to focus on are
I. Round off error
II. Truncation error.

Pre. By. Gebresilassie H. Page 3 of 22


I. Round-off Errors
Round-off error is due to the inaccuracies that arise due to a finite number of digits of precision used to
represent numbers. All computers represent numbers, except for integer and some fractions, with
imprecision.

Digital computers use floating-point numbers of fixed word length. This type of representation will not
express the exact or true values correctly. Error introduced by the omission of significant figures due to
computer imperfection is called the round-off error. Round-off errors are avoidable in most of the
computations. When n digits are used to represent a real number, then one method is keep the first n digits
and chop off all remaining digits. Another method is to round to the nth digit by examining the values of
the remaining digits.

Consider a positive real number xin the normalized decimal form

x = (0.b1 b2 . . . bk bk+1 . . .)10 × 10e


We say that the number x is chopped to k digits when all digits following the kth digits are discarded; that
is, the digits bk+1 bk+2 . . . are chopped off to obtain fl(x) = (0.b1 b2 . . . bk )10 ×10e.
Conversely, x is rounded to k digits when fl(x) is obtained by choosing fl(x) nearest to x; that is, adding
one to bk ifbk+1 ≥ 5 and chop off all but the first k digits if bk+1 <5

II. TRUNCATION ERROR


A round-off error arises in terminating the decimal expansion and rounding. In contrast, the truncation
error terminates a process. So, the truncation error generally refers to the error involved in terminating
an infinite sequence or series after a finite number of terms that is, replacing non computable problems
with computable ones. To make the idea precise,
For example, the Maclaurin series for e x is given as
x2 x3
e  1 x 
x
  ....................
2! 3!
This series has an infinite number of terms but when using this series to calculate e x , only a finite number
of terms can be used. For example, if one uses three terms to calculate e x , then
x2
ex  1 x  .
2!
The truncation error for such an approximation is
 x2 

Truncation error = e  1  x x
,
 2! 
x3 x4
   .......................
3! 4!
But, how can truncation error be controlled in this example? We can use the concept of relative
approximate error to see how many terms need to be considered. Assume that one is calculating e1.2
using the Maclaurin series, then
1.2 2 1.2 3
e 1.2
 1  1.2    ...................
2! 3!

Pre. By. Gebresilassie H. Page 4 of 22


Let us assume one wants the absolute relative approximate error to be less than 1 %. In Table 1, we show
the value of e1.2 , approximate error and absolute relative approximate error as a function of the number of
terms n .
n e 1 .2 Ea a %
1 1 - -
2 2.2 1.2 54.546
3 2.92 0.72 24.658
4 3.208 0.288 8.9776
5 3.2944 0.0864 2.6226
6 3.3151 0.020736 0.62550
Using 6 terms of the series yields a a < 1%.
truncation error can take place in other mathematical procedures as well.
For example, to find the derivative of a function, we define
f x  x   f x 
f x   lim
x 0 x
But since we cannot use x  0, we have to use a finite value of x , to give
f ( x  x )  f ( x )
f ( x ) 
x
So the truncation error is caused by choosing a finite value of x as opposed to a x  0.
For example, in finding f (3) for f ( x)  x 2 , we have the exact value calculated as follows.
f ( x)  x 2
From the definition of the derivative of a function,
f ( x  x )  f ( x )
f ( x )  lim
x 0 x
( x  x)  ( x) 2
2
 lim
x 0 x
x 2  2 xx  (x) 2  x 2
 lim
x 0 x
 lim ( 2 x  x )  2 x
x 0

This is the same expression you would have obtained by directly using the formula from your differential
calculus class
d n
( x )  nx n1
dx
By this formula for
f ( x)  x 2
f ( x )  2 x
The exact value of f (3) is
f (3)  2  3  6
If we now choose x  0.2 , we get

Pre. By. Gebresilassie H. Page 5 of 22


f (3  0.2)  f (3)
f (3) 
0.2
f (3.2)  f (3) 3.2 2  3 2 10.24  9 1.24
 =    6.2
0.2 0.2 0.2 0.2
We purposefully chose a simple function f ( x)  x 2 with value of x  2 and x  0.2 because we
wanted to have no round-off error in our calculations so that the truncation error can be isolated. The
truncation error in this example is
6  6.2  0.2.
Can you reduce the truncate error by choosing a smaller x ?
Another example of truncation error is the numerical integration of a function,
b
I   f ( x)dx
a

Exact calculations require us to calculate the area under the curve by adding the area of the
rectangles as shown in Figure 2. However, exact calculations require an infinite number of such
rectangles. Since we cannot choose an infinite number of rectangles, we will have truncation error.
For example, to find
9

x
2
dx ,
3

we have the exact value as


9
9
 x3 
3 
2
x dx  
 3 3
 9 3  33 
   234
 3 
If we now choose to use two rectangles of equal width to approximate the area (see Figure 2) under the
curve, the approximate value of the integral
9

x dx  ( x 2 ) (6  3)  ( x 2 ) (9  6)
2
x 3 x 6
3

 (32 )3  (6 2 )3
 27  108  135
y

90

y = x2
60

30

0 x
0 3 6 9 12

Pre. By. Gebresilassie H. Page 6 of 22


Figure Plot of y  x 2 showing the approximate area under the curve from x  3 to x  9
using two rectangles.

Again, we purposefully chose a simple example because we wanted to have no round off error
in our calculations. This makes the obtained error purely truncation. The truncation error is
234  135  99
Can you reduce the truncation error by choosing more rectangles as given in Figure 3? What is the
truncation error?
y

90

y = x2
60

30

0 x
0 1.5 3 4.5 6 7.5 9 10.5 12

Figure Plot of y  x 2 showing the approximate area under the curve from x  3
to x  9 using four rectangles.

B. Quantifying the error

What is true error?


True error denoted by Et is the difference between the true value (also called the exact value) and the
approximate value.
True Error  True value – Approximate value
Relative true error
Relative true error is denoted by t and is defined as the ratio between the true error and the true value.
True Error
Relative True Error 
True Value
Approximate error
Approximate error is denoted by E a and is defined as the difference between the present approximation
and previous approximation.
Approximate Error  Present Approximation – Previous Approximation
Relative approximate error
Relative approximate error is denoted by a and is defined as the ratio between the approximate error
and the present approximation.
Approximat e Error
Relative Approximate Error 
Present Approximation
Example
The derivative of a function f (x) at a particular value of x can be approximately calculated by

Pre. By. Gebresilassie H. Page 7 of 22


f ( x  h)  f ( x)
f ( x) 
h
Of f (2) For f ( x)  7e 0.5 x and h  0.3 , find
a. The approximate value of f (2)
b. The true value of f (2)
c. The true error for part (a)
d. Relative true error at x  2 .
e. f (2) using h  0.3
f. f (2) using h  0.15
g. approximate error for the value of f (2) for part (f)
h. Relative approximate error in calculating f (2) using values from h  0.3 and h  0.15 .

Solution
a) The approximate value of f (2) b) The exact value of f (2) can be calculated by
f ( x  h)  f ( x ) using our knowledge of differential calculus.
f ( x) 
h f ( x)  7e 0.5 x
For x  2 and h  0.3 , f ' ( x)  7  0.5  e0.5 x  3.5e
0.5 x

f (2  0.3)  f (2)
f (2)  So the true value of f ' ( 2) is
0.3
f ' (2)  3.5e 0.5( 2)  9.5140
f (2.3)  f (2)
 c) True error is calculated as
0.3
Et = True value – Approximate value
7e 0.5 ( 2.3)
 7e 0.5 ( 2 )
  9.5140  10.265  0.722
0.3
22.107  19.028
  10.263
0.3
The magnitude of true error does not show how bad the error is. A true error of Et  0.722 may seem
to be small, but if the function given in the Example 1 were f ( x)  7  10 6 e 0.5 x , the true error in
6
calculating f (2) with h  0.3, would be Et  0.722  10 . This value of true error is smaller, even
when the two problems are similar in that they use the same value of the function argument, x  2 and
the step size, h  0.3 . This brings us to the definition of relative true error.
d) Relative true error is calculated as Absolute relative true errors may also need to be
True Error calculated.
t 
True Value
In such cases,
 0.722
 t | 0.075888 |
9.5140
 0.0758895 = 0.0758895
Relative true errors are also presented as = 7.58895 %
percentages. For this example,
t  0.0758895  100% e) The approximate expression for the
derivative of a function is
 7.58895%

Pre. By. Gebresilassie H. Page 8 of 22


f ( x  h)  f ( x ) f ( x  h)  f ( x)
f ' ( x)  . f ( x) 
h h
For x  2 and h  0.3 , For x  2 and h  0.15 ,
f (2  0.3)  f (2) f (2  0.15)  f (2)
f ' (2)  f ' (2) 
0.3 0.15
f (2.3)  f (2) f (2.15)  f (2)
 
0.3 0.15
7e 0.5 ( 2.3)
 7e 0.5 ( 2 )
7e 0.5 ( 2.15 )
 7e 0.5( 2)
 
0.3 0.15
22.107  19.028 20.50  19.028
  10.265   9.8799
0.3 0.15
f) Repeat the procedure of part (e) with
h  0.15,
g) So the approximate error, E a is
Ea  Present Approximation – Previous Approximation
 9.8799  10.265  0.38474
The magnitude of approximate error does not show how bad the error is . An approximate error of
Ea  0.38300 may seem to be small; but for f ( x)  7  10 6 e 0.5 x , the approximate error in calculating
6
f ' (2) with h  0.15 would be Ea  0.38474  10 . This value of approximate error is smaller, even
when the two problems are similar in that they use the same value of the function argument, x  2 , and
h  0.15 and h  0.3 . This brings us to the definition of relative approximate error.
h) The relative approximate error is calculated as
Approximat e Error
a 
Present Approximat ion
 0.38474
  0.038942
9.8799
Relative approximate errors are also presented as percentages. For this example,
a  0.038942  100%
=  3.8942 %
Absolute relative approximate errors may also need to be calculated. In this example
a  | 0.038942 |  0.038942 Or 3.8942%

1.3. Binary Representation of Numbers


After reading this chapter, you should be able to:
1. convert a base-10 real number to its binary representation,
2. Convert a binary number to an equivalent base-10 number.
In everyday life, we use a number system with a base of 10. For example, look at the number
257.56. Each digit in 257.56 has a value of 0 through 9 and has a place value. It can be written as

Pre. By. Gebresilassie H. Page 9 of 22


257.76  2  10 2  5  101  7  10 0  7  10 1  6  10 2
In a binary system, we have a similar system where the base is made of only two digits 0 and 1. So it is a
base 2 system. A number like (1011.0011) in base-2 represents the decimal number as
 
(1011.0011)2  (1  23  0  22  1  21  1  20 )  (0  21  0  22  1  23  1  24 ) 10
 11.1875
in the decimal system.
To understand the binary system, we need to be able to convert binary numbers to decimal
numbers and vice-versa.
We have already seen an example of how binary numbers are converted to decimal numbers. Let
us see how we can convert a decimal number to a binary number. For example take the decimal number
11.1875. First, look at the integer part: 11.
1. Divide 11 by 2. This gives a quotient of 5 and a remainder of 1. Since the remainder is 1,
a0  1 .
2. Divide the quotient 5 by 2. This gives a quotient of 2 and a remainder of 1. Since the
remainder is 1, a1  1 .
3. Divide the quotient 2 by 2. This gives a quotient of 1 and a remainder of 0. Since the
remainder is 0, a 2  0 .
4. Divide the quotient 1 by 2. This gives a quotient of 0 and a remainder of 1. Since the
remainder is, a3  1 .
Since the quotient now is 0, the process is stopped. The above steps are summarized in Table 1.

Table
Converting a base-10 integer to binary representation.
Quotient Remainder
11/2 5 1  a0
5/2 2 1  a1
2/2 1 0  a2
1/2 0 1  a3
Hence
(11)10  (a3 a2 a1a0 ) 2
 (1011) 2
For any integer, the algorithm for finding the binary equivalent is given in the flow chart on the next page.

Pre. By. Gebresilassie H. Page 10 of 22


Now let us look at the decimal part, that is, 0.1875.
1. Multiply 0.1875 by 2. This gives 0.375. The number before the decimal is 0 and the number
after the decimal is 0.375. Since the number before the decimal is 0, a 1  0 .
2. Multiply the number after the decimal, that is, 0.375 by 2. This gives 0.75. The number before
the decimal is 0 and the number after the decimal is 0.75. Since the number before the decimal is
0, a 2  0 .
3. Multiply the number after the decimal, that is, 0.75 by 2. This gives 1.5. The number before the
decimal is 1 and the number after the decimal is 0.5. Since the number before the decimal is 1,
a 3  1 .
4. Multiply the number after the decimal, that is, 0.5 by 2. This gives 1.0. The number before the
decimal is 1 and the number after the decimal is 0. Since the number before the decimal is 1,
a4  1 .
Since the number after the decimal is 0, the conversion is complete. The above steps are summarized in
Table 2.

Pre. By. Gebresilassie H. Page 11 of 22


Table Converting a base-10 fraction to binary representation
Number after Number before
Number
decimal decimal
0.1875  2 0.375 0.375 0  a 1
0.375  2 0.75 0.75 0  a2
0.75  2 1.5 0.5 1  a 3
0.5  2 1.0 0.0 1  a 4
Hence
(0.1875)10  (a1a 2 a 3a 4 ) 2
 (0.0011)2
The algorithm for any fraction is given in a flowchart on the next page.
Having calculated
(11)10  (1011) 2
and
(0.1875)10  (0.0011) 2 ,
we have
(11.1875)10  (1011.0011) 2 .

Pre. By. Gebresilassie H. Page 12 of 22


Start

Fraction F to be converted
Input (F) 10
to binary format

i  1

Multiply F by 2 to get number


before decimal, S and after
decimal, T

ai = R
i  i 1

Is T = 0?
No

Yes
n=i

(F) 10 = (a-
1 . . .a-n ) 2
STOP

In the above example, when we were converting the fractional part of the number, we were left with 0
after the decimal number and used that as a place to stop. In many cases, we are never left with a 0 after
the decimal number. For example, finding the binary equivalent of 0.3 is summarized in Table 3.

Table. Converting a base-10 fraction to approximate binary representation.


Number after Number before
Number
decimal decimal
0.3  2 0.6 0.6 0  a 1
0.6  2 1.2 0.2 1  a 2
0.2  2 0.4 0.4 0  a 3
0.4  2 0.8 0.8 0  a4
0.8  2 1.6 0.6 1  a 5

Pre. By. Gebresilassie H. Page 13 of 22


As you can see the process will never end. In this case, the number can only be approximated in binary
format, that is,
(0.3)10  (a 1a  2 a 3a  4 a 5 ) 2  (0.01001) 2
Q: But what is the mathematics behinds this process of converting a decimal number to binary format?
A: Let z be the decimal number written as
z  x. y
where
x is the integer part and y is the fractional part.
We want to find the binary equivalent of x . So we can write

x  an 2 n  an1 2 n1  ...  a0 2 0


If we can now find a0 ,. . ., a n in the above equation then
( x)10  (an an1 . . .a0 ) 2
We now want to find the binary equivalent of y . So we can write
y  b1 2 1  b2 2 2  ...  bm 2  m
If we can now find b1 ,. . ., bm in the above equation then
( y)10  (b1b2 . . .bm ) 2
Let us look at this using the same example as before.
Example 1
Convert (11.1875)10 to base 2.
Solution
To convert (11)10 to base 2, what is the highest power of 2 that is part of 11. That power is 3, as 2 3  8
to give
11  2 3  3
What is the highest power of 2 that is part of 3. That power is 1, as 21  2 to give
3  21  1
So
11  2 3  3  2 3  21  1
What is the highest power of 2 that is part of 1. That power is 0, as 2 0  1 to give
1  20
Hence
(11)10  23  21  1  23  21  20  1 23  0  2 2  1 21  1 20  (1011) 2
To convert (0.1875)10 to the base 2, we proceed as follows. What is the smallest negative power of 2
that is less than or equal to 0.1875. That power is  3 as 23  0.125 .
So

Pre. By. Gebresilassie H. Page 14 of 22


0.1875  23  0.0625
What is the next smallest negative power of 2 that is less than or equal to 0.0625? That power is  4 as
2 4  0.0625 .
So
0.1875  23  24
Hence
(0.1875)10  2 3  0.0625  2 3  2 4  0  2 1  0  2 2  1 2 3  1 2 4  (0.0011) 2
Since
(11)10  (1011) 2
and
(0.1875)10  (0.0011) 2
we get
(11.1875)10  (1011.0011) 2
Can you show this algebraically for any general number?
Example
Convert (13.875)10 to base 2.
Solution
For (13)10 , conversion to binary format is shown in Table 4.

Table 4. Conversion of base-10 integer to binary format.


Quotient Remainder
13/2 6 1  a0
6/2 3 0  a1
3/2 1 1  a2
1/2 0 1  a3
So
(13)10  (1101)2 .
Conversion of (0.875)10 to binary format is shown in Table 5.

Table Converting a base-10 fraction to binary representation.


Number after Number before
Number
decimal decimal
0.875  2 1.75 0.75 1  a1
0.75  2 1.5 0.5 1  a 2
0.5  2 1.0 0.0 1  a3

So
(0.875)10  (0.111) 2

Pre. By. Gebresilassie H. Page 15 of 22


Hence
(13.875)10  (1101.111)2

1.4 Taylor Theorem Revisited


After finishing this topic, you should be able to
1. understand the basics of Taylor’s theorem,
2. write transcendental and trigonometric functions as Taylor’s polynomial,
3. use Taylor’s theorem to find the values of a function at any point, given the values of the function
and all its derivatives at a particular point,
4. calculate errors and error bounds of approximating a function by Taylor series, and
5. Revisit the chapter whenever Taylor’s theorem is used to derive or explain numerical methods for
various mathematical procedures.
The use of Taylor series exists in so many aspects of numerical methods that it is imperative to devote a
separate chapter to its review and applications. For example, you must have come across expressions
such as
x2 x4 x6
cos(x)  1     (1)
2! 4! 6!
x3 x5 x7
sin( x)  x     (2)
3! 5! 7!
x2 x3
ex  1 x    (3)
2! 3!
All the above expressions are actually a special case of Taylor series called the Maclaurin series. Why
are these applications of Taylor’s theorem important for numerical methods? Expressions such as given
in Equations (1), (2) and (3) give you a way to find the approximate values of these functions by using the
basic arithmetic operations of addition, subtraction, division, and multiplication.

Example
Find the value of e 0.25 using the first five terms of the Maclaurin series.
Solution
The first five terms of the Maclaurin series for e x is
x2 x3 x4
ex 1 x   
2! 3! 4!
0.25 2 0.25 3 0.25 4
e 0.25  1  0.25   
2! 3! 4!
 1.2840
The exact value of e 0.25 up to 5 significant digits is also 1.2840.
But the above discussion and example do not answer our question of what a Taylor series is.
Here it is, for a function f x 
f x  2 f x  3
f x  h   f x   f x h  h  h  (4)
2! 3!

Pre. By. Gebresilassie H. Page 16 of 22


Provided all derivatives of f x  exist and are continuous between x and x  h .
What does this mean in plain English?
As Archimedes, would have said (without the fine print), “Give me the value of the function at a single
point, and the value of all (first, second, and so on) its derivatives, and I can give you the value of the
function at any other point”.
It is very important to note that the Taylor series is not asking for the expression of the function
and its derivatives, just the value of the function and its derivatives at a single point.
Now the fine print: Yes, all the derivatives have to exist and be continuous between x (the point where
you are) to the point, x  h where you are wanting to calculate the function at. However, if you want to
calculate the function approximately by using the n th order Taylor polynomial, then 1st ,2 nd ,...., n th
derivatives need to exist and be continuous in the closed interval[ x, x  h] , while the (n  1) th derivative
needs to exist and be continuous in the open interval ( x, x  h) .

Example 2
 
Take f x   sinx  , we all know the value of sin    1 . We also know the f x   cosx  and
2
   
cos   0 . Similarly, f x    sin(x) and sin   1 . In a way, we know the value of sinx  and
2 2

all its derivatives at x  . We do not need to use any calculators, just plain differential calculus and
2
trigonometry would do. Can you use Taylor series and this information to find the value of sin2 ?
Solution

x
2
xh2

h  2 x  2  0.42920
2
So
h2 h3 h4
f x  h   f x   f x h  f x   f x   f ( x) 
2! 3! 4!

x
2
h  0.42920
   
f x   sinx  , f    sin    1
2 2
 
f x   cosx  , f    0
2

Pre. By. Gebresilassie H. Page 17 of 22


 
f x    sinx  , f    1
2
 
f x    cos(x) , f    0
2
 
f x   sin(x) , f    1
2
Hence
        h   h   h
2 3 4
f   h   f    f  h  f    f    f   
2  2 2  2  2!  2  3!  2  4!
 
f   0.42920   1  00.42920  1
0.42920  0 0.42920  1 0.42920  
2 3 4

2  2! 3! 4!
 1  0  0.092106  0  0.00141393  
 0.90931
The value of sin2 I get from my calculator is 0.90930 which is very close to the value I just obtained.
Now you can get a better value by using more terms of the series. In addition, you can now use the value
calculated for sin2 coupled with the value of cos2 (which can be calculated by Taylor series just like
this example or by using the sin 2 x  cos2 x  1 identity) to find value of sinx  at some other point. In
this way, we can find the value of sinx  for any value from x  0 to 2 and then can use the
periodicity of sinx  , that is sinx   sinx  2n , n  1,2, to calculate the value of sinx  at any
other point.
Example 3
x3 x5 x7
Derive the Maclaurin series of sinx   x    
3! 5! 7!
Solution

In the previous example, we wrote the Taylor series for sinx  around the point x  . Maclaurin series
2
is simply a Taylor series for the point x  0 .
f x   sinx  , f 0  0
f x   cosx  , f 0  1
f x    sinx  , f 0  0
f x    cosx  , f 0  1
f x   sinx  , f 0  0
f x   cos(x) , f 0  1

Using the Taylor series now,


h2 h3 h4 h5
f x  h   f x   f x h  f x   f x   f x   f x   
2! 3! 4 5

Pre. By. Gebresilassie H. Page 18 of 22


h2 h3 h4 h5
f 0  h   f 0  f 0h  f 0  f 0  f 0  f
        0  
2! 3! 4 5
h2 h3 h4 h5
f h   f 0  f 0h  f 0
 f 0  f 0  f 0  
2! 3! 4 5
2 3 4 5
h h h h
 0  1h   0 1  0 1 
2! 3! 4 5
h3 h5
h  
3! 5!
So
x3 x5
f x   x   
3! 5!

x3 x5
sin  x   x    
3! 5!
Example 4
Find the value of f 6 given that f 4  125 , f 4  74 , f 4  30 , f 4  6 and all other higher
derivatives of f x  at x  4 are zero.
Solution
h2 h3
f x  h   f x   f x h  f x   f x   
2! 3!
x4
h  64  2
Since fourth and higher derivatives of f x  are zero at x  4 .
22 23
f 4  2  f 4  f 42  f 4  f 4
2! 3!
 2 2   23 
f 6  125  742  30   6 
 2!   3! 
 125  148  60  8  341
Note that to find f 6 exactly, we only needed the value of the function and all its derivatives at some
other point, in this case, x  4 . We did not need the expression for the function and all its derivatives.
Taylor series application would be redundant if we needed to know the expression for the function, as we
could just substitute x  6 in it to get the value of f 6 .
Actually, the problem posed above was obtained from a known function f x   x 3  3x 2  2 x  5
where f 4  125 , f 4  74 , f 4  30 , f 4  6 , and all other higher derivatives are zero.

Pre. By. Gebresilassie H. Page 19 of 22


Error in Taylor Series
As you have noticed, the Taylor series has infinite terms. Only in special cases such as a finite
polynomial does it have a finite number of terms. So whenever you are using a Taylor series to calculate
the value of a function, it is being calculated approximately.
The Taylor polynomial of order n of a function f (x) with (n  1) continuous derivatives in the domain
[ x, x  h] is given by
h2 n
f x  h   f x   f x h  f ' ' x   f n 
x  h  Rn  x 
2! n!
Where the remainder is given by

Rn x  
x  hn1 f n 1 c  .
(n  1)!
Where
xc xh
That is, c is some point in the domain x, x  h  .
Example 5
The Taylor series for e x at point x  0 is given by
x2 x3 x4 x5
ex  1 x     
2! 3! 4! 5!
a) What is the truncation (true) error in the representation of e1 if only four terms of the series are used?
b) Use the remainder theorem to find the bounds of the truncation error.
Solution
a) If only four terms of the series are used, then
x2 x3
ex  1 x  
2! 3!
12 13
e1  1  1  
2! 3!
 2.66667
The truncation (true) error would be the unused terms of the Taylor series, which then are
x4 x5
Et   
4! 5!
14 15
  
4! 5!
 0.0516152
b) But is there any way to know the bounds of this error other than calculating it directly? Yes,
n
f x  h   f x   f x h    f n 
x  h  Rn  x 
n!
Where

Rn x  
x  hn1 f n 1 c  , x  c  x  h , and
n  1!

Pre. By. Gebresilassie H. Page 20 of 22


c is some point in the domain x, x  h  . So in this case, if we are using four terms of the Taylor series,
the remainder is given by x  0, n  3

R3 x  
0  131 f 31 c 
3  1!
ec
f c  
1 4 

4! 24
Since
xc xh
0  c  0 1
0  c 1
The error is bound between
e0 e1
 R3 1 
24 24

 R3 1 
1 e
24 24
0.041667  R3 1  0.113261
So the bound of the error is less than 0.113261 which does concur with the calculated error of
0.0516152 .
Example 6
The Taylor series for e x at point x  0 is given by
x2 x3 x4 x5
ex  1 x     
2! 3! 4! 5!
As you can see in the previous example that by taking more terms, the error bounds decrease and hence
you have a better estimate of e1 . How many terms it would require to get an approximation of e1 within
a magnitude of true error of less than 10 6 ?
Solution
Using n  1 terms of the Taylor series gives an error bound of

Rn x  
x  hn1 f n 1 c 
n  1!
x  0, h  1, f ( x)  e x

Rn 0 
0  1
n 1
f n 1
c    1
n 1
ec
n  1! n  1!
Since
xc xh
0  c  0 1
0  c 1

Pre. By. Gebresilassie H. Page 21 of 22


 Rn 0 
1 e
(n  1)! (n  1)!
So if we want to find out how many terms it would require to get an approximation of e1 within a
magnitude of true error of less than 10 6 ,
e
 10 6
(n  1)!
(n  1)! 10 6 e
(n  1)! 10 6  3 (As we do not know the value of e but it is less than 3)
n9
So 9 terms or more will get e1 within an error of 10 6 in its value
We can do calculations such as the ones given above only for simple functions. To do a similar analysis
of how many terms of the series are needed for a specified accuracy for any general function, we can do
that based on the concept of absolute relative approximate errors discussed above as follows.
We use the concept of absolute relative approximate error, which is calculated after each term in the
series is added. The maximum value of m , for which the absolute relative approximate error is less than
0.5  10 2m %, is the least number of significant digits correct in the answer. It establishes the accuracy
of the approximate value of a function without the knowledge of remainder of Taylor series or the true
error.

Pre. By. Gebresilassie H. Page 22 of 22

You might also like