Slides_2010_02_19

# Slides_2010_02_19 - Applied linear algebra and numerical...

This preview shows pages 1–10. Sign up to view the full content.

Applied linear algebra and numerical analysis Session 19 Prof. Ulrich Hetmaniuk Department of Applied Mathematics February 19, 2010

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Computer arithmetic It is important to be aware of limitations and of potential pitfalls of computer arithmetic. Careless construction of algorithms can have sometimes dramatic consequences.
Floating point real numbers Double precision ( - 1 ) s × 2 e - 1023 × ( 1 + m ) 1 bit for sign: s is either 0 or 1 11 bits for exponent: 0 e 2 11 - 1 = 2047 e = 0 is reserved for representing 0 (when m = 0). e = 0 and m 6 = 0 gives the denormalized numbers. 0 < e < 2047 is the range for normalized numbers. e = 2047 is reserved to represent Inf ( m = 0) and NaN ( m 6 = 0). 52 bits for mantissa: 0 m 1 - 2 - 53 Range of positive real numbers = [ 2 - 1022 , 2 1023 ] [ 2 . 2 × 10 - 308 , 1 . 8 × 10 308 ] If an operation gives a number outside this range, we get an overflow or underflow.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Floating point real numbers Special symbols Inf and NaN Inf means “too large to represent”. “NaN” (“not a number”), which covers all other errors. When a nonzero number is divided by zero (the divisor must be exactly zero), a “divide by zero” event occurs. Floating-point hardware is generally designed to handle operands of infinity in a reasonable way, such as (+Inf) + (+7) = (+Inf) (+Inf) × ( - 2) = ( - Inf) (+Inf) × 0 = NaN — there is no meaningful thing to do
Floating point real numbers Machine epsilon Half the distance between 1 and the next larger floating point number, 1 + 2 - 52 . It is also defined as x R , there exists a floating number x 0 , x - x 0 ε machine x 0 . Double precision: 2 - 52 2 . 22 × 10 - 16 16 digits of relative accuracy Single precision: 2 - 23 1 . 19 × 10 - 7 7 digits of relative accuracy

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Floating point arithmetic When arithmetic is done the result must generally be rounded off to nearest machine number. Example On a decimal machine with 3-digit mantissa and 2-digit exponent: 0 . 523 e 00 + 0 . 745 e 00 = 0 . 1268 e 01 will be rounded to 0.127e01. 0 . 523 e 00 + 0 . 745 e - 04 = 0 . 5230745 e 00 will be rounded to 0.523e00. 0 . 523 e 00 * 0 . 745 e 00 = 0 . 389635 e 00 will be rounded to 0.390e00.
Floating point arithmetic An awareness of when loss of significance can occur is useful. Subtraction of nearly equal operands may cause extreme loss of accuracy. Conversions to integer can be dangerous. Testing for safe division is problematic. A nonzero denominator may produce an overflow. Testing for equality is problematic. Programmers often perform comparisons within some tolerance.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example t 0 = 1 3 , t i + 1 = q t 2 i + 1 - 1 t i ˜ t i + 1 = t i q t 2 i + 1 + 1 t i = ˜ t i π 62 i
Floating point arithmetic Naive use of floating-point arithmetic can lead to many problems. The creation of thoroughly robust floating-point software is challenging.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern