Order of calculation in all math equations I already asked a question (Order of operations in rotation matrix notation.) about the order in which a particular equation is "processed" and now I need to generalise that and learn the rules of math notation. I can't find this sort of 'documentation' in any of my books or on the web.
In the "construction" equation in J.M.'s answer to Matrix for rotation around a vector, in what order does the equation get 'processed'?
Commentators on my first question seemed doubtful as to the ambiguity in mathematical notation that I seem to be experiencing and that parentheses are commonplace, yet I rarely see them used to denote processing priority, so its obviously implied (which is no good for the unwashed).
The main problem I have is that the sine function has a power-of 2 right after it, which throws my assumption that the very next symbol is what should be fed into the function.
Even though I've been programming since I was 8, I'm finding math almost as hard-going as anyone else and I feel that it is the compressive, symbolic syntax that's the problem.
Anyway, can anyone recommend a primer on reading math, rather like a programming language specification?
Luke
 A: You are exactly right that the expression in J.M.'s (original) answer contains ambiguity.  Mathematicians can distinguish the correct meaning easily because we are used to seeing things written this way, but it can be difficult for the uninitiated.  Let me break it down for you.

$$\mathbf I+\sin\,\varphi\mathbf W+2\sin^2\frac{\varphi}{2}\mathbf W^2$$



*

*To begin with, often when people do linear algebra (arithmetic with matrices and vectors), they will bold the symbol for a matrix (an array) or a vector (a tuple) to distinguish it from a scalar (a number).  In this case, J.M. was distinguishing that I and W are matrices.  (Conventionally capital bolded letters like ${\bf A}$ denote matrices, while lower case bolded letters like ${\bf v}$ denote vectors.)   In particular, I refers to the identity matrix, which is the matrix with diagonal entries $1$ and all other entries $0$.  Sometimes we write this as ${\bf I_n}$ instead to distinguish the dimensions of that particular matrix. $$\mathbf{I}_n =\underbrace{\left.\left(\begin{array}{ccccc}1&0&0&\cdots &0\\0&1&0&\cdots &0\\0&0&1&\cdots &0\\ \vdots&&&\ddots &\\0&0&0&\cdots &1\end{array}\right)\right\}}_{n\text{ columns}}\,n\text{ rows}$$ 

*As you learned in the last post, $\sin$ is a trigonometric function.  Generally we write $\sin(\theta)$ to denote the $\sin$ of $\theta$, but we sometimes leave the parenthesis out when we believe the meaning is unambiguous.  $\sin\varphi {\bf W}$ appears ambiguous because you don't know whether you should be $\sin$'ing $\varphi$ or $\varphi{\bf W}$.  However, you can't $\sin$ a matrix, so now that you know the convention that matrices are bolded, it should be clear that $\sin{\varphi}{\bf W}$ denotes a scalar $\sin(\varphi)$ multiplied by a matrix ${\bf W}$.  A scalar multiplied by a matrix is simply the scalar applied to each entry in the matrix, so $$\begin{eqnarray*}\sin\varphi {\bf W}&=&\sin\varphi \left(\begin{array}{ccc}  W_{11} & W_{12} & \cdots &  W_{1n} \\ W_{21} & W_{22} & \cdots &  W_{2n} \\ \vdots &  & \ddots & \\ W_{m1} & W_{m2} & \cdots &  W_{mn} \end{array}\right)\\&=&\left(\begin{array}{ccc}\sin(\varphi) W_{11} &\sin(\varphi) W_{12} & \cdots & \sin(\varphi) W_{1n} \\ \sin(\varphi) W_{21} &\sin(\varphi) W_{22} & \cdots & \sin(\varphi) W_{2n} \\ \vdots &  & \ddots & \\\sin(\varphi)  W_{m1} & \sin(\varphi) W_{m2} & \cdots & \sin(\varphi)W_{mn} \end{array}\right).\end{eqnarray*}$$

*There is another weird notation here.  $\sin^2\theta$, for whatever reason, is how we write $(\sin(\theta))^2$.  (I honestly don't know how this originated.  Usually when you have a function $f$ and you write $f^2(x)$, it means $f(f(x))$, not $(f(x))^2$, but for trigonometric functions this is different.)  So in the expression $2\sin^2\frac{\varphi}{2}{\bf W^2}$, you would first evaluate the scalar $2\sin^2\frac{\varphi}{2}$: first divide $\varphi$ by $2$, then compute the $\sin$, then square it, then multiply by $2$. Set the result aside (let's call it $\alpha$), compute ${\bf W}^2={\bf W}\cdot{\bf W}$ with matrix multiplication, and then multiply each entry of ${\bf W}^2$ by $\alpha$ term by term.

*The very last thing you do is add the three matrices $I$, $\sin\varphi {\bf W}$, and $2\sin^2\frac{\varphi}{2}{\bf W}^2$ together.  Addition of matrices is simply term by term, i.e. $$A+B=\left(\begin{array}{ccc}  A_{11} & A_{12} & \cdots &  A_{1n} \\ A_{21} & A_{22} & \cdots &  A_{2n} \\ \vdots &  & \ddots & \\ A_{m1} & A_{m2} & \cdots &  A_{mn} \end{array}\right)+\left(\begin{array}{ccc}  B_{11} & B_{12} & \cdots &  B_{1n} \\ B_{21} & B_{22} & \cdots & B_{2n} \\ \vdots &  & \ddots & \\ B_{m1} & B_{m2} & \cdots &  B_{mn} \end{array}\right)=\left(\begin{array}{ccc}  A_{11}+B_{11} & A_{12}+B_{12} & \cdots &  A_{1n}+B_{1n} \\ A_{21}+B_{21} & A_{22}+B_{22} & \cdots &A_{2n}+ B_{2n} \\ \vdots &  & \ddots & \\ A_{m1}+B_{m1} &A_{m2}+ B_{m2} & \cdots &  A_{mn}+B_{mn} \end{array}\right).$$
Note that $A+B$ is only defined when $A$ and $B$ have the same dimensions - if $A$ is an $m\times n$ matrix, $B$ has to be too.
Hope this helps! It may help to compute a small example (with $2\times 2$ matrices) with pen and paper.
A: There are many conventions here which need to be learned.  Parentheses override anything.  Horizontal fraction bars (but not diagonal ones) come with parentheses around the stuff above and below them.  Then exponents come before multiplication/division, which come before addition/subtraction.  We just got (again) the question of how to parse $6/2(1+2)$ which computers know is $9$ but many people think is $1$ and we see similar forms with both intents.
The particular form you reference $2 \sin^2 \frac \varphi 2$ is special.  Because trigonometry functions often need squaring we write them this way instead of $2(\sin \frac \varphi 2)^2$, which is equivalent.  Aside from trigonometry, you rarely see $f^2(x)$ and if you do, it is sometimes the square of $f(x)$ and sometimes $f(f(x))$-the author owes you an explanation.  Usually only one of these makes sense.  Another trouble is arguments of trigonometry functions-we sometimes write $\sin x$ without parentheses, but is $\sin 2 \pi \omega t$ supposed to be $\sin (2) \pi \omega t$ or $\sin (2\pi \omega t)$?  I would bet heavily on the latter.
A: The basic answer is that trig functions are special.  Other than those, math symbols usually behave pretty much the same way.  I personally almost always mean $f(x)^2$ when I write $f^2(x)$, and I have a bunch of other conventions I use to ensure that I understand my notes, but as long as you get to the right answer, most teachers either don't care precisely what notation you use to get the answer, as long as the end result is in the notation they use.  Those who do care usually don't mind a few extra sets of parentheses.
