Sunteți pe pagina 1din 24

CHE338_Lecture#2

Approximation and Errors

For reading
Reference
Chapra

Chapter
3

Page
52-77

Objectives

To introduce computer numbers (binary floating-point


numbers)

To introduce round-off errors

To introduce machine epsilon

Numerical errors
Numerical methods generate:
approximate solutions that are close to the exact
solutions (analytical solutions).
Exact numerical errors are difficult to be computed:
a) Given input data from measurements are not
exact

b) Numerical algorithm itself generate errors such


as round-off errors.

, e, or 7
3.14159265...

Accuracy and Precision

Errors related to both calculations and measurements


are described:
How close is a computed or measured value
to the true value

How close is a computed or measured value


to previously computed or measured values.
A systematic deviation from the actual value.
Magnitude of scatter.

Accuracy and precision

Lets say
49Km/h is exact.
Read the meter 10
times.

Significant digits (figures)


Number of significant figures indicates precision. Significant digits of
number are those that can be used with confidence, e.g., the number
of certain digits plus one estimated digit.
To present numbers with how precise your measurements or
predications are

48.9
49.0
49.8
.
.
.

Significant digits (figures)


Number of significant figures indicates precision. Significant digits of
number are those that can be used with confidence, e.g., the number
of certain digits plus one estimated digit.

5.38
5.380
5.3800

Zeros are sometimes used to locate the decimal point not significant
figures.
0.00001753
0.0001753
0.001753

37.
37000
7

Significant digits (figures)


Number of significant figures indicates precision. Significant digits of
number are those that can be used with confidence, e.g., the number
of certain digits plus one estimated digit.

5.38 x 104
5.380 x 104
5.3800x 104

Zeros are sometimes used to locate the decimal point not significant
figures.
0.00001753
0.0001753
0.001753

Definition of errors
Example 3.1 (Textbook): Measuring the lengths of a
bridge and a rivet
True length of the bridge: 10,000cm
Measured length: 9999cm

True length of the rivet: 10cm

Measured length: 9cm

Definition of Numerical errors


To account for the magnitude of the quantities

No true solution (analytical solution) is given. To numerically


find solutions close to true values, we use approximated
approaches to represent exact mathematical operations and
physical quantities
This leads to errors in solutions.
10

Definition of Numerical errors


No true solution (analytical solution) is given. To find
solutions to close to true solutions, we use approximated
approaches to represent exact mathematical operations and
physical quantities

Approximat e error
a
100%
Approximat ion
Iterative approach to find a solution, example
Newtons method

11

Tolerance
Stopping Criterion:

Specified tolerance, user defined

If the following condition is met, then

s (0.5 10

(2 -n)

)%

Say that the results is correct


to at least n significant figures.

12

Example 2.1 (Example 3.2 in the textbook)


2

x
x
x
e 1 x
2 3
n!
x

Exponential function can be represented by the


following infinite series.
Error=approximation +error

Adding more terms in sequence leads to a


better estimate of the function.

13

Example 2.1 (Example 3.2 in the textbook)


2
3
n
x
x
x
ex 1 x
2 3
n!

Evaluated at x=0.5 and at least three significant figures,


0.05%)

s (0.5 10

(2 -n)

)%

How many terms should be added ?

14

Errors: Round-off
Representation of numbers by computer:
Numbers then can be expressed by a finite
number of significant digits

, e, or 7
3.14159265...

Numbers stored in a binary format (2-base)

Fractional quantities stored in floating point form

15

Binary numbers
10-base numbers are mostly used for mathematical operations.

16

Binary numbers
10-base numbers are mostly used for mathematical operations.
1563=(1x103)+(5x102)+(6x101)+(3x10o)
2-base

1563=(1x210)+(1x29) )+(0x28) )+(0x27) +(0x26) +(0x25)


+(1x24) +(1x23) +(0x22) +(1x21) +(1x20)
1563=11000011011two

16-bit computer for -173


17

Floating-point (machine number) for real numbers


General floating-point form:
exponent

m.be
mantissa

Base of the number system


used

for a base-10 system


for a base-2 system

0.1 m<1
0.5 m<1

18

Floating-point (machine number) for real numbers


Four decimal digit (4 bit) for mantissa with the exponent
of -3,-2,---,4.

A finite set of numbers can be represented


19

Example 2.2 (Example 3.5 in the textbook)


Lets say: if you are only allowed to have a system:
+/-

+/-

21

20

2-1

2-2

2-3

10-BASE

0.062500

0.078125

0.01562
5

0.093750

(e=-3)

0.109375

0.125000

0.156250

0.187500

0.218750

Gap (interval)
x
Smallest

0.015625
0.03125
(e=-2)

Largest
20

Floati
Floating-point
(machine number) for real numbers

Floating point representation allows both fractions


and very large numbers to be expressed on the
computer.
Floating point numbers take up more room.
Take longer to process than integer numbers.
Round-off errors are introduced because
mantissa holds only a finite number of significant
figures.

21

Floating-point (machine number) for real numbers


Floati

Round-off errors due to a finite number of quantities


that can be presented within the limited range. Thus,
Some numbers can not precisely matched (limited
precision) referred as quantizing errors.

Example:
p=3.14159265358 to be stored on a base-10 system
carrying 7 significant digits.
p=3.141592 chopping error

t=0.00000065

p=3.141593 rounded

t=0.00000035
22

Machine epsilon
The interval (x) increases as x ( the numbers in
magnitude) increases. This means the quantizing errors
are proportional to the magnitude of the numbers.

For chopping

For rounding

For chopping with 2-base and t =3, then


23

Summary

Normalized Binary floating number (m2e)

Quantizing errors and round-off errs

Machine epsilon

x
x

24

S-ar putea să vă placă și