Computational Physics Chapter 1 Weihua Gu Shanghai Jiao Tong University 14/09/2015 口回1元,4元↑至0QC Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/0920151/103
Computational Physics Chapter 1 Weihua Gu Shanghai Jiao Tong University 14/09/2015 Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/09/2015 1 / 103
Chapter 1 Errors Uncertainties in Computations Last update:September 12,2016 1口“回4元4元t至0QC Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/0920152/103
Chapter 1 Errors & Uncertainties in Computations Last update: September 12, 2016 Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/09/2015 2 / 103
Computers are incredibly fast,accurate,and stupid;humans are incredibly slow,inaccurate,and brilliant;together they are powerful beyond imagination. Albert Einstein ¥口“1元4元↑至QC Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/09201531103
Computers are incredibly fast, accurate, and stupid; humans are incredibly slow, inaccurate, and brilliant; together they are powerful beyond imagination. Albert Einstein Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/09/2015 3 / 103
Computer Number Representation Outline Computer Number Representation 2 Machine Precision Types of Errors Subtractive Cancelation and Misc Operations 5 Effective Algorithm Reducing Steps of Computation Error Assessment Best Approximation Review Summary 口“4元元t重0QC Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/09/20154/103
Computer Number Representation Outline 1 Computer Number Representation 2 Machine Precision 3 Types of Errors 4 Subtractive Cancelation and Misc Operations 5 Effective Algorithm 6 Reducing Steps of Computation 7 Error Assessment 8 Best Approximation 9 Review & Summary Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/09/2015 4 / 103
Computer Number Representation Binary Form o All numbers are stored in memory in binary form. Word length is the number of bits used to store a number. expressed in bytes. 1 byte =1 B=8 bits A typical printed page required ~3kB Using 64 bits integers in the range 1-203~1019 (the sian represented by the first bit) The ratio of the size of the universe to the size of a proton~ 1041 1口“4元,4元↑重QC Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/0920155/103
Computer Number Representation Binary Form All numbers are stored in memory in binary form. Word length is the number of bits used to store a number, expressed in bytes. 1 byte ≡ 1 B = 8 bits A typical printed page required ∼3kB. Using 64 bits ⇒ integers in the range 1 − 2 63 ∼ 1019 (the sign represented by the first bit). The ratio of the size of the universe to the size of a proton ∼ 1041 . Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/09/2015 5 / 103
Computer Number Representation Binary Form oAll numbers are stored in memory in binary form. o Word length is the number of bits used to store a number, expressed in bytes. 1byte三1B=8bits A typical printed page required ~3kB. Using 64 bits=integers in the range 1-263~1019 (the sign represented by the first bit). The ratio of the size of the universe to the size of a proton 1041 1口“4元,4元↑重QC Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/0920155/103
Computer Number Representation Binary Form All numbers are stored in memory in binary form. Word length is the number of bits used to store a number, expressed in bytes. 1 byte ≡ 1 B = 8 bits A typical printed page required ∼3kB. Using 64 bits ⇒ integers in the range 1 − 2 63 ∼ 1019 (the sign represented by the first bit). The ratio of the size of the universe to the size of a proton ∼ 1041 . Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/09/2015 5 / 103
Computer Number Representation Binary Form o All numbers are stored in memory in binary form. o Word length is the number of bits used to store a number, expressed in bytes. 1 byte=1 B=8 bits A typical printed page required ~3kB. Using 64 bits=integers in the range 1-263~1019(the sign represented by the first bit). The ratio of the size of the universe to the size of a proton~ 1041. ¥口“1元4元↑至QC Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/0920155/103
Computer Number Representation Binary Form All numbers are stored in memory in binary form. Word length is the number of bits used to store a number, expressed in bytes. 1 byte ≡ 1 B = 8 bits A typical printed page required ∼3kB. Using 64 bits ⇒ integers in the range 1 − 2 63 ∼ 1019 (the sign represented by the first bit). The ratio of the size of the universe to the size of a proton ∼ 1041 . Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/09/2015 5 / 103
Computer Number Representation The Challenge (12)10-1·23+1.22+0.2+0·20=(1100)2 (0.625)10=1.2-1+0.2-2+1.2-3=(0.101)2 (0.626)10=1.2-1+0.2-2+1.2-3+…=(0.101…)2 ≈(0.101)2 max range of number max significant digits ) finite number of bits of memory Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/09/20156/103
Computer Number Representation The Challenge (12) 10 = 1 · 2 3 + 1 · 2 2 + 0 · 2 1 + 0 · 2 0 = (1100) 2 (0.625) 10 = 1 · 2 −1 + 0 · 2 −2 + 1 · 2 −3 = (0.101) 2 (0.626) 10 = 1 · 2 −1 + 0 · 2 −2 + 1 · 2 −3 + · · · = (0.101 · · ·) 2 ≈ (0.101) 2 max range of number max significant digits ↔ finite number of bits of memory Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/09/2015 6 / 103
Computer Number Representation Two Schemes o fixed-point notation Mx=sign×(an2”+an-12n-1+…+a02°+…+a-m2-m) where n+m=N-2.The particular values for N,m,and n are machine-dependent. o floating-point notation 口“日1元4元↑至0QC Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/0920157/103
Computer Number Representation Two Schemes fixed-point notation Nfix = sign × αn2 n + αn−12 n−1 + · · · + α02 0 + · · · + α−m2 −m where n + m = N − 2. The particular values for N, m, and n are machine-dependent. floating-point notation. Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/09/2015 7 / 103
Computer Number Representation Two Schemes o fixed-point notation Mx=sign×(an2”+an-12n-1+…+a02°+…+a-m2-m) where n+m=N-2.The particular values for N,m,and n are machine-dependent. o floating-point notation. 1口“4元,4元↑重QC Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/0920157/103
Computer Number Representation Two Schemes fixed-point notation Nfix = sign × αn2 n + αn−12 n−1 + · · · + α02 0 + · · · + α−m2 −m where n + m = N − 2. The particular values for N, m, and n are machine-dependent. floating-point notation. Weihua Gu (Shanghai Jiao Tong University) Computational Physics Chapter 1 14/09/2015 7 / 103