;;; ;;; Parameters ;;; (define \$x [|θ φ|]) (define \$X [|(* r (sin θ) (cos φ)) ; = x (* r (sin θ) (sin φ)) ; = y (* r (cos θ)) ; = z |]) ;; ;; Local basis ;; (define \$e_i_j (∂/∂ X_j x~i)) e_i_j ;[|[|(* r (cos θ) (cos φ)) (* r (cos θ) (sin φ)) (* -1 r (sin θ)) |] ; [|(* -1 r (sin θ) (sin φ)) (* r (sin θ) (cos φ)) 0 |] ; |]_i_j ;; ;; Metric tensor ;; (define \$g__ (generate-tensor 2#(V.* e_%1_# e_%2_#) {2 2})) (define \$g~~ (M.inverse g_#_#)) g_#_#;[| [| r^2 0 |] [| 0 (* r^2 (sin θ)^2) |] |]_#_# g~#~#;[| [| (/ 1 r^2) 0 |] [| 0 (/ 1 (* r^2 (sin θ)^2)) |] |]~#~# ;; ;; Christoffel symbols of the first kind ;; (define \$Γ_j_k_l (* (/ 1 2) (+ (∂/∂ g_j_l x~k) (∂/∂ g_j_k x~l) (* -1 (∂/∂ g_k_l x~j))))) Γ_#_#_#;(tensor {2 2 2} {0 0 0 (* -1 r^2 (sin θ) (cos θ)) 0 (* r^2 (sin θ) (cos θ)) (* r^2 (sin θ) (cos θ)) 0} )_#_#_# Γ_1_#_#;[| [| 0 0 |] [| 0 (* -1 r^2 (sin θ) (cos θ)) |] |]_#_# Γ_2_#_#;[| [| 0 (* r^2 (sin θ) (cos θ)) |] [| (* r^2 (sin θ) (cos θ)) 0 |] |]_#_# ;; ;; Christoffel symbols of the second kind ;; (define \$Γ~__ (with-symbols {i} (. g~#~i Γ_i_#_#))) Γ~#_#_#;(tensor {2 2 2} {0 0 0 (* -1 (sin θ) (cos θ)) 0 (/ (cos θ) (sin θ)) (/ (cos θ) (sin θ)) 0} )~#_#_# Γ~1_#_#;[| [| 0 0 |] [| 0 (* -1 (sin θ) (cos θ)) |] |]_#_# Γ~2_#_#;[| [| 0 (/ (cos θ) (sin θ)) |] [| (/ (cos θ) (sin θ)) 0 |] |]_#_# ;; ;; Covariant derivative of metric tensor ;; (define \$∇g___ (with-symbols {i j m n} (- (∂/∂ g_i_j x~m) (. Γ~n_m_i g_n_j) (. Γ~n_m_j g_i_n)))) ∇g_#_#_#;=>(tensor {2 2 2} {0 0 0 0 0 0 0 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~#_#_#_#;(tensor {2 2 2 2} {0 0 0 0 0 (sin θ)^2 (* -1 (sin θ)^2) 0 0 -1 1 0 0 0 0 0} )~#_#_#_# R~#_#_1_1;[| [| 0 0 |] [| 0 0 |] |]~#_# R~#_#_1_2;[| [| 0 (sin θ)^2 |] [| -1 0 |] |]~#_# R~#_#_2_1;[| [| 0 (* -1 (sin θ)^2) |] [| 1 0 |] |]~#_# R~#_#_2_2;[| [| 0 0 |] [| 0 0 |] |]~#_# (define \$R____ (with-symbols {i} (. g_i_# R~i_#_#_#))) R_#_#_#_#;(tensor {2 2 2 2} {0 0 0 0 0 (* r^2 (sin θ)^2) (* -1 r^2 (sin θ)^2) 0 0 (* -1 r^2 (sin θ)^2) (* r^2 (sin θ)^2) 0 0 0 0 0} )_#_#_#_# R_#_#_1_1;[| [| 0 0 |] [| 0 0 |] |]_#_# R_#_#_1_2;[| [| 0 (* r^2 (sin θ)^2) |] [| (* -1 r^2 (sin θ)^2) 0 |] |]_#_# R_#_#_2_1;[| [| 0 (* -1 r^2 (sin θ)^2) |] [| (* r^2 (sin θ)^2) 0 |] |]_#_# R_#_#_2_2;[| [| 0 0 |] [| 0 0 |] |]_#_# ;; ;; Ricci curvature ;; (define \$Ric__ (with-symbols {i} (contract + R~i_#_i_#))) Ric_#_#;[| [| 1 0 |] [| 0 (sin θ)^2 |] |]_#_# ;; ;; Scalar curvature ;; (define \$scalar-curvature (with-symbols {j k} (. g~j~k Ric_j_k))) scalar-curvature;(/ 2 r^2) ;; ;; Covariant derivative of Riemann curvature tensor ;; (define \$∇R_____ (with-symbols {i j k l m n} (- (∂/∂ R_i_j_k_l x~m) (. Γ~n_m_i R_n_j_k_l) (. Γ~n_m_j R_i_n_k_l) (. Γ~n_m_k R_i_j_n_l) (. Γ~n_m_l R_i_j_k_n)))) ∇R_#_#_#_#_# ;(tensor {2 2 2 2 2} {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} )_#_#_#_#_#