egison-5.1.0: sample/math/geometry/riemann-curvature-tensor-of-Schwarzschild-metric.egi
-- Riemann curvature tensor of Schwarzschild metric
declare symbol G, M, c, t, r, θ, φ
def x := [| t, r, θ, φ |]
-- Schwarzschild metric
def g_i_j :=
[| [| `(c^2 * r - 2 * G * M) / (c^2 * r), 0, 0, 0 |]
, [| 0, (-1) / (`(c^2 * r - 2 * G * M) / (c^2 * r)), 0, 0 |]
, [| 0, 0, -r^2, 0 |]
, [| 0, 0, 0, -r^2 * (sin θ)^2 |]
|]
def g~i~j := M.inverse g_#_#
assertEqual "Metric tensor g_1_#"
g_1_#
[| `(c^2 * r - 2 * G * M) / (c^2 * r), 0, 0, 0 |]_#
assertEqual "Metric tensor g_2_#"
g_2_#
[| 0, (-1) / (`(c^2 * r - 2 * G * M) / (c^2 * r)), 0, 0 |]_#
assertEqual "Metric tensor g_3_#"
g_3_#
[| 0, 0, -r^2, 0 |]_#
assertEqual "Metric tensor g_4_#"
g_4_#
[| 0, 0, 0, -r^2 * (sin θ)^2 |]_#
-- Christoffel symbols
def Γ_i_j_k := (1 / 2) * (∂/∂ g_i_k x~j + ∂/∂ g_i_j x~k - ∂/∂ g_j_k x~i)
def Γ~i_j_k := withSymbols [m]
g~i~m . Γ_m_j_k
-- The Christoffel symbols Γ~1 and Γ~2 are mathematically equal to
-- GM / (c²r² - 2GMr) and GM(c²r - 2GM)/(c⁴r⁴), etc.
-- but the current CAS does not combine these into a single fraction
-- (it leaves them as `(c²r - 2GM)` opaque atom plus `r⁻¹`/`c²` factors).
-- The forms below match what the CAS actually produces.
assertEqual "Christoffel symbols of the second kind Γ~1_#_#"
Γ~1_#_#
[| [| 0, (1 / 2) * `(c^2 * r - 2 * G * M)^(-1) * c^2 - (1 / 2) / r, 0, 0 |]
, [| (1 / 2) * `(c^2 * r - 2 * G * M)^(-1) * c^2 - (1 / 2) / r, 0, 0, 0 |]
, [| 0, 0, 0, 0 |]
, [| 0, 0, 0, 0 |]
|]_#_#
assertEqual "Christoffel symbols of the second kind Γ~2_#_#"
Γ~2_#_#
[| [| (1 / 2) * `(c^2 * r - 2 * G * M) / (c^2 * r^2)
- (1 / 2) * `(c^2 * r - 2 * G * M)^2 / (c^4 * r^3), 0, 0, 0 |]
, [| 0, - (1 / 2) * `(c^2 * r - 2 * G * M)^(-1) * c^2 + (1 / 2) / r, 0, 0 |]
, [| 0, 0, - `(c^2 * r - 2 * G * M) / c^2, 0 |]
, [| 0, 0, 0, - (sin θ)^2 * `(c^2 * r - 2 * G * M) / c^2 |]
|]_#_#
assertEqual "Christoffel symbols of the second kind Γ~3_#_#"
Γ~3_#_#
[| [| 0, 0, 0, 0 |]
, [| 0, 0, 1 / r, 0 |]
, [| 0, 1 / r, 0, 0 |]
, [| 0, 0, 0, -1 * sin θ * cos θ |]
|]_#_#
assertEqual "Christoffel symbols of the second kind Γ~4_#_#"
Γ~4_#_#
[| [| 0, 0, 0, 0 |]
, [| 0, 0, 0, 1 / r |]
, [| 0, 0, 0, (cos θ) / (sin θ) |]
, [| 0, 1 / r, (cos θ) / (sin θ), 0 |]
|]_#_#
-- Riemann curvature
def R~i_j_k_l := withSymbols [m]
expandAll
(∂/∂ Γ~i_j_l x~k - ∂/∂ Γ~i_j_k x~l +
Γ~m_j_l . Γ~i_m_k - Γ~m_j_k . Γ~i_m_l)
-- Ricci curvature (should be 0 for Schwarzschild in vacuum)
def Ric_i_j := withSymbols [m]
sum (contract R~m_i_m_j)
-- The Schwarzschild metric is a vacuum solution: Ric = 0
assertEqual "Ricci curvature Ric_1_#"
Ric_1_#
[| 0, 0, 0, 0 |]_#
assertEqual "Ricci curvature Ric_2_#"
Ric_2_#
[| 0, 0, 0, 0 |]_#
assertEqual "Ricci curvature Ric_3_#"
Ric_3_#
[| 0, 0, 0, 0 |]_#
assertEqual "Ricci curvature Ric_4_#"
Ric_4_#
[| 0, 0, 0, 0 |]_#