270 likes | 575 Vues
Computational Physics. PS 587. We are still waiting for the Ph D class to join in… . Till then, refresh some concepts in programming (later). Discuss some general techniques which may be useful in any case Accuracy, and why it is important. Decimal System.
E N D
Computational Physics PS 587
We are still waiting for the Ph D class to join in… • Till then, refresh some concepts in programming (later). • Discuss some general techniques which may be useful in any case • Accuracy, and why it is important.
Decimal System • Foundation of our computer revolution. • Imagine computing in the Roman system CCXXXII times XLVIII, i.e. 232 48. • Zero was invented by Indian mathematicians, who were inspired by the Babylonian and the Chinese number systems, particularly as used in abacuses.
The Discovery of Decimal Fractions • Persians and Arabs invented the representation of decimal fractions that we use today. • They discovered the rules for basic arithmetic operations that we now learn in school.
The Long Journey Adelard 1080 AD Khwarizmi 780 AD Kashani 1380 AD House of Wisdom 9thc. AD Brahmagupta, 598 AD Sridhara, 850 AD Diophantus 3rdc. AD
Khwarizmi (780 – 850) • Settled in the House of Wisdom (Baghdad). • Wrote three books: • Hindu Arithmetic • Al-jabr va Al-Moghabela • Astronomical Tables • The established words:“Algorithm” from “Al-Khwarizmiand “Algebra” from “Al-jabr”testify to his fundamentalcontribution to human thought.
The Long Journey Adelard 1080 AD Khwarizmi 780 AD Kashani 1380 AD House of Wisdom 9thc. AD Brahmagupta, 598 AD Sridhara, 850 AD Diophantus 3rdc. AD
After a long rivalry between Algorists and abacists, the decimal system replaced the abacus. Adelard of Bath (1080 – 1160) • First English Scientist. • Translated from Arabic to Latin Khwarizmi’s astronomical tables with their use of zero.
The Long Journey Adelard 1080 AD Khwarizmi 780 AD Kashani 1380 AD House of Wisdom 9thc. AD Brahmagupta, 598 AD Sridhara, 850 AD Diophantus 3rdc. AD
Computed up to 16 decimal places: • Took the unit circle. • Took the unit circle. • Took the unit circle. • The circumferences of the inscribed and circumscribed polygons with n sides give lower and upper bounds for 2. • The circumferences of the inscribed and circumscribed polygons with n sides give lower and upper bounds for 2. • He used • Computed up to 16 decimals. Kashani (1380 – 1429) • Developed arithmetic algorithms for fractions, that we use today.
Kashani (1380 – 1429) • Kashani invented the first mechanical special purpose computers: • to find when the planets are closest, • to calculate longitudes of planets, • to predict lunar eclipses.
Napier(1550-1617) Pascal(1632 – 1662) • Oughtred(1575 – 1660) Leibniz(1646 –1716) Babbage(1792 – 1871) Mechanical Computers in Europe
Sign Mantissa Exponent • Represents only a finite collection of numbers. Modern Computers: Floating Point Numbers • Any other number like is rounded or approximated to a close floating point number.
Computers lie. One has to be alert.
Floating Point Arithmetic is not sound • Especially when adding BIG numbers: • But using IEEE’s standard precision, we get three different results,
What is 0 on the computer? • 0 is the smallest number such that 0+1=1. • Compute the 0 on your calculator. This is related to the number of bits used to represent a real number. Typically this will be something like 10-8.
Floating Point Arithmetic is not sound • A simple calculation shows: • But using IEEE’s standard precision, we get three different results, all wrong.
Double precision floating-point arithmetic gives: • The correct solution is: Failure of Floating Point Computation
Failure of Floating Point Computation • Depending on the floating point format, the sequence tends to 1 or 2 or 3 or 4. • In reality, it oscillates about 1.51 and 2.37.
Floating Point Exact Arithmetic Failure of Floating Point Computation • In any floating point format, the sequence converges to 100. • In reality, it converges to 6.
Floating Point Exact Arithmetic Failure of Floating Point Computation • In any floating point format, the sequence converges to 100. • In reality, it converges to 6.
Floating Point Exact Arithmetic Failure of Floating Point Computation • In any floating point format, the sequence converges to 100. • In reality, it converges to 6.
3.14159265358979323846264338327950288419716939937510582974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609...3.14159265358979323846264338327950288419716939937510582974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609...