# Plotting Vector Fields for the Basis Vectors of Different Coordinate Systems

In short, I am hoping to plot out vector fields for the basis vectors of my elliptic cylindrical coordinate system.

For more information on the coordinate system I mentioned, Wolfram|Alpha has a site that quickly provides it: https://mathworld.wolfram.com/EllipticCylindricalCoordinates.html

The basis vectors for my coordinate system are defined below.

$$\hat{\mu} = \frac{1}{a \sqrt{\sinh^2 {\mu} + \sin^2 {v}}} (a \sinh{\mu} \cos{v} \; \hat{i} + a \cosh{\mu} \sin{v} \; \hat{j})$$

$$\hat{v} = \frac{1}{a \sqrt{\sinh^2 {\mu} + \sin^2 {v}}} (-a \cosh{\mu} \sin{v} \; \hat{i} + a \sinh{\mu} \cos{v} \; \hat{j})$$

$$\hat{z} = 1 \hat{z}$$

Despite knowing my basis vectors, though, creating vector field plots in the $$x$$, $$y$$ plane for my basis vectors has been giving me a really hard time.

I realize that Wolfram provides a tutorial on the topic (i.e. https://reference.wolfram.com/language/howto/PlotAVectorField.html), however, plotting a different coordinate system (rather than Cartesian) has proven to be quite difficult as I am a novice at Mathematica.

Therefore, any assistance to help me figure out how to plot out the vector fields would be greatly appreciated. Thank you very much for reading this!

• What code have you tried? Do you have a conversion function of elliptic-cylindrical coordinates to cartesian coordinates already? – flinty Sep 9 '20 at 15:48
• @flinty , as for the "conversion function" you've mentioned, I did try CoordinateTransform but to no avail as the code did not provide me the conversion I wanted for my coordinate system. I did try to refer to this site (mathematica.stackexchange.com/questions/173081/…) for more information, but I did not quite understand what the user was doing save for the CoordinateTransform command. Anyway, do you have any suggestions on how I should first go about constructing this conversion function? Thank you so much for the comment and help! – Athenian Sep 9 '20 at 16:20
• You don't need CoordinateTransform. You can just write your own functions ellipticCylToCartesian[{mu,v,z}] and cartesianToEllipticCyl[{x,y,z}]. – flinty Sep 9 '20 at 16:23
• @flinty , thank you for the help! I did try to search online on how to create my own functions which help translate the coordinate systems like you seem to demonstrate above. However, I do not think I am looking at the right places. Or, do I just simply write ellipticCylToCartesian[{mu,v,z}] := "the equations"? Note that by "the equations", I mean the equations I have originally provided in the question prompt. Thank you. – Athenian Sep 9 '20 at 16:58

Let's start with the definition of the Elliptic Cylindrical coordinates, that tells us how they map to cartesian coordinates:

\[CurlyPhi] = {\[FormalA] Cosh[u] Cos[v], \[FormalA] Sinh[u] Sin[v], w}


Honestly, i mainly used [FormalA] here, because the function TransformedField that we'll use later uses it by default for the free parameter a of the coordinate system and i haven't figured out yet how to specify a different value, so this choice of naming saves us one symbol replacement later.

Alternatively, instead of giving the definition manually we could also conveniently use

\[CurlyPhi] = CoordinateTransformData[
"EllipticCylindrical" -> "Cartesian",
"Mapping",
{u, v, w}
]


, which does the same.

Now, since we want to have the basis vectors and not just the point mappings, we need the jacobian with respect to {u,v,w} which gives us the unnormalized basis vectors:

jacobian = D[\[CurlyPhi], {{u, v, w}}];
jacobian // MatrixForm


Now we can use the builtin function TransformedField to reexpress the jacobian in cartesian coordinates for us:

basisunnormalized =
Simplify[
TransformedField[
"EllipticCylindrical" -> "Cartesian",
Transpose[jacobian],
{u, v, w} -> {x, y, z}
],
\[FormalA] > 0
]


Note that we transposed the jacobian, so that each of the three list elements holds a basis-vector (corresponding to the direction of increasing u, v and w).

GraphicsRow[
VectorPlot[#, {x, -2, 2}, {y, -2, 2}] & /@
(basisunnormalized[[{1, 2}, {1, 2}]] /. \[FormalA] -> 1)
]


or normalize the basis vectors if needed.

Edit:

The choice to start with the jacobian was mainly based on its simpler structure compared to the normalized basis vectors, which gives simpler (plain rational fraction without trigonometric functions) expressions after invoking TransformedField. But with some extra care we can also work with the normalized basis vectors and in the process skip a lot of manual work.

The basis you gave in the questions can either be computed via normalizing our jacobian

basisnormalized = Transpose[
Simplify[
Normalize /@ Transpose[jacobian],
u > 0 && v > 0 && \[FormalA] > 0
]
]


or directly via

basisnormalized = CoordinateTransformData[
"EllipticCylindrical" -> "Cartesian",
"OrthonormalBasisRotation",
{u, v, w}
]


giving

basisnormalized //MatrixForm


Invoking TransformedField now already works but can't get rid of the trigonometric functions Cos[2 v] and Cosh[2 u] which contain double angles. By using TrigExpand we can convert them to powers of single angle trigonometric expressions, which TransformedField has an easier time with:

basisnormalized2 = basisnormalized /. {a : (Cos | Cosh)[2 _] :> TrigExpand[a]}


or in an easier readable form

basisnormalized2 = basisnormalized /. {
Cos[2 v] -> Cos[v]^2 - Sin[v]^2,
Cosh[2 u] -> Cosh[u]^2 + Sinh[u]^2
};


results in

basisnormalized2 //MatrixForm


which we can use to get an expression in terms of x, y and z without trigonometric functions:

basisnormalizedcartesian = Simplify[
TransformedField[
"EllipticCylindrical" -> "Cartesian",
basisnormalized2,
{u, v, w} -> {x, y, z}
],
\[FormalA] > 0
]

• Thank you for the awesome answer! While it did take a little while, I believe I understand most of what is going on here in the provided code. In your answer, though, you had unnormalized basis vectors. If I want to normalize the basis vectors, do I simply change the code basisunnormalized to basisnormalized? Or, do I need to write the code down for the equation like $\hat{u} = \frac{\vec{u}}{||u||}$ to make the change? – Athenian Sep 9 '20 at 18:13
• @Athenian making the change as you’ve stated would do no more than to change basisunnormalized to redfishbluefish—that is, that is only the name of the symbol that you’d be changing, which refers to the expressions after the equals sign. You would need to apply something like Normalize or the formula you’ve noted to normalize the expression. – CA Trevillian Sep 10 '20 at 7:04
• @Athenian You're welcome! Like CA Trevillian explained, basisunnormalized is just an arbitrary name we assign the expression to, so only changing that won't change the expression. I edited my answer to show how to get an expression for the normalized basis vectors. – Thies Heidecke Sep 10 '20 at 8:10
• @ThiesHeidecke Thank you very much for the detailed edits and clear explanation! After reading the comments, it makes perfect sense that just changing the naming convention to basisunnormalized won't change the code's results. Anyway, I'll study your edits and codes in-depth and practice doing it myself. Once again, thank you for the help! – Athenian Sep 10 '20 at 8:35