Find formulas for spherical coordinates in terms of Cartesian coordinates using Maple

maplemultivariable-calculus

We can go from spherical coordinates $(r, \theta, \phi)$ to cartesian coordinates $(x,y,z)$ using the equations:

$x=r sin(\theta) cos(\phi)$

$y = r sin(\theta) sin(\phi)$

$z = r cos(\theta)$

Consider the task of finding formulas for $r$, $\theta$, and $\phi$ in terms of $x,y$, and $z$. The three equations above are a system that can be solved for $r$, $\theta$, and $\phi$.

This is a relatively easy task with pen and paper.

$r = \sqrt{x^2+y^2+z^2}$

$\theta = cos^{-1}\frac{z}{r}=cos^{-1}\frac{z}{\sqrt{x^2+y^2+z^2}}$

$\phi = tan^{-1} \frac{y}{x}$

How can we get Maple to obtain the same result?

If we try:

solve({r*sin(t)*cos(p) = x, r*sin(t)*sin(p) = y, r*cos(t) = z}, [r, t, p])

We obtain some very long and relatively illegible expression.

enter image description here

If my reasoning is correct about the simplicity of solving the original problem, why is it apparently not as straightforward in Maple? Furthermore, is there a way in Maple to obtain a relatively nice-looking solution?

Best Answer

Something like this?

simplify(solve({r*sin(t)*cos(p) = x,
                r*sin(t)*sin(p) = y,
                r*cos(t) = z},
               [r, t, p], explicit)[1]) assuming real:

   [r = (x^2+y^2+z^2)^(1/2),
    t = arctan((x^2+y^2)^(1/2),z),
    p = arctan(y,x)]
Related Question