-- Verify that Einstein tensor vanishes for Schwarzschild metric -- d for down index -- u for up index -- metric tensor gdd = zero(4,4) gdd[1,1] = -F(r) gdd[2,2] = 1/F(r) gdd[3,3] = r^2 gdd[4,4] = r^2 sin(theta)^2 X = (t,r,theta,phi) -- X is for computing gradients -- Step 1. Calculate guu guu = inv(gdd) -- Step 2. Calculate connection coefficients ("Gravitation" by MTW p. 210) -- -- Gamma = 1/2 (g + g - g ) -- abc ab,c ac,b bc,a -- -- The comma means gradient which increases the rank of gdd by 1 gddd = d(gdd,X) -- Transpose indices to match abc GAMDDD = 1/2 (gddd + -- indices are already in correct order transpose(gddd,2,3) - -- transpose c and b transpose(gddd,2,3,1,2)) -- transpose c and a, then b and a -- Raise first index -- -- a au -- Gamma = g Gamma -- bc ubc -- -- Sum over index u means contraction GAMUDD = dot(guu,GAMDDD) -- Step 3. Calculate Riemann tensor (MTW p. 219) -- -- a is alpha -- b is beta -- c is gamma -- d is delta -- u is mu -- -- a a a a u a u -- R = Gamma - Gamma + Gamma Gamma - Gamma Gamma -- bcd bd,c bc,d uc bd ud bc -- -- Do the gradient once and save in a temporary variable T1 = d(GAMUDD,X) -- T2 is the product Gamma Gamma contracted over u T2 = dot(transpose(GAMUDD,2,3),GAMUDD) -- Now put it all together. Transpose indices to match abcd. RUDDD = transpose(T1,3,4) - -- transpose d and c T1 + -- already in correct order transpose(T2,2,3) - -- transpose c and b transpose(T2,2,3,3,4) -- transpose d and b, then d and c -- Step 4. Calculate Ricci tensor (MTW p. 343) -- -- a -- R = R -- uv uav -- -- Contract over "a" (1st and 3rd indices) RDD = contract(RUDDD,1,3) -- Step 5. Calculate Ricci scalar (MTW p. 343) -- -- uv -- R = g R -- uv R = contract(dot(guu,transpose(RDD))) -- Step 6. Finally, calculate Einstein tensor (MTW p. 343) -- -- G = R - 1/2 g R -- uv uv uv Gmunu = RDD - 1/2 gdd R "Einstein tensor" Gmunu "Verify that Einstein tensor vanishes for Schwarzschild metric" F(r) = 1 - 2 M/r F Gmunu = simplify(Gmunu) Gmunu