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 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.
SIMPLE STATISTICS Arithmetic mean Standard deviation
Simple Statistics cont. Variance, sy2 Coefficient of variation
Pseudo Code Review for First Programming Assignment Raw Data Code Output Data
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
Pseudo Code Review for First Programming Assignment Raw Data Code Output Data 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.
Pseudo Code for Average 10 77.8 39.2 56.7 98.2 88.7 86.2 76.3 82.5 93.6 78.2 Data file input.dat Read an ASCII file that 1. Inputs number of students n 2. Inputs scores y(n)
Pseudo Code for Average DIMENSION Y OPEN INPUT.DAT READ N DO I=1,N READ Y(N) CONTINUE DO J=1,N SUM=SUM+Y(J) AVERAGE = SUM/N PRINT “AV”
PROBLEM Modify the pseudo-code to calculate the variance.
Approximation and Errors 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
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
increasing accuracy increasing precision
Error Definitions Numerical error - use of approximations to represent exact mathematical operations and quantities true value = approximation + error error, et=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. True relative percent error But we may not know the true answer apriori
Error definitions cont. May not know the true answer apriori This leads us to develop an iterative approach of numerical methods
Error definitions cont. Usually not concerned with sign, but with tolerance Want to assure a result is correct to n significant figures
Example Consider a series expansion to estimate trigonometric functions 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 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 derivative at another point Zero order approximation This is good if the function is a constant.
Taylor Series Expansion First order approximation 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
Taylor Series Expansion
Example Use zero through fourth order Taylor series expansion to approximate f(1) given f(0) = 1.2 (i.e. h = 1) Note: f(1) = 0.2
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 = p/4 and xi+1 = p /3 h = p /3 - p /4 = p /12
Functions with infinite number of derivatives Zero order f(p /3) = cos (p/4 ) = 0.707 et = 41.4% First order f(p /3) = cos (p/4 ) - sin (p/4 )(p/12) et = 4.4% Second order f(p /3) = 0.498 et = 0.45% By n = 6 et = 2.4 x 10-6 %
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
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 et for each approximation.