How to use quaternions express number How to use quaternions express number like 49 as sums of four squares
based on their factorizations?
I just start to learn  quaternion in my math class,
I tired to find my class note :
Quaternions look like  a + b i + c j + d k .
Hmmmm ... i guess a,b,c,d are integers.Real numbers commutate i,j,k?
and..sum of four squares will look like this?
$8     =      4+4+0+0 $
$9     =      4+4+1+0 $
$10    =      4+4+1+1$
$49 =？　$

Quaternions $q=a+b\mathbf{i}+c\mathbf{j}+d\mathbf{k}$ have a "norm" defined by
$$ |a+b\mathbf{i}+c\mathbf{j}+d\mathbf{k}|^2 =  a^2+b^2+c^2+d^2.  $$
This is a generalization of $|a+bi|=a^2+b^2$ defined for complex numbers. Indeed, it is still multiplicative: we have $|xy|=|x||y|$ for quaternions $x$ and $y$.
How can we use this idea to write whole numbers as sums of four squares? Let's do a more illustrative example first: say $42$. To write $42=a^2+b^2+c^2+d^2$ we want to find a quaternion $a+b\mathbf{i}+c\mathbf{j}+d\mathbf{k}$ with square norm $42$. We can factor $42$ with smaller numbers in various ways, for example as $6\cdot 7$ or $3\cdot 14$. So to write $42$ as $|x|^2$, it is sufficient to find $x$s for which $|x|^2$ is $6$ and $7$, or $3$ and $14$. Indeed, we have
$$ 6=0^2+1^2+1^2+2^2 \\ 7=1^2+1^2+1^2+2^2 $$
(one may permute the summands any way one likes) and then
$$ \begin{array}{l} 6=|\mathbf{i}+\mathbf{j}+2\mathbf{k}|^2 \\ 7 =|1+\mathbf{i}+\mathbf{j}+2\mathbf{k}|^2 \end{array}$$
which implies
$$ \begin{array}{ll} 42 & =|(\mathbf{i}+\mathbf{j}+2\mathbf{k})(1+\mathbf{i}+\mathbf{j}+2\mathbf{k})|^2 \\ & =|-6+\mathbf{i}+\mathbf{j}+2\mathbf{k}|^2 \\ & =6^2+1^2+1^2+2^2. \end{array} $$
Alternatively,
$$ \begin{array}{r} 3 = 1^2+1^2+0^2+1^2 \\ 14 = 0^2+1^2+2^2+3^2 \end{array} $$
which tells us
$$ \begin{array}{l} \phantom{1}3 = |1+\mathbf{i}+\mathbf{k}|^2 \\ 14 = |\mathbf{i}+2\mathbf{j}+3\mathbf{k}|^2 \end{array} $$
which implies
$$ \begin{array}{ll} 42 & = |(1+\mathbf{i}+\mathbf{k})(\mathbf{i}+2\mathbf{j}+3\mathbf{k})|^2 \\ & = |-4-\mathbf{i}+5\mathbf{k}|^2 \\ & = 4^2+1^2+0^2+5^2. \end{array} $$
I'll let you play around with $49=7\cdot7$. We can write $7=1^2+1^2+2^2+1^2$, but there are different ways to permute the summands. See what they tell you.
Note that you will need to know how to multiply two quaternions to do this. This involves using the distributive property and the multiplication table for $\mathbf{i},\mathbf{j},\mathbf{k}$ (or a helpful mnemonic).
