CISC 121 Lecture Notes - Floating Point
wunch and 39345 others unlocked
35
CISC 121 Full Course Notes
Verified Note
35 documents
Document Summary
>def swappairs(list): if len(list) < 2: return list else: return [list[1], list[0]] + swappairs(list[2:]) Adding numbers of different size can lose the smaller all together if the gap is large enough. In that order, with only 3 decimal places, answer = 1000. In general add from the smallest to the largest**** Derived using calculus sin(x) = x - x^3/3! If you add the sum forever, you get the exact value. Alternatively you can get close to the exact value of sin(x) as you add up more and more terms. Both of the above are true with real arithmetic two ways to calculate ln(2): ln(2) = 0. 693147180559945 1 - 1/2 + 1/3 - 1/4 + . ln(2) = 0. 693147180559945 2(1/3 + 1/3(1/3)^3 + 1/5(1/3)^7) The bottom one, fewer terms must be added for good accuracy. Let"s say hypothetical computer allows exponents from -5 to 5.