0% found this document useful (0 votes)
115 views9 pages

Computational Methods - Error Analysis

This chapter introduces numerical methods and error analysis. It discusses types of errors like round-off error and truncation error. It also discusses ways to reduce errors like rearranging polynomials into nested form to avoid cancellation errors during subtraction of nearly equal numbers. Numerical software is used to solve computational problems using numerical methods. Accuracy can be improved by changing the order of operations to minimize errors from rounding.

Uploaded by

Flagrant Bunny
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
115 views9 pages

Computational Methods - Error Analysis

This chapter introduces numerical methods and error analysis. It discusses types of errors like round-off error and truncation error. It also discusses ways to reduce errors like rearranging polynomials into nested form to avoid cancellation errors during subtraction of nearly equal numbers. Numerical software is used to solve computational problems using numerical methods. Accuracy can be improved by changing the order of operations to minimize errors from rounding.

Uploaded by

Flagrant Bunny
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 9

TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1

CHAPTER 1 INTRODUCTION

In this Chapter, you will learn:

 types of error,
 ways of error reduction,
 types of software that are used to solve computational problems using
numerical methods.

1. ERROR ANALYSIS

Definition of Error

An error, e in Numerical Mathematics is the difference between the actual value (Exact
value) and its computed value. If x* represents the computed value of a quantity, the
actual value for which is x, then the difference:

e  actual value - computed value


 x  x*

Ways of Error’s Measurement

 Absolute Error

eabs  actual value - computed value


 x  x*

 Relative Error
eabs
erel 
x
x  x*

x

KCY/NOORSHAHIDA/THL Page | 1
TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1

Types of Error

 Round-off Error

Rules for rounding off a number


(a) If a digit to be dropped is 0, 1, 2, 3 or 4: leave the next remaining digit unchanged.

(b) If a digit to be dropped is 5, 6, 7, 8 or 9: increase the next remaining digit by one.

Round-off error is an error to introduce by rounding off numbers to limited number


decimal places.

 Chopping Error

Number x is chopped to n digits when all digits that follow the n-th digit are
discarded and none of the remaining n digits is changed.

 Truncation Error

Truncation error is defined as the replacement of one series by another with fewer terms.
The error arising from this approximation is called the truncation error.
Example: The infinite Taylor Series

 
exp x 2  1  x 2 
x 4 x 6 x8
 
2! 3! 4!
 ... 
x 2n
n!
 ...

 
might be replaced with the first 5 terms: exp x 2  1  x 2 
x 4 x6 x8
 
2! 3! 4!

Example 1: Given an actual value, x = 1.485642 and its computed value, x* = 1.492101.
Find the following.
(a) Absolute error (b) Relative error

eabs
erel 
eabs  x  x * x
 1.485642  1.492101 0.006459

 - 0.006459 1.485642
 0.006459  0.00434762

KCY/NOORSHAHIDA/THL Page | 2
TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1

Example 2: Round-off the actual value, x = 22/7 to five decimal places and find its
absolute error.

22
x  3.142857143... eabs  x  x *
7
x*  ______________ 

Example 3: Chop the actual value, x = 22/7 to five decimal places and find its relative
error.

22 x  x*
x  3.142857143... erel 
7 x
x*  ______________ 

2. ERROR REDUCTION

Nested Form

A polynomial function is given in (2.1):

pn x   a0  a1 x  a2 x 2  ...  an1 x n1  an x n (2.1)

For polynomial evaluation, the rearrangement of terms into nested form will sometimes
produce a better result. In nested form, each power of x is factored out as far as it will go.
The nested form of a polynomial function is given in (2.2).

pn x   a0  a1 x  a2 x 2  ...  an1 x n1  an x n


 a0  xa1  xa2  ...  xan1  an x ...
(2.2)

KCY/NOORSHAHIDA/THL Page | 3
TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1

Example 4: Consider the following polynomial function with the given value x.

f x   x 3  6.1x 2  3.2 x  1.5; x  4.71

(a) Rewrite f x  in the nested form.

f x   x 3  6.1x 2  3.2 x  1.5


 x3.2  xx  6.1  1.5

(b) Find f x  in (a) according to three different evaluations below.

(i) Exact evaluation


polynomial function , f x   x 3  6.1x 2  3.2 x  1.5
f 4.71  4.71  6.14.71  3.24.71  1.5
3 2

 104.487111  6.122.1841  15.072  1.5


 104.487111  135.32301  15.072  1.5
 14.263899

nested form, f x   x3.2  xx  6.1  1.5


f 4.71  4.713.2  4.714.71  6.1  1.5  4.71 3.3469  1.5
 4.713.2  4.71 1.39  1.5  15.763899  1.5
 4.713.2  6.5469  1.5  14.263899

(ii) Three-digit rounding-off evaluation


polynomial function , f x   x 3  6.1x 2  3.2 x  1.5
f 4.71  4.71  6.14.71  3.24.71  1.5
3 2

 104  6.122.2  15.1  1.5


 104  135  15.1  1.5
 14.4

nested form, f x   x3.2  xx  6.1  1.5


f 4.71  4.713.2  4.714.71  6.1  1.5  4.71 3.35  1.5
 4.713.2  4.71 1.39  1.5  15.8  1.5
 4.713.2  6.55  1.5  14.3

KCY/NOORSHAHIDA/THL Page | 4
TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1

(iii) Three-digit chopping evaluation


polynomial function , f x   x 3  6.1x 2  3.2 x  1.5
f 4.71  4.71  6.14.71  3.24.71  1.5
3 2

 104  6.122.1  15  1.5


 104  134  15  1.5
 13.5
nested form, f x   x3.2  xx  6.1  1.5
f 4.71  4.713.2  4.714.71  6.1  1.5  4.71 3.34  1.5
 4.713.2  4.71 1.39  1.5  15.7  1.5
 4.713.2  6.54  1.5  14.2

(c) Find the relative error for the following

Polynomial Function

(i) Exact evaluation and the three-digit rounding-off evaluation

actual value, x  f 4.71  14.263899


computed value, x*  f 4.71  14.4
x  x*  14.263899  14.4 0.136101
erel     0.0095416
x  14.263899 14.263899

(ii)Exact evaluation and the three-digit chopping evaluation

actual value, x  f 4.71  14.263899


computed value, x*  f 4.71  13.5
x  x*  14.263899  13.5  0.763899 0.763899
erel      0.05355
x  14.263899 14.263899 14.263899

Nested Form

(i) Exact evaluation and the three-digit rounding-off evaluation

actual value, x  f 4.71  14.263899


computed value, x*  f 4.71  14.3
x  x*  14.263899  14.3 0.036101
erel     0.002531
x  14.263899 14.263899

KCY/NOORSHAHIDA/THL Page | 5
TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1

(ii)Exact evaluation and the three-digit chopping evaluation

actual value, x  f 4.71  14.263899


computed value, x*  f 4.71  14.2
x  x*  14.263899  14.2  0.063899 0.063899
erel     0.00448
x  14.263899 14.263899 14.263899

**Accuracy loss due to the round-off and chopping errors can be reduced by rearranging
the polynomial function into nested form.

Avoiding Loss of Significance in Subtraction

Loss of significance occurs when nearly equal numbers are subtracted. Consider two
numbers which are nearly equal, p  0.31415926536 and q  0.31415957341 .

p  q  0.31415926536  0.31415957341
 0.0000030805

After subtraction, their difference is  0.0000030805 with only FIVE decimal digits of
significance. This phenomenon is called loss of significance. There are various
techniques that can be used to avoid loss of significance such as the use of rationalization
and Taylor series.

 Rationalization
Rationalizing is removing the radical in the numerator or denominator:
f ( x)  x  4  2
( x  4  2)
= ( x  4  2)
( x  4  2)
x

( x  4  2)

As as result, this prodecure allows original terms to be cancelled off and thereby
removes the subtraction.

KCY/NOORSHAHIDA/THL Page | 6
TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1

Example 5: Consider the following function:


f ( x)  x( x  1  x )

i) Approximation of f (500) for given f ( x) correctly to six-digit and rounding:


f (500)  500( 501  500)
 500(22.3830  22.3607)
=11.1500

ii) Rewrite the given function in a way that avoids the loss of significance:
( x 1  x)
f ( x)  x( x  1  x ) *
( x 1  x)
x
=
x 1  x )

iii) Approximation of f (500) for f ( x) from (ii) correctly to six-digit and rounding:
500
f (500) 
501  500)
=11.1748

iv) Compare the results of (i) and (iii). The actual value is 11.1748.
For (i), eabs  x  x *  11.1748  11.1500  0.0248
For (ii), eabs  x  x *  11.1748  11.1748  0

**Accuracy loss due to the round-off can be reduced by avoiding loss of significant digits.

 The use of Taylor Series

Taylor series can be used to remove the subtraction from the nearly equal numbers’
subtraction. The terms can be converted into the Taylor series. The Taylor series
expansion for some Trigonometry functions is given in the following.

x3 x5
sin x  x    ...
3! 5!
x2 x4
cos x  1    ...
2! 4!
x3 2x5
tan x  x    ...
3 15

KCY/NOORSHAHIDA/THL Page | 7
TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1

Example 6: Consider the following function:

f ( x)  tan x  sin x

i) Rewrite the given function to avoid loss of significance by using first two nonzero
terms in the Taylor series expansion:

x3 x3
f ( x)  ( x  )  (x  )
3 3!

1
= x3
2

ii) Approximation of f (0.0125) for f ( x) from (i) correctly seven-digit and rounding:
1
f (0.0125)  (0.0125)3
2

= 106

iii) Find the absolute error given that actual value is 9.766 x107 .

KCY/NOORSHAHIDA/THL Page | 8
TRIMESTER 2 TMA1301 COMPUTATIONAL METHODS CHAPTER 1

3. INTRODUCTION TO SOFTWARE

Programming languages such as C, C++ and Java can be used to solve the numerical or
mathematical problems. However, interactive computing environments such as FreeMat,
Octave and MATLAB provide powerful, built-in mathematical capabilities and a very
high-level programming language for rapid mathematical problem solving. FreeMat is a
free open source numerical computing environment and programming language, similar
to MATLAB and GNU Octave. FreeMat integrates extensive mathematical capabilities,
especially in linear algebra, with powerful scientific visualization, a high-level
programming language and a variety of toolboxes.

FreeMat is chosen in this course due to the several reasons as stated below:

i) FreeMat supports many MATLAB functions and some IDL functionalities, it


features a codeless interface to external C and C++,
ii) Superior built-in documentation: FreeMat provides a good documentation.
iii) FreeMat is a free environment for rapid numerical computing, engineering and
scientific prototyping and data processing.
iv) FreeMat is user friendly for implementing matrix algebra based calculations.
v) Easier to pick up for the beginning users to learn and use the software to solve
the numerical problems.

KCY/NOORSHAHIDA/THL Page | 9

You might also like