+ All Categories
Home > Documents > NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale...

NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale...

Date post: 19-Dec-2015
Category:
View: 223 times
Download: 3 times
Share this document with a friend
Popular Tags:
29
NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier
Transcript
Page 1: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

NUMERICAL ERROR

ENGR 351

Numerical Methods for Engineers

Southern Illinois University Carbondale

College of Engineering

Dr. L.R. Chevalier

Page 2: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Copyright© 1999 by Lizette R. Chevalier

Permission is granted to students at Southern Illinois University at Carbondaleto make one copy of this material for use in the class ENGR 351, NumericalMethods 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, withoutthe prior written permission of the copyright owner.

Page 3: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

SIMPLE STATISTICS

Arithmetic mean Standard deviation

21

2

21

1

......

n

yys

n

yyy

n

yy

iy

ni

Page 4: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Simple Statistics cont.

100..

1

2

2

y

sVC

n

yys

y

iy

Variance, sy2

Coefficient of variation

Page 5: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Pseudo Code Review for First Programming Assignment

Raw

Dat

a

Cod

e

Out

put D

ata

Page 6: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

ASCII• Acronym for American Standard Code for

Information Interchanged• Pronounced ask-key• Also referred to as a text file

– Generate in C++, Fortran, Basic, etc. editors– Generate in Notepad– Can generate in Word, but need to save as a text file

• Executable programs are never stored in ASCII format

Page 7: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Pseudo Code Review for First Programming Assignment

Raw

Dat

a

Cod

e

Out

put D

ata

These are in ASCII format, unless you are using an executable version of your code. In that case, only the data (input and output) are ASCII format.

Page 8: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Pseudo Code for Average

Read an ASCII file that1. Inputs number of students n2. Inputs scores y(n)

1077.839.256.798.288.786.276.382.593.678.2

Data fileinput.dat

Page 9: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

DIMENSION YOPEN INPUT.DATREAD NDO I=1,NREAD Y(N)CONTINUEDO J=1,NSUM=SUM+Y(J)CONTINUEAVERAGE = SUM/NPRINT “AV”

Pseudo Code for Average

Page 10: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

PROBLEM

Modify the pseudo-code to calculate the variance.

1

2

2

n

yys i

y

Page 11: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Approximation and ErrorsSignificant Figures

• 4 significant figures– 1.845– 0.01845– 0.0001845

• 43,500 ? confidence

• 4.35 x 104 3 significant figures

• 4.350 x 104 4 significant figures

• 4.3500 x 104 5 significant figures

Page 12: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

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

Page 13: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

increasing accuracyin

crea

sing

pre

cisi

on

Page 14: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Error Definitions

• Numerical error - use of approximations to represent exact mathematical operations and quantities

• true value = approximation + error– error, 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

Page 15: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Error definitions cont.

100valuetrue

errortruet

• True relative percent error• But we may not know the true answer apriori

Page 16: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Error definitions cont.• May not know the true answer apriori

a

approximate error

approximation 100

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

100.

..

100

approxpresentapproxpreviousapproxpresent

ionapproximaterroreapproximat

a

Page 17: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Error definitions cont.

• Usually not concerned with sign, but with tolerance

• Want to assure a result is correct to n significant figures

%105.0 2 ns

sa

Page 18: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Example

Consider a series expansion to estimate trigonometricfunctions

xxxx

xx .....!7!5!3

sin753

Estimate sin / 2 to three significant figures

Page 19: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

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

Page 20: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

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

ii xfxf 1

This is good if the function is a constant.

Page 21: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Taylor Series Expansion

• First order approximation

slope multiplied by distance

Still a straight line but capable of predicting an increase or decrease - LINEAR

iiiii xxxfxfxf 11 '

Page 22: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Taylor Series Expansion

• Second order approximation - captures some of the curvature

2111 !2

''' ii

iiiiii xx

xfxxxfxfxf

Page 23: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Taylor Series Expansion

ii

nni

n

iiiii

xxsizestephwhere

Rhn

xf

hxf

hxf

hxfxfxf

1

......

321

!

!3

'''

!2

'''

Page 24: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Taylor Series Expansion

1

11

1

......

321

!1

!

!3'''

!2''

'

iin

n

n

ii

nni

n

iiiii

xxhn

fR

xxsizestephwhere

Rhn

xf

hxf

hxf

hxfxfxf

Page 25: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Example

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

f x 01 015 0 5 0 25 1 24 3 2. . . . .x x x x

-1

-0.5

0

0.5

1

1.5

0 0.5 1 1.5

x

f(x)

Note:f(1) = 0.2

Page 26: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Functions with infinite number of derivatives

• f(x) = cos x

• f '(x) = -sin x

• f "x) = -cos x

• f "'(x) = sin x

• Evaluate the system where xi = /4 and xi+1

= /3

• h = /3 - /4 = /12

Page 27: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

Functions with infinite number of derivatives

• Zero order– f( /3) = cos (/4 ) = 0.707 t = 41.4%

• First order– f( /3) = cos (/4 ) - sin (4 )(/12) t = 4.4%

• Second order– f( /3) = 0.498 t = 0.45%

• By n = 6 t = 2.4 x 10-6 %

Page 28: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

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 107

Page 29: NUMERICAL ERROR ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.

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 t for each approximation.


Recommended