;;; ;;; Parameters ;;; (define \$x [|θ φ ψ|]) (define \$X [|(* r (cos θ)) (* r (sin θ) (cos φ)) (* r (sin θ) (sin φ) (cos ψ)) (* r (sin θ) (sin φ) (sin ψ)) |]) ;; ;; Local basis ;; (define \$e ((flip ∂/∂) x~# X_#)) e ;[|[| (* -1 r (sin θ)) (* r (cos θ) (cos φ)) (* r (cos θ) (sin φ) (cos ψ)) (* r (cos θ) (sin φ) (sin ψ)) |] ; [| 0 (* -1 r (sin θ) (sin φ)) (* r (sin θ) (cos φ) (cos ψ)) (* r (sin θ) (cos φ) (sin ψ)) |] ; [| 0 0 (* -1 r (sin θ) (sin φ) (sin ψ)) (* r (sin θ) (sin φ) (cos ψ)) |]|] ;; ;; Metric tensor ;; (define \$g__ (generate-tensor 2#(V.* e_%1 e_%2) {3 3})) (define \$g~~ (M.inverse g_#_#)) g_#_#;[| [| r^2 0 0 |] [| 0 (* r^2 (sin θ)^2) 0 |] [| 0 0 (* r^2 (sin θ)^2 (sin φ)^2) |] |]_#_# g~#~#;[| [| (/ 1 r^2) 0 0 |] [| 0 (/ 1 (* r^2 (sin θ)^2)) 0 |] [| 0 0 (/ 1 (* r^2 (sin θ)^2 (sin φ)^2)) |] |]~#~# (with-symbols {i j k} (. g~i~j g_j_k));[| [| 1 0 0 |] [| 0 1 0 |] [| 0 0 1 |] |] ;; ;; Christoffel symbols of the first kind ;; (define \$Γ_j_k_l (* (/ 1 2) (+ (∂/∂ g_j_k x~l) (∂/∂ g_j_l x~k) (* -1 (∂/∂ g_k_l x~j))))) Γ_1_#_#;[| [| 0 0 0 |] [| 0 (* -1 r^2 (sin θ) (cos θ)) 0 |] [| 0 0 (* -1 r^2 (sin θ) (cos θ) (sin φ)^2) |] |]_#_# Γ_2_#_#;[| [| 0 (* r^2 (sin θ) (cos θ)) 0 |] [| (* r^2 (sin θ) (cos θ)) 0 0 |] [| 0 0 (* -1 r^2 (sin θ)^2 (sin φ) (cos φ)) |] |]_#_# Γ_3_#_#;[| [| 0 0 (* r^2 (sin θ) (cos θ) (sin φ)^2) |] [| 0 0 (* r^2 (sin θ)^2 (sin φ) (cos φ)) |] [| (* r^2 (sin θ) (cos θ) (sin φ)^2) (* r^2 (sin θ)^2 (sin φ) (cos φ)) 0 |] |]_#_# ;; ;; Christoffel symbols of the second kind ;; (define \$Γ~__ (with-symbols {i} (. g~#~i Γ_i_#_#))) Γ~1_#_#;[| [| 0 0 0 |] [| 0 (* -1 (sin θ) (cos θ)) 0 |] [| 0 0 (* -1 (sin θ) (cos θ) (sin φ)^2) |] |]_#_# Γ~2_#_#;[| [| 0 (/ (cos θ) (sin θ)) 0 |] [| (/ (cos θ) (sin θ)) 0 0 |] [| 0 0 (* -1 (sin φ) (cos φ)) |] |]_#_# Γ~3_#_#;[| [| 0 0 (/ (cos θ) (sin θ)) |] [| 0 0 (/ (cos φ) (sin φ)) |] [| (/ (cos θ) (sin θ)) (/ (cos φ) (sin φ)) 0 |] |]_#_# ;; ;; Riemann curvature tensor ;; (define \$R~i_j_k_l (with-symbols {m} (+ (- (∂/∂ Γ~i_j_l x~k) (∂/∂ Γ~i_j_k x~l)) (- (. Γ~m_j_l Γ~i_m_k) (. Γ~m_j_k Γ~i_m_l))))) R~#_#_1_1;[| [| 0 0 0 |] [| 0 0 0 |] [| 0 0 0 |] |]~#_# R~#_#_1_2;[| [| 0 (sin θ)^2 0 |] [| -1 0 0 |] [| 0 0 0 |] |]~#_# R~#_#_1_3;[| [| 0 0 (* (sin θ)^2 (sin φ)^2) |] [| 0 0 0 |] [| -1 0 0 |] |]~#_# R~#_#_2_1;[| [| 0 (* -1 (sin θ)^2) 0 |] [| 1 0 0 |] [| 0 0 0 |] |]~#_# R~#_#_2_2;[| [| 0 0 0 |] [| 0 0 0 |] [| 0 0 0 |] |]~#_# R~#_#_2_3;[| [| 0 0 0 |] [| 0 0 (* (sin θ)^2 (sin φ)^2) |] [| 0 (* -1 (sin θ)^2) 0 |] |]~#_# R~#_#_3_1;[| [| 0 0 (* -1 (sin θ)^2 (sin φ)^2) |] [| 0 0 0 |] [| 1 0 0 |] |]~#_# R~#_#_3_2;[| [| 0 0 0 |] [| 0 0 (* -1 (sin θ)^2 (sin φ)^2) |] [| 0 (sin θ)^2 0 |] |]~#_# R~#_#_3_3;[| [| 0 0 0 |] [| 0 0 0 |] [| 0 0 0 |] |]~#_# (define \$R____ (with-symbols {i} (. g_i_# R~i_#_#_#))) R_#_#_#_#;(tensor {3 3 3 3} {0 0 0 0 0 0 0 0 0 0 (* r^2 (sin θ)^2) 0 (* -1 r^2 (sin θ)^2) 0 0 0 0 0 0 0 (* r^2 (sin θ)^2 (sin φ)^2) 0 0 0 (* -1 r^2 (sin θ)^2 (sin φ)^2) 0 0 0 (* -1 r^2 (sin θ)^2) 0 (* r^2 (sin θ)^2) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (* r^2 (sin θ)^4 (sin φ)^2) 0 (* -1 r^2 (sin θ)^4 (sin φ)^2) 0 0 0 (* -1 r^2 (sin θ)^2 (sin φ)^2) 0 0 0 (* r^2 (sin θ)^2 (sin φ)^2) 0 0 0 0 0 0 0 (* -1 r^2 (sin θ)^4 (sin φ)^2) 0 (* r^2 (sin θ)^4 (sin φ)^2) 0 0 0 0 0 0 0 0 0 0} )_#_#_#_# ;; ;; Ricci curvature ;; (define \$Ric__ (with-symbols {i} (contract + R~i_#_i_#))) Ric_#_#;[| [| 2 0 0 |] [| 0 (* 2 (sin θ)^2) 0 |] [| 0 0 (* 2 (sin θ)^2 (sin φ)^2) |] |]_#_# ;; ;; Scalar curvature ;; (define \$scalar-curvature (with-symbols {j k} (. g~j~k Ric_j_k))) scalar-curvature;(/ 6 r^2) ;; ;; Conformal curvature tensor ;; (define \$C_i_k_l_m (+ (. R_i_k_l_m) (+ (- (. Ric_i_m g_k_l) (. Ric_i_l g_k_m)) (- (. Ric_k_l g_i_m) (. Ric_k_m g_i_l))) (* (/ scalar-curvature 2) (- (. g_i_l g_k_m) (. g_i_m g_k_l))))) C_#_#_#_# ;(tensor {3 3 3 3} {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} )_#_#_#_#