# Inverse substitution polar-cartesian

When I have an expression in polar coordinates and I substitute the definition of $r$ and $\phi$, I get the corresponding expression in polar coordinates. I would like to go back and obtain the same expression now as a function of $r$ and $\phi$, but the code below doesn't simplify the ArcTan as I would like:

ρ[x_, y_] := Sqrt[x^2 + y^2];
Θ[x_, y_] := ArcTan[x, y];
$Assumptions = r > 0 && r ∈ Reals, ϕ ∈ Reals; ϕ /. r -> ρ[x, y] /. ϕ -> Θ[x, y] % /. x -> r Cos[ϕ] /. y -> r Sin[ϕ] ## 2 Answers First of all,$Assumptions isn't used anywhere in the original code because you're just doing replacements. You have to use a function such as FullSimplify that actually checks the setting of $Assumptions. To decide what functions do this, look for the option Assumptions in the Options of that function. With that said, here is how to do the inversion: ρ[x_, y_] := Sqrt[x^2 + y^2]; Θ[x_, y_] := ArcTan[x, y];$Assumptions =
r > 0 && r ∈ Reals && -Pi/2 < ϕ < Pi/2;

ϕ /. r -> ρ[x, y] /. ϕ -> Θ[x, y]

(* ==> ArcTan[x, y] *)

% /. x -> r Cos[ϕ] /. y -> r Sin[ϕ]

(* ==> ArcTan[r Cos[ϕ], r Sin[ϕ]] *)

FullSimplify[%]

(* ==> ϕ *)

The only other thing I had to change is to restrict the angle range in $Assumptions so that the ArcTan can in fact be uniquely inverted. So you are trying to use coordinate transformation for a function. You can do it in this way. Say you have a function f[x,y] which you transform into g[r,q] and then use the reverse transformation to get back f[x,y]. f[x,y] g[r_, q_] = f[x, y] /. {x -> r Cos[q], y -> r Sin[q]} f1[x_, y_] = g[r, q] /. {r -> Sqrt[x^2 + y^2], q -> ArcTan[x, y]} f[x, y] f[r Cos[q], r Sin[q]] f[x, y] Is that what you are looking for? Also notice that I don't use any form for f[x,y]. So it is true for both scalar and vectors. In your example you get ArcTan[r Cos[ϕ], r Sin[ϕ]] instead of ϕ because ArcTan is bounded within -Pi/2 to Pi/2 but your ϕ doesn't have such bound. When you use it in another expression, it will give you right answer. Tan[ArcTan[r Cos[ϕ], r Sin[ϕ]]] Tan[ϕ] • I want to transform a symbolic expression and not a specific vector – usumdelphini Jun 10 '16 at 13:15 • Thanks, but this still doesn't work in my case, because I do not want to transform a vector but a scalar expression of (x,y) to the corresponding expression as a function of$(r,\phi)\$ and back. – usumdelphini Jun 10 '16 at 13:52
• Also, it doesn't allow me to convert to polar (or cartesian) coordinate the components of a vector in cartesian coordinates (or polar), seperately. – usumdelphini Jun 10 '16 at 13:53