egison-3.7.11: sample/math/geometry/riemann-curvature-tensor-of-S1.egi
;;;
;;; Parameters
;;;
(define $x [|θ|])
(define $X [|(* r (sin θ)) ; = x
(* r (cos θ)) ; = y
|])
;;
;; Local basis
;;
(define $e ((flip ∂/∂) x~# X_#))
e;[| [| (* r (cos θ)) (* -1 r (sin θ)) |] |]_#~#
;;
;; Metric tensor
;;
(define $g__ (generate-tensor 2#(V.* e_%1 e_%2) {1 1}))
(define $g~~ (M.inverse g_#_#))
g_#_#;[| [| r^2 |] |]_#_#
g~#~#;[| [| (/ 1 r^2) |] |]~#~#
;;
;; Christoffel symbols of the first kind
;;
(define $Γ___
(with-symbols {j k l}
(* (/ 1 2)
(+ (∂/∂ g_j_k x~l)
(∂/∂ g_j_l x~k)
(* -1 (∂/∂ g_k_l x~j))))))
Γ_#_#_#;(tensor {1 1 1} {0} )_#_#_#
;;
;; Christoffel symbols of the second kind
;;
(define $Γ~__
(with-symbols {i j k l}
(. g~i~j Γ_j_k_l)))
Γ~#_#_#;(tensor {1 1 1} {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 {1 1 1 1} {0} )~#_#_#_#
(define $R____ (with-symbols {i} (. g_i_# R~i_#_#_#)))
R_#_#_#_#;(tensor {1 1 1 1} {0} )_#_#_#_#
;;
;; Ricci curvature
;;
(define $Ric__ (with-symbols {i j k} (contract + R~i_j_k_i)))
Ric_#_#;[| [| 0 |] |]_#_#
;;
;; Scalar curvature
;;
(define $scalar-curvature (with-symbols {j k} (. g~j~k Ric_j_k)))
scalar-curvature;0