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 Q1p* 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.
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:
outputs the results
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}. $$