# One Quaternion two different 4x4 matrix representations and a same result just multiplying unit quaternions.

Working with different papers I found out two ways on writing Quaternions as 4X4 matrices by "two ways" I'm trying to say that the signs on the coefficients of the matrices are a little bit different both of the satisfy Hamilton's theorem and the basic algebra.

One thing that I noticed using a Matlab script is that the determinant is no the same for the matrices.

Let's call q this quaternion and Q1 and Q2 are the forms in which I'm working.

The following are the 2 ways that I wrote the 4X4 matrices and all their derivation:

Q1:

First: $$q0 \begin{bmatrix} 1&0\\ 0&1 \end{bmatrix} + q1\begin{bmatrix} i&0\\ 0&-i \end{bmatrix} + q2\begin{bmatrix} 0&-1\\ 1&0 \end{bmatrix} +q3\begin{bmatrix} 0&-i\\ -i&0 \end{bmatrix}$$

Then: $$Q1= \begin{bmatrix} q0 + q1i&-q2-q3i\\-q2+q3i&q0−q1i\end{bmatrix} ,det(Q1)=q0^2+q1^2+q2^2+q3^2$$

That as a 4x4 Matrix becomes:

$$\begin{bmatrix}q0&-q1&-q2&q3\\q1&q0&-q3&-q2\\q2&q3&q0&q1\\-q3&q2&-q1&q0\end{bmatrix}$$

Q2:

First: $$q0 \begin{bmatrix} 1&0\\ 0&1 \end{bmatrix} + q1\begin{bmatrix} i&0\\ 0&i \end{bmatrix} + q2\begin{bmatrix} 0&i\\ -i&0 \end{bmatrix} +q3\begin{bmatrix} 0&-1\\ 1&0 \end{bmatrix}$$

Then: $$Q1= \begin{bmatrix} q0 + q1i&q2i-q3\\-q2i+q3&q0+q1i\end{bmatrix} ,det(Q1)=q0^2+2q0q1i-q1^2-q2^2-2q2q3i+q3^2$$

That as a 4x4 Matrix becomes:

$$\begin{bmatrix}q0&-q1&-q2&-q3\\q1&q0&-q3&q2\\q2&q3&q0&-q1\\q3&-q2&q1&q0\end{bmatrix}$$

I Used this last 4X4 matrix to derive this next formula for quaternion rotations in 3D but couldn't derive the formula using Q1.

qpq^-1 Matrix Rotation Formula

Both of them can ver verified with the following: Hamilton relation

For example:

If I try to multiply to Quaternions qp making q a 4X4 matrix the product *Q1*p* gives quite the same results as Q2 just with the difference of the sign of the "k" coefficient of the output quaternion. This product works as I described above under the condition that the "p" quaternion is a unit quaternion.

When p is not a unit quaternion the product is very different.

let's call D1 the determinant of Q1 and D2 the determinant of Q2.

My guess on this is that determinant D2 that is the only difference that I found so far In the two ways I express q is the one that causes this effect but I want to know why and learn more.

I now the Determinant is the one that tells us how is the area, volume or hypervolume is going to be scaled once you multiply by that matrix.

This guess might not be correct ant the reason that this multiplication changes when p stops being a unit vector is just something else.

• Is there a question somewhere ? – Captain Lama Apr 24 at 20:02
• Also note that your matrix representations do not satisfy the usual Hamilton relations, since the generators do not anti-commute. – Captain Lama Apr 24 at 20:30
• The latter set of matrices don't represent Hamilton's quaternions. This is obvious from the the observation that setting $q1=1$, $q0=q2=q3=0$ gives you the matrix $$\pmatrix{i&0\cr0&i\cr},$$ and, as a scalar matrix this commutes with all the others. But. the quaternion $i$ does not commute with the quaternions $j$ and $k$. – Jyrki Lahtonen Apr 24 at 20:42

If you look carefully, you will notice that any one of the two $$\ 4\times 4\$$ matrices can be transformed into the other by negating the last row and the last column. They represent the same linear transformation except for the last basis vector is negated. Obviously, this can be generalized to produce $$2^4$$ different matrices to linearly represent quaternions.

The Mathematica code:

doit[M_] := (
i0 = M /. {q0 -> 1, q1 -> 0, q2 -> 0, q3 -> 0};
i1 = M /. {q0 -> 0, q1 -> 1, q2 -> 0, q3 -> 0};
i2 = M /. {q0 -> 0, q1 -> 0, q2 -> 1, q3 -> 0};
i3 = M /. {q0 -> 0, q1 -> 0, q2 -> 0, q3 -> 1};
{i1.i1, i2.i2, i3.i3, i1.(i2.i3), i1.i2, i2.i3, i3.i1,
i2.i1, i3.i2, i1.i3} /. {i0 -> I0, -i0 -> -I0, i1 -> I1,
-i1 -> -I1, i2 -> I2, -i2 -> -I2, i3 -> I3, -i3 -> -I3})
M1 = {{q0, -q1, -q2, q3}, {q1, q0, -q3, -q2}, {q2, q3, q0, q1}, {-q3, q2, -q1, q0}};
M2 = {{q0, -q1, -q2, -q3}, {q1, q0, -q3, q2}, {q2, q3, q0, -q1}, {q3, -q2, q1, q0}};
doit[M1]
doit[M2]


output the results

{-I0, -I0, -I0, -I0, I3, I1, I2, -I3, -I1, -I2}
{-I0, -I0, -I0, -I0, I3, I1, I2, -I3, -I1, -I2}


which demonstrates that the two matrices do satisfy the quaternion equations

$$i^2 = j^2 = k^3 = i\ j\ k = -1,\ i\ j = k,\ j\ k = i,\ k\ i = j,\ j\ i = -k,\ k\ j = -i,\ i\ k = -j.$$

Also the determinants of both $$4\times 4$$ matrices are equal to $$\ (q0^2+q1^2+q2^2+q3^2)^2.$$

The second representation is claimed to be

$$q0 \begin{bmatrix} 1&0\\ 0&1 \end{bmatrix} + q1\begin{bmatrix} i&0\\ 0&i \end{bmatrix} + q2\begin{bmatrix} 0&i\\ -i&0 \end{bmatrix} + q3\begin{bmatrix} 0&-1\\ 1&0 \end{bmatrix}$$

but it really should be

$$q0 \begin{bmatrix} 1&0\\ 0&1 \end{bmatrix} + q1\begin{bmatrix} i&0\\ 0&i \end{bmatrix} + q2\begin{bmatrix} 0&-J\\ J&0 \end{bmatrix} + q3\begin{bmatrix} 0&-I\\ I&0 \end{bmatrix}$$

where $$i = \begin{bmatrix} 0&-1 \\ 1&0 \end{bmatrix}, \quad I = \begin{bmatrix} 0&1\\ 1&0 \end{bmatrix},\quad J = \begin{bmatrix} 1&0\\ 0&-1 \end{bmatrix}.$$

• Thanks for your answer I understand that both satisfy Quaternion algebra but, do you have an idea if the different determinant causes the different result when Q1p and Q2p under the condition that p is not unitary. – Carlos Echeverria St Apr 24 at 21:33