70 likes | 92 Views
CIS541 – Lab1 Analysis. Roger Crawfis. Computers Do As They’re Told. Garbage in Garbage out Most of life’s problems emanate from an underlying communication problem. No different with computers: You thought you told the computer to do one thing. It did another.
E N D
CIS541 – Lab1 Analysis Roger Crawfis
Computers Do As They’re Told • Garbage in Garbage out • Most of life’s problems emanate from an underlying communication problem. • No different with computers: • You thought you told the computer to do one thing. It did another. • You thought the input or intended use of your system was A. It was given B. OSU/CIS 541
Lab1 Results • Results were identical to digits shown for Taylor series and sin(x). Results for different step sizes. ??? OSU/CIS 541
Lab1 Results • Why was the value of x equal to –0.1 at the end of the loop? • 32-bit floating point accuracy • x = -0.1 + 0.00000001 -0.1 • The value of sin(-0.1) = -0.09983342, why wasn’t the result equal to this value as well? OSU/CIS 541
Forcing Floating-Point Arithmetic • Do you believe the other numbers generated by your program? • What is the difference between these two statements? • Sum += x; // one term of the Taylor Series • Sum += x*(1-x*x*( 1 / (3*2*1) ) ); // two terms of the Taylor Series Absolutely nothing!!! OSU/CIS 541
Lab1 – Lessons Learned • More work is not necessarily better. • Do not trust the answers blindly. See if they make sense. • Computer precision is limited. • Round-off errors actually do happen. • Sleep is for weenies ! • … OSU/CIS 541
Lessons Learned Computers have limited capabilities!!! OSU/CIS 541