Professional Documents
Culture Documents
ECE257 Numerical Methods and Scientific Computing
ECE257 Numerical Methods and Scientific Computing
ECE257 Numerical Methods and Scientific Computing
Error Analysis
Todays class:
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Introduction
Error is the difference between the exact solution and a numerical method solution. In most cases, you dont know what the exact solution is, so how do you calculate the error. Error analysis is the process of predicting what the error will be even if you dont know what the exact solution Errors can also be introduced by the fact that the numerical algorithm has been implemented on a computer
John A. Chandy Dept. of Electrical and Computer Engineering University of Connecticut
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
From Numerical Methods for Engineers, Chapra and Canale, Copyright The McGraw-Hill Companies, Inc.
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4 John A. Chandy Dept. of Electrical and Computer Engineering University of Connecticut
Significant digits
Can a number be used with confidence? How accurate is the number? How many digits of the number do we trust?
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Significant digits
From Numerical Methods for Engineers, Chapra and Canale, Copyright The McGraw-Hill Companies, Inc.
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4 John A. Chandy Dept. of Electrical and Computer Engineering University of Connecticut
Significant digits
The significant digits of a number are those that can be used with confidence
The digits that are known with certainty plus one estimated digit
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Significant digits
49.0 mph - 3 significant digits
Accuracy is how close a computed or measured value is to the true value Precision is how close individual computed or measured values agree with each other
Reproducability
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
From Numerical Methods for Engineers, Chapra and Canale, Copyright The McGraw-Hill Companies, Inc.
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4 John A. Chandy Dept. of Electrical and Computer Engineering University of Connecticut
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Error Definitions
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Error Definitions
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Error definitions
Example:
Line voltage
E t = 120V 119V = 1V
t =
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Error definitions
What if we dont know the true value? Use an approximation of the true value
approximate error t = 100% approximate value
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Error Definitions
For most problems, we are interested in keeping the error less than specified error tolerance
a < s
How many iterations do you do, before youre satisfied that the result is correct to at least n significant digits?
s = (0.5 x 10 2n )%
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4 John A. Chandy Dept. of Electrical and Computer Engineering University of Connecticut
Example
As we add terms to the expansion, the expression becomes more exact Using this series expansion, can we calculate e0.5 to three significant digits?
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Example
First approximation
e 0.5 = 1
Second approximation
e 0.5 = 1+ 0.5 = 1.5
Error approximation
1.5 0.5 a = = 33.3% > 0.05% 1.5
John A. Chandy Dept. of Electrical and Computer Engineering University of Connecticut
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Example
Third approximation 2
e
0.5
Error approximation
1.625 1.5 a = = 7.69% > 0.05% 1.625
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4 John A. Chandy Dept. of Electrical and Computer Engineering University of Connecticut
Example
Terms 1 2 3 4 5 6 1 1.5 1.625 1.645833333 1.6484375 1.648697166 Result t 39.3% 9.02% 1.44% 0.175% 0.0172% 0.00142% 33.3% 7.69% 1.27% 0.158% 0.0158% a
Round-Off Errors
Round-off errors are caused because exact numbers can not be expressed in a fixed number of digits as with computer representations For example, a 32-bit number only has a range from 2147483648 to 2147483647 For larger numbers or fractional quantities, we can use floating point numbers, but we will encounter round-off errors
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Floating-Point
What can be represented in N bits? Unsigned 2s Complement 1s Complement BCD But, what about? very large numbers? 9,349,398,989,787,762,244,859,087,678 very small number? 0.0000000000000000000000045691 rationals irrationals transcendentals 2/3 0 - 2N-1 to to 2N 2N-1 - 1
N
2
e
John A. Chandy Dept. of Electrical and Computer Engineering University of Connecticut
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Mantissa
radix (base)
Sign, magnitude
Issues:
IEEE F.P.
1.M x 2
e - 127
Arithmetic (+, -, *, / ) Representation, Normal form Range and Precision Rounding Exceptions (e.g., divide by zero, overflow, underflow) Errors Properties ( negation, inversion, if A B then A - B 0 )
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4 John A. Chandy Dept. of Electrical and Computer Engineering University of Connecticut
Floating-Point Numbers
Representation of floating point numbers in IEEE 754 standard: 1 8 23 single precision E sign S M mantissa: exponent: sign + magnitude, normalized excess 127 binary integer binary significand w/ hidden integer bit: 1.M 1 < E < 254 (E=0,255 are used for special values) -1.5 = 1 01111111 10 . . . 0
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Problems:
Limited range of representable numbers
Finite number of representable numbers within range Interval between numbers increases as numbers grow in magnitude
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
From Numerical Methods for Engineers, Chapra and Canale, The McGraw-Hill Companies, Inc.
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4 John A. Chandy Dept. of Electrical and Computer Engineering University of Connecticut
Range of numbers for IEEE single-precision is from 2-126 to (2-2-23)2127 or 1.18x10-38 to 3.40x1038 Overflow becomes infinity and underflow becomes zero. Double precision extends range to (2-252)21023
John A. Chandy Dept. of Electrical and Computer Engineering University of Connecticut
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
It may make sense to do further computations with infinity e.g., X/0 > Y may be a valid comparison
Not a number, but not infinity (e.q. sqrt(-4)) invalid operation exception (unless operation is = or =) NaN S 1 . . . 1 non-zero HW decides what goes here
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Quantization
Finite number of representable numbers due to round-off or chopping becomes 3.1416 or 3.1415 instead of 3.1415926535 Due to base-conversion, rational numbers may become unrepresentable as well.
0.110 becomes 0.000110011001100110011001102
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Increasing Interval x
Allows floating point numbers to preserve significant digits Quantization errors will be proportional to magnitude of number
x for chopping x x for rounding x 2
= bt with implicit 1
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Round-off errors
Large numbers of interdependent computations Adding a large and small number Subtractive calculation
Subtracting two nearly equal numbers
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
In 1982, the index was initiated with a starting value of 1000.000 with three digits of precision and truncation After 22 months, the index was at 524.881 The index should have been at 1009.811. Successive additions and subtractions introduced truncation error that caused the index to be off so much.
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Ariane rocket
Ariane 5 rocket was launched in June 1996. The rocket was on course for 36 seconds and then veered off and crashed The internal reference system was trying to convert a 64-bit floating point number to a 16-bit integer. This caused an overflow which was sent to the onboard computer The on-board computer interpreted the overflow as real flight data and bad things happened.
John A. Chandy Dept. of Electrical and Computer Engineering University of Connecticut
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Patriot missile
The Patriot missile had an on-board timer that incremented every tenth of a second Software accumulated a floating point time value by adding 0.1 seconds Problem is that 0.1 in floating point is not exactly 0.1. With a 23 bit representation it is really only 0.0999999046326. Thus, after 100 hours (3,600,000 ticks), the software timer was off by .3433 seconds. Scud missile travels at 1676 m/s. In .3433 seconds, the Scud was 573 meters away from where the Patriot thought it was.
John A. Chandy Dept. of Electrical and Computer Engineering University of Connecticut
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4
Next Lecture
ECE 257 Numerical Methods and Scientific Computing Fall 2004 Lecture 4