packages feed

egison-5.1.0: sample/math/geometry/polar-laplacian-2d-3.egi

-- Polar Laplacian in 2D using function symbol

declare symbol r, θ : MathValue

def f := function (r, θ)

def x : Vector MathValue := [| r, θ |]

def X : Vector MathValue := [| r * cos θ, r * sin θ |]

-- Local basis
def e_i_j : Matrix MathValue := ∂/∂ X_j x~i

-- Metric tensor
def g_i_j : Matrix MathValue := generateTensor (\[a, b] -> V.* e_a e_b) [2, 2]
def g~i~j : Matrix MathValue := M.inverse g_#_#

assertEqual "Metric tensor"
  g_#_#
  [| [| 1, 0 |], [| 0, r^2 |] |]_#_#

-- Christoffel symbols
def Γ_i_j_k : Tensor MathValue := withSymbols [j, k, l]
  (1 / 2) * (∂/∂ g_j_l x~k + ∂/∂ g_j_k x~l - ∂/∂ g_k_l x~j)

def Γ~i_j_k : Tensor MathValue := withSymbols [i, j, k, l]
  g~i~j . Γ_j_k_l

-- Laplacian via Christoffel symbols
def Laplacian : MathValue := withSymbols [i, j, k]
  g~i~j . ∂/∂ (∂/∂ f x~j) x~i - g~i~j . Γ~k_i_j . ∂/∂ f x~k

assertEqual "Laplacian in polar coordinates"
  Laplacian
  (∂/∂ (∂/∂ f r) r + ∂/∂ f r / r + ∂/∂ (∂/∂ f θ) θ / r^2)