Introduction - Computer Errors.pdf

17
GENG4405 Numerical Methods and Modelling Arcady Dyskin

Transcript of Introduction - Computer Errors.pdf

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 1/17

GENG4405

Numerical Methods andModellingArcady Dyskin

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 2/17

GENG4405 Slide 2

Topics

• Computer arithmetic. Truncation and roundofferrors

• Matrices

• Linear equations. Methods of solution

• Ill-conditioned matrices

• Interpolation and curve fitting

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 3/17

GENG4405 Slide 3

Errors

• Types of errors• Computer arithmetic. Truncation and roundoff

errors

• Example. Numerical differentiation• Example. Unstable algorithm

Absolute error r r ar

!="

Relative errora

r r

r

r r

!"!=#

Here r is the exact value, r a is an approximate value

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 4/17

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 5/17

GENG4405 Slide 5

Example. Compression of a

layered sampleUniaxial loading oflayered material(glass layers) stress vs strain - glass1

01020304050607080

0 0.002 0.004 0.006 0.008

strain

s t r e s s

( M P a

)

Stress-strain curve (courtesy Glen Snowen)

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 6/17

GENG4405 Slide 6

Tangential modulus

!"#"$

!#

=!d d E )(

-20000

-10000

0

10000

20000

30000

40000

50000

60000

70000

80000

0 10 20 30 40 50 60 70 80

! [10 -6]

E (! )[MPa]

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 7/17

GENG4405 Slide 7

Types and sources of errors• Human/Faulty equipment errors (can be corrected)

– Checks and verifications

• Errors of measurements – Systematic

• Calibration

– Random• Repeated measurements• Statistical treatment

• Truncation/Roundoff errors – Computer arithmetic – Small – Double precision computations

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 8/17

GENG4405 8

Computer arithmetic. Truncation

and roundoff errorsThe floating-point arithmetic

Real numbers are usually represented in computers by floating-point numbers F. They are characterised by: the number base " , the precision t and the exponentrange [ L, U ].

U e Lt id d d d

xi

e

t

t !!="#!!#$%%&

'(()

*

#

++

#

+

#

±= ,,,1,10,221 …!

If d 1#0 (for x#0), then the floating-point number system F is normalised . The integere is called the exponent

t t d d f !++!= …

1is the mantissa (fraction)

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 9/17

GENG4405 Slide 9

Precision PC

Real (real*4) mode ! = = = = "2 24 123 123, , ,t U L Double precision (real*8) mode, ! = = = = "2 53 1023 1023, , ,t U L

Real (real*4) mode ! = = = =

"10 7 38 38, , ,t U L Double precision (real*8) mode, ! = = = = "10 16 308 308, , ,t U L

Any real number x is replaced in a computer by the closest number, fl ( x), from F

The relative error in rounding ( x#0): t

x x x fl !"#

! 1

21)(

In decimal system it would approximately correspond to

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 10/17

GENG4405 Slide 10

Influence of small errors

• Catastrophic cancellation – Loss of accuracy due to subtraction of close numbers

0.123456-0.123455=0.000001 (only one significant digit left)

– Numerical differentiation

• Unstable algorithms• Sensitive models

– Ill conditioned systems (next two chapters)

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 11/17

GENG4405 Slide 11

Unstable algorithms.

Example: Moment of inertia

x

y

Non-homogeneous material

1)( !

= x

e x "

1 m

1 m

2

1

0

12 E dxe x I x y != " #

! "=

1

0

2 )( dx x x I y

Relative density distribution

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 12/17

GENG4405 Slide 12

Moments of inertia for different

shapes

x

y

1 m

1 m

3

1

0

13 E dxe x I x y != " #

x 1 m

4

1

0

14 E dxe x I x y != " #

y

1 m

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 13/17

GENG4405 Slide 13

General case

E n

= x n e x! 1 dx > 00

1

"

Integration by parts gives the following direct recurrent formula

632120.01

1,1 01 !"="=

"

e E nE E

nn

x 1 m

y

1 m

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 14/17

GENG4405 Slide 14

Calculations

Computer with " =10and t =6

n

Recurrent

formula Exact

2 0.264242 0.264241

3 0.207274 0.2072774 0.170904 0.170893

5 0.14548 0.14533

6 0.12712 0.126802

7 0.11016 0.1123848 0.11872 0.100932

9 -0.06848 0.091612

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 15/17

GENG4405 Slide 15

Analysis of recurrent computation

of inertia moments

!"#=!"#=

!"#=!""#"#=

!"+=!"+"#=

!#=

!+=

362880!9

6207274.023264242.031

2264242.02367879.021

367879.0

63212.0

999

3

2

1

0

exact exact E E E

E

E

E

E

!

Initial roundoff error 610368.0 !"#$

The error of 9-th step is 0.133> E 9exact

This algorithm is unstable – error accumulation

11 !!=

nn nE E

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 16/17

Stable algorithm

• Note• Inverse recurrent formula

• Error is damped• Start with• This approximation has an error not greater than 1/21.• When the 9th term is approached, the initial error is divided

by• It becomes less than• The obtained result is• The relative error is about

E n ! 1

=

1 ! E n

n

E 20

! 0

20 !19 !…!10 = 3628801.3 ! 10 " 7

E 9

! 0.09161123

1.4 ! 10 " 6

GENG4405 16

E n

= x n e x! 1 dx <

0

1

" x n dx =1

n + 10

1

"

8/14/2019 Introduction - Computer Errors.pdf

http://slidepdf.com/reader/full/introduction-computer-errorspdf 17/17

GENG4405 Slide 17

Summary• Errors

– Measurements – Computational

• Computer arithmetic• Truncation and roundoff errors

• Controlled by precision - formula• Catastrophic cancellation

– Subtraction of close numbers

• Unstable algorithms – Simple methods could lead to catastrophic accumulation of errors