egison-3.10.2: sample/math/geometry/curvature-form.egi
;;; Parameters and Metric tensor
(define $x [| θ φ |])
(define $g__ [| [| r^2 0 |] [| 0 (* r^2 (sin θ)^2) |] |])
(define $g~~ [| [| (/ 1 r^2) 0 |] [| 0 (/ 1 (* r^2 (sin θ)^2)) |] |])
;;; Christoffel symbols
(define $Γ_j_k_l
(* (/ 1 2)
(+ (∂/∂ g_j_l x~k)
(∂/∂ g_j_k x~l)
(* -1 (∂/∂ g_k_l x~j)))))
(define $Γ~__ (with-symbols {i} (. g~#~i Γ_i_#_#)))
;;; 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)))))
(assert-equal "Riemann curvature" R~#_#_1_1 [| [| 0 0 |] [| 0 0 |] |]~#_#)
(assert-equal "Riemann curvature" R~#_#_1_2 [| [| 0 (sin θ)^2 |] [| -1 0 |] |]~#_#)
(assert-equal "Riemann curvature" R~#_#_2_1 [| [| 0 (* -1 (sin θ)^2) |] [| 1 0 |] |]~#_#)
(assert-equal "Riemann curvature" R~#_#_2_2 [| [| 0 0 |] [| 0 0 |] |]~#_#)
;;; Connection form
(define $ω Γ~#_#_#)
;;; Curvature form
(define $d
(lambda [%A]
!((flip ∂/∂) x A)))
(define $wedge
(lambda [%X %Y]
!(. X Y)))
(define $Ω
(with-symbols {i j}
(df-normalize (+ (d ω~i_j)
(wedge ω~i_k ω~k_j)))))
(assert-equal "Curvature form" Ω~#_#_1_1 [| [| 0 0 |] [| 0 0 |] |]~#_#)
(assert-equal "Curvature form" Ω~#_#_1_2 [| [| 0 (/ (sin θ)^2 2) |] [| (/ -1 2) 0 |] |]~#_#)
(assert-equal "Curvature form" Ω~#_#_2_1 [| [| 0 (/ (* -1 (sin θ)^2) 2) |] [| (/ 1 2) 0 |] |]~#_#)
(assert-equal "Curvature form" Ω~#_#_2_2 [| [| 0 0 |] [| 0 0 |] |]~#_#)