Error - Civil and Environmental Engineering | SIU

Download Report

Transcript Error - Civil and Environmental Engineering | SIU

NUMERICAL ERROR

ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier

Copyright © 2003 by Lizette R. Chevalier Permission is granted to students at Southern Illinois University at Carbondale to make one copy of this material for use in the class ENGR 351, Numerical Methods for Engineers. No other permission is granted.

All other rights are reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the copyright owner.

Objectives

• • To understand error terms Become familiar with notation and techniques used in this course

Approximation and Errors Significant Figures

• • • • • 4 significant figures • 1.845

• 0.01845

• 0.0001845

43,500 ? confidence 4.35 x 10 4 3 significant figures 4.350 x 10 4 4.3500 x 10 4 4 significant figures 5 significant figures

Accuracy and Precision

• • Accuracy - how closely a computed or measured value agrees with the true value Precision - how closely individual computed or measured values agree with each other • number of significant figures • spread in repeated measurements or computations

Accuracy and Precision

increasing accuracy

Error Definitions

• • Numerical error - use of approximations to represent exact mathematical operations and quantities true value = approximation + error • error, e t =true value - approximation • subscript

t

represents the true error • shortcoming....gives no sense of magnitude • normalize by true value to get true relative error

Error definitions cont.

e

t

true error true value

 100 • True relative percent error

Example

Consider a problem where the true answer is 7.91712. If you report the value as 7.92, answer the following questions.

1. How many significant figures did you use?

2. What is the true error?

3. What is the relative error?

Error definitions cont.

• May not know the true answer apriori e

a

approximat e error approximat ion

 100

Error definitions cont.

• May not know the true answer apriori e

a

approximat e error approximat ion

 100 • This leads us to develop an iterative approach of numerical methods

Error definitions cont.

• May not know the true answer apriori e

a

approximate error

 100

approximation

• This leads us to develop an iterative approach of numerical methods e

a

 

approximat e error

 100

approximat ion present approx

.

previous present approx

.

approx

.

 100

Error definitions cont.

• • Usually not concerned with sign, but with tolerance Want to assure a result is correct to significant figures

n

Error definitions cont.

• • Usually not concerned with sign, but with tolerance Want to assure a result is correct to significant figures

n

e

a

e

s

  e

s

 0 .

5  10 2 

n

 %

Example

Consider a series expansion to estimate trigonometric functions sin

x

x

x

3 3 !

x

5 !

5 

x

7 7 !

 .....

  

x

  Estimate sin p / 2 to three significant figures

Error Definitions cont.

• Round off error - originate from the fact that computers retain only a fixed number of significant figures • Truncation errors - errors that result from using an approximation in place of an exact mathematical procedure

Error Definitions cont.

• • Round off error - originate from the fact that computers retain only a fixed number of significant figures Truncation errors - errors that result from using an approximation in place of an exact mathematical procedure

To gain insight consider the mathematical formulation that is used widely in numerical methods - TAYLOR SERIES

TAYLOR SERIES

• • Provides a means to predict a function value at one point in terms of the function value at and its derivatives at another point Zero order approximation

TAYLOR SERIES

• • Provides a means to predict a function value at one point in terms of the function value at and its derivative at another point Zero order approximation

f

 

i

1 

f

 

i

This is good if the function is a constant.

Taylor Series Expansion

• First order approximation

f

 

i

1 

f

 

i

f

'  

i x i

 1 

x i

 slope multiplied by distance

Taylor Series Expansion

• First order approximation

f

 

i

1 

f

 

i

f

'  

i x i

 1 

x i

 slope multiplied by distance Still a straight line but capable of predicting an increase or decrease - LINEAR

Taylor Series Expansion

• Second order approximation - captures some of the curvature

Taylor Series Expansion

• Second order approximation - captures some of the curvature

f

 

i

1 

f

 

i

f

'  

i x i

 1 

x i

 

f

' '   2 !

x i x i

 1 

x i

 2

Taylor Series Expansion

f

 

i

1 

f

 

i

f

'  

i h

f

''  

i h

2 2 !

f

' ''  

i h

3 3 !

 ......

f n

 

i h n n

!

R n where h

step size

x i

 1 

x i

Taylor Series Expansion

f

 

i

1 

f

 

i

f

'  

i h

f

''  

i h

2 2 !

f

' ''  

i h

3 3 !

 ......

f n

 

i h n n

!

R n where h

step size

x i

 1 

x i R n

 

f

n n

 1   1     !

h n

 1

x i

  

x i

 1

Example

Use zero through fourth order Taylor series expansion to approximate f(1) given f(0) = 1.2 (i.e. h = 1)     .

x

4  0 15

x

3 

x

2 

x

 Note: f(1) = 0.2

1.4

1.2

1 0.8

0.6

0.4

0.2

0 0 0.2

0.4

0.6

0.8

1 x

Solution

• • n=0 • f(1) = 1.2

• e t = abs [(0.2 - 1.2)/0.2] x 100 = 500% n=1 • f '(x) = -0.4x

3 - 0.45x

2 -x -0.25

• f '(0) = -0.25

• f(1) = 1.2 - 0.25

h • e t =375% = 0.95

Solution

• • n=2 • f "=-1.2 x 2 • f "'(0)=-0.9

• f(1) = 0.3

• e t =50% - 0.9x -1 • f "(0) = -1 • f(1) = 0.45

• n=3 e t = 125% • f "'=-2.4x - 0.9

Solution

• • • • n=4 • f ""(0) = -2.4

• f(1) = 0.2 EXACT Why does the fourth term give us an exact solution?

The 5th derivative is zero In general, nth order polynomial, we get an exact solution with an nth order Taylor series

Solution

1.4

1.2

1 0.8

0.6

0.4

0.2

0 0 True Solution Zero Order 1st Order 2nd Order 3rd Order 0.2

0.4

0.6

x 0.8

1 1.2

Exam Question

How many significant figures are in the following numbers?

A. 3.215

B. 0.00083

C. 2.41 x 10 -3 D. 23,000,000 E. 2.3 x 10 7

Taylor Series Problem

Use zero- through fourth-order Taylor series expansions to predict f(4) for f(x) = ln x using a base point at x = 2. Compute the percent relative error e t for each approximation.

1.6

1.4

1.2

1 0.8

0.6

0.4

0.2

0 0 1 2 3 4 5 x

 

i

1   

i

f

'  

i

f

' '  

i h

2 2 !

 . . . . . .

where h

f n

 

i h n n

!

step size

 

R n x i

 1 

x i f

' ' '  

i h

3 3 !

 1. Determine the step size h = 4 - 2 = 2 2. Determine the analytical solution f(4) = ln(4) = 1.3863

3. Determine the derivatives for f(2)