(3.) Approximation and Errors (Part 1)

Preview:

DESCRIPTION

A and E

Citation preview

1

CHE338_Lecture#2

For reading

Reference Chapter Page

Chapra 3 52-77

Approximation and Errors

2

Objectives

To introduce computer numbers (binary floating-point

numbers)

To introduce round-off errors

To introduce machine epsilon

3

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.

...14159265.3

7,,

ore

4

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.

5

Accuracy and precision

Let’s say

49Km/h is exact.

Read the meter 10

times.

6

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

.

.

.

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 3

5.380

5.3800

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

0.00001753 4

0.0001753

0.001753

37.

37000

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 x 104 3

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

9

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

10

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.

11

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

%100ionApproximat

error eApproximat

a

Iterative approach to find a solution, example

Newton’s method

12

Tolerance

Stopping Criterion:

)%n)-(2

s 10 (0.5Say that the results is correct

to at least n significant figures.

Specified tolerance, user defined

If the following condition is met, then

13

Example 2.1 (Example 3.2 in the textbook)

!321

32

n

xxxxe

nx

Error=approximation +error

Adding more terms in sequence leads to a

better estimate of the function.

Exponential function can be represented by the

following infinite series.

14

Example 2.1 (Example 3.2 in the textbook)

!321

32

n

xxxxe

nx

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

0.05%)

How many terms should be added ?

)%n)-(2

s 10 (0.5

15

Errors: Round-off

Representation of numbers by computer:

...14159265.3

7,,

oreNumbers then can be expressed by a finite

number of significant digits

Numbers stored in a binary format (2-base)

Fractional quantities stored in “floating point” form

16

Binary numbers

10-base numbers are mostly used for mathematical operations.

17

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

18

Floating-point (machine number) for real numbers

General floating-point form:

em.bexponent

Base of the number system

used

mantissa

for a base-10 system 0.1 ≤m<1 for a base-2 system 0.5 ≤m<1

19

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

20

Example 2.2 (Example 3.5 in the textbook)

Let’s say: if you are only allowed to have a system:

+/- +/- 21 20

2-1

2-2

2-3

10-BASE Gap (interval)

∆x

0 1 1 1 1 0 0 0.062500 Smallest 0.01562

5

(e=-3)

0 1 1 1 1 0 1 0.078125

0 1 1 1 1 1 0 0.093750

0 1 1 1 1 1 1 0.109375 0.015625

0 1 1 0 1 0 0 0.125000 0.03125

(e=-2) 0 1 1 0 1 0 1 0.156250

0 1 1 0 1 1 0 0.187500

0 1 1 0 1 1 1 0.218750

: : : : : : : :

0 0 1 1 1 1 1 7 Largest

21

Floati

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.

Floating-point (machine number) for real numbers

22

Floati Floating-point (machine number) for real numbers

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

23

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

24

Normalized Binary floating number (m2e)

Quantizing errors and round-off errs

Machine epsilon

Summary

x

x

Recommended