# Change the coordinates from $(x,y)$ to $(\mu,\theta)$?

Suppose I have the following definition:

$$x=\cosh \mu\cos\theta, \quad y=\sinh\mu\sin\theta$$

I want to change the coordinates $(x,y)$ to $(\mu,\theta)$, suppose $x\in(-1,1), y\in(-1,1)$.

Here is how I do with a single point:

x1 = 1; y1 = -1;
sols = NSolve[{
Cosh[μ] Cos[θ] == x1
, Sinh[μ] Sin[θ] == y1 && 0 < θ < 2 Pi && μ > 0
}, {μ, θ}
];

{μ, θ} /. sols[]


Now I want to change a couple of coordinates at the same time and return a table of the desired coordinates:

talbe = Flatten[Table[{x, y}, {x, -1, 1, 0.3}, {y, -1, 1, 0.3}], 1];


How can I achieve this?

### Edit:

the NSolve method is slow when the point grows, is there any faster method? Besides, NSolve sometimes failed to get the solution.

Your coordinates are elliptic cylindrical coordinates coordinates at a fixed value of $z$ and with $a = 1$. Mathematica has built-in knowledge of these coordinates, and you can use CoordinateTransformData to convert between any two coordinate systems that Mathematica knows about. In your case, you want

a = 1; z = 0;
{μ, θ} = Drop[CoordinateTransform["Cartesian" -> {{"EllipticCylindrical", a}}, {x, y, z}], -1]

(* {ArcCosh[Sqrt[1 + x^2 + y^2 + Sqrt[-4 x^2 + (1 + x^2 + y^2)^2]]/Sqrt],
ArcTan[x Sqrt[-2 + Sqrt Sqrt[1 + x^2 + y^2 + Sqrt[-4 x^2 + (1 + x^2 +  y^2)^2]]] Sqrt[2 + Sqrt Sqrt[1 + x^2 + y^2 + Sqrt[-4 x^2 + (1 + x^2 + y^2)^2]]], Sqrt y Sqrt[1 + x^2 + y^2 + Sqrt[-4 x^2 + (1 + x^2 + y^2)^2]]]} *)


This turns out to be a closed-form expression, which probably implies that you could have derived it yourself. But it's probably better, and definitely easier, to rely on the prowess of the good people at Wolfram instead. Note the use of the two-argument form of ArcTan in the result for θ, which implies that you would have to be careful about quadrant issues if you were to write this yourself.

To apply this to a list of variables, define a function μθ[{x_, y_}] that calls CoordinateTransformation:

μθ[{x_, y_}] = Drop[CoordinateTransform["Cartesian" -> {{"EllipticCylindrical", 1}}, {x, y, 0}], -1]
table = Flatten[Table[{x, y}, {x, -1, 1, 1.0}, {y, -1, 1, 1.0}], 1]
μθ /@ table

(* {{-1., -1.}, {-1., 0.}, {-1., 1.}, {0., -1.}, {0., 0.}, {0., 1.},
{1., -1.}, {1., 0.}, {1., 1.}} *)

(* {{1.06128, -2.23704}, {0., 3.14159}, {1.06128, 2.23704}, {0.881374, -1.5708},
{0., Indeterminate}, {0.881374, 1.5708}, {1.06128, -0.904557}, {0., 0.},
{1.06128, 0.904557}} *)


Note that since elliptic cylindrical coordinates are ill-defined for $y = 0$ and $|x| \leq 1$, applying this transformation to the point {0,0} leads to a result of Indeterminate.

More information concerning the coordinate systems programmed into Mathematica can be found at the documentation page for CoordinateChartData.

Define a function as follows:

sols[x1_, y1_] :=
First[NSolve[{Cosh[μ] Cos[θ] == x1,
Sinh[μ] Sin[θ] == y1 &&
0 < θ < 2 Pi && μ > 0}, {μ, θ}]]


Check for known values

sols[1, -1]

(* {μ -> 1.06128, θ -> 5.37863} *)


Then create a table

Table[{x1, y1, sols[x1, y1]}, {x1, 1, 5}, {y1, -5, -1}]

• BTW I would really like to know how I can change the [Theta] into the actual Theta symbol in the post. I searched but could not find it. Any help is appreciated. May 24, 2017 at 14:26
• See the accepted answer, you need to install something. mathematica.stackexchange.com/questions/27289/… May 24, 2017 at 14:34
• buzhidao: Excellent. Thanks a ton for this. May 24, 2017 at 14:47
• Since the function sols uses a numerical technique (NSolve), the function's arguments should be restricted to numeric values: sols[x1_?NumericQ, y1_?NumericQ] := ... May 24, 2017 at 15:19