{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

9scientific

# 9scientific - Applications of Scientific Computing 9...

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

Introduction to Computer Science Sedgewick and Wayne Copyright © 2007 http://www.cs.Princeton.EDU/IntroCS 9. Scientific Computing 2 Applications of Scientific Computing Science and engineering challenges. ! Fluid dynamics. ! Seismic surveys. ! Plasma dynamics. ! Ocean circulation. ! Electronics design. ! Pharmaceutical design. ! Human genome project. ! Vehicle crash simulation. ! Global climate simulation. ! Nuclear weapons simulation. ! Molecular dynamics simulation. Common features. ! Problems tend to be continuous instead of discrete. ! Algorithms must scale to handle huge problems. Commercial applications. ! Web search. ! Financial modeling. ! Computer graphics. ! Digital audio and video. ! Natural language processing. ! Architecture walk-throughs. ! Medical diagnostics (MRI, CAT). 3 Floating Point IEEE 754 representation. ! Used by all modern computers. ! Scientific notation, but in binary. ! Single precision: float = 32 bits. ! Double precision: double = 64 bits. Ex. Single precision representation of -0.453125 . 1 0 1 1 1 1 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 sign bit exponent significand 125 1/2 + 1/4 + 1/16 = 0.8125 -1 -1 ! 2 125 - 127 ! 1. 8125 = -0.453125 bias phantom bit 4 Floating Point Remark. Most real numbers are not representable, including " and 1/10. Roundoff error. When result of calculation is not representable. Consequence. Non-intuitive behavior for uninitiated. Financial computing. Calculate 9% sales tax on a 50¢ phone call. Banker's rounding. Round to nearest integer, to even integer if tie. if ( 0.1 + 0.2 == 0.3 ) { // NO } if ( 0.1 + 0.3 == 0.4 ) { // YES } double a1 = 1.14 * 75 ; // 85.49999999999999 double a2 = Math . round ( a1 ); // 85 double b1 = 1.09 * 50 ; // 54.50000000000001 double b2 = Math . round ( b1 ); // 55 SEC violation (!) you lost 1¢

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

View Full Document
5 Floating Point Floating point numbers are like piles of sand; every time you move them around, you lose a little sand and pick up a little dirt. - Kernighan and Plauger 6 Catastrophic Cancellation A simple function. Goal. Plot f(x) for -4 # 10 -8 \$ x \$ 4 # 10 -8 . Exact answer f ( x ) = 1 " cos x x 2 7 Catastrophic Cancellation A simple function. Goal. Plot f(x) for -4 # 10 -8 \$ x \$ 4 # 10 -8 . f ( x ) = 1 " cos x x 2 IEEE 754 double precision answer 8 Catastrophic Cancellation Ex. Evaluate fl(x) for x = 1.1e-8 . ! Math.cos(x) = 0.99999999999999988897769753748434595763683319091796875 . ! (1.0 - Math.cos(x)) = 1.1102e-16 ! (1.0 - Math.cos(x)) / (x*x) = 0.9175 Catastrophic cancellation. Devastating loss of precision when small numbers are computed from large numbers, which themselves are subject to roundoff error. nearest floating point value agrees with exact answer to 16 decimal places. inaccurate estimate of exact answer (6.05 # 10 -17 ) 80% larger than exact answer (about 0.5) public static double fl ( double x ) { return ( 1.0 - Math . cos ( x )) / ( x * x ); }
9 Numerical Catastrophes Ariane 5 rocket. [June 4, 1996] ! 10 year, \$7 billion ESA project exploded after launch. ! 64-bit float converted to 16 bit signed int. ! Unanticipated overflow.

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 ]}

### Page1 / 9

9scientific - Applications of Scientific Computing 9...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online