Errors Intensive Computation

Similar documents
Errors. Intensive Computation. Annalisa Massini 2017/2018

Averaging, Errors and Uncertainty

Compute the behavior of reality even if it is impossible to observe the processes (for example a black hole in astrophysics).

Numerical Methods - Lecture 2. Numerical Methods. Lecture 2. Analysis of errors in numerical methods

that relative errors are dimensionless. When reporting relative errors it is usual to multiply the fractional error by 100 and report it as a percenta

2.13 Linearization and Differentials

SPH3U1 Lesson 03 Introduction. 6.1 Expressing Error in Measurement

Numbers and Data Analysis

(a) Show that there is a root α of f (x) = 0 in the interval [1.2, 1.3]. (2)

Exact and Approximate Numbers:

Linear Equations in Linear Algebra

Calculus 1 - Lab ) f(x) = 1 x. 3.8) f(x) = arcsin( x+1., prove the equality cosh 2 x sinh 2 x = 1. Calculus 1 - Lab ) lim. 2.

The Fundamental Theorem of Calculus Part 3

Take the measurement of a person's height as an example. Assuming that her height has been determined to be 5' 8", how accurate is our result?

nonlinear simultaneous equations of type (1)

Reporting Measurement and Uncertainty

Numerical Algorithms. IE 496 Lecture 20

Pre-Lab: Primer on Experimental Errors

Lecture 4.2 Finite Difference Approximation

Chapter 6. Nonlinear Equations. 6.1 The Problem of Nonlinear Root-finding. 6.2 Rate of Convergence

MATH SKILL HANDBOOK. a (b ) II. Measurements and Significant Figures. 0 mm

LIES MY CALCULATOR AND COMPUTER TOLD ME

1 Backward and Forward Error

Error analysis for the physical sciences A course reader for phys 1140 Scott Pinegar and Markus Raschke Department of Physics, University of Colorado

PHYS 2211L - Principles of Physics Laboratory I Propagation of Errors Supplement

CHAPTER 3a. INTRODUCTION TO NUMERICAL METHODS

A Few Concepts from Numerical Analysis

Measurements and Data Analysis An Introduction

a) i b) ii c) iii d) i and ii e) ii and iii a) b) c) d) e)

Computer Problems for Taylor Series and Series Convergence

Lies My Calculator and Computer Told Me

Physics 2020 Laboratory Manual

Elements of Floating-point Arithmetic

SECTION 4-3 Approximating Real Zeros of Polynomials Polynomial and Rational Functions

AP Calculus AB Summer Assignment

Statistical Geometry Processing Winter Semester 2011/2012

Fundamentals of Algebra, Geometry, and Trigonometry. (Self-Study Course)

MATH2071: LAB #5: Norms, Errors and Condition Numbers

Measurement Uncertainties

Fundamentals of data, graphical, and error analysis

(i) find the points where f(x) is discontinuous, and classify each point of discontinuity.

In #1-5, find the indicated limits. For each one, if it does not exist, tell why not. Show all necessary work.

Appendix II Calculation of Uncertainties

Appendix A: Significant Figures and Error Analysis

FP1 PAST EXAM QUESTIONS ON NUMERICAL METHODS: NEWTON-RAPHSON ONLY

Chapter 1. Numerical Errors. Module No. 1. Errors in Numerical Computations

y x is symmetric with respect to which of the following?

Uncertainty, Error, and Precision in Quantitative Measurements an Introduction 4.4 cm Experimental error

Numbers and Uncertainty

Notes for Chapter 1 of. Scientific Computing with Case Studies

APPM 1360 Final Exam Spring 2016

Chapter 6 Overview: Applications of Derivatives

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

CE 601: Numerical Methods Lecture 7. Course Coordinator: Dr. Suresh A. Kartha, Associate Professor, Department of Civil Engineering, IIT Guwahati.

Lecture 4.5 Schemes for Parabolic Type Equations

Jim Lambers MAT 610 Summer Session Lecture 2 Notes

Arithmetic and Error. How does error arise? How does error arise? Notes for Part 1 of CMSC 460

BRIDGE CIRCUITS EXPERIMENT 5: DC AND AC BRIDGE CIRCUITS 10/2/13

Pre-Calculus and Trigonometry Capacity Matrix

Math 2414 Activity 1 (Due by end of class Jan. 26) Precalculus Problems: 3,0 and are tangent to the parabola axis. Find the other line.

Name Solutions to Test 3 November 7, 2018

Appendix B: Accuracy, Precision and Uncertainty

1 ERROR ANALYSIS IN COMPUTATION

Recurring Decimals. Mathswatch. Clip ) a) Convert the recurring decimal 036. to a fraction in its simplest form.

Elements of Floating-point Arithmetic

7.4. The Primary Trigonometric Ratios. LEARN ABOUT the Math. Connecting an angle to the ratios of the sides in a right triangle. Tip.

Physics 115 Experiment 1. Introduction to Measurement and Error Analysis (PHY 115 and 117)

6.5 Trigonometric Equations

Find the following limits. For each one, if it does not exist, tell why not. Show all necessary work.

SANDY CREEK HIGH SCHOOL

Measurements and Data Analysis

Date Morning/Afternoon MAXIMUM MARK 100 DRAFT. GCSE MATHEMATICS J560/06 Paper 6 (Higher Tier) PRACTICE PAPER MARK SCHEME. Duration: 1 hours 30 minutes

Appendix C: Accuracy, Precision, and Uncertainty

Math 2414 Activity 1 (Due by end of class July 23) Precalculus Problems: 3,0 and are tangent to the parabola axis. Find the other line.

GAP CLOSING. Intermediate/ Senior Student Book

Measurement and Uncertainty

AP Calculus AB Summer Assignment

Chapter Adequacy of Solutions

Summer AP Assignment Coversheet Falls Church High School

ERROR AND GRAPHICAL ANALYSIS WORKSHEET

Chapter 1: Introduction and mathematical preliminaries

APPLICATIONS OF DIFFERENTIATION

ADDITIONAL MATHEMATICS

Physics 1140 Fall 2013 Introduction to Experimental Physics

ACCUPLACER MATH 0310

SPH4C COLLEGE PHYSICS

Revision Guide for Chapter 8

Calculus with business applications, Lehigh U, Lecture 05 notes Summer

Floating-point Computation

G r a d e 1 1 P r e - C a l c u l u s M a t h e m a t i c s ( 3 0 S ) Final Practice Exam Answer Key

Decimal Scientific Decimal Scientific

Composition of and the Transformation of Functions

Honors Calculus Summer Preparation 2018

Topic 1.2 Measurement and Uncertainties Uncertainty and error in measurement. Random Errors

Nonlinear Equations. Chapter The Bisection Method

Epsilon Delta proofs

Summer AP Assignment Coversheet Falls Church High School

Geometric Modeling Summer Semester 2010 Mathematical Tools (1)

Introduction to Measurement

Further factorising, simplifying, completing the square and algebraic proof

Transcription:

Errors Intensive Computation Annalisa Massini - 2015/2016

OVERVIEW

Sources of Approimation Before computation modeling empirical measurements previous computations During computation truncation or discretization Rounding Accuracy of final result reflects all these Uncertainty in input may be amplified by problem Perturbations during computation may be amplified by algorithm

Eample: Approimations Computing surface area of Earth using formula A = 4πr 2 involves several approimations Earth is modeled as sphere, idealizing its true shape Value for radius is based on empirical measurements and previous computations Value for π requires truncating infinite process Values for input data and results of arithmetic operations are rounded in computer

Sources of Error Scientific computing usually gives ineact answers Eample: the code = sqrt(2) produces something that is not the mathematical 2 differs from 2 by an amount that we call the error The goal of a scientific computation is rarely the eact answer, but a result that is as accurate as needed An accurate result has a small error We use A to denote the eact answer to some problem A to denote the computed approimation to A The error is A A

Sources of Error There are four primary ways in which error is introduced into a computation: Roundoff error from ineact computer arithmetic Truncation error from approimate formulas Termination of iterations Statistical error in Monte Carlo

Sources of Error It is important to understand the likely relative sizes of the various kinds of error This will help in the design of computational algorithms In particular, it will help us focus our efforts on reducing the largest sources of error We need to understand the various sources of error to debug scientific computing software If a result is supposed to be A and instead is A: The difference between A and A is the result of a programming mistake Or, the way of calculating something is simply not accurate enough

Error propagation Error propagation also is important A typical computation has several stages, with the results of one stage being the inputs to the net Errors in the output of one stage most likely mean that the output of the net would be ineact even if the second stage computations were done eactly It is unlikely that the second stage would produce the eact output from ineact inputs On the contrary, it is possible to have error amplification

Error propagation If the second stage output is very sensitive to its input, small errors in the input could result in large errors in the output; that is, the error will be amplified. A method with large error amplification is unstable The condition number of a problem measures the sensitivity of the answer to small changes in its input data The condition number is determined by the problem, not the method used to solve it The accuracy of a solution is limited by the condition number of the problem

Error propagation A problem is called ill-conditioned if the condition number is so large that it is hard or impossible to solve it accurately enough A computational strategy is likely to be unstable if it has an ill-conditioned subproblem Eample Suppose we solve a system of linear differential equations using the eigenvector basis of the corresponding matri Finding eigenvectors of a matri can be ill-conditioned This makes the eigenvector approach to solving linear differential equations potentially unstable, even when the differential equations themselves are well-conditioned

COMPUTATIONAL ERRORS

Absolute Error and Relative Error Absolute error: Relative error: approimate value - true value absolute error true value Equivalently: appro value = (true value) (1 + rel error) True value usually unknown, so we estimate or bound error rather than compute it eactly Relative error often taken relative to approimate value, rather than (unknown) true value

Data Error and Computational Error Typical problem: compute value of function f: R R for given argument = true value of input f() = desired result = approimate (ineact) input f = approimate function actually computed Total error: f f = f f + f f computational error + propagated data error Algorithm has no effect on propagated data error

Eample We need to compute value of sin( π 8) without a calculator We could approimate π with 22/7, but it is easier to use π = 3 Also, we can approimate sine function by truncating Taylor series after first term (we are considering a small value of the argument), that is sin = Computational error is given by using f sin ( 3 8) 3 8 0.3750 and f = 0.3662 (obtained by using a calculator) f f = 0.3750 0.3662 = 0.0088 Propagated data error is given by using f by using a calculator) f f = 0.3662 0.3826 = 0.0164 = 0.3826 (obtained Computational error and propagated data error balance each other

Truncation Error and Rounding Error Truncation error: difference between true result (for actual input) and result produced by given algorithm using eact arithmetic Due to approimations such as truncating infinite series or terminating iterative sequence before convergence Rounding error: difference between result produced by given algorithm using eact arithmetic and result produced by same algorithm using limited precision arithmetic Due to ineact representation of real numbers and arithmetic operations upon them Computational error is sum of truncation error and rounding error, but one of these usually dominates

Eample: Finite Difference Approimation Error in finite difference approimation f f + h f() h ehibits tradeoff between rounding error and truncation error Truncation error bounded by Mh/2, where M bounds f (t) for t near Rounding error bounded by 2ε/h, where error in function values bounded by ε Total error minimized when h 2 ε/m Error increases for smaller h because of rounding error and increases for larger h because of truncation error

FORWARD ERRORS AND BACKWARD ERRORS

Forward and Backward Error Suppose we want to compute y = f(), where f : R R, but obtain approimate value y Forward error: Δy = y y Backward error: Δ =, where f = y f y=f() Backward error f Forward error f y = f = f()

Eample: Forward and Backward Error As approimation to y = 2, the value y = 1.4 has absolute forward error Δy = y y = 1.4 1.41421 0.0142 or relative forward error of about 1 percent Since 1.96 = 1.4, absolute backward error is Δ = = 1.96 2 = 0.04 or relative backward error of 2 percent

Backward Error Analysis Idea: approimate solution is eact solution to modified problem Questions are: How much must original problem change to give result actually obtained? How much data error in input would eplain all error in computed result? Approimate solution is good if it is eact solution to nearby problem Backward error is often easier to estimate than forward error

Eample: Backward Error Analysis Approimating cosine function f = cos, by truncating Taylor series after two terms gives y = f = 1 2 /2 Forward error is given by Δ y = y y = f f = 1 2 2 cos To determine backward error, need value such that f = f For cosine function, = arccos f = arccos(y)

Eample continued For = 1 y = f 1 = cos 1 0.5403 y = f 1 = 1 12 2 = 0.5 = arccos y = arccos 0.5 = 1.0472 Forward error: Δy = y y 0.5 0.5403 = 0.0403 Backward error: Δ = 1.0472 1 = 0.0472

SENSITIVITY AND CONDITIONING

Well-Posed Problems Problem is well-posed if solution eists is unique depends continuously on problem data Otherwise, problem is ill-posed Even if problem is well posed, solution may still be sensitive to input data Computational algorithm should not make sensitivity worse

Sensitivity and Conditioning Problem is insensitive, or well-conditioned, if relative change in input causes similar relative change in solution Problem is sensitive, or ill-conditioned, if relative change in solution can be much larger than that in input data Condition number : relative change in solution cond = relative change in input data = (f f )/f() ( )/ = Δy/y Δ/ Problem is sensitive, or ill-conditioned, if cond 1

Condition number Condition number is amplification factor relating relative forward error to relative backward error relative forward error = cond relative backward error Condition number usually is not known eactly and may vary with input, so rough estimate or upper bound is used for cond, yielding relative forward error < cond relative backward error

Eample: Evaluating Function Evaluating function f for approimate input = + instead of true input gives Absolute forward error: = f + f() f () Relative forward error: f + f() f() f () f() Condition number: cond f f = f () f() Relative error in function value can be much larger or smaller than that in input, depending on particular f and

Eample: Sensitivity Tangent function is sensitive for arguments near π/2 tan(1.57079) 1.58058 10 5 tan(1.57078) 6.12490 10 4 Relative change in output is quarter million times greater than relative change in input For = 1.57079, cond 2.48275 10 5

Condition Number for Linear Systems Consider the system 7 10y 1 5 7 y 0.7 It has solution 0 y 0.1 The perturbed system 7ˆ 10yˆ 1.01 5ˆ 7 yˆ 0.69 has the solution ˆ 0.17 yˆ 0.22

Condition Number for Linear Systems In solving a linear system A = b, we need to know the sensitivity of the solution to changes in the right side b Consider the linear systems What is? We simply solve for r b A b A ~ ~ ~ r A b A r b A 1 1 1 ] [ ~ r A r A 1 1 ~ A r A A r A 1 1 ~

Condition Number for Linear Systems Since A = b, we have b A, and then ~ 1 A A r b The number cond( A) for the matri A and for the linear system ~ r cond( A) b A 1 A is the condition number

Condition Number for Linear Systems We can also prove a lower inequality, obtaining 1 cond( A) r b ~ cond( A) r b In addition, given any nonsingular A, there are vectors b and r for which either of the above inequalities is actually an equality

Condition Number for Linear Systems With 1 cond( A) r b ~ cond( A) r b we see that if cond(a) 1, then small relative changes in b are guaranteed to lead to equally small relative changes in But if cond(a) is very large, then there are values of b and r for which r is small and ~ is large b In practice, it is very difficult to know whether your choice of b and r is good or bad

MEASUREMENTS ERRORS

2015/2016 Intensive Computation - Linear Systems 35 Measurements Errors There are three types of limitations to measurements: 1) Instrumental limitations Any measuring device can only be used to measure to with a certain degree of fineness Our measurements are no better than the instruments we use to make them

2015/2016 Intensive Computation - Linear Systems 36 Measurements Errors There are three types of limitations to measurements: 2) Systematic errors and blunders These are caused by a mistake which does not change during the measurement. For eample, if the platform balance you used to weigh something was not correctly set to zero with no weight on the pan, all your subsequent measurements of mass would be too large. Systematic errors do not enter into the uncertainty. They are either identified and eliminated or lurk in the background producing a shift from the true value.

2015/2016 Intensive Computation - Linear Systems 37 Measurements Errors There are three types of limitations to measurements: 3) Random errors These arise from unnoticed variations in measurement technique, tiny changes in the eperimental environment, etc. Random variations affect precision. Truly random effects average out if the results of a large number of trials are combined.

2015/2016 Intensive Computation - Linear Systems 38 Precision and Accuracy A precise measurement is one where independent measurements of the same quantity closely cluster about a single value that may or may not be the correct value An accurate measurement is one where independent measurements cluster about the true value of the measured quantity Systematic errors: are not random and therefore can never cancel out affect the accuracy but not the precision of a measurement

2015/2016 Intensive Computation - Linear Systems 39 Precision and Accuracy A. Low precision, Low accuracy: The average (the X) is not close to the center B. Low precision, High accuracy: The average is close to the true value C. High precision, Low accuracy: The average is not close to the true value

2015/2016 Intensive Computation - Linear Systems 40 Uncertainty of Measurements Errors are quantified by associating an uncertainty with each measurement Eample, the best estimate of a length L is 2.59cm, but due to uncertainty, the length might be as small as 2.57cm or as large as 2.61cm L can be epressed with its uncertainty in two different ways: 1. Absolute Uncertainty Epressed in the units of the measured quantity: L 2.59 0.02 cm 2. Percentage Uncertainty Epressed as a percentage independent of the units Above, since 0.02 / 2.59 1% we would write L 7.7cm 1%

2015/2016 Intensive Computation - Linear Systems 41 Significant Digits Eperimental numbers must be written in a way consistent with the precision to which they are known: significant digits (or figures) that have physical meaning 1. All definite digits and the first doubtful digit are considered significant 2. Leading zeros are not significant digits Eample: L=2.31cm has 3 significant figures. For L=0.0231m, the zeros serve to move the decimal point to the correct position 3. Trailing zeros are significant digits: they indicate the number s precision 4. One significant digit should be used to report the uncertainty or occasionally two, especially if the second digit is a five

2015/2016 Intensive Computation - Linear Systems 42 Rounding Numbers To keep the correct number of significant figures, numbers must be rounded off The discarded digit is called the remainder There are three rules for rounding: Rule 1: If the remainder is less than 5, drop the last digit. Rounding to one decimal place: 5.346 5.3 Rule 2: If the remainder is greater than 5, increase the final digit by 1. Rounding to one decimal place: 5.798 5.8 Rule 3: If the remainder is eactly 5 then round the last digit to the closest even number. This is to prevent rounding bias. Remainders from 1 to 5 are rounded down half the time and remainders from 6 to 10 are rounded up the other half. Rounding to one decimal place: 3.55 3.6, also 3.65 3.6

2015/2016 Intensive Computation - Linear Systems 43 Eamples Eample The period of a pendulum is given by T 2 l g 2 Here, l 0.24m is the pendulum length and g 9.81m s is the acceleration due to gravity WRONG: T 0.983269235922 s T 0.98 s RIGHT: Note You can obtain the first number by a calculator but there is no way you know T to that level of precision When no uncertainties are given, report your value with the same number of significant digits as the value with the smallest number of significant digits

2015/2016 Intensive Computation - Linear Systems 44 Eamples Eample The mass of an object was found to be uncertainty of WRONG: RIGHT: with an Note The first way is wrong because the uncertainty should be reported with one significant digit Eample The length of an object was found to be an uncertainty of WRONG: RIGHT: 0.032g m 3.56 0.032 g m 3.56 0.03 g 0.03 cm L 2.593 0.03cm L 2.59 0.03cm 3.56g 2.593 cm Note The first way is wrong because it is impossible for the third decimal point to be meaningful with

2015/2016 Intensive Computation - Linear Systems 45 Eamples Eample The velocity was found to be of 0.6 m/s WRONG: RIGHT: with an uncertainty Note The first way is wrong because the first discarded digit is a 5 In this case, the final digit is rounded to the closest even number, 4 Eample The distance was found to be 45600 m with an uncertainty of 1m WRONG: 4 d 4.560010 m Note The first way is wrong because it tells us nothing about the uncertainty. Scientific notation shows we know the value to within 1m RIGHT: v 2.5 0.6 m/s v 2.4 0.6 m/s d 45600 m 2.45 m/s

2015/2016 Intensive Computation - Linear Systems 46 Statistical Analysis of Small Data Sets Repeated measurements allow you: To obtain a better idea of the actual value To characterize the uncertainty of your measurement There are a number of quantities that are very useful in data analysis, that eploits: The value obtained from a particular measurement, The times a measurement is repeated, N

2015/2016 Intensive Computation - Linear Systems 47 Statistical Analysis of Small Data Sets Oftentimes (e.g. in lab) N is small, usually no more than 5 to 10 For small data sets we use the following formulas: Mean - avg The average of all values of (the best value of ) avg 1 2 N N Range - R The spread of the data set. This is the difference between the maimum and minimum values of R ma min

2015/2016 Intensive Computation - Linear Systems 48 Statistical Analysis of Small Data Sets Uncertainty in a measurement - Δ Determine this uncertainty by making multiple measurements. From data you know that lies somewhere between ma and min R ma min 2 2 Uncertainty in the Mean - Δ avg The actual value of will be somewhere in a neighborhood around avg. This neighborhood of values is the uncertainty in the mean. avg Measured value - m The final reported value of a measurement of contains both the average value and the uncertainty in the mean m N avg 2 R avg N

2015/2016 Intensive Computation - Linear Systems 49 Statistical Analysis of Large Data Sets If only random errors affect a measurement, it can be shown mathematically that in the limit of an infinite number of measurements ( N ), the distribution of values follows a normal distribution (i.e. the bell curve) This distribution has a peak at the mean value width given by the standard deviation σ avg and a

2015/2016 Intensive Computation - Linear Systems 50 Statistical Analysis of Large Data Sets We never take an infinite number of measurements However, for a large number of measurements, N~10-10 2 or more, measurements may be approimately normally distributed

2015/2016 Intensive Computation - Linear Systems 51 Statistical Analysis of Large Data Sets For large data sets we use the following formulas: Mean - avg The average of all values of (the best value of ) This is the same as for small data sets avg N i 1 N Uncertainty in a measurement - Δ The vast majority of your data lies in the range avg i N i 1 ( i N avg 2 )

2015/2016 Intensive Computation - Linear Systems 52 Statistical Analysis of Large Data Sets For large data sets we use the following formulas: Uncertainty in the Mean - Δ avg The actual value of will be somewhere in a neighborhood around avg. This neighborhood of values is the uncertainty in the mean avg N Measured Value - m The final reported value of a measurement of contains both the average value and the uncertainty in the mean m avg avg

2015/2016 Intensive Computation - Linear Systems 53 Propagation of Uncertainties Oftentimes we combine multiple values, each of which has an uncertainty, into a single equation The way these uncertainties combine depends on how the measured quantity is related to each value Rules for how uncertainties propagate are: Addition/Subtraction z y z 2 ( ) ( y ) 2 Multiplication Division z y z y z z y y 2 2 y y y y 2 2

Eamples Addition The sides of a fence are measured with a tape measure to be 124.2cm, 222.5cm, 151.1cm and 164.2cm Each measurement has an uncertainty of 0.07cm Calculate the measured perimeter P m including its uncertainty P 124. 2cm 222.5cm 151.1cm 164.2cm 662.0cm P (0.07) 2 (0.07) 2 (0.07) 2 (0.07) 2 0.14cm P m 662. 0 0.1cm

Eamples Multiplication The sides of a rectangle are measured to be 15.3cm and 9.6cm Each length has an uncertainty of 0.07cm Calculate the measured area A m including its uncertainty A 15.3cm 9.6cm 146.88cm 2 0.07 0.07 A 15.3cm 9.6cm 1.3cm 15.3 9.6 2 2 2 A m 147 1cm 2

References Scientific Computing: An Introductory Survey - Chapter 1 M.T. Heath http://web.engr.illinois.edu/~heath/scicomp/notes/chap01.pdf Principles of Scientic Computing Sources of Error http://www.cs.nyu.edu/courses/spring09/g22.2112-001/book/sourcesoferror.chapter.pdf Error analysis for linear systems http://homepage.math.uiowa.edu/~atkinson/m171.dir/sec_8-4.pdf Averaging, Errors and Uncertainty - Lab Manual Dept of Physics & Astronomy http://virgo-physics.sas.upenn.edu/uglabs/lab_manual/error_analysis.pdf