Loading [MathJax]/extensions/TeX/mathchoice.js

Wednesday, February 1, 2017

Spherical Harmonics - learn to roll your own

It doesn't take much reading about the cosmic microwave background before you butt up against the concept of spherical harmonics (aka those funny looking Yml(θ,ϕ) guys) and if you're like me they threw you for a loop at first glance. Typically introduced in the context of studying anisotropies of the CMB they are essentially an alternate way of representing functions defined on the surface of a sphere. In this case the sphere we're interested in is the sky around the Earth and the function to be represented is the intensity of CMB radiation finally arriving at Earth after billions of years flying through space between photon decoupling during recombination and today. I won't go into too much detail about the physics of the CMB in this post but suffice it to say that these anisotropies are the definitive evidence for the Big Bang and cosmological inflation.

Spherical harmonics can be used to represent any arbitrary function as a (potentially infinite) list of coefficients that weight how much each harmonic contributes. If you're coming from an engineering background this may make more sense when thought of like an extension to the Fourier series where an arbitrary function can be decomposed into a (potentially infinite) weighted sum of sinusoids, each representing a specific frequency component of the original signal. Spherical harmonics are much the same but rather than using one-dimensional sinusoids defined along a circle the decomposition uses two-dimensional functions defined along the surface of a sphere. What is important to grok is that any signal can be totally defined solely in terms of the values of the weights for each harmonic.

To get a better understanding of how exactly this works in practice I wrote a small program to generate image maps to visually see how each unweighted harmonic varies across the surface of the sphere. The first step in doing so was getting a basic handle on the math involved. We'll start with the formal definition of our signal of interest T(θ,ϕ) where Yml is a spherical harmonic (specific to degree l and order m) and aml is the weighting factor for that specific harmonic.

T(θ,ϕ)=l=0+lm=lamlYml(θ,ϕ)

We're interested in displaying each harmonic individually so we'll need the definition of the spherical harmonic Yml with normalization factor nml.

Yml(θ,ϕ)=nmlPml(cos(θ))eimϕ
nml=2l+14π(lm)!(l+m)!

Keep in mind aml and eimϕ are both complex quantities even if the end result we're displaying will just be the real value.

amlYml(θ,ϕ)=amlnmlPml(cos(θ))eimϕ
amlYml(θ,ϕ)=nmlPml(cos(θ))aml(cos(mϕ)+i sin(mϕ))
amlYml(θ,ϕ)=nmlPml(cos(θ))(Re(aml)+i Imag(aml))(cos(mϕ)+i sin(mϕ))
Re(amlYml(θ,ϕ))=nmlPml(cos(θ))(Re(aml)cos(mϕ)Imag(aml)sin(mϕ))

For the purposes of the image generation I'm simply using Re(aml)=Imag(aml)=1.

Pml is the associated Legendre polynomial. For this the easiest way to deal with the associated Legendre polynomials was to simply precompute them as I wasn't able to find a free C# library for computing them dynamically. Since I'm planning on generating 6000x3000 pixel images that are rectilinear projections of the surface of the sphere I'll need 3000 equally spaced samples. This is relatively simple to generate with numerical computing software such as GNU Octave or MATLAB. The script I used in Octave to generate the values for the first 50 associated Legendre polynomials Pml of cos(θ) and export them to CSVs is below.

for i = 0:49 
csvwrite(strcat(strcat("legendres-",num2str(i)),".csv"), legendre(i, cos(0:pi/3000:pi*2999/3000)));
endfor

Note that this only gets you results for m>=0 but we can extend this with the simple relation below.

Pml=(1)m(lm)!(l+m)!Pml

That's all the math we're using! I wrote up a quick script that reads in the CSV output from the Octave script and uses it to calculate Re(amlYml(θ,ϕ)) for each l where l50 and each m where lml linearly sampling θ between 0 and π 3000 times and ϕ between 0 and 2π 6000 times. It then takes the resulting data and outputs an image where the minimum value is blue and the maximum value is red. The entire project is available here: https://github.com/btouellette/SphericalHarmonics/

The whole purpose of doing this was to get a better handle on the concept of spherical harmonics by visual inspection so let's take a look at what we end up with!

l=0, m=0

l=1, m=0

l=1, m=1

l=2, m=0

l=2, m=1

l=2, m=2

l=3, m=0

l=3, m=1

l=3, m=2

l=3, m=3

A quick look at the results shows us that l is related to the number of repetitions on the surface of the sphere and m is related to the "orientation" of the repetitions. I've left out the images for negative m as they aren't particularly illuminating but a quick look will confirm that they are simply the same as the positive m results but with a rotation of 90°m applied.

One last look at these, this time from the perspective of an observer inside the sphere looking outward as we do at the cosmos!






Thursday, November 12, 2015

The Friedmann Equation from the beginning

The single most important equation of modern cosmology is the Friedmann equation which relates the expansion of space to the energy density and curvature of the universe.
(˙aa)2=8πG3ρkc2a2
It was discovered in 1922 as a consequence of general relativity and accurately describes the Hubble expansion despite being introduced seven years before Hubble discovered his law. It applies in a simplified universe which consists only of a perfect fluid and is isotropic (looks the same no matter which way you look) and homogenous (is the same everywhere). The conditions of isotropy and homogeneity are commonly known as the cosmological principle. While it obviously does not hold on small scales, on large enough distance scales the cosmological principle appears to be true. Averaging over large enough distances things seem to look the same in every direction and at every place. The precise scale at which things begin to look statistically homogenous and the validity of the cosmological principle itself have been debated as larger and larger structures are found but there is still strong evidence in support of it in the incredible homogeneity of the cosmic microwave background.

To speak mathematically about the expansion of the universe we first need to define a scale factor a(t) which is a relation between the size of the universe at time t and now (usually referred to as t0) such that at the current time a=1. At a point where the universe is half the size it is today a=0.5. The evolution of the scale factor with time tells us exactly how the universe expands or contracts over time. As a consequence of homogeneity the scale factor can only be a function of time, not position.

We can (and will) derive the Friedmann equation from the Einstein equation but we can arrive at the same result with a much simpler argument. First let us define a comoving coordinate, one which moves with the expansion of the universe such that the coordinate of a point does not change with time. The physical distance between two points in the universe is time-dependent due to the expansion of the universe but the (comoving) coordinate distance between two points remains fixed. By reusing the scale factor to define comoving coordinate R=ra(t) we can arrive at some simple relations to R for distance, velocity, acceleration, and volume respectively.

r=aR
˙r=˙aR
¨r=¨aR
V=43πa3R3

Imagine an expanding spherical shell of mass m at a constant comoving R in a homogenous expanding universe. Using the shell theorem (which generalizes to general relativity) the only gravitational potential energy for the shell comes from the mass interior to the shell. Because the shell is defined by a comoving coordinate the total mass interior to the shell remains constant.
Mi=V(t)ρ(t)=43πr3(t)ρ(t)=43πa3(t)R3ρ(t)
Conservation of mechanical energy of this spherical shell of mass implies the sum of potential and kinetic energy for the shell remains constant:
K(t)+U(t)=E
Let us introduce a new parameters k (dimensions of 1length2) such that the energy takes the form 12mkc2R2. Remember that R for a given expanding mass shell is constant with dimensions length.
12m˙r2(t)GMimr(t)=12mkc2R2
If the total energy of the system is 0 the mass shell comes to rest at infinity (k=0, flat). If the total energy of the shell is negative the shell eventually halts and contracts back in on itself (k>0, closed, bounded). If the total energy is positive the shell expands forever (k<0, open, unbounded). Replacing ˙r(t) and Mi and simplifying:
12m˙a2(t)R243πGa2(t)R2ρ(t)m=12mkc2R2
˙a2(t)R283πGa2(t)R2ρ(t)=kc2R2
(˙a(t)a(t))283πGρ(t)=kc2a2(t)
The final equation correctly does not depend on r or R as it must satisfy our initial assumptions of homogeneity. It must only be a function of parameters which are the same everywhere in the universe and for every potential shell. Any possible changes done to this system that don't violate homogeneity or isotropy won't change the energy of the mass shell so k is constant. As an aside in some situations you will see k interpreted as a dimensionless parameter where k{+1,0,1} corresponding to our three cases for the total energy of the shell. Doing so simply requires a reinterpretation of the scale factor a(t) to incorporate some of the aspects of k associated with the curvature of the space and to have units of length. I will touch on the curvature aspect later but will maintain the convention of a(t) being dimensionless and k being on a continuum.

While this imaginary universe is certainly evocative this derivation is not exactly precise. What exactly is meant by the density ρ(t)? The shell theorem still holds in general relativity but it isn't clear whether this density is simply a matter density as would be appropriate in the Newtonian model or if it encompasses non-Newtonian sources of gravity such as radiation or dark energy. Let's take a step back from this imaginary model and examine things from the perspective of general relativity to attempt to clarify this issue.

The cosmological principle severely restricts the form the metric of the universe may take since the metric must be the same at every point in space and in every direction for a given time. More formally a spacetime is only isotropic and homogeneous if it can be divided up into a family of spacelike three-surfaces which are themselves isotropic and homogeneous. The time coordinate serves to identify individual spacelike three-surfaces with constant time across them. The most generic possible metric of any spacetime can be written as:
ds2=αc2dt2+3i=1βidxidt+dS2
Here dS2 is the line element of space (containing no time components) and α,β1,β2,β3 are all scaling constants. The first simplification we can perform is to change to a time coordinate in which α=1 via dt=αdt. This will also change the values of βi but as they are still just constants we arrive at a metric (where dt and βi are potentially different from the previous metric) with the form:
ds2=c2dt2+3i=1βidxidt+dS2
We know that the four-velocity for points in comoving coordinates must be in a timelike direction only as otherwise isotropy would be violated. Spatial velocity for these points would cause things to look different in the direction of the three-velocity compared to other directions (think Doppler effect). More formally the four-velocity of each point in comoving coordinates is orthogonal to any vector which is tangent to the surface of homogeneity (the spacelike three-surface of constant time). Mathematically this tells us that the four-velocity uα=(c,0,0,0), a tangent vector is of form xα=(0,x1,x2,x3), and for all tangent vectors:
ux=gμνuμxν=gtiutxi=gtixi=0
Since xi is not necessarily 0 this implies gti=0 for all i. As git=0 as well this further implies a lack of mixed space and time terms in the metric so βi=0 resulting in the metric:
ds2=c2dt2+dS2
The three-dimensional metric dS2 is also restricted by assumptions of isotropy and homogeneity. Due to homogeneity no matter what form the metric takes the curvature of space must be the same at all spatial positions for a given time. This limits us to one of three possible configurations. It is either flat, positively curved (spherical), or negatively curved (hyperbolic).


Remember that these images are two-dimensional surfaces embedded in three-dimensions and our use of these terms refers to the three-dimensional universe we live in and not to a lower dimensional embedding. Do not read too heavily into parallels with lower dimensional examples. The important takeaway is that in two-dimensional space these figures are the only types of surfaces which have the same curvature at each point along the two dimensional plane. Similarly if the cosmological principle holds the universe will have the same curvature at each point across the entire three dimensional space. One of the interesting parallels that does hold is that in a positively curved space the sum of the angles of a triangle is greater than 180° while in a negatively curved space the sum will be less than 180°. This is a consequence of the fact that the angle between two lines does not remain constant in a curved space and gives us an avenue for testing the curvature of space. While we can't construct cosmologically sized triangles to measure the angles of we can model the observational effects of different curvature on things like the incoming light from the cosmic microwave background or counts of galaxies at different distances compared to models of galactic formation.


dS2 may vary with time so long as it varies everywhere identically. One source of possible time variation is the scale factor. It must apply everywhere across the space (no position dependence) the same to maintain homogeneity giving dS2=a2(t)(dΩ3)2. The other similar source of time dependence is in the curvature which we have not assumed to be constant.

We know that (dΩ3)2 for the flat, isotropic, and homogenous universe takes the form dx2+dy2+dz2 in Cartesian coordinates as it is just the standard metric of three dimensional space. To explore the effect that the curvature might have on the metric we will introduce a fourth dimension w and consider the three dimensional universe as an embedded surface in a four dimensional space. For the spherical case and at a specific timeslice the surface with radius of curvature Rc (not to be confused with our comoving coordinate) is defined by:
R2c=x2+y2+z2+w2
We know that the three dimensional radius is defined by:
r2=x2+y2+z2
w2=R2cr2
Taking the differential of the original equation for the surface:
2RcdRc=2xdx+2ydy+2zdz+2wdw
Since this slice of geometry is taken at a specific time the curvature is just a constant:
0=xdx+ydy+zdz+wdw
dw=xdx+ydy+zdzw
dw=rdrR2cr2 
dw=rdrR2cr2
We now arrive at the distance function across the space without reference to our higher dimension w:
(dΩ3)2=dx2+dy2+dz2+dw2=dx2+dy2+dz2+r2dr2R2cr2
We recognize dx2+dy2+dz2 as our standard metric of three dimensional space and we have a an additional term which represents the change in the distance due to the curvature of the space. Rewriting entirely in spherical coordinates results in:
(dΩ3)2=dr2+r2(dθ2+sin2θdϕ2)+r2dr2R2cr2
Combining the dr2 terms and simplifying results in:
(dΩ3)2=(1+r2R2cr2)dr2+r2(dθ2+sin2θdϕ2)
(dΩ3)2=R2cR2cr2dr2+r2(dθ2+sin2θdϕ2)
(dΩ3)2=dr21r2R2c+r2(dθ2+sin2θdϕ2)
We can generalize this to the flat case by considering flat as the spherical case but with infinite radius of curvature and we can see as expected the final curvature related term in the metric drops out. For the hyperbolic case we repeat this procedure with a different equation defining the embedding:
R2c=x2y2z2w2
r2=x2y2z2
w2=R2cr2
0=xdxydyzdzwdw
dw=xdxydyzdzw
dw=rdrR2cr2 
(dΩ3)2=dx2dy2dz2dw2=dx2+dy2+dz2+r2dr2R2cr2
(dΩ3)2=dr2+r2(dθ2+sin2θdϕ2)+r2dr2R2cr2
Here we reach the same result as previously except with R2c interpreted as the negative of the square of the radius of curvature. We gain some insight into the role of k now by associating it with the Gaussian curvature of a two-dimensional spatial slice of the space at the current time (a(t)=1, necessary since expansion will reduce the curvature) allowing us to express all three cases with a single metric.
k=1R2c
(dΩ3)2=dr21kr2+r2(dθ2+sin2θdϕ2)
This makes the metric which is the most general possible metric compatible with the cosmological principle:
ds2=c2dt2+a2(t)(dr21kr2+r2(dθ2+sin2θdϕ2))
The terms closed/bounded and open/unbounded used for the different cases k>0 and k<0 refer to the volume integral V=AdΩ3 where A is constructed taking into account the scale factor. If k>0 this integral is definite and the universe can be said to have a finite volume at a fixed time.

Now that we have the final metric to play with we can get really down and dirty with it. Starting with the Einstein equation we look only at the temporal equation:
Rμν12gμνRΛgμν=8πGc4Tμν
Rtt12gttRΛgtt=8πGc4Ttt
A quick note here that the stress-energy tensor Tμν will have opposite sign depending on the definition used for the Ricci tensor so this will sometimes appear slightly differently. The sign of the cosmological constant Λ varies with the metric signature as well. By the way the history of the cosmological constant is quite interesting. It was originally inserted into the Einstein equation as an effort to describe a static universe and Friedmann and Hubble's discoveries led to it being removed. Recent observations calculating the acceleration of the expansion of the universe have shown the need for an energy density of empty space (or vacuum energy density) which takes the form of the cosmological constant. Moving forward we know gtt=c2 from a quick look at the metric reducing this to:
Rtt+12c2R+Λc2=8πGc4Ttt
The first thing we need to find is the Ricci curvature tensor Rμν which we find by contracting the Riemann tensor as defined by the Christoffel symbols of our metric. We'll use this to get the value of the Ricci scalar R as well:
Rμν=Rαμαν=νΓαμααΓαμν+ΓλμαΓαλνΓλμνΓαλα
R=gμνRμν
We'll need a bunch of Christoffel symbols so let's go ahead and calculate all of them. This is made much easier by the fact that our metric is diagonal. The only non-zero metric components are matched terms which are listed below along with all their partial derivatives:

gtt=c2
grr=a21kr2
gθθ=a2r2
gϕϕ=a2r2sin2θ

tgtt=0
rgtt=0
θgtt=0
ϕgtt=0

tgrr=2a˙a1kr2
rgrr=2kra2(1kr2)2
θgrr=0
ϕgrr=0

tgθθ=2a˙ar2
rgθθ=2a2r
θgθθ=0
ϕgθθ=0

tgϕϕ=2a˙ar2sin2θ
rgϕϕ=2a2rsin2θ
θgϕϕ=2a2r2sinθcosθ
ϕgϕϕ=0

Since our metric is diagonal this also makes finding the contravariant components trivial using gaagaa=1:

gtt=1c2
grr=1kr2a2
gθθ=1a2r2
gϕϕ=1a2r2sin2θ

Now we have everything we need to calculate the Christoffel symbols using:
Γik=12gim(gmk+kgmmgk)
The metric connection is necessarily torsion-free Γik=Γik reducing the number of calculations necessary.

Γttt=12gtm(tgmt+tgmtmgtt)=0
Γttr=Γtrt=12gtm(rgmt+tgmrmgtr)=0
Γttθ=Γtθt=12gtm(θgmt+tgmθmgtθ)=0
Γttϕ=Γtϕt=12gtm(ϕgmt+tgmϕmgtϕ)=0
Γtrr=12gtm(rgmr+rgmrmgrr)=12gtttgrr=a˙ac2(1kr2)
Γtrθ=Γtθr=12gtm(θgmr+rgmθmgrθ)=0
Γtrϕ=Γtϕr=12gtm(ϕgmr+rgmϕmgrϕ)=0
Γtθθ=12gtm(θgmθ+θgmθmgθθ)=12gtttgθθ=a˙ar2c2
Γtθϕ=Γtϕθ=12gtm(ϕgmθ+θgmϕmgθϕ)=0
Γtϕϕ=12gtm(ϕgmϕ+ϕgmϕmgϕϕ)=12gtttgϕϕ=a˙ar2sin2θc2

Γrtt=12grm(tgmt+tgmtmgtt)=0
Γrtr=Γrrt=12grm(rgmt+tgmrmgtr)=12grrtgrr=˙aa
Γrtθ=Γrθt=12grm(θgmt+tgmθmgtθ)=0
Γrtϕ=Γrϕt=12grm(ϕgmt+tgmϕmgtϕ)=0
Γrrr=12grm(rgmr+rgmrmgrr)=12grrrgrr=kr(1kr2)
Γrrθ=Γrθr=12grm(θgmr+rgmθmgrθ)=0
Γrrϕ=Γrϕr=12grm(ϕgmr+rgmϕmgrϕ)=0
Γrθθ=12grm(θgmθ+θgmθmgθθ)=12grrrgθθ=r(1kr2)
Γrθϕ=Γrϕθ=12grm(ϕgmθ+θgmϕmgθϕ)=0
Γrϕϕ=12grm(ϕgmϕ+ϕgmϕmgϕϕ)=12grrrgϕϕ=rsin2θ(1kr2)

Γθtt=12gθm(tgmt+tgmtmgtt)=0
Γθtr=Γθrt=12gθm(rgmt+tgmrmgtr)=0
Γθtθ=Γθθt=12gθm(θgmt+tgmθmgtθ)=12gθθtgθθ=˙aa
Γθtϕ=Γθϕt=12gθm(ϕgmt+tgmϕmgtϕ)=0
Γθrr=12gθm(rgmr+rgmrmgrr)=0
Γθrθ=Γθθr=12gθm(θgmr+rgmθmgrθ)=12gθθrgθθ=1r
Γθrϕ=Γθϕr=12gθm(ϕgmr+rgmϕmgrϕ)=0
Γθθθ=12gθm(θgmθ+θgmθmgθθ)=0
Γθθϕ=Γθϕθ=12gθm(ϕgmθ+θgmϕmgθϕ)=0
Γθϕϕ=12gθm(ϕgmϕ+ϕgmϕmgϕϕ)=12gθθθgϕϕ=sinθcosθ

Γϕtt=12gϕm(tgmt+tgmtmgtt)=0
Γϕtr=Γϕrt=12gϕm(rgmt+tgmrmgtr)=0
Γϕtθ=Γϕθt=12gϕm(θgmt+tgmθmgtθ)=0
Γϕtϕ=Γϕϕt=12gϕm(ϕgmt+tgmϕmgtϕ)=12gϕϕtgϕϕ=˙aa
Γϕrr=12gϕm(rgmr+rgmrmgrr)=0
Γϕrθ=Γϕθr=12gϕm(θgmr+rgmθmgrθ)=0
Γϕrϕ=Γϕϕr=12gϕm(ϕgmr+rgmϕmgrϕ)=12gϕϕrgϕϕ=1r
Γϕθθ=12gϕm(θgmθ+θgmθmgθθ)=0
Γϕθϕ=Γϕϕθ=12gϕm(ϕgmθ+θgmϕmgθϕ)=12gϕϕθgϕϕ=cosθsinθ
Γϕϕϕ=12gϕm(ϕgmϕ+ϕgmϕmgϕϕ)=0

Great, now we have everything we need to find Rμν using the contraction of the Riemann tensor and the following observations which help to reduce the number of necessary calculations
  1. The Ricci tensor is symmetric on a Riemannian manifold (Rμν=Rνμ)
  2. If the first and second or second and third lower index in the Riemann tensor are matched that component of the tensor must be zero through the skew symmetry of the tensor
  3. The Christoffel symbols of this metric are always zero if they do not have exactly two of their three indices matched
  4. If an upper and lower index of the Christoffel symbol are the matching ones it is only non-zero if the non-matching index precedes the matching one in this list: t,r,θ,ϕ
  5. If the Christoffel symbol has a t lower index it is only a function of t, not any spatial coordinate
Rμν=Rαμαν=Rtμtν+Rrμrν+Rθμθν+Rϕμϕν
Rtt=Rtttt+Rrtrt+Rθtθt+Rϕtϕt
Rtt=Rrtrt+Rθtθt+Rϕtϕt
Rtt=tΓrtr+ΓrtrΓrrt+tΓθtθ+ΓθtθΓθθt+tΓϕtϕ+ΓϕtϕΓϕϕt
Rtt=3t(˙aa)+3˙a2a2
Rtt=3(¨aa˙a2a2)+3˙a2a2
Rtt=3¨aa

Rtr=Rrt=Rtttr+Rrtrr+Rθtθr+Rϕtϕr
Rtr=Rrt=Rθtθr+Rϕtϕr
Rtr=Rrt=ΓθtθΓθθrΓrtrΓθrθ+ΓϕtϕΓϕϕrΓrtrΓϕrϕ=0

Rtθ=Rθt=Rtttθ+Rrtrθ+Rθtθθ+Rϕtϕθ
Rtθ=Rθt=Rrtrθ+Rϕtϕθ
Rtθ=Rθt=ΓrtrΓrrθΓθtθΓrθr+ΓϕtϕΓϕϕθΓθtθΓϕθϕ=0

Rtϕ=Rϕt=Rtttϕ+Rrtrϕ+Rθtθϕ+Rϕtϕϕ
Rtϕ=Rϕt=Rrtrϕ+Rθtθϕ
Rtϕ=Rϕt=ΓrtrΓrrϕΓϕtϕΓrϕr+ΓθtθΓθθϕΓϕtϕΓθϕθ=0

Rrr=Rtrtr+Rrrrr+Rθrθr+Rϕrϕr
Rrr=Rtrtr+Rθrθr+Rϕrϕr
Rrr=tΓtrr+ΓrrtΓtrr+rΓθrθ+ΓθrθΓθθrΓtrrΓθtθΓrrrΓθrθ+rΓϕrϕ+ΓϕrϕΓϕϕrΓtrrΓϕtϕΓrrrΓϕrϕ
Rrr=t(a˙ac2(1kr2))+˙aaa˙ac2(1kr2)+r(1r)+1r2a˙ac2(1kr2)˙aakr1kr21r+r(1r)+1r2a˙ac2(1kr2)˙aakr1kr21r
Rrr=˙a2c2(1kr2)a¨ac2(1kr2)2kr1kr21ra˙ac2(1kr2)˙aa
Rrr=2˙a2c2(1kr2)a¨ac2(1kr2)2k1kr2

Rrθ=Rθr=Rtrtθ+Rrrrθ+Rθrθθ+Rϕrϕθ
Rrθ=Rθr=Rtrtθ+Rϕrϕθ
Rrθ=Rθr=ΓϕrϕΓϕϕθΓθrθΓϕθϕ=0

Rrϕ=Rϕr=Rtrtϕ+Rrrrϕ+Rθrθϕ+Rϕrϕϕ
Rrϕ=Rϕr=Rtrtϕ+Rθrθϕ
Rrϕ=Rϕr=ΓθrθΓθθϕΓϕrϕΓθϕθ=0

Rθθ=Rtθtθ+Rrθrθ+Rθθθθ+Rϕθϕθ
Rθθ=Rtθtθ+Rrθrθ+Rϕθϕθ
Rθθ=tΓtθθ+ΓθθtΓtθθrΓrθθ+ΓθθrΓrθθΓtθθΓrtrΓrθθΓrrr+θΓϕθϕ+ΓϕθϕΓϕϕθΓtθθΓϕtϕΓrθθΓϕrϕ
Rθθ=t(a˙ar2c2)+˙aaa˙ar2c2+r(r(1kr2))1rr(1kr2)a˙ar2c2˙aa+r(1kr2)kr(1kr2)+θ(cosθsinθ)+cosθsinθcosθsinθa˙ar2c2˙aa+r(1kr2)1r
Rθθ=(˙a2r2c2+a¨ar2c2)+((1kr2)2kr2)+kr2(1sin2θ)+cos2θsin2θ˙a2r2c2
Rθθ=a¨ar2c2+(12kr2)(1sin2θ)+cos2θsin2θ2˙a2r2c2
Rθθ=a¨ar2c2+(12kr2)+cos2θ1sin2θ2˙a2r2c2
Rθθ=a¨ar2c22kr22˙a2r2c2

Rθϕ=Rϕθ=Rtθtϕ+Rrθrϕ+Rθθθϕ+Rϕθϕϕ
Rθϕ=Rϕθ=Rtθtϕ+Rrθrϕ
Rθϕ=Rϕθ=ΓϕθϕΓtϕtΓϕθϕΓrϕr=0

Rϕϕ=Rtϕtϕ+Rrϕrϕ+Rθϕθϕ+Rϕϕϕϕ
Rϕϕ=Rtϕtϕ+Rrϕrϕ+Rθϕθϕ
Rϕϕ=tΓtϕϕ+ΓϕϕtΓtϕϕrΓrϕϕ+ΓϕϕrΓrϕϕΓtϕϕΓrtrΓrϕϕΓrrrθΓθϕϕ+ΓϕϕθΓθϕϕΓtϕϕΓθtθΓrϕϕΓθrθ
Rϕϕ=t(a˙ar2sin2θc2)+˙aaa˙ar2sin2θc2r(rsin2θ(1kr2))+1r(rsin2θ(1kr2))a˙ar2sin2θc2˙aa(rsin2θ(1kr2))kr(1kr2)θ(sinθcosθ)+cosθsinθ(sinθcosθ)a˙ar2sin2θc2˙aa(rsin2θ(1kr2))1r
Rϕϕ=t(a˙ar2sin2θc2)+r(rsin2θ(1kr2))+kr2sin2θ+θ(sinθcosθ)cos2θ˙a2r2sin2θc2
Rϕϕ=(˙a2r2sin2θc2+a¨ar2sin2θc2)+(sin2θ(1kr2)2kr2sin2θ)+kr2sin2θ+(cos2θsin2θ)cos2θ˙a2r2sin2θc2
Rϕϕ=2˙a2r2sin2θc2a¨ar2sin2θc22kr2sin2θ

Whew...

We have the Ricci tensor! It is diagonal just like our metric. We could have saved some time not calculating off diagonal components but they are trivial for the most part and a diagonal metric is not a guarantee that the Ricci tensor is diagonal as well. Luckily getting the Ricci scalar from the Ricci tensor is a lot easier than getting the Ricci tensor from the Riemann tensor.
R=gμνRμν
R=1c23¨aa1kr2a2(2˙a2c2(1kr2)+a¨ac2(1kr2)+2k1kr2)1a2r2(a¨ar2c2+2kr2+2˙a2r2c2)1a2r2sin2θ(2˙a2r2sin2θc2+a¨ar2sin2θc2+2kr2sin2θ)
R=3¨aac2(2˙a2a2c2+¨aac2+2ka2)(¨aac2+2ka2+2˙a2a2c2)(2˙a2a2c2+¨aac2+2ka2)
R=3¨aac23(2˙a2a2c2+¨aac2+2ka2)
R=6¨aac26˙a2a2c26ka2
The only term in the Einstein equation we're missing now is the energy-momentum tensor Tμν (sometimes called the stress-energy tensor). For a perfect fluid in equilibrium (which our cosmological fluid satisfies due to the cosmological principle) this tensor takes a fairly simple form:
Tμν=(ρc2+p)uμuν+pgμν
As we elaborated earlier uα=(c,0,0,0) in our comoving coordinates and we can see that the tensor is also diagonal making this:

Ttt=(ρc2+p)utut+pgtt=(ρc2+p)c2pc2=ρc4
Trr=pgrr=pa21kr2
Tθθ=pgθθ
Tϕϕ=pgϕϕ

And we're pretty much done! Swap all the values we've found into the temporal Einstein equation and we get
Rtt+12c2R+Λc2=8πGc4Ttt
3¨aa+12c2(6¨aac26˙a2a2c26ka2)+Λc2=8πGc4ρc4
3˙a2a23kc2a2+Λc2=8πGρ
(˙aa)2=8πG3ρkc2a2+Λc23
This looks (thankfully) quite familiar and we now can identify ρ as the energy density and not just the mass density and we have the addition of the Λ term which represents the contribution of a cosmological constant (the energy density of empty space) to the expansion of the universe. In Newtonian mechanics this value is zero however recent research points to the existence of dark energy of which the energy of the vacuum (Λ) is the simplest possible form.

Itching for more? We've only examined the temporal Einstein equation. There are three more we can calculate for the matched spatial coordinates. All three end up reducing to the second Friedmann equation which describes the second derivative of the scale factor so let's just go with the r equation.
Rrr12grrRΛgrr=8πGc4Trr
2˙a2c2(1kr2)a¨ac2(1kr2)2k1kr212a21kr2(6¨aac26˙a2a2c26ka2)Λa21kr2=8πGc4pa21kr2
2˙a2c2a¨ac22ka22(6¨aac26˙a2a2c26ka2)Λa2=8πGc4pa2
2˙a2a2c22ka2+2¨aac2+3˙a2a2c2+3ka2Λ=8πGc4p
2¨aa+˙a2a2+kc2a2Λc2=8πGc2p
We're close but we want the resulting equation to be a function of ¨aa only and not ˙aa so let's substitute the first Friedman equation in.
2¨aa+8πG3ρkc2a2+Λc23+kc2a2Λc2=8πGc2p
2¨aa+8πG3ρ2Λc23=8πGc2p
¨aa=4πGc2p4πG3ρ+Λc23
¨aa=4πG3(3pc2+ρ)+Λc23
So we've arrived at the only equations that describe the expansion or contraction of a universe compatible with the cosmological principle. As we can see these are only dependent on the energy density ρ, the curvature of space k, the cosmological constant aka the vacuum energy Λ, and the pressure of the cosmological fluid p. Different types of energy scale with the size of the universe at different rates and have different pressures associated with them. While the true history of the universe is a constant interplay between the different types we can roughly divide the history of the universe into different eras where these equations are dominated by each type, the radiation, matter, and dark energy eras. Building on top of these equations and bringing in quantum mechanics and astronomical observations has allowed cosmology to develop as a rich and exciting branch of physics.

Wednesday, October 28, 2015

Configuring MathJax for Blogger

The first step to enabling TeX formatting on your Blogger page is to include the MathJax Javascript file in your Blogger template. Under Template -> Edit HTML you should add the following just after the opening <head> tag:


    <script src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript">    

    MathJax.Hub.Config({
        HTML: ['input/TeX','output/HTML-CSS'],
        TeX: { extensions: ['AMSmath.js','AMSsymbols.js'], equationNumbers: { autoNumber: 'AMS' } },
        extensions: ['tex2jax.js'],
        jax: ['input/TeX','output/HTML-CSS'],
        tex2jax: { inlineMath: [ ['$','$'], ['\\(','\\)'] ],
                   displayMath: [ ['$$','$$'], ['\\[','\\]'] ],
                   skipTags: ["script","noscript","style","textarea","code"],
                   processEscapes: true },
        'HTML-CSS': { availableFonts: ['TeX'], linebreaks: { automatic: true } }
    });
    </script>

In this case I have removed 'pre' from the list of HTML tags skipped over by MathJax. If you are using the Compose tab to post in Blogger rather than raw HTML this is necessary as it uses the <pre> tag throughout. If you want to show TeX intermingled with <code> blocks you can remove that tag from skipTags as well.

MathJax will use the color defined under Page -> Text Color in your template customization so make sure that is set correctly as the Blogger editor will explicitly set the text color in some cases.

This should be all you need to do to enable TeX processing in all posts and comments on your blog. I have listed a few examples along with their raw text below for you to test with.

\(P(E) = {n \choose k} p^k (1-p)^{n-k}\)
\[P(E) = {n \choose k} p^k (1-p)^{n-k}\]

When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$


P(E) = {n \choose k} p^k (1-p)^{n-k}
P(E) = {n \choose k} p^k (1-p)^{n-k}



When a \ne 0, there are two solutions to ax^2 + bx + c = 0 and they are x = {-b \pm \sqrt{b^2-4ac} \over 2a}.