;;; ;;; 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)) |] |]~#~# ;; ;; Laplacian ;; (define \$sqrt-g (sqrt (M.det g_#_#))) sqrt-g;(* r^2 (sin θ)) (define \$Laplacian (/ (contract + (∂/∂ (* sqrt-g (. g~i~j (∂/∂ (f r θ φ) x~j))) x~i)) sqrt-g)) Laplacian ;(/ (+ (* 2 r (sin θ)^2 (f|1 r θ φ)) (* r^2 (sin θ)^2 (f|1|1 r θ φ)) (* (cos θ) (f|2 r θ φ) (sin θ)) (* (sin θ)^2 (f|2|2 r θ φ)) (f|3|3 r θ φ)) (* (sin θ)^2 r^2))