Docsity

Computational Physics - Study Materials | PHYS 4007, Study notes of Physics

Partial preview of the text

Download Computational Physics - Study Materials | PHYS 4007 and more Study notes Physics in PDF only on Docsity!

PHYS-4007/5007: Computational Physics

Course Lecture Notes

Section VI

Dr. Donald G. Luttermoser East Tennessee State University

Version 4.

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.

VI–2 PHYS-4007/5007: Computational Physics

d) Then solving for y, we get

y = y 1 + y^2 −^ y^1 x 2 − x 1 (x − x 1 ) = y 1 + m (x − x 1 ). (VI-2)

e) There may be times where you need a regularly spaced grid of data points (i.e., xj − xi = constant, where j − i =

  1. to pass to another function (such as an integration routine, see §VII of the notes). You would then need to interpolate your data to determine your data’s y values at the regularly spaced x values from your original (uneven) data. Such is the time when you would need a linear interpolation procedure. The IDL function INTERPOL will carry out such an operation for you.
  1. Lagrange Interpolation.

a) Suppose that the data on either side of the unknown point we are interested in is not following a linear distribution, but instead, is following a curved path. Then a straight line is not the best representation of your data.

b) In such cases, it is better to fit to a polynomial instead of a straight line. This leads us to an interpolation scheme developed by Lagrange.

c) One can fit an (n − 1)-order polynomial,

fi(x) ' a 0 + a 1 x + a 2 x^2 + · · · + an− 1 xn−^1 , (x ' xi)., (VI-3) to n values of the function f (x) evaluated at points xi.

d) The formula is written as the sum of polynomials

f (x) ' f 1 λ 1 (x) + f 2 λ 2 (x) + · · · + fnλn(x) , (VI-4)

Donald G. Luttermoser, ETSU VI–

where λi(x) =

∏n j( 6 =i)=

x − xj xi − xj

x − x 1 xi − x 1

x − x 2 xi − x 2

x − xn xi − xn

(VI-5)

and note that (^) ∞ ∑ i=

λi = 1. (VI-6)

e) For 3 points, Eq. (VI-4) provides a second-degree poly- nomial, while for eight points, it gives a seventh-order polynomial. It is easy to see that for 2 points, Lagrange interpolation just reduces to the linear interpolation de- scribed above.

f) The Lagrange interpolation has no constraints that the data be evenly spaced.

g) The difference between the value of the polynomial eval- uated at some x and that of the actual function is equal to the remainder : R ≈ (x − x 1 )(x − x 2 ) · · · (x − xn) n! f (n)(ζ) , (VI-7) where ζ lies somewhere in the interval of interpolation, but is otherwise undetermined.

h) Lagrangian interpolation is typically used to fit only local data, though it can be use to fit the data globally. How- ever, there are better ways to fit nonlinear global data =⇒ polynomial least square fitting (which we are not going to have time to cover in this class).

  1. Interpolation with Cubic Splines. a) A sophisticated variation of the n = 4 Lagrange interpo- lation, known as cubic splines sometimes offers superior fits to nonlinear data.

Donald G. Luttermoser, ETSU VI–

by approximating them from the second derivatives:

f (^) i(3) ' f^

(2) i+1 −^ f^

(2) i xi+1 − xi

. (VI-12)

i) In practice, it is better to use a cubic spline routine sup- plied by the programming language (e.g., SPLINE in IDL) or math library.

B. Data Fitting: Gaussian Distributions.

  1. The most important probability distribution for use in statistical analysis of data is the Gaussian or normal error distribution. a) Mathematically, it is an approximation to the binomial distribution for the special limiting case where the num- ber of possible different observations, n, become infinitely large and the probability of success, p, for each is finitely large so that np  1.

b) Physically, it is useful because it seems to describe the distribution of random observations for most experiments.

c) In spectra, it describes the shape of many spectral lines.

  1. This type of data fitting can be considered both a “global” and a “local” data fitting technique, depending on what is being fitted. In the case of spectra, one often finds either absorption lines and or emission lines superimposed on a gradually varying continuum. Often, it is useful just to isolate the individual lines from the continuum and fit these lines to the proper profile distribution. More times than not, such lines follow a Gaussian distribution.
  2. Figure VI-1 shows the Gaussian profile and labels the various components to this distribution. The Gaussian distribution func-

VI–6 PHYS-4007/5007: Computational Physics

-3σ -2σ σ 0 σ 2 σ 3 σ x - μ

PG

(x,

μ, σ)

PG (max)

‘μ’

Γ

σ

P.E.

Figure VI–1: The Gaussian distribution function.

tion is defined by

PG(x, μ, σ) =

σ

2 π exp

 −^1 2

( (^) x − μ σ

) 2   (^). (VI-13)

a) It is a continuous function describing the probability that from a parent distribution with a mean μ and a standard deviation σ, the value of the random observation would be x.

b) The probability function is properly defined such that the probability dPG(x, μ, σ) that the value of a random ob- servation will fall within the interval dx around x is given by dPG(x, μ, σ) = PG(x, μ, σ) dx. (VI-14)

c) Gaussian distributions are bell shaped and characterized by the full-width-at-half-maximum (FWHM), which is gen- erally called the half-width Γ =⇒ the range of x between

VI–8 PHYS-4007/5007: Computational Physics

  1. Gaussian Distributions in Nature: Absorption and Emission Lines. a) In many cases in nature and in the laboratory (e.g., stellar spectra and emission discharge tubes), dark and/or bright “lines” are seen in the spectra objects emit.

b) Often, the shapes of these lines, in either wavelength, fre- quency, or energy space, follow a Gaussian shape.

c) If a spectral line has a rest (also called “lab”) wavelength λ◦, we can describe a line profile, φ(∆λ), such that it is normalized over the entire profile: ∫ (^) +∞ −∞ φ(∆λ)^ d∆λ^ = 1^ ,^ (VI-21) where ∆λ = λ − λ◦ (VI-22) and λ represents the wavelength at a specific point along the profile. i) In practice (i.e., computer programming), one does not carry the integration from −∞ to +∞, but in- stead, just carries the integration across the line profile (i.e., ±(∆λ)max ≈ 3 σ to 5σ).

ii) Also note that

φ(∆λ) d∆λ = −φ(ν) dν , (VI-23)

where ν (= c/λ) is the frequency of the line profile.

d) If an object that is emitting a spectrum is moving with respect to the observer, the “rest” wavelength (i.e., line center) gets shifted via the Doppler effect: ∆λ λ◦

λ − λ◦ λ◦

vr c = z , (VI-24)

Donald G. Luttermoser, ETSU VI–

where here λ is the observed line center, λ◦ is the line center as measured in the lab, vr is the radial velocity of the moving object, c is the speed of light in the vacuum, and z is a parameter called the redshift. i) If a line is redshifted, λ > λ◦ and vr > 0 =⇒ the object is moving away from us.

ii) If a line is blueshifted, λ < λ◦ and vr < 0 =⇒ the object is moving toward us.

iii) Note that Eq. (VI-24) is valid only when vr  c (i.e., the motion is nonrelativistic).

e) We also can write a more general expression for the red- shift, z = ∆λ λ◦

√ √^ 1 +^ vr/c 1 − vr/c

− 1. (VI-25)

where, here, we have included the relativistic (i.e., vr < ∼ c) correction for the Doppler Effect. i) Rewriting this relativistic formula, we can express velocity as a function of redshift: vr c =

(z + 1)^2 − 1 (z + 1)^2 + 1.^ (VI-26)

ii) You will note that there is no way a velocity cal- culated from the relativistic form of the Doppler effect can exceed the of light =⇒ the special theory of relativity is not violated!

f) If an absorption/emission line has a Gaussian distribu- tion, its profile function follows the form

φ(∆λ) =

√^1

π ∆λG^ exp

 − ∆λ

2 ∆λ^2 G

  (^) (VI-27)

Donald G. Luttermoser, ETSU VI–

convolved with the Gaussian of the spectrograph.

c) Spectrographs with ∆λ 1 / 2 < 1 ˚A (1 ˚A = 10−^10 m) are said to be high-resolution or high-dispersion spectrographs.

d) Spectrographs with ∆λ 1 / 2 > 1 ˚A are said to be low- resolution or low-dispersion spectrographs.

e) ∆λ 1 / 2 effectively determines whether two spectral lines separated by ∆λ can be split into individual lines. i) If ∆λ < ∆λ 1 / 2 , the two spectral lines will appear as one in a spectrum.

ii) If ∆λ > ∆λ 1 / 2 , the two spectral lines will appear as two individual lines.

  1. Line profiles emitted from a gas tend to have Gaussian shapes due to the fact that the atoms and molecules that make up the gas are randomly moving in the gas =⇒ they are said to be following a Maxwellian or Maxwellian-Boltzmann distribution. a) As individual particles absorb and emit photons, the pho- tons are shifted via the Doppler effect based on their rel- ative thermal motion with respect to the observer.

b) As such, Gaussian profiles are often referred to as Doppler broadening of a spectral line.

c) Since the particles are following a Maxwellian distribution in velocity space, they have a Gaussian distribution in wavelength or frequency space, where the Gaussian (or Doppler) width is equal to the thermal Doppler width

∆λG = ∆λD = ∆λth = λ◦

√ 2 kT /mβ c

(VI-31)

VI–12 PHYS-4007/5007: Computational Physics

where k = 1. 38062 × 10 −^23 J/K is Boltzmann’s constant, T is the temperature of the gas, c is the speed of light, and mβ is the mass of the radiating particle.

d) As a result of this, one can determine the temperature of a gas by measuring the half-width of a line arising from a gas (after, of course, one has subtracted off the instrument profile).

e) In practice, life isn’t quite this easy as is shown in the Astrophysics course (ASTR-3415).

  1. Most of the math-oriented programming languages have func- tions that will fit data to a Gaussian profile. In IDL, there are 2 intrinsic functions dealing with fitting Gaussians: a) The GAUSSFIT function computes a non-linear least-squares fit to a function f (x) with from 3 to 6 unknown param- eters. f (x) is a linear combination of a Gaussian and a quadratic; the number of terms is controlled by the key- word parameter NTERMS. The syntax for this function is

Result = GAUSSFIT(X, Y [, A] [, ESTIMATES=array] [, NTERMS=integer(3 to 6)])

(Note that the square brackets ‘[ ]’ here means optional parameters.) i) X: An n-element vector of independent variables (data).

ii) Y: A vector of dependent variables (same vector length as X).

VI–14 PHYS-4007/5007: Computational Physics

  • NTERMS=3:

f (x) = A 0 e−z^2 /^2.

Note that this last value just fits the data to a Gaussian profile.

b) Result = GAUSSINT(X) evaluates the integral of the Gaus- sian probability function and returns the result. The Gaussian integral is defined as:

GAUSSINT(X) ≡

√^1

2 π

∫ (^) x −∞ e

−t^2 / (^2) dt.

If X is double precision, the result is double precision, oth- erwise the argument is converted to floating-poin and the result is floating point. The result has the same structure as the input argument, X.

C. Data Fitting: The Method of Least Squares.

  1. Introduction. Here we will discuss fitting data to a straight line. See your textbook for a more general discussion of Least Squares for higher-order equation fits. a) If the data measurements are a linear function of some other variable, we can use the method of linear least- squares fit.

b) The data will contain errors in their measurement, as such, we will need to calculate a goodness of fit.

c) Let’s say that y = f (x) in a linear sense, then

y = a 1 + a 2 x , (VI-32)

then, our task is the figure out a 1 (i.e., the y-intercept), a 2 (i.e., the slope), and their uncertainties from the data.

Donald G. Luttermoser, ETSU VI–

Note that some authors use the y = A + Bx notation and others use y = b + mx notation. These, of course, are all the same equation with a 1 = A = b (i.e., y-intercepts) in the three equations and a 2 = B = m (i.e., the slopes).

d) The method of least-squares also is called linear regres- sion.

  1. The Goodness of Fit: χ^2. a) The chi-squared test also is called the Method of Max- imum Likelihood. It is the assumption that the observed set of measurements is more likely to have come from the parent distribution than some other distribution or ran- dom event.

b) The χ^2 is determined with

χ^2 ≡ ∑N i=

( (^) ∆y i σi

) 2

∑N i=

  yi^ −^ f^ (xi) σi

 

2

∑N i=

  1 σ i^2 (yi − a 1 − a 2 xi)^2

  (^) , (VI-33)

where N represents the total number of data measure- ments.

c) The best fit to the assumed functional dependence will occur when χ^2 is at a minimum: ∂χ^2 ∂am = 0, (m = 1, M), (VI-34)

where M is the maximum number of terms in our poly- nomial fit.

Donald G. Luttermoser, ETSU VI–

  ∑^ N i=

x^2 i σ i^2

∑N i=

yi σ i^2

∑N i=

xi σ^2 i

∑N i=

xiyi σ^2 i

 

= SxxSy^ −^ SxSxy ∆

(VI-39)

a 2 =

∣∣ ∣∣ ∣∣

∑(1/σ 2 i )^

∑(y ∑ i/σ^ i^2 ) (xi/σ^2 i ) ∑(xiyi/σ^2 i )

∣∣ ∣∣ ∣∣

= 1 ∆

  ∑^ N i=

σ i^2

∑N i=

xiyi σ^2 i

∑N i=

xi σ^2 i

∑N i=

yi σ^2 i

 

= SSxy^ −^ SxSy ∆

(VI-40)

∣∣ ∣∣ ∣∣

∑(1/σ 2 i )^

∑(x ∑ i/σ^2 i^ ) (xi/σ i^2 ) ∑(x^2 i /σ i^2 )

∣∣ ∣∣ ∣∣

=

∑N i=

σ^2 i

∑N i=

x^2 i σ i^2

  ∑^ N i=

xi σ i^2

 

2

= SSxx − S x^2 (VI-41)

  1. Combining Statistical and Experimental Errors. a) In the equations above, yi corresponds to individual mea- surements each with their own statistical errors =⇒ statistical fluctuations in the collection of finite numbers over a finitely long interval of time =⇒ σi(yi).

b) Note that there also can be uncertainties in our indepen- dent variable xi. i) For example, yi might be displacement measure- ments and xi the times the measurements are made.

ii) Since the time measurement also has an uncer- tainty, σi(xi), we have 2 uncertainties to worry about.

iii) σi(xi) is referred to as the experimental error.

VI–18 PHYS-4007/5007: Computational Physics

c) As such, the σi’s in Eqs. (VI-39) through (VI-41) are the combination of these 2 uncertainties which is found with

σ i^2 = σ i^2 (xi) + σ i^2 (yi). (VI-42)

  1. If we known the statistical and experimental errors, or have de- termined an approximate σ from the sample variance from your fitted function, the theory of least squares then gives an expres- sion for the variance or uncertainty in the deduced parameters:

σ a^21 = Sxx ∆ , σ^2 a 2 =

S

. (VI-43)

  1. A measure of the dependence of the parameters on each other is given by the correlation coefficient:

ρ(a 1 , a 2 ) = cov(a 1 , a 2 ) σa 1 σa 2

, (VI-44)

cov(a 1 , a 2 ) = −Sx ∆

. (VI-45)

a) Here cov(a 1 , a 2 ) is the covariance of a 1 and a 2 and vanishes if a 1 and a 2 are independent.

b) The correlation coefficient ρ(a 1 , a 2 ) lies in the range − 1 ≤ ρ ≤ 1. i) Positive ρ indicates that the errors in a 1 and a 2 are likely to have the same sign.

ii) Negative ρ indicate opposite signs.

  1. The preceding analytic solutions for the parameters are of the form found in statistics books, but are not optimal for numerical calculations because subtractive cancellation can make the an- swers unstable. We can improve the stability of the calculations