# Polar to Cartesian and Cartesian to Polar Transformation

I have noticed some odd behavior when converting from Polar < -- > Cartesian.

We want to convert to polar and then back to Cartesian:

$$(x',y')=(x-y-x(x^2+y^2)+\frac{xy}{\sqrt{x^2+y^2}},x+y-y(x^2+y^2)-\frac{x^2}{\sqrt{x^2+y^2}} )$$

If we do:

  field={x-y-x(x^2+y^2)+x y/Sqrt[x^2+y^2],x+y-y(x^2+y^2)-x^2/Sqrt[x^2+y^2]}

TransformedField[
"Cartesian" -> "Polar", field, {x, y} -> {r, \[Theta]}]


This produces, after FullSimplify[%, Trig -> True]:

$$\left\{r-r^3,r-\sqrt{r^2} \cos (\theta )\right\}$$

Not the same result ($r'$ looks good, $\theta'$ looks odd). Question 1: Why?

When we convert this expression back (I have noticed this odd behavior with every example I have done and am trying to understand why MMA is doing this), we do:

  field = {r-r^3,r-Sqrt[r^2] Cos[\[Theta]]};

TransformedField["Polar"->"Cartesian",field,{r,\[Theta]}->{x,y}]


This produces:

$$\left\{\frac{x \left(\sqrt{x^2+y^2}-\left(x^2+y^2\right)^{3/2}\right)}{\sqrt{x^2+y^2}}-\frac{y \left(\sqrt{x^2+y^2}-x\right)}{\sqrt{x^2+y^2}},\frac{y \left(\sqrt{x^2+y^2}-\left(x^2+y^2\right)^{3/2}\right)}{\sqrt{x^2+y^2}}+\frac{x \left(\sqrt{x^2+y^2}-x\right)}{\sqrt{x^2+y^2}}\right\}$$

Compare this to the original. Question 2: Why are those $\sqrt{x^2 + y^2}$ terms there?

• Answer for the second question: you've made a simple mistake, what you need is TransformedField["Polar" -> "Cartesian", field, {r, \[Theta]} -> {x, y}] – xzczd Aug 29 '16 at 5:15
• @xzczd: Sorry, that was just a copy error (corrected) - the result has the issue (or my confusion) as described. Thanks. – Moo Aug 29 '16 at 5:28
• Since r is non-negative, you can simplify your expression in polar coordinates. – mikado Aug 29 '16 at 5:47
• Why do we need to say $r$ is non-negative? $r = \dfrac{x}{\cos t}$, seems like it should take on any value, positive and negative. – Moo Aug 29 '16 at 5:50
• Well, generally it's not rare to see those symbolic transformation functions not producing the simplest form of the results. As to the question in the comment: just compare the result of TransformedField["Cartesian" -> "Polar", field, {x, y} -> {r, \[Theta]}] /. r -> -1 // Simplify and Simplify[TransformedField["Cartesian" -> "Polar", field, {x, y} -> {r, \[Theta]}], r > 0] /. r -> -1 – xzczd Aug 29 '16 at 6:10