You are on page 1of 27

Lecture 2

Types of Numerical Errors, Error Propagation

Anna Yershova
Department of Computer Science University of Illinois at Urbana-Champaign

August 25, 2011

Anna Yershova (UIUC)

CS 357

August 25, 2011

1 / 27

Announcements

HW1 https://wiki.engr.illinois.edu/display/cs357fa11/Homework Due on Sep 1st

Anna Yershova (UIUC)

CS 357

August 25, 2011

2 / 27

Last Time

What is the subject of Numerical Analysis Applications of Numerical Analysis Importance of Error study in Numerical Analysis

Anna Yershova (UIUC)

CS 357

August 25, 2011

3 / 27

Today

How to measure errors (absolute, relative) Sources of error (input, round-off, truncation) Propagation error Taylor Series (examples of errors) Big-O (bounding errors) Signicant digits (bounding errors)

Anna Yershova (UIUC)

CS 357

August 25, 2011

4 / 27

Absolute Error
AbsoluteError(a) = ApproximateValue(a ) ExactValue(a)

Example
2

How to measure absolute error without knowing the true value?


Anna Yershova (UIUC) CS 357 August 25, 2011 5 / 27

Signicant Digits
Denition
|a| = |a a| 0.5 10t Then, a is said to have t correct decimals. If t > 0, the digits in positions with unit 10t are called signicant digits.

Example

Anna Yershova (UIUC)

CS 357

August 25, 2011

6 / 27

Signicant Digits
Example

Anna Yershova (UIUC)

CS 357

August 25, 2011

7 / 27

Absolute Error
AbsoluteError(a) = ApproximateValue(a ) ExactValue(a)

Example
Numerical calculation of derivative of a function f (x)

Anna Yershova (UIUC)

CS 357

August 25, 2011

8 / 27

Absolute vs Relative Error


AbsoluteError(a) = ApproximateValue(a ) ExactValue(a)

Example
Numerical calculation of derivative of a function f (x) = 3ex/2

Anna Yershova (UIUC)

CS 357

August 25, 2011

9 / 27

Relative Error
RelativeError a a = AbsoluteError(a ) ExactValue(a)

Example
Numerical calculation of derivative of a function f (x) = 3 106 ex/2

Anna Yershova (UIUC)

CS 357

August 25, 2011

10 / 27

Relative Error
RelativeError a a = AbsoluteError(a ) ExactValue(a)

Example
2

Often a percentage is given instead


Anna Yershova (UIUC) CS 357 August 25, 2011 11 / 27

Today

How to measure errors (absolute, relative) Sources of error (input, round-off, truncation) Propagation error Taylor Series (examples of errors) Big-O (bounding errors) Signicant digits (bounding errors)

Anna Yershova (UIUC)

CS 357

August 25, 2011

12 / 27

Sources of errors. Input Error


Denition
Input errors are the result of the input data being measured with limited accuracy, or real numbers represented in a computer with a xed number of digits.

Example
Numerical interpolation

Anna Yershova (UIUC)

CS 357

August 25, 2011

13 / 27

Sources of errors. Rounding Error


Example

Anna Yershova (UIUC)

CS 357

August 25, 2011

14 / 27

Sources of errors. Truncation Error


Denition
Truncation errors arise when an innite process is replaced by a nite one.

Example
Differentiation

Anna Yershova (UIUC)

CS 357

August 25, 2011

15 / 27

Truncation Error
Example
Series: Taylor series

Anna Yershova (UIUC)

CS 357

August 25, 2011

16 / 27

Big O
Denition
f (x) = O(g(x)) if and only if there exists a positive real number M and a real number x0 such that |f (x)| M|g(x)| for all x > x0 .

Example

Anna Yershova (UIUC)

CS 357

August 25, 2011

17 / 27

Truncation Error
Example
Maclaurin Series: Taylor series with a = 0

Anna Yershova (UIUC)

CS 357

August 25, 2011

18 / 27

Truncation Error
Example
Maclaurin Series, e4

Anna Yershova (UIUC)

CS 357

August 25, 2011

19 / 27

Truncation Error
Example
Maclaurin Series, sin x

Anna Yershova (UIUC)

CS 357

August 25, 2011

20 / 27

Truncation Error
Example
Integration

Anna Yershova (UIUC)

CS 357

August 25, 2011

21 / 27

Truncation Error vs Rounding Error


Example

Anna Yershova (UIUC)

CS 357

August 25, 2011

22 / 27

Error Propagation
When approximate values are used in computations, their errors will propagate in the results.

Example

Anna Yershova (UIUC)

CS 357

August 25, 2011

23 / 27

Error Propagation
Example
Addition, subtraction

Anna Yershova (UIUC)

CS 357

August 25, 2011

24 / 27

Error Propagation
Example
Multiplication, division

Anna Yershova (UIUC)

CS 357

August 25, 2011

25 / 27

Error Propagation
Example
Function evaluation, mean value theorem

Anna Yershova (UIUC)

CS 357

August 25, 2011

26 / 27

Error Propagation
Example
Finite Taylor series

Anna Yershova (UIUC)

CS 357

August 25, 2011

27 / 27

You might also like