I'm trying to follow a book that uses the variable $x$ for dimension in cartesian coordinates and $x'$ for the polar coordinates. I'd like to use this typesetting in my Mathematica notebook so I don't have to mentally convert.

Instead of using $r$ and $\theta$, how would you typeset something like:$$mat=\begin{bmatrix}cos x'^2 & -x'^1 sin x'^2 \\sin x'^2 & x'^1 cos x'^2\end{bmatrix}$$Where $x'^1$ is used in the place of $r$ and $x'^2$ is used in the place of $\theta$? Is it practical to work with this kind of typesetting in Mathematica?


1 Answer 1


Usually it's not advised to do computations with typeset objects because they can have structures that are affected by the computations themselves. Though, if you wanted to programatically make symbols to use in say $\LaTeX$, then Mathematica's typesetting abilities are great.

In this case, one has to take care though because Mathematica already has a defined use for the ' character (namely Derivative). So you could use the \[Prime] or Esc ' Esc character in

vars = Array[Superscript[x, "\[Prime]" <> ToString[#]] &, 2];
mat == {
 {Cos[t], -r Sin[t]}, 
 {Sin[t], r Cos[t]}
} /. Thread[{r, t} -> vars] // MatrixForm // TraditionalForm // TeXForm

$ \text{mat}=\left( \begin{array}{cc} \cos \left(x^{\text{$\prime $2}}\right) & -\sin \left(x^{\text{$\prime $2}}\right) x^{\text{$\prime $1}} \\ \sin \left(x^{\text{$\prime $2}}\right) & \cos \left(x^{\text{$\prime $2}}\right) x^{\text{$\prime $1}} \\ \end{array} \right) $

Though for this case I would personally use xp1 and xp2 instead of $x^{\text{$\prime $1}}$ and $x^{\text{$\prime $2}}$, respectively, when doing computations.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.