Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Course Lecture Notes - Computational Physics | PHYS 4007, Study notes of Physics

Material Type: Notes; Professor: Luttermoser; Class: Computational Physics; Subject: Physics (PHYS); University: East Tennessee State University; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 08/18/2009

koofers-user-h0l-2
koofers-user-h0l-2 🇺🇸

10 documents

1 / 23

Toggle sidebar

Related documents


Partial preview of the text

Download Course Lecture Notes - Computational Physics | PHYS 4007 and more Study notes Physics in PDF only on Docsity! PHYS-4007/5007: Computational Physics Course Lecture Notes Section V Dr. Donald G. Luttermoser East Tennessee State University Version 4.1 Abstract These class notes are designed for use of the instructor and students of the course PHYS-4007/5007: Computational Physics taught by Dr. Donald Luttermoser at East Tennessee State University. Donald G. Luttermoser, ETSU V–3 is much less than the total number of “real” num- bers (which of course is infinite). iii) The more calculations a computer does, the larger the roundoff error. iv) This error can cause some algorithms to become unstable. v) If the roundoff error value > value of the number being represented =⇒ the result is referred to as garbage. vi) For instance, a computer may compute the fol- lowing as 2 ( 1 3 ) −2 3 = 0.6666666−0.6666667 = −0.0000001 6= 0 . vii) We need to worry about significant figures on a computer: • On a 32-bit CPU, single precision is stored in one word → 4 bytes (REAL∗4 or REAL). • On a 32-bit CPU, double precision is stored in two words → 8 bytes (REAL∗8). • Trailing digits beyond these “bytes” are lost (if you ask a code to print more digits out, the printed digits should be considered as garbage ). f) What kind of error do we make in representing a real number in a floating point number system? V–4 PHYS-4007/5007: Computational Physics i) Absolute Error: true value - approximate value. ii) Relative Error: true value - approximate value true value . Relative error is not defined if the true value is zero. 2. Accuracy versus Precision. a) Accuracy is how close an experiment comes to the “true” value. i) It is a measure of the correctness of the result. ii) For an experimenter, it is a measure of how skilled the experimenter is. iii) For a programmer, it is a measure on how good they are at programming and the assumptions used in the algorithm. b) Precision of an experiment is a measure of how exactly the result is determined without reference to what the results means. i) It is a measure of the precision of the instruments being used in the experiment. ii) The precision of an experiment is dependent on how well we can overcome or analyze random er- rors. iii) In programming, it is a measure of how many bits are used to store numbers and perform calculations. Donald G. Luttermoser, ETSU V–5 3. Uncertainties. a) The term error signifies a deviation of the result from some “true” value. i) However, since we often cannot know the “true” value of a measurement prior to the experiment, we can only determine estimates of the errors inherent to the experiment. ii) The difference between two measurements is called the discrepancy between the results. iii) The discrepancy arises due to the fact that we can only determine the results to a certain uncer- tainty. b) There are two classes of uncertainties: i) The most prominent type: Those which result from fluctuations in repeated measurements of data from which the results are calculated. ii) The secondary type: Those which result from the fact that we may not always know the appropriate theoretical formula for expressing the result. c) Probable Error: The magnitude of the error which we estimate we have made in our determination of the results. i) This does not mean that we expect our results to be wrong by this amount. ii) Instead, it means that if we are wrong in our re- sults, it probably won’t be wrong by more than the probable error. V–8 PHYS-4007/5007: Computational Physics B. Useful Theorems in Computational Physics. 1. Intermediate Value Theorem. Let f(x) ba a continuous func- tion on the closed interval [a, b]. If for some number α and for some x1, x2 ∈ [a, b] we have f(x1) ≤ α ≤ f(x2), then there is some point c ∈ [a, b] such that α = f(c). (V-5) Here the notation [a, b] means the interval consisting of the real numbers x such that a ≤ x ≤ b. 2. Rolle’s Theorem. Let f(x) be continuous on the closed, finite interval [a, b] and differentiable on (a, b). If f(a) = f(b) = 0, there is a point c ∈ (a, b) such that f ′(c) = 0. (V-6) Here the notation (a, b) means the interval consisting of the real numbers x such that a < x < b. 3. Mean-Value Theorem for Integrals. Let g(x) be a non- negative function integrable on the interval [a, b]. If f(x) is con- tinuous on [a, b], then there is a point c ∈ [a, b] such that ∫ b a f(x)g(x) dx = f(c) ∫ b a g(x) dx (V-7) (more to come in §VII of the notes). 4. Mean-Value Theorem for Derivatives. Let f(x) be continu- ous on the finite, closed interval [a, b] and differentiable on (a, b). Then there is a point c ∈ (a, b) such that f(b)− f(a) b − a = f ′(c) (V-8) (more to come in §VII of the notes). Donald G. Luttermoser, ETSU V–9 5. Taylor’s Theorem (with Remainder). Let f(x) have the continuous derivative of order n + 1 on some interval (a, b) con- taining the points x and x◦. Set f(x) = f(x◦) + f ′(x◦) 1! (x − x◦) + f ′′(x◦) 2! (x − x◦)2 + + · · · + f (n)(x◦) n! (x − x◦)n + Rn+1(x). (V-9) Then there is a number c between x and x◦ such that Rn+1(x) = f (n+1)(c) (n + 1)! (x − x◦)n+1. (V-10) 6. Let f(x) be a continuous function on the finite, closed interval [a, b]. Then f(x) assumes its maximum and minimum values on [a, b]; i.e., there are points x1, x2 ∈ [a, b] such that f(x1) ≤ f(x) ≤ f(x2) (V-11) for all x ∈ [a, b]. 7. Integration by Parts. Let f(x) and g(x) be real values func- tions with derivatives continuous on [a, b]. Then ∫ b a f ′(t)g(t) dt = f(t)g(t)|t=bt=a − ∫ b a f(t)g′(t) dt. (V-12) 8. Fundamental Theorem of Integral Calculus. Let f(x) be continuous on the interval [a, b], and let F (x) = ∫ x a f(t) dt for all x ∈ [a, b]. (V-13) Then F (x) is differentiable on (a, b) and F ′(x) = f(x). (V-14) V–10 PHYS-4007/5007: Computational Physics C. The Mathematics of Errors and Uncertainties. 1. Subtractive Cancellation. a) For the following, let the “actual” numbers be represented by unmarked variables and those on the computer be des- ignated with a ‘c’ subscript. b) The representation of a simple subtraction is then a = b − c =⇒ ac = bc − cc , (V-15) ac = b(1 + b) − c(1 + c) , (V-16) =⇒ ac a = 1 + b b a − c a c , (V-17) where the error of the number/variable is given by  = computer number - actual number actual number . (V-18) c) From Eq. (V-17), the average error in a is a weighted average of the errors in b and c. d) We can have some cases, however, when the error in a increases when b ≈ c because we subtract off (and thereby lose) the most significant parts of both numbers =⇒ this leaves the least significant parts. e) If you subtract two large numbers, and end up with a small one, there will be less significance in the small one. i) For example, if a is small, it must mean that b ≈ c and so ac a = 1 + a , (V-19) a ≈ b a (b − c) . (V-20) Donald G. Luttermoser, ETSU V–13 iv) As such, this long of a calculation with 32-bit arithmetic (hence inherently possesses only 6 to 7 places of precision) probably contains much noise. 3. Definitions from Statistics and Probability Theory. a) The mean, µ, of the parent population (i.e., measure- ments) is defined as the limit of the sum N determinations xi of the quantity x divided by the number N determina- tions. µ ≡ lim N→∞   1 N N∑ i=1 xi   . (V-25) The mean is therefore equivalent to the centroid or aver- age value of the quantity x. b) The median, µ1/2, of the parent population is defined as that value for which, in the limit of an infinite number of determinations xi of the quantity x, half of the observa- tions will be less than the median and half will be greater than the median. i) In terms of the parent distribution, this means that the probability, P , is 50% that any measure- ment xi will be large or smaller than the median: P (xi ≤ µ1/2) = P (xi ≥ µ1/2) = 50%. (V-26) ii) Much computer time is wasted by figuring out median values. As such, fast sorting routines have been developed in many programming languages (e.g., SORT in IDL). Then, the median is just the element in an array that is at the midway point. c) The most probable value, µmax, of the parent popula- tion is that value for which the parent distribution has V–14 PHYS-4007/5007: Computational Physics greatest value: P (µmax) ≥ P (x 6= µmax) . (V-27) d) The deviation di of any measurement xi from the mean µ of the parent distribution is defined as di = xi − µ . (V-28) i) Deviations are generally defined with respect to the mean for computational purposes. ii) If µ is the true value of the quantity, then di is the true error in xi. iii) The average deviation d for an infinite number of observations must vanish by virtue of the definition of the mean (see Eq. V-25): lim N→∞ d = lim N→∞   1 N N∑ i=1 (xi − µ)   = lim N→∞   1 N N∑ n=1 xi  − µ = µ − µ = 0 . iv) The average deviation α, therefore, is defined as the average of the magnitudes of the deviations, which are given by the absolute values of the devi- ations: α ≡ lim N→∞   1 N N∑ n=1 |xi − µ|   . (V-29) v) The average deviation is a measure of the disper- sion of the expected observations about the mean. Donald G. Luttermoser, ETSU V–15 e) The variance σ2 is defined as the limit of the average of the squares of the deviations of the mean: σ2 ≡ lim N→∞   1 N N∑ n=1 (xi − µ)2   = lim N→∞   1 N N∑ n=1 x2i  − µ2 . (V-30) i) The standard deviation σ is the square root of the variance. ii) The standard deviation is thus the root mean square of the deviations, where we define the root mean square to be the square root of the mean or average of the square of an argument. iii) In computational work, the standard deviation σ is considered an appropriate measure of the uncer- tainty of a measurement or a calculation. 4. Errors in Algorithms. An algorithm is often characterized by its step size h or by the number of steps N it takes to reach its goal. If the algorithm is “good,” it should give an exact answer in the limit h → 0 or N → ∞. Here, we present methods for determining the error in your code. a) Let’s assume that an algorithm takes a large number of N steps to get a good answer and that the approximation error approaches zero like apprx ' α Nβ . (V-31) b) In Eq. (V-31), α and β are empirical constants that would change for different algorithms, and may be “constant” only for N → ∞. V–18 PHYS-4007/5007: Computational Physics b) How do the uncertainties in L◦, W◦, and H◦ affect the uncertainty in V◦? Let L, W , H, and V be the actual (i.e., ‘true’) value, then ∆L = L◦ − L, ∆W = W◦ − W , and ∆H = H◦ − H. c) The error in V is approximately the sum of the products of the errors in each dimension times the effect that di- mension has on the final value of V : ∆V ' ∆L ( ∂V ∂L ) + ∆W ( ∂V ∂W ) + ∆H ( ∂V ∂H ) , (V-38) of for our example, ∆V ' W◦ H◦ ∆L + L◦ H◦ ∆W + L◦ W◦ ∆H . (V-39) Dividing this equation by Eq. (V-37) gives ∆V V◦ ' ∆L L◦ + ∆W W◦ + ∆H H◦ . (V-40) 2. In general, we do not know the actual errors in the determina- tion of any of the parameters. The following describes how we estimate the uncertainties. a) Let’s define x = f(u, v, . . .) . (V-41) b) Assume the most probable value for x is given by x = f(u, v, . . .) . (V-42) c) Individual results for x (xi) are found by individual mea- surements of other parameters, that is ui, vi, . . ., giving xi = f(ui, vi, . . .) . (V-43) d) Using Eq. (V-30), the variance in x is then σ2x = limN→∞ 1 N ∑ (xi − x)2 . (V-44) Donald G. Luttermoser, ETSU V–19 e) Following Eq. (V-38), the deviation for measurement in x is xi − x ' (ui − u) ( ∂x ∂u ) + (vi − v) ( ∂x ∂v ) + · · · (V-45) f) Combining these two equations gives σ2x = limN→∞ 1 N ∑[ (ui − u) ( ∂x ∂u ) + (vi − v) ( ∂x ∂v ) + · · · ]2 = lim N→∞ 1 N ∑  (ui − u)2 ( ∂x ∂u )2 + (vi − v)2 ( ∂x ∂v )2 + 2(ui − u)(vi − v) ( ∂x ∂u ) ( ∂x ∂v ) + · · · ]2 = σ2u ( ∂x ∂u )2 + σ2v ( ∂x ∂v )2 + 2σ2uv ( ∂x ∂u ) ( ∂x ∂v ) + · · · , (V-46) where σ2uv ≡ limN→∞ 1 N ∑ [(ui − u)(vi − v)] . (V-47) g) If measurements in u and v are uncorrelated, one should get as many negative values as positive values for the terms in the series of Eq. (V-47). As such, this summation in Eq. (V-47) → 0. So σ2x = σ 2 u ( ∂x ∂u )2 + σ2v ( ∂x ∂v )2 + · · · (V-48) 3. Specific Formulas. a) Addition and Subtraction. Let x be the weighted sum of u and v: x = au ± bv . (V-49) i) Then, the partial derivatives are simply the weight- ing coefficients (which are constant): ( ∂x ∂u ) = a , ( ∂x ∂v ) = ±b . (V-50) V–20 PHYS-4007/5007: Computational Physics ii) Eq. (V-46) then becomes σ2x = a 2σ2u + b 2σ2v + 2abσ 2 uv . (V-51) b) Multiplication and Division. Now let x be the weighted product of u and v: x = ±auv . (V-52) i) The partial derivatives of each variable contain the values of the other variable: ( ∂x ∂u ) = ±av , ( ∂x ∂v ) = ±au . (V-53) ii) Eq. (V-46) yields σ2x = a 2v2σ2u + a 2u2σ2v + 2a 2uvσ2uv , (V-54) which can be expressed more symmetrically as σ2x x2 = σ2u u2 + σ2v v2 + 2 σ2uv uv . (V-55) iii) Similarly, if x is obtained through division, x = ±au v , (V-56) the variance for x is given by σ2x x2 = σ2u u2 + σ2v v2 − 2σ 2 uv uv . (V-57) c) Powers. Let x be obtained by raising the variable u to a power: x = au±b . (V-58) i) The partial derivative of x with respect to u is ( ∂x ∂u ) = ±abu±b−1 = ±bx u . (V-59)
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved