packages feed

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

--
-- 3D Polar (Spherical) Laplacian using chain rule
--

declare symbol r, θ, φ : MathExpr

def x := r * sin θ * cos φ
def y := r * sin θ * sin φ
def z := r * cos θ

def u := function (x, y, z)

def uR := ∂/∂ u r
def uRR := ∂/∂ (∂/∂ u r) r
def uΘ := ∂/∂ u θ
def uΘΘ := ∂/∂ (∂/∂ u θ) θ
def uΦ := ∂/∂ u φ
def uΦΦ := ∂/∂ (∂/∂ u φ) φ

-- Laplacian in spherical coordinates:
-- Δu = ∂²u/∂r² + (2/r)∂u/∂r + (1/r²)∂²u/∂θ² + (cos θ / (r² sin θ))∂u/∂θ + (1/(r sin θ)²)∂²u/∂φ²
-- Should simplify to u|1|1 + u|2|2 + u|3|3
assert "Laplacian in spherical coordinates"
  (show (uRR + 2 / r * uR + 1 / r ^ 2 * uΘΘ + cos θ / (r ^ 2 * sin θ) * uΘ + 1 / (r * sin θ) ^ 2 * uΦΦ) = "u|2|2 (r * 'sin θ * 'cos φ) (r * 'sin θ * 'sin φ) (r * 'cos θ) + u|1|1 (r * 'sin θ * 'cos φ) (r * 'sin θ * 'sin φ) (r * 'cos θ) + u|3|3 (r * 'sin θ * 'cos φ) (r * 'sin θ * 'sin φ) (r * 'cos θ)")