












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













Igor Volobouev
Computational Physics (PHYS 5322)
Texas Tech University
Learning how to get the models right is the one of themain purposes of this course Bodies move in elliptical orbits in a central gravitationalfield? Such a nice abstraction! Now, lets try to use GPSsatellite orbits so that we can determine our owncoordinates with ~1 m precision. Suddenly, we have totake into account that
Earth is neither round nor uniform, it rotates and has tides There are many other bodies in the solar system Sun exerts radiation pressure There is some residual atmosphere even at 20,000 km altitude Clocks run at different rates on the satellites and on the ground Signals move in curved trajectories (just as Einstein predicted) Atmosphere (ionosphere in particular) is a refractive medium
If you’ve done all you can and the model still does notwork – perhaps you have discovered new physics!
Usually easy to deal with
The computer actually tells you when your hard drivestarts dying. Just pay attention.
However, certain failure mechanisms are difficultto detect and control
Design mistakes (pentium FDIV bug) Electromigration Power glitches Single event upsets
Redundancy helps when calculations aremission-critical
Example: triple or quadruple computer redundancy isstandard on space systems and ICBMs You might want to repeat a long-running calculation
0
0
x
N n
n
n
n
x
−
=
∞ =
−
Numbers are represented in a computer withlimited range and accuracy
Hypothetical example: let say, computer keeps fourdecimal places. Then 1/3 = 0.3333 and 2/3 = 0.6667.Now, 2*(1/3) – 2/3 = – 0.
≠
Representing numbers in “double precisionfloating point” (every such number in a computeris encoded using 64 bits) is a reasonable trade-off between accuracy, range, and computationspeed
This may not be optimal for all types of applications.Arbitrary-precision arithmetic software packages doexist and can be used if necessary. They incur a hugehit in computation speed (FPU becomes useless).
IEEE 754 Representation for
Doubles
Number Type
s
e
, and
f
Value
Normal
e
Subnormal
e
f
Signed zero
e
f
s
e
f
+Inf
s
e
f
–Inf
Not a number
e
f
NaN
1023
−
×
×
−
e
f
s
1022
−
×
×
−
f
s
×
−
s
Precision: 1 part in 2
52
(approximately 16 decimal
places) Range: from 4.9 × 10
to 1.8 × 10
308
Underflow: happens when result magnitude issmaller than the smallest positive number.Usually converted to 0. Overflow: happens when result magnitude islarger than the largest positive number. Usuallyconverted to Inf. 0/0, 0×
etc.
produce NaNs.
FP
FP
FP
b
c
FP
b
c
FP
a
a
b
c
b
c
FP
FP
FP
b
c
FP
b
c
b
c
m
m
Approximation errors in algorithms often behaveas
α
k
(for large
) where
is the number of
steps and
α
and
k
are some empirical constants.
If we assume that round-off errors from differentsteps are uncorrelated then the total errorbehaves as
ε
total
α
k
β√
(where
β
is the
error from one step, usually on the order ofseveral
ε
m
). The first term dominates at small
and the second at large
. As a consequence,
there is an optimal value of
at which
ε
total
is
minimized.
Best way to study convergence: compare with a knownanswer for some parameter values in your problem If there is no reference case, study the behavior of yourresult,
R
, as a function of
N
. Plot
as a function of log
10
N
(
R
(
2N
) approximates the exact
answer)
.
If you obtain a straight line drop-off, you can
deduce the value of
k
from the slope. If your code is fast,
run until you see the onset of the round-off errordomination. Be sensible: the error model just described might not workfor your particular algorithm. Also, converged
≠
correct.
log
10
Hopefully, this lecture will help you scratch yourhead in a more systematic manner when resultsof your calculations do not look right Let’s do some exercises now: http://highenergy.phys.ttu.edu/~igv/Computation alPhysics/Labs/lab1.html Reading assignment for the next class: chapters1 and 2 from Giordano & Nakanishi. Don’t forgetthe programming homework you already have.