;;; ;;; Spherical coordinates ;;; (define \$x [|r θ φ|]) (define \$X [|(* r (sin θ) (cos φ)) ; = x (* r (sin θ) (sin φ)) ; = y (* r (cos θ)) ; = z |]) ;; ;; Local coordinates ;; (define \$e ((∂/∂ X_# \$) x~#)) e ;[|[| (* (sin θ) (cos φ)) (* (sin θ) (sin φ)) (cos θ) |] ; [| (* r (cos θ) (cos φ)) (* r (cos θ) (sin φ)) (* -1 r (sin θ)) |] ; [| (* -1 r (sin θ) (sin φ)) (* r (sin θ) (cos φ)) 0 |]|] ;; ;; Metric tensor ;; (define \$g__ (generate-tensor 2#(V.* e_%1 e_%2) {3 3})) (define \$g~~ (with-symbols {i j} (/ (unit-tensor {3 3})_i_j g_i_j))) g_#_#;[| [| 1 0 0 |] [| 0 r^2 0 |] [| 0 0 (* r^2 (sin θ)^2) |] |]_#_# g~#~#;[| [| 1 0 0 |] [| 0 (/ 1 r^2) 0 |] [| 0 0 (/ 1 (* r^2 (sin θ)^2)) |] |]~#~# ;; ;; Christoffel symbols of the first kind ;; (define \$Γ___ (with-symbols {j k l} (* (/ 1 2) (+ (∂/∂ g_j_l x~k) (∂/∂ g_j_k x~l) (* -1 (∂/∂ g_k_l x~j)))))) Γ_#_#_#;(tensor {3 3 3} {0 0 0 0 (* -1 r) 0 0 0 (* -1 r (sin θ)^2) 0 r 0 r 0 0 0 0 (* -1 r^2 (sin θ) (cos θ)) 0 0 (* r (sin θ)^2) 0 0 (* r^2 (sin θ) (cos θ)) (* r (sin θ)^2) (* r^2 (sin θ) (cos θ)) 0} )_#_#_# Γ_1_#_#;[| [| 0 0 0 |] [| 0 (* -1 r) 0 |] [| 0 0 (* -1 r (sin θ)^2) |] |]_#_# Γ_2_#_#;[| [| 0 r 0 |] [| r 0 0 |] [| 0 0 (* -1 r^2 (sin θ) (cos θ)) |] |]_#_# Γ_3_#_#;[| [| 0 0 (* r (sin θ)^2) |] [| 0 0 (* r^2 (sin θ) (cos θ)) |] [| (* r (sin θ)^2) (* r^2 (sin θ) (cos θ)) 0 |] |]_#_# ;; ;; Christoffel symbols of the second kind ;; (define \$Γ~__ (with-symbols {i j k l} (. g~i~j Γ_j_k_l))) Γ~#_#_#;(tensor {3 3 3} {0 0 0 0 (* -1 r) 0 0 0 (* -1 r (sin θ)^2) 0 (/ 1 r) 0 (/ 1 r) 0 0 0 0 (* -1 (sin θ) (cos θ)) 0 0 (/ 1 r) 0 0 (/ (cos θ) (sin θ)) (/ 1 r) (/ (cos θ) (sin θ)) 0} )~#_#_# Γ~1_#_#;[| [| 0 0 0 |] [| 0 (* -1 r) 0 |] [| 0 0 (* -1 r (sin θ)^2) |] |]_#_# Γ~2_#_#;[| [| 0 (/ 1 r) 0 |] [| (/ 1 r) 0 0 |] [| 0 0 (* -1 (sin θ) (cos θ)) |] |]_#_# Γ~3_#_#;[| [| 0 0 (/ 1 r) |] [| 0 0 (/ (cos θ) (sin θ)) |] [| (/ 1 r) (/ (cos θ) (sin θ)) 0 |] |]_#_# ;; ;; Laplacian ;; (. g~i~j (∂/∂ (∂/∂ (f r θ φ) x~j) x~i)) ;(/ (+ (* (f|1|1 r θ φ) r^2 (sin θ)^2) (* (f|2|2 r θ φ) (sin θ)^2) (f|3|3 r θ φ)) (* r^2 (sin θ)^2)) (. (. g~i~j Γ~k_i_j) (∂/∂ (f r θ φ) x~k)) ;(/ (+ (* -2 (f|1 r θ φ) r (sin θ)) (* -1 (cos θ) (f|2 r θ φ))) (* r^2 (sin θ))) (define \$Laplacian (- (. g~i~j (∂/∂ (∂/∂ (f r θ φ) x~j) x~i)) (. (. g~i~j Γ~k_i_j) (∂/∂ (f r θ φ) x~k)))) Laplacian ;(/ (+ (* (f|1|1 r θ φ) r^2 (sin θ)^2) (* (f|2|2 r θ φ) (sin θ)^2) (f|3|3 r θ φ) (* 2 (f|1 r θ φ) r (sin θ)^2) (* (cos θ) (f|2 r θ φ) (sin θ))) (* r^2 (sin θ)^2))