0% found this document useful (0 votes)
111 views8 pages

Chapter 1 Introduction: in This Chapter, You Will Learn

This chapter introduces computational methods. It discusses types of errors like round-off error and truncation error. Absolute and relative errors are defined. Methods to reduce errors are presented, including rearranging polynomials into nested form and avoiding loss of significance in subtraction. Round-off and chopping errors can be reduced by using nested forms when evaluating polynomials.

Uploaded by

Arvin 97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views8 pages

Chapter 1 Introduction: in This Chapter, You Will Learn

This chapter introduces computational methods. It discusses types of errors like round-off error and truncation error. Absolute and relative errors are defined. Methods to reduce errors are presented, including rearranging polynomials into nested form and avoiding loss of significance in subtraction. Round-off and chopping errors can be reduced by using nested forms when evaluating polynomials.

Uploaded by

Arvin 97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

TMA1301 Computational Methods

Chapter 1: Introduction

CHAPTER 1 INTRODUCTION
In this Chapter, you will learn:

 the types of error,


 how to reduce the error,
 the usage of MATLAB software in solving mathematical problems.

1.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

e|¿|=|actual value−computed value|¿


¿|x−x ¿|

 Relative Error

e|¿|
e rel = ¿
| x|
|x−x ¿|
¿
|x|

Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6 th Edition, 1
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 1: Introduction

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 nth 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
4
2 2 x x6 x8 x2 n
exp ( x )=1+ x + + + +…+ +…
2 ! 3! 4 ! n!

x4 x6 x8
might be replaced with the first 5 terms:exp ( x 2 )=1+ x 2 + + +
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


e|¿|=|x− x |¿
¿

¿|1.485642−1.492101|
¿|−0.006459|
¿ 0.006459

(b) Relative error


e
e rel = |¿| ¿
| x|
0.006459
¿
|1.485642|
¿ 0.00434762

Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6 th Edition, 2
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 1: Introduction

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

22
x= =3.142857143 …
7
x ¿=3.14286

e|¿|=|x− x |¿
¿

¿|3.142857143−3.14286|
¿|−0.000002857|
¿ 0.000002857

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

22
x= =3.142857143 …
7
x ¿=3.14285

e|¿|
e rel = ¿
| x|
|3.142857143−3.14285|
¿
|3.142857143|
|0.000007143|
¿
|3.142857143|
0.000007143
¿
3.142857143
¿ 0.000002272

1.2 ERROR REDUCTION

Nested Form

A polynomial function is given in (2.1):

pn ( x ) =a0 +a 1 x +a2 x 2+ …+an−1 xn −1 +a n 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 +a 1 x +a2 x 2+ …+an−1 xn −1 +a n x n

Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6 th Edition, 3
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 1: Introduction

¿ a0 + x ( a1+ x ( a2+ …+ x ( an−1 +an x ) … ) ) (2.2)

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

f ( x )=x 3−6.1 x 2 +3.2 x +1.5 ; x=4.71

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

f ( x )=x 3−6.1 x 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.1 x 2 +3.2 x +1.5
3 2
f ( 4.71 )=( 4.71 ) −6.1 ( 4.71 ) + 3.2 ( 4.71 )+1.5
¿ 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−6.1 x 2 +3.2 x +1.5


f ( 4.71 )=4.71 ( 3.2+ 4.71 ( 4.71−6.1 ) ) +1.5
¿ 4.71 ( 3.2+ 4.71 (−1.39 ) ) +1.5
¿ 4.71 ( 3.2−6.5469 )+1.5
¿ 4.71 (−3.3469 ) +1.5
¿−15.763899+ 1.5
¿−14.263899

(ii) Three-digit rounding-off evaluation


polynomial function, f ( x )=x 3−6.1 x 2 +3.2 x +1.5
f ( 4.71 )=( 4.71 )3 −6.1 ( 4.71 )2+ 3.2 ( 4.71 )+1.5
¿ 104−6.1 ( 22.2 )+15.1+1.5
¿ 104−135+15.1+1.5
¿−14.4

nested form, f ( x )=x 3−6.1 x 2 +3.2 x +1.5


f ( 4.71 )=4.71 ( 3.2+ 4.71 ( 4.71−6.1 ) ) +1.5
¿ 4.71 ( 3.2+ 4.71 (−1.39 ) ) +1.5
¿ 4.71 ( 3.2−6.55 )+1.5
¿ 4.71 (−3.35 ) +1.5

Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6 th Edition, 4
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 1: Introduction

¿−15.8+1.5
¿−14.3

(iii) Three-digit chopping evaluation


polynomial function, f ( x )=x 3−6.1 x 2 +3.2 x +1.5
3 2
f ( 4.71 )=( 4.71 ) −6.1 ( 4.71 ) + 3.2 ( 4.71 )+1.5
¿ 104−6.1 ( 22.1 )+15+ 1.5
¿ 104−134+15+1.5
¿−13.5

nested form, f ( x )=x 3−6.1 x 2 +3.2 x +1.5


f ( 4.71 )=4.71 ( 3.2+ 4.71 ( 4.71−6.1 ) ) +1.5
¿ 4.71 ( 3.2+ 4.71 (−1.39 ) ) +1.5
¿ 4.71 ( 3.2−6.54 ) +1.5
¿ 4.71 (−3.34 )+1.5
¿−15.7+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
e rel = = = =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
e rel = = = = =0.05355
|x| |−14.263899| 14.263899 14.263899

Nested Form

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

Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6 th Edition, 5
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 1: Introduction

actual value, x=f ( 4.71 )=−14.263899


¿
computed value, x =f ( 4.71 ) =−14.3
¿
| x−x | |−14.263899+14.3| 0.036101
e rel = = = =0.002531
|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 ) =−14.2
| x−x ¿| |−14.263899+14.2| |−0.063899| 0.063899
e rel = = = = =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 a result, this procedure allows original terms to be cancelled off and thereby removes the
subtraction.

Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6 th Edition, 6
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 1: Introduction

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 ( x )=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), e|¿|=|x− x |=|11.1748−11.1500|=0.0248¿


¿

For (iii), e|¿|=|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.

Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6 th Edition, 7
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7
TMA1301 Computational Methods
Chapter 1: Introduction

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 1 3
( )(
f ( x ) = x+
3
− x−
3! 2
= x )
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 ×10−7.

e|¿|=|x− x |¿
¿

¿|9.766 × 10−7−10−6|
¿−2.34 ×10−8

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 MATLAB,
Maple and Mathematica provide powerful, built-in mathematical capabilities and a very high-
level programming language for rapid mathematical problem solving. One of the most widely
used computing environments is MATLAB, which is a proprietary product of The MathWorks,
Inc. MATLAB, which stands for MATrix LABoratory, is an interactive system that integrates
extensive mathematical capabilities, especially in linear algebra, with powerful scientific
visualization, a high-level programming language and a variety of toolboxes.

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

i) Consistency: Functions have been commented by several researchers are highly consistent in
MATLAB, making it easier to return to coding in MATLAB after a break.
ii) Superior built-in documentation: MATLAB provides a good documentation.
iii) Existing packages and models: it seems like MATLAB is well established as substantial
existing code to guide subsequent researchers.
iv) MATLAB 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.

Adapted from
Ward Cheney, David Kincaid, (2008) Numerical Mathematics and Computing, 6 th Edition, 8
Brooks/Cole Cengage Learning, ISBN 0-534-8993-7

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy