{ "cells": [ { "cell_type": "markdown", "id": "96c3442e", "metadata": {}, "source": [ "# Hodge Laplacian in Spherical Coordinates\n", "\n", "In $(r,\\theta,\\phi)$ coordinates, the Euclidean metric is\n", "\n", "$$ds^2=dr^2+r^2d\\theta^2+r^2\\sin^2\\theta\\,d\\phi^2.$$\n", "\n", "We build $d$, $\\star$, and the codifferential from this metric. With\n", "the codifferential convention used below, the scalar result is the\n", "negative of the usual positive-coordinate Laplace operator.\n" ] }, { "cell_type": "markdown", "id": "80c07a49", "metadata": {}, "source": [ "## Spherical metric\n", "\n", "The determinant is $r^4\\sin^2\\theta$, while the inverse metric contains\n", "the angular scale factors $r^{-2}$ and\n", "$(r^2\\sin^2\\theta)^{-1}$.\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "8851b573", "metadata": {}, "outputs": [], "source": [ "declare symbol r, θ, φ : MathValue\n", "\n", "def N : Integer := 3\n", "def x : Vector MathValue := [| r, θ, φ |]\n", "\n", "def g_i_j : Matrix MathValue :=\n", " [| [| 1, 0, 0 |]\n", " , [| 0, r ^ 2, 0 |]\n", " , [| 0, 0, r ^ 2 * (sin θ) ^ 2 |] |]_i_j\n", "def g~i~j : Matrix MathValue :=\n", " [| [| 1, 0, 0 |]\n", " , [| 0, 1 / r ^ 2, 0 |]\n", " , [| 0, 0, 1 / (r ^ 2 * (sin θ) ^ 2) |] |]~i~j\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "2015dd74", "metadata": {}, "outputs": [ { "data": { "text/html": [ "$\\begin{pmatrix} 1 & 0 & 0 \\\\ 0 & r^{2} & 0 \\\\ 0 & 0 & \\sin(θ)^{2} r^{2} \\\\ \\end{pmatrix}_{\\#\\#}^{\\;\\;}$" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "g_#_#\n" ] }, { "cell_type": "markdown", "id": "c00a1543", "metadata": {}, "source": [ "## Differential-form operators\n", "\n", "The Hodge star raises the form indices with $g^{ij}$ and contracts them\n", "against the three-dimensional Levi-Civita tensor.\n" ] }, { "cell_type": "code", "execution_count": 3, "id": "210a0cf0", "metadata": {}, "outputs": [], "source": [ "def d (A : Tensor MathValue) : Tensor MathValue :=\n", " !(flip ∂/∂) x A\n", "\n", "def hodge (A : DiffForm MathValue) : DiffForm MathValue :=\n", " let k := dfOrder A\n", " in withSymbols [i, j]\n", " sqrt (abs (M.det g_#_#)) *\n", " foldl\n", " (.)\n", " ((ε' N k)_(i_1)..._(i_N) . A..._(j_1)..._(j_k))\n", " (map (\\n -> g~(i_n)~(j_n)) [1..k])\n", "\n", "def δ (A : DiffForm MathValue) : DiffForm MathValue :=\n", " let k := dfOrder A\n", " in ((-1) ^ (N * (k + 1) + 1)) * hodge (d (hodge A))\n" ] }, { "cell_type": "markdown", "id": "08fa7851", "metadata": {}, "source": [ "The Hodge Laplacian is $d\\delta+\\delta d$, with shorter endpoint\n", "formulas for scalars and volume forms.\n" ] }, { "cell_type": "code", "execution_count": 4, "id": "138d5b01", "metadata": {}, "outputs": [], "source": [ "def Δ (A : DiffForm MathValue) : DiffForm MathValue :=\n", " match dfOrder A as integer with\n", " | #0 -> δ (d A)\n", " | #N -> d (δ A)\n", " | _ -> d (δ A) + δ (d A)\n", "\n", "def f : MathValue := function (r, θ, φ)\n" ] }, { "cell_type": "code", "execution_count": 5, "id": "5dd385fe", "metadata": {}, "outputs": [ { "data": { "text/html": [ "$-\\frac{\\partial^2 f}{\\partial 1^2} - 2 \\frac{\\partial f}{\\partial 1} r^{-1} - \\frac{\\partial^2 f}{\\partial 2^2} r^{-2} - \\cos(θ) \\sin(θ)^{-1} \\frac{\\partial f}{\\partial 2} r^{-2} - \\sin(θ)^{-2} \\frac{\\partial^2 f}{\\partial 3^2} r^{-2}$" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "Δ f\n" ] }, { "cell_type": "markdown", "id": "a1f2e150", "metadata": {}, "source": [ "After simplification, the output is\n", "\n", "$$\n", "\\Delta f=-\\left(\n", "f_{rr}+\\frac{2}{r}f_r\n", "+\\frac1{r^2}f_{\\theta\\theta}\n", "+\\frac{\\cos\\theta}{r^2\\sin\\theta}f_\\theta\n", "+\\frac1{r^2\\sin^2\\theta}f_{\\phi\\phi}\n", "\\right).\n", "$$\n", "\n", "Each coordinate-dependent coefficient follows from the metric; the\n", "calculation contains no spherical-coordinate Laplacian formula as an\n", "input.\n" ] } ], "metadata": { "kernelspec": { "display_name": "Egison", "language": "egison", "name": "egison" }, "language_info": { "codemirror_mode": "egison", "file_extension": ".egi", "mimetype": "text/x-egison", "name": "egison" } }, "nbformat": 4, "nbformat_minor": 5 }