packages feed

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

--
-- 2D Polar Laplacian using chain rule
--

declare symbol r, θ : MathExpr

def x : MathExpr := r * cos θ
def y : MathExpr := r * sin θ

def u := function (x, y)

def uR : MathExpr := ∂/∂ u r

assert "∂u/∂r"
  (show uR = "u|1 (r * 'cos θ) (r * 'sin θ) * 'cos θ + u|2 (r * 'cos θ) (r * 'sin θ) * 'sin θ")

def uRR : MathExpr := ∂/∂ (∂/∂ u r) r

def uΘ : MathExpr := ∂/∂ u θ
def uΘΘ : MathExpr := ∂/∂ (∂/∂ u θ) θ

-- Laplacian in polar coordinates: ∂²u/∂r² + (1/r)∂u/∂r + (1/r²)∂²u/∂θ²
-- Full Laplacian should simplify to u|1|1 + u|2|2
assert "Full Laplacian in polar coordinates"
  (show (uRR + 1 / r * uR + 1 / r ^ 2 * uΘΘ) = "u|2|2 (r * 'cos θ) (r * 'sin θ) + u|1|1 (r * 'cos θ) (r * 'sin θ)")