Sie sind auf Seite 1von 10

Chapter 1

Numbers, Errors andAccuracy





1.1 Introduction

Numerical Methods are widely used by scientists and engineers to solve problems. To
perform calculations in Numerical Methods, different calculating devices such as
calculators, computers are available. Most of these calculating devices work on
numbers with a fixed word length (usually 10 digits).But this does not mean that every
calculation done by them are correct to this accuracy. We have to use these devices in
such a way that it gives the best possible result closer to the exactvalue.
Numerical calculations involve errors due to the use of approximate values instead of
exact values and due to the methods used are also approximate. Numerical analysis
deals with the approximate solution of the problems and the effect of errors in
numerical calculations.


1.2 Representation of Numbers

1.2.1 Length of Numbers

Numbers used in calculations are usually approximate because they have been
truncated after a chosen number of digits. For example, 3333 . 1 and 14159 . 3 are
approximate values of
3
4
and t respectively. In counting the length of a number we use
decimal places or significant digits.

Decimal places (d.p.): The number of digits counted after the decimal marker.
Significant figures (s.f.): All digits including zero are counted from the first non-
zero digit.

Two common ways of reducing a number to a specified length are as follows:

Chopping: After a fixed number of digits, the remaining digits are dropped
maintaining the place value of the numbers.
Rounding: The last retained digit is corrected up (added 1) if the succeeding digit
is greater than or equal to 5, otherwise chopped off maintaining the
place value of the numbers.

For example
2.30498 = 2.3, correct to 1 d.p./2 s.f = 2.30, correct to 2 d.p./3 s.f.
= 2.305, correct to 3 d.p./4 s.f. = 2.3050, correct to 4 d.p./5 s.f.
2 Introduction to NUMERICAL METHODS

1.2.2 Numbers in Standard Form

Numbers with very large or very small magnitude are difficult both to write and
manipulate and they are usually written in standard form. Many electronic calculators
also display their numbers in standard form. To express a number in standard form,
shift the decimal point to the right of the first non-zero digit, and then multiply by the
correct power of 10.
For example,

5
10 45 . 3 345000 =

4
10 7 . 6 00067 . 0

=

1.3 Review of Taylor Series

The Taylor series is frequently used in numerical analysis and it will be reviewed now.

Taylors Theorem:Let ) (x f have ) 1 ( + n continuous derivatives in ] , [ b a . Then for
] , [ b a c e , the Taylors expansion about c x = is
) , ( ) (
!
) (
) (
! 2
) (
) ( ) ( ) ( ) (
) (
2
x R c f
n
c x
c f
c x
c f c x c f x f
n
n
n
+

+ + ' '

+ ' + =
for some between x and c.
The term ) , ( x R
n
is the remainder term. The Lagranges form of the remainder is
) (
! ) 1 (
) (
) , (
) 1 (
1

+
+
+

=
n
n
n
f
n
c x
x R
In order to get an infinite series to represent ) (x f , it is necessary and sufficient to
show that 0 ) , ( x R
n
as n .
In special case,where 0 = c , the Taylor series is also called the Maclaurin series.
Some familiar and useful series are
+ + + + =
! 3 ! 2
1
3 2
x x
x e
x
for all real x
+ =
! 4 ! 2
1 cos
4 2
x x
x for all real x
+ =
! 5 ! 3
sin
5 3
x x
x x for all real x
+ = +
3 2
) 1 ln(
3 2
x x
x x ) 1 1 ( s < x
+ + = +
3 2 1
1 ) 1 ( x x x x ) 1 1 ( < < x

+

+

+ + = +
3 2
! 3
) 2 )( 1 (
! 2
) 1 (
1 ) 1 ( x x x x
o o o o o
o
o
, ) 1 1 ( < < x
The last series is the general Binomial expansion which terminates for positive integral
values of o.


CHAPTER 1: Numbers, Errors and Accuracy 3
1.4 Errors Analysis

1.4.1 Error Measurement

Numerical calculations can be in error due to the use of approximate values in the
calculation. The following definitions are used in measuring the errors.

Absolute error = |True value Approximate value|
Relative error =
value True
value Approx. value True
value True
error Absolute
=
Percentage of error = Relative error 100 %

Note that in absence of true value an approximate relative error, ,
a
e can be estimated
by using the relation
100
ion approximat Current
on appoximati Previous ion approximat Current

= e
a


1.4.2 Rounding Error

If 2.326 is a number rounded to 3 d.p., the true value o is
3265 . 2 3255 . 2 < so or 0005 . 0 326 . 2 = o
Thus the maximum absolute error is
3
2
1
10 0005 . 0

= ,
In general,if a number is rounded to n decimal places, the maximum absolute error
is
n
10
2
1
.

Consider two numbers 235.3 and 0.003267 which are rounded to 4 s.f.. The errors can
be estimated as follows
For 235.3, the relative error is
3
2
1
3
2
1
2
1
2
1
10
353 . 2
10
10 353 . 2
10


<


For 0.003267. the relative error is
3
2
1
3
2
1
3
6
2
1
10
267 . 3
10
10 267 . 3
10

<


In general, if a number is rounded to n significant figures the maximum relative
error is
1
2
1
10
+

n
.

1.4.3 Chopping Error

In chopping a number like 34.5678 upto 2 decimal places will be 34.56 and the error is

2
10 78 . 0 0078 . 0

=
From the above example it can be seen that when a number is chopped off after n
decimal places, the absolute error is

n
r

10 where 1 0 < s r .
The maximum value of r is 1.
Thus, if a number is chopped off after n decimal places, the maximum absolute
error is
n
10 1 .
4 Introduction to NUMERICAL METHODS


1.4.4 Truncation Error

Truncation errors arise when a complicated mathematical expression is replaced by a
simple expression. This terminology originated from the technique of replacing a
function with a finite number of terms instead of the infinite Taylor series. For
example, consider the integral

}

5 . 0
0
2
dx e
x

By truncating the infinite series
+ + =

! 3 ! 2
1
6 4
2
2
x x
x e
x

with only 4 terms, we have
dx
x
x dx e
x
} }
|
|
.
|

\
|
+ ~

5 . 0
0
4
2
5 . 0
0
2
1
2

=
10
03125 . 0
3
125 . 0
5 . 0
10 3
5 . 0
0
5 3
+ =
(
(

+
x x
x
= 461458 . 0 (to 6 d.p.)
The exact value of the integral is 461281 . 0 (to 6 d.p.).
Thus using only three terms of the infinite series we have
Truncation error = 461458 . 0 461281 . 0
=
4
10 69 . 1



1.5Accuracy in Calculation

The accuracy of any computation is always of great importance. In numerical analysis
our aim is to get the best possible accuracy using the available facilities.
The rounding off error is half of the error obtained in chopping. Thus it is preferable to
use rounding rather than chopping in the arithmetic operations when both options are
available.
In a numerical calculation, continuous rounding off to a fixed number of digits may
affect the last digit of the number. Thus at each stage of the computation retain at least
one extra digit than the required number of digits and then round off in the final result.

1.5.1 Computer Accuracy

Most computers do arithmetic operations using the binary number system. But we
communicate with the computer (input/output) in base 10 numbers. For this purpose
floating-point mode for numbers are used in scientific and engineering applications.
Floating-point representation gives the maximum number of significant figures by
shifting the decimal point to the left of the first non-zero digit with appropriate power
of 10.

For example,

CHAPTER 1: Numbers, Errors and Accuracy 5
23400 is represented as
5
10 234 . 0
34 . 2 is represented as 10 234 . 0
000234 . 0 is represented as
3
10 234 . 0


Digital computers permit two or three types of number representation:

single precision (6 to 7 significant decimal digits)
double precision (13 to 14 digits)
extended precision ( 19 to 20 digits)


1.5.2 Calculator Accuracy

Scientific calculators work with eight to twelve digits.But this does not mean that every
displayed results are correct to this accuracy. In normal mode we may loose some of
the significant digits and hence the accuracy may be lost. Accuracy and number of
significant digits of the calculations can be increased by using scientific mode of the
calculator. In scientific mode, a real number is denoted by standard form. For example,

4
10 34 . 2 23400 = ,
4
10 34 . 2 000234 . 0

=



1.5.3 Cancellation Effects

Consider two numbers a = 2.141326 and b = 2.141314 which are correct to 7
significant digits,but the difference 000012 . 0 = b a is correct to only 2 significant
digits.
The subtraction of two nearly equal numbers may cause a poor accuracy in numerical
calculation. This is called loss of significance due to the cancellation of significant
digits.
For example, consider the values of

2
) cos( 1
) (
x
x
x f

=
for small values of x. Using a microcomputer that has 8 digits of accuracy, we have

0001 . 0
99995000 . 0 1
) 01 . 0 (
) 01 . 0 cos( 1
) 01 . 0 (
2

=

= f
5 . 0
10 1 . 0
10 5 . 0
3
4
=


The result is accurate to 1 significant digit. By using the Taylor series expansion for cos
x, we have

(
(

|
|
.
|

\
|
+ + =

=
! 6 ! 4 ! 2
1 1
1 cos 1
) (
6 4 2
2 2
x x x
x x
x
x f
+ =
720 24 2
1
4 2
x x


Using the above series with two terms, we have
6 Introduction to NUMERICAL METHODS
49999583 . 0 00000417 . 0 5 . 0
24
) 01 . 0 (
2
1
) 01 . 0 (
2
= = = f
The results is the same as that obtained by rounding the true answers
4725 4999958333 . 0 to 8 digits.
Some of the techniques that can be used to reduce the loss of significance in subtraction
are rationalization, Taylor series expansion, logarithmic properties, rearrangement of
terms in the function, etc.

For example,

(a) Near 0 = x ,
|
|
.
|

\
|
+ =
! 5 ! 3
sin
5 3
x x
x x x x
+ =
! 5 ! 3
5 3
x x

(b) For large x,
|
.
|

\
|
+ = +
x
x x
1
1 ln ln ) 1 ln(
+ =
3 2
3
1
2
1 1
x x
x

.

(c) For b ac b ~ 4
2
with 0 > b , we can use

ac b b
ac b b
a
ac b b
a
ac b b
4
4
2
4
2
4
2
2 2 2

+
=
+


ac b b
c
4
2
2


This avoids the subtraction of two nearly equal numbers.

Example 1.2
Use the familiar quadratic formula ) 2 ( ) 4 ( /
2
a ac b b x = to find the roots of
the quadratic equation 0 1 9876
2
= + x x using your calculator that carries only
few decimal digits. Investigate the example, and also find the roots correct to ten
significant figures .

Solution: The exact solutions are

2
4 ) 9876 ( 9876
2
1
+
= x and
2
4 ) 9876 ( 9876
2
2

= x
and the roots correct to 12 significant figures are
99989874 . 9875
1
= x
4
2
10 4 0125557009 . 1

= x
Using calculator with ten-digits,

3 2
10 875999797 . 9 999797 . 9875 4 ) 9876 ( = =
and the roots are
CHAPTER 1: Numbers, Errors and Accuracy 7
9999 . 9875
1
= x 0001015 . 0
2
= x

3
10 875999900 . 9 =
4
10 015000000 . 1

=
Note that
2
x involves subtraction of nearly two equal numbers and gives result with
fewer correct digits. To obtain a more accurate approximation for
2
x , we may use the
rationalization of the numerator. In this case

4 ) 9876 ( 9876
4 ) 9876 ( 9876
2
4 ) 9876 ( 9876
2
2 2
2
+
+


= x

4
2
10 012555701 . 1
4 9876 ( 9876
2

=
+
=
which is correct to 10 significant digits.

1.6Numerical Methods Using Spreadsheet

Microsoft Excel is a very powerful and widely used spreadsheet. For our numerical
calculations we shall use MS Excel.

1.6.1 A Short Introduction to Spreadsheet

Spreadsheets are made up of
- columns (designated by letters)
- rows (designated by numbers)
- cells (intersections of columns and rows)
A B C D E
1
2
3
4 C4
5

Data Entry: There are three types of data that can be entered in a cell.

data types examples descriptions
LABEL Solution text for caption
CONSTANT 3.245 fixed numerical data
FORMULA =2*sin(a2)+2 for calculation

* All formulas MUST begin with an equal sign (=).
* Most of the common functions are available in MS Excel with usual name.
The function name can be typed in either upper or lower case, but Excel
displays it in upper case.
List of functions can be searched by clicking
x
f select a category
Select a function.


8 Introduction to NUMERICAL METHODS
Copy and Paste: Copy and Paste or by highlighting and dragging contents of the cell
can be copied to other cells.
When a formula is copied, the cell references may change based on the type of
reference used.

Type of references:
Relative reference: The address of a cell based on the relative position of the cell
that contains the formula.
Absolute reference: This is used to keep the cell references unchanged after
copying to another cell. The $ sign before column letter is used to make
column fixed and $ symbol before row number is used to make row fixed.

A B C D E
1
2 1 =SIN(A$2)
3


4
5 =SIN(C$2)

The table below shows the changes when the formula in cell B2 is copied to D5.

Formula in B2 Descriptions Changes when
copied to D5
=SIN(A2) Relative column and row =SIN(C5)
=SIN(A$2) Relative column and absolute row =SIN(C$2)
=SIN($A2) Absolute column and relative row =SIN($A5)
=SIN($A$2) Absolute column and absolute row =SIN($A$2)


IF commands

The conditional command IF has the general form
IF(logical_test, value_if_true, value_if_false)

A B C D
1 x y Is x>= y Cell entry in C
2 8 2 8 if(a2>=b2, a2, "No")
3 3 4 No if(a3>=b3, a3, "No")

1.6.2 Numerical Calculations Using MS Excel

For illustration we shall compute the value of e (exponential) using the exponential
series
+ + + + + + = =
!
1
! 3
1
! 2
1
! 1
1
1 ) 1 exp(
n
e
The Excel calculation of e using partial sums

!
1
! 3
1
! 2
1
! 1
1
1
n
S
n
+ + + + + =

Excel Entry Excel Output
CHAPTER 1: Numbers, Errors and Accuracy 9
A B A B
1 n S
n
1 n S
n

2 0 1 2 0 1
3 1 =B2+1/FACT(a3) 3 1 2
4 2 4 2 2.5
5 3 5 3 2.666666667
6 4 2.708333333


7 5 2.716666667
8 6 2.718055556
9 7 2.718253968
10 8 2.71827877
11 9 2.718281526
12 10 2.718281801
13 11 2.718281826
14 12 2.718281828
15 13 2.718281828


1.6.3Drawing Graphs using MS Excel

For example,consider the graphs of x x f cos 7 ) (
1
= and x x f 2 1 ) (
2
= .

Excel Worksheet Entry for data Creating Chart (Graph)
A B C 1 Tabulate the data values.
1 x f
1
(x) f
2
(x) 2 Select data range (cells A2:C14)
2 -6 =7*cos(A2) =1-2*A2 3 In the Insert menu, select Chart
3 -5 4 In the Chart Wizard, select Char type:
4 XY (Scatter) and Chart sub-type :
5 Select Finish to complete the diagram.
Excel Results 6 Change the size of the diagram by dragging
A B C and change the background color (optional)
1 x f
1
(x) f
2
(x) 7 Place the diagram in the desired location
2 -6 6.721192 13 by dragging.
3 -5 1.985635 11
4 -4 -4.575505 9
5 -3 -6.929947 7
6 -2 -2.913028 5
7 -1 3.782116 3
8 0 7 1
9 1 3.782116 -1
10 2 -2.913028 -3
11 3 -6.929947 -5
12 4 -4.575505 -7
13 5 1.985635 -9 There are three intersections and hence
14 6 6.721192 -11 the number of real roots is three.
-15
-10
-5
0
5
10
15
-10 -5 0 5 10









10 Introduction to NUMERICAL METHODS
Exercise 1


1. The number 135 is given to 3 significant figures and the number 4.7 is given to 2
significant figures. Find
(a) the maximum value, (b) the minimum value, (c) the relative error, (d) the
absolute error, for
(i) the sum 135 47, (ii) the quotient 135/47.

2. State the maximum errors in the following numbers which are correct to the
significant figures given.
(a) 32.23 (b) 0.00235 (c) 5.00245 (d) 98 (e) 47000

3. Compare the results of calculating f(500) and g(500) using 6 digits and rounding,
where
] 1 [ ) ( x x x x f + = and
x x
x
x g
+ +
=
1
) (
Given that the true value in each case is 11.1747553 (to 9 s.f.).

4. Calculate ) 01 . 0 ( f for the function 1 ) ( = x e x f
x
correct to 5 significant figures.
Use 0101 . 1
01 . 0
~ e .

5. Find a way to calculate x x x f + = 2 ) ( correctly when x is large.
Determine ) 1000 ( f correct to 8 decimal places (rounded).

6. Use 4 digits arithmetic with rounding to determine the roots of the quation
0 1 1 . 82
2
= + x x as accurately as possible.

7. Use 5 digits arithmetic with rounding to determine the roots of the equation
0 3 205 2
2
= + x x correct to 5 significant figures. Use 94 . 204 42001 ~ .

8. Obtain the roots of the equation 0 7 23456
2
= + x x , correct to 9 significant
figures.

Das könnte Ihnen auch gefallen