Math.375 Fall 2005 4. Errors in Numerical Computation Vageli Coutsias.

Slides:



Advertisements
Similar presentations
Theory of Measurements and Errors
Advertisements

3- 1 Chapter 3 Introduction to Numerical Methods Second-order polynomial equation: analytical solution (closed-form solution): For many types of problems,
Introduction to Matlab
Roundoff and truncation errors
Suggested problems from text (6 th edition) Chapter 3.1 p85 Problems 1, 4, 9, 10 Computer problems 1, 2, 4, 7 Chapter 3.2 p101 Problems 4, 15, 17, 19 Computer.
2009 Spring Errors & Source of Errors SpringBIL108E Errors in Computing Several causes for malfunction in computer systems. –Hardware fails –Critical.
Accuracy and Precision in the Lab. Precision and Accuracy Errors in Scientific Measurements Precision - Refers to reproducibility or “How close the measurements.
Measurements and Numbers
Numerical Computation
Introduction to Scientific Computing ICE / ICE 508 Prof. Hyuckjae Lee KAIST- ICC
Total Recall Math, Part 2 Ordinary diff. equations First order ODE, one boundary/initial condition: Second order ODE.
ECIV 201 Computational Methods for Civil Engineers Richard P. Ray, Ph.D., P.E. Error Analysis.
Approximations and Errors
COS 323: Computing for the Physical and Social Sciences Szymon Rusinkiewicz.
Round-Off and Truncation Errors
1 Part 3 Truncation Errors (Supplement). 2 Error Propagation How errors in numbers can propagate through mathematical functions? That is, what's the effect.
Lecture 2: Numerical Differentiation. Derivative as a gradient
Computer-Aided Analysis on Energy and Thermofluid Sciences Y.C. Shih Fall 2011 Chapter 6: Basics of Finite Difference Chapter 6 Basics of Finite Difference.
COS 323: Computing for the Physical and Social Sciences Szymon Rusinkiewicz.
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Numerical Analysis ECIV 3306 Chapter 3 Approximations and Errors.
Second Term 05/061 Part 3 Truncation Errors (Supplement)
1 Error Analysis Part 1 The Basics. 2 Key Concepts Analytical vs. numerical Methods Representation of floating-point numbers Concept of significant digits.
Ch 8.1 Numerical Methods: The Euler or Tangent Line Method
MTH16_Lec-14_sec_10-1_Infinite_Series.pptx 1 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical &
Lecture 2 Number Representation and accuracy
Warm Up 1. How many miles is 870,655 in? (Hint: There are 5,280 ft in 1 mile). 2. Do you weigh yourself? Which scale would you use? Why? How do you know.
MATH 685/CSI 700 Lecture Notes Lecture 1. Intro to Scientific Computing.
An Introduction to Programming and Algorithms. Course Objectives A basic understanding of engineering problem solving process. A basic understanding of.
ES 240: Scientific and Engineering Computation. Chapter 4 Chapter 4: Errors Uchechukwu Ofoegbu Temple University.
Taylor’s Polynomials & LaGrange Error Review
Truncation Error and the Taylor Series
Round-off Errors.
9.3 Taylor’s Theorem: Error Analysis for Series
Chapter 3 Math Toolkit. 3.1~3.2 Significant Figures & in Arithmetic.
MECN 3500 Inter - Bayamon Lecture 3 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
9.7 and 9.10 Taylor Polynomials and Taylor Series.
Introduction to Scientific Computing - - A Matrix Vector Approach Using Matlab Written by Charles F.Van Loan 陈 文 斌 // ORG: 复旦大学 (Revised.
Uncertainty in Measurement
Numerical Methods.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 3.
Sensitivity derivatives Can obtain sensitivity derivatives of structural response at several levels Finite difference sensitivity (section 7.1) Analytical.
Meeting 15 Introduction to Numerical Methods Error Analysis.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 7.
Lecture 4 - Numerical Errors CVEN 302 June 10, 2002.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 8.
Numerical Analysis CC413 Propagation of Errors.
Chapter 3- Model Fitting. Three Tasks When Analyzing Data: 1.Fit a model type to the data. 2.Choose the most appropriate model from the ones that have.
Negative binary numbers 1 Computer Architectures M.
Errors in Numerical Methods
INTRO TO OPTIMIZATION MATH-415 Numerical Analysis 1.
Uncertainty2 Types of Uncertainties Random Uncertainties: result from the randomness of measuring instruments. They can be dealt with by making repeated.
9.3 Taylor’s Theorem: Error Analysis yes no.
Taylor series are used to estimate the value of functions (at least theoretically - now days we can usually use the calculator or computer to calculate.
ESO 208A/ESO 218 LECTURE 2 JULY 31, ERRORS MODELING OUTPUTS QUANTIFICATION TRUE VALUE APPROXIMATE VALUE.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 6.
Univariate Point Estimation Confidence Interval Estimation Bivariate: Linear Regression Multivariate: Multiple Regression 1 Chapter 4: Statistical Approaches.
Numerical Analysis CC413 Propagation of Errors. 2 In numerical methods, the calculations are not made with exact numbers. How do these inaccuracies propagate.
MTH16_Lec-14_sec_10-1_Infinite_Series.pptx 1 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical &
Chapter 2 Errors in Numerical Methods and Their Impacts.
NUMERICAL ANALYSIS I. Introduction Numerical analysis is concerned with the process by which mathematical problems are solved by the operations.
The Taylor Polynomial Remainder (aka: the Lagrange Error Bound)
Taylor series in numerical computations (review)
Chapter 2 ERROR ANALYSIS
Math.375 Fall 2005 I - Numbers and Formats
Theory of Measurements and Errors
Math.375 Fall 2005 Errors in Numerical Computation
Topic 11: Measurement and Data Processing
9.3 Taylor’s Theorem: Error Analysis for Series
Math.375 Fall 2005 I - Numbers and Formats
Math 375 Fall Functions Vageli Coutsias.
Presentation transcript:

Math.375 Fall Errors in Numerical Computation Vageli Coutsias

Types of errors in numerical computation Roundoff errors Pi = Pi = Truncation errors Cos x = 1 – x^2/2 Cos x = 1 – x^2/2 + x^4/4! Errors usually accumulate randomly (random walk) But they can also be systematic, and the reasons may be subtle!

x = linspace(1-2*10^-8,1+2*10^-8,401); f = x.^7-7*x.^6+21*x.^5-35*x.^4+35*x.^3-21*x.^2+7*x-1; plot(x,f) CANCELLATION ERRORS

g = -1+x.*(7+x.*(-21+x.*(35+x.*(-35+x.*(21+x.*(-7+x)))))); plot(x,g)

h = (x-1).^7; plot(x,h)

plot(x,h,x,g,x,f)

z(1) = 0; z(2) = 2; for k = 2:29 z(k+1) = 2^(k-1/2)*(1-(1-4^(1-k)*z(k)^2)^(1/2))^(1/2); end semilogy(1:30,abs(z-pi)/pi)

% Plot derivative error vs. h % to exhibit optimal step clear fname = 'sin'; fname1= 'cos'; delta = eps; hmin = 10^6*eps; hmax = 10^10*eps; xmax = 1; x=pi/4; M2=1; % estimate for second derivative hopt = 2*sqrt(delta/M2);% h for minimum error yopt = (M2/2)*hopt+2*delta/hopt; d = (feval(fname,x+hopt)-feval(fname,x))/hopt;

h = linspace(hmin,hmax,1000); y1 = (M2/2)*h; % truncation error y2 = 2*delta./h; % roundoff error y = y1 + y2; % total error derivh =(feval(fname,x+h) - feval(fname,x))./h; abserr = abs(feval(fname1,x)-derivh); loglog(h,y,h,y1,h,y2,h,abserr,hopt,yopt,'bo'); xlabel(sprintf('hopt = %3.2d, d%s(%3.2d)/dx=… %3.2d +/-%3.2d',hopt,fname,x,d,err)) ylabel('abserr, maxerr') title(sprintf('derivative error as function of h … for %s(x)',fname)) axis([hmin hmax 10^(-12) 10^(-4)])

Vocabulary Consistency – correctness - … Convergence (rate) Efficiency (operation counts) Numerical Stability (error amplification) Accuracy (relative vs. absolute error) Roundoff vs. Truncation

Due to limitations in computer arithmetic, need to practice “defensive coding”. Mathematics  numerics + implementation The sequence of computations carried out for the solution of a mathematical problem can be so complex as to require a mathematical analysis of its own correctness. How can we determine efficiency? TextText

Recurrence relations

Instability is inescapable; But one can learn to ride it!

APPENDIX NUMERICAL MONSTERS: a collection of curious phenomena exhibited by computations at the limit of machine precision

The first monster: T(x) = e^x * log(1+e^-1) For x>30 a dramatic deviation from the theoretical value 1 is found. For x>36.7 the plotted value drops (incorrectly) to zero Here: x = linspace(0,40,1000); y = exp(x).*log(1+exp(-x)); for k=1:50, term = x*term/k; s = s+term;err(k) = abs(f(k) - s);end relerr = err/exp(x); semilogy(1:nTerms,relerr)% semilogy(1:nTerms,err) ylabel('Relative Error in Partial Sum.') xlabel('Order of Partial Sum.') title(sprintf('x = %5.2f',x)) figure semilogy(1:nTerms,err)%end term = 1; s = 1; f = exp(x)*ones(nTerms,1); for k=1:50, term = x*term/k; s = s+term; err(k) = abs(f(k) - s); end relerr = err/exp(x); semilogy(1:nTerms,relerr)% semilogy(1:nTerms,err) ylabel('Relative Error in Partial Sum.') xlabel('Order of Partial Sum.') title(sprintf('x = %5.2f',x)) figure semilogy(1:nTerms,err)%end for k=1:50, term = x*term/k; s = s+term;err(k) = abs(f(k) - s);end relerr = err/exp(x); semilogy(1:nTerms,relerr)% semilogy(1:nTerms,err) ylabel('Relative Error in Partial Sum.') xlabel('Order of Partial Sum.') title(sprintf('x = %5.2f',x)) figure semilogy(1:nTerms,err)%end term = 1; s = 1; f = exp(x)*ones(nTerms,1); for k=1:50, term = x*term/k; s = s+term; err(k) = abs(f(k) - s); end relerr = err/exp(x); semilogy(1:nTerms,relerr)% semilogy(1:nTerms,err) ylabel('Relative Error in Partial Sum.') xlabel('Order of Partial Sum.') title(sprintf('x = %5.2f',x)) figure semilogy(1:nTerms,err)%end

Pet Monster I

III.MISCELLANEOUS OPERATIONS: (1) Setting ranges for axes, axis([ ]) (2) Superimposing plots: plot(x,y,x,exp(x),'o') (3) using "hold on/hold off" (4) Subplots: subplot(m,n,k)

Summary Roundoff and other errors Multiple plots

References C. Essex, M.Davidson, C. Schulzky, “Numerical Monsters”, preprint. Higham & Higham, Matlab Guide, SIAM B5 Trailer;