<- previous index next ->
Numerical differentiation can be applied to all orders in all coordinate systems. It gets more complicated, yet a reasonable extension of Cartesian coordinate systems. These are all partial derivatives. This page will develop Spherical derivatives up to fourth order from corresponding Cartesian derivatives. ∇f(x,y,z,t) = ∂f/∂x + ∂f/∂y + ∂f/∂z + ∂f/∂t ∇2f(x,y,z,t) = ∂2f/∂2x + ∂2f/∂2y + ∂2f/∂2z + ∂2f/∂2t ∇3f(x,y,z,t) = ∂3f/∂3x + ∂3f/∂3y + ∂3f/∂3z + ∂3f/∂3t ∇4f(x,y,z,t) = ∂4f/∂4x + ∂4f/∂4y + ∂4f/∂4z + ∂4f/∂4tSpherical coordinates
Theta Θ below is angle from Z axis. Phi Φ below is angle from X axis in X Y planex = r * sin(Θ) * cos(Φ) r = sqrt(x^2 + y^2 + z^2) 0 < r y = r * sin(Θ) * sin(Φ) Φ = atan2(y,x) 0 ≤ Φ < 2Π Φ = acos(x/sqrt(x^2+y^2)) Φ = asin(y/sqrt(x^2+y^2)) z = r * cos(Θ) Θ = atan2(sqrt(x^2+y^2),z) 0 < Θ < Π θ = acos(z/sqrt(x^2+y^2+z^2)) θ = asin(sqrt(x^2+y^2)/sqrt(x^2+y^2+z^2)) cos(Θ) = z/r = z/sqrt(x^2 + y^2 + z^2) sin(Θ) = sqrt(x^2 + y^2)/r cos(Φ) = x/sqrt(x^2 + y^2) sin(Φ) = y/sqrt(x^2 + y^2) Gradient ∇f a vector ^ ^ ^ ∇f(r,Θ,Φ) = r ∂f/∂r + Θ 1/r ∂f/∂Θ + Φ 1/r sin(Φ) ∂f/∂φ Laplacian ∇2f a scalar, divergence ∇˙f ∇2f(r,Θ,Φ) = 1/r2 ∂/∂r(r2*∂f/∂r) + 1/(r2 sin(Θ)) ∂f/∂Θ(sin(Θ) ∂f/∂Θ) + 1/(r2 sin(Θ)2) ∂2f/∂2Φ = 2/r ∂f/∂r + ∂2f/∂r2 + cos(Θ)/(r2 sin(Θ)2 ∂f/∂Θ + 1/(r2 ∂2f/∂Θ2 + 1/(r2 sin(Θ)2) ∂2f/∂Φ2 ∇✗f curl a vector ∇✗f = {1/(r sin(Θ))(∂/∂Θ(fφ sin(Θ))- ∂fθ/∂Φ) , 1/r (1/sin(Θ) ∂fr/∂Φ - ∂/∂r(r fθ) , 1/r (∂/∂r(r fφ - ∂fr/∂Θ) }
testing equations for correct numerical output
check_thetaphi_deriv.c check_thetaphi_deriv_c.out
<- previous index next ->