[PYTHON] Quaternion considered in representation matrix

Even if a complex number is included in the components of the complex number representation matrix, it does not become a quaternion representation matrix. However, it is expected to have a similar shape, so we will use that as a clue to explore the quaternion representation matrix. We also mention that incorporating biquaternions will improve the outlook. A calculation by SymPy is attached.

This is a series of articles.

  1. Complex vector considered as a real vector
  2. Bicomplex numbers considered by representation matrix
  3. Quaternion considered by representation matrix ← This article
  4. Pauli matrices and biquaternions in Clifford algebra

This article has related articles.

Bicomplex number

In Previous article, I found the bicomplex number representation matrix.

\begin{align}
&a+bi+cj+dk \\
&=(a+bi)+(c+di)j \\
&↦\left(\begin{matrix}a+bi & -(c+di) \\ c+di & a+bi\end{matrix}\right) \\
&=a \underbrace{\left(\begin{matrix} 1& 0 \\ 0& 1 \end{matrix}\right)}_{1}
 +b \underbrace{\left(\begin{matrix} i& 0 \\ 0& i \end{matrix}\right)}_{i}
 +c \underbrace{\left(\begin{matrix} 0&-1 \\ 1& 0 \end{matrix}\right)}_{j}
 +d \underbrace{\left(\begin{matrix} 0&-i \\ i& 0 \end{matrix}\right)}_{ij=k}
\end{align}

Consider the quaternion representation matrix with reference to this structure.

Quaternion

In quaternions, $ i, j, k $ are all squared to $ -1 $.

i^2=j^2=k^2=-1

Bicomplex numbers have $ k ^ 2 = 1 $, which is different from quaternions. However, since the relationship $ ij = k $ is common to quaternions, isn't it possible to bring it to $ k ^ 2 = -1 $ by modifying the definitions of $ i $ and $ j $?

Representation matrix

Since $ j $ is inherited from the complex representation matrix, it is convenient to have the same quaternion. Leave $ j $ as it is and let the components of $ i $ be the unknowns $ x, y, z, w $. Prepare for the calculation with SymPy.

>>> from sympy import *
>>> x,y,z,w=symbols("x y z w")
>>> i=Matrix([[x,y],[z,w]])
>>> j=Matrix([[0,-1],[1,0]])
\begin{align}
i&↦\left(\begin{matrix} x& z \\ y& w \end{matrix}\right) \\
j&↦\left(\begin{matrix} 0&-1 \\ 1& 0 \end{matrix}\right)
\end{align}

From $ i ^ 2 = -1, \ k = ij, \ k ^ 2 = -1 $

>>> i**2
Matrix([
[x**2 + y*z,  w*y + x*y],
[ w*z + x*z, w**2 + y*z]])
>>> k=i*j
>>> k
Matrix([
[y, -x],
[w, -z]])
>>> k**2
Matrix([
[-w*x + y**2,  -x*y + x*z],
[  w*y - w*z, -w*x + z**2]])
\begin{align}
i^2&↦\left(\begin{matrix} x& y \\ z& w \end{matrix}\right)^2
=\left(\begin{matrix} x^2+yz & wy+xy \\ wz+xz & w^2+yz \end{matrix}\right)
=\left(\begin{matrix} -1 & 0 \\ 0 & -1 \end{matrix}\right) \\
k^2&↦\left(\begin{matrix} y & -x \\ w & -z \end{matrix}\right)^2
=\left(\begin{matrix} -wx+y^2 & -xy+xz \\ wy-wz & -wx+z^2 \end{matrix}\right)
=\left(\begin{matrix} -1 & 0 \\ 0 & -1 \end{matrix}\right)
\end{align}

Organize the relationship by comparing the ingredients.

x^2+yz=w^2+yz=y^2-xw=z^2-xw=-1 \\
y(x+w)=z(x+w)=x(y-z)=w(y-z)=0

The solution is not unique, but the relationships that must be met are known.

x=-w,\ y=z,\ x^2+y^2=-1

i selection

Since the simplest possible form is desirable, we will narrow down to the solution with two $ 0 $.

\begin{align}
(1)&\ x=0\ ⇒\ w=0,\ y^2=-1,\ y=z \\
(2)&\ y=0\ ⇒\ z=0,\ x^2=-1,\ x=-w
\end{align}

If you write it in a concrete form, you have the following four choices.

\left(\begin{matrix} x & z \\ y & w \end{matrix}\right)
=\left(\begin{matrix} 0 & ±i \\ ±i & 0 \end{matrix}\right),
 \left(\begin{matrix} ±i & 0 \\ 0 & ∓i \end{matrix}\right)\ (Multiple issues in the same order)

The rest is a matter of decision. Here, the base is the form obtained by multiplying by $ i $ and removing the imaginary number.

i\left(\begin{matrix} 0 & ±i \\ ±i & 0 \end{matrix}\right),
i\left(\begin{matrix} ±i & 0 \\ 0 & ∓i \end{matrix}\right)
=\left(\begin{matrix} 0 & ∓1 \\ ∓1 & 0 \end{matrix}\right),
 \left(\begin{matrix} ∓1 & 0 \\ 0 & ±1 \end{matrix}\right)\ (Multiple issues in the same order)

Of the four shapes on the right side, the simplest is probably the next shape without a minus sign. It is a matrix that is a mirror image inverted (not transposed) of the identity matrix up and down (or left and right).

i\left(\begin{matrix} 0 & -i \\ -i & 0 \end{matrix}\right)
=\left(\begin{matrix} 0 &  1 \\  1 & 0 \end{matrix}\right)

Determine the representation matrix of $ i $ from the left side.

i↦\left(\begin{matrix} 0 & -i \\ -i & 0 \end{matrix}\right)

Confirmation of k

If you decide $ i $, $ k $ will be decided automatically. ʻI` is the imaginary $ i $ defined in SymPy.

>>> i=Matrix([[0,-I],[-I,0]])
>>> j=Matrix([[0,-1],[1,0]])
>>> k=i*j
>>> k
Matrix([
[-I, 0],
[ 0, I]])
k=ij
↦\left(\begin{matrix} 0&-i \\-i& 0 \end{matrix}\right)
 \left(\begin{matrix} 0&-1 \\ 1& 0 \end{matrix}\right)
=\left(\begin{matrix}-i& 0 \\ 0& i \end{matrix}\right)

Summary

Now you have a quaternion representation matrix. The summary is as follows.

\begin{align}
&a+bi+cj+dk \\
&↦a \underbrace{\left(\begin{matrix} 1& 0 \\ 0& 1 \end{matrix}\right)}_{1}
 +b \underbrace{\left(\begin{matrix} 0&-i \\-i& 0 \end{matrix}\right)}_{i}
 +c \underbrace{\left(\begin{matrix} 0&-1 \\ 1& 0 \end{matrix}\right)}_{j}
 +d \underbrace{\left(\begin{matrix}-i& 0 \\ 0& i \end{matrix}\right)}_{k} \\
&=\left(\begin{matrix}a-di & -(c+bi) \\ c-bi & a+di\end{matrix}\right) \\
&=\left(\begin{matrix}(a+di)^* & -(c+bi) \\ (c+bi)^* & a+di\end{matrix}\right)
\end{align}

It's not very neat, but the biquaternion, which I'll explain later, makes it clear why we did this.

Determinant

It is good to be aware that complex conjugates appear in the components of the representation matrix and the determinant is the square of the norm.

\begin{align}
&\det\left(\begin{matrix}(a+di)^* & -(c+bi) \\ (c+bi)^* & a+di\end{matrix}\right) \\
&=(a+di)^*(a+di)+(c+bi)^*(c+bi) \\
&=a^2+b^2+c^2+d^2 \\
&=||a+bi+cj+dk||^2
\end{align}

Confirmation of calculation rules

Check if the quaternion arithmetic rules are met.

Original square

Check the original square.

>>> i**2
Matrix([
[-1,  0],
[ 0, -1]])
>>> j**2
Matrix([
[-1,  0],
[ 0, -1]])
>>> k**2
Matrix([
[-1,  0],
[ 0, -1]])
\begin{align}
i^2
&↦\left(\begin{matrix} 0&-i \\-i& 0 \end{matrix}\right)^2
 =\left(\begin{matrix}-1& 0 \\ 0&-1 \end{matrix}\right) \\
j^2
&↦\left(\begin{matrix} 0&-1 \\ 1& 0 \end{matrix}\right)^2
 =\left(\begin{matrix}-1& 0 \\ 0&-1 \end{matrix}\right) \\
k^2
&↦\left(\begin{matrix}-i& 0 \\ 0& i \end{matrix}\right)^2
 =\left(\begin{matrix}-1& 0 \\ 0&-1 \end{matrix}\right)
\end{align}

It became $ i ^ 2 = j ^ 2 = k ^ 2 = -1 $.

Patrol

For quaternions, the relationship between the original factor and the product appears cyclically ($ i → j → k → i → j → \ cdots $).

ij=k,\ jk=i,\ ki=j

Check the patrol.

>>> i*j
Matrix([
[-I, 0],
[ 0, I]])
>>> j*k
Matrix([
[ 0, -I],
[-I,  0]])
>>> k*i
Matrix([
[0, -1],
[1,  0]])
>>> i*j==k
True
>>> j*k==i
True
>>> k*i==j
True

Anticommutative

The quaternion element has the property that the sign is inverted when the order of the products is changed, which is called anticommutative property.

ij=-ji,\ jk=-kj,\ ki=-ik

The relationship between $ ij = k $ and $ k ^ 2 = -1 $ can also be explained by anticommutativeness. Because the factor cannot move freely due to anticommutative property, it cannot be $ -1 $ unless adjacent elements are exchanged and the same elements are adjacent.

k^2=(ij)^2=i\underbrace{(ji)}_{Exchange}j=-i(ij)j=-\underbrace{(ii)}_{-1}\underbrace{(jj)}_{-1}=-1

Check anti-commutative property.

>>> j*i
Matrix([
[I,  0],
[0, -I]])
>>> k*j
Matrix([
[0, I],
[I, 0]])
>>> i*k
Matrix([
[ 0, 1],
[-1, 0]])
>>> i*j==-j*i
True
>>> j*k==-k*j
True
>>> k*i==-i*k
True
(i+2j)(3j+4k)=3ij+4ik+6jj+8jk=-6+8i-4j+3k \\
(3j+4k)(i+2j)=3ji+4ki+6jj+8kj=-6-8i+4j-3k \\
∴(i+2j)(3j+4k)≠-(3j+4k)(i+2j)

Conjugated

From the Hermitian conjugate of the representation matrix, we get the quaternion conjugate.

\begin{align}
(a+bi+cj+dk)^*
↦&\left(\begin{matrix}(a+di)^* & -(c+bi) \\ (c+bi)^* & a+di\end{matrix}\right)^{\dagger} \\
=&\left(\begin{matrix}a+di & -(c+bi)^* \\ c+bi & (a+di)^*\end{matrix}\right)^{\top} \\
=&\left(\begin{matrix}a+di & c+bi \\ -(c+bi)^* & (a+di)^*\end{matrix}\right) \\
=&\left(\begin{matrix}(a-di)^* & c+bi \\ -(c+bi)^* & a-di\end{matrix}\right) \\
↦&(a-dk)-(cj+bi) \\
=&a-bi-cj-dk
\end{align}

All the signs of the imaginary part are inverted.

Biquaternion

The representation matrix of $ i, j, k $ adopted this time was selected based on the following criteria.

i,j,k↦
\left(\begin{matrix} 0&-i \\-i& 0 \end{matrix}\right),
\left(\begin{matrix} 0&-1 \\ 1& 0 \end{matrix}\right),
\left(\begin{matrix}-i& 0 \\ 0& i \end{matrix}\right)

$ I $ as an element of a quaternion and $ i $ as a component in the representation matrix are different. In the original notation, the imaginary number multiplied by the component is written as $ h $ for distinction.

\begin{align}
hi,hj,hk
&↦\underbrace{i}_{h}\underbrace{\left(\begin{matrix} 0&-i \\-i& 0 \end{matrix}\right)}_{i},
  \underbrace{i}_{h}\underbrace{\left(\begin{matrix} 0&-1 \\ 1& 0 \end{matrix}\right)}_{j},
  \underbrace{i}_{h}\underbrace{\left(\begin{matrix}-i& 0 \\ 0& i \end{matrix}\right)}_{k} \\
&=\left(\begin{matrix} 0& 1 \\ 1& 0 \end{matrix}\right),
  \left(\begin{matrix} 0&-i \\ i& 0 \end{matrix}\right),
  \left(\begin{matrix} 1& 0 \\ 0&-1 \end{matrix}\right)
\end{align}

If you add $ h $ to a quaternion as an element, you get an extension of the quaternion called a biquaternion.

\begin{align}
&(a_0+a_1i+a_2j+a_3k)+(a_4+a_5i+a_6j+a_7k)h \\
&=a_0+a_1i+a_2j+a_3k+a_4h+a_5hi+a_6hj+a_7hk
\end{align}

Quaternion to biquaternion extension is the same technique as complex to bicomplex extension. ([Cayley-Dixon Construction Method](https://ja.wikipedia.org/wiki/%E3%82%B1%E3%83%BC%E3%83%AA%E3%83%BC%EF%BC % 9D% E3% 83% 87% E3% 82% A3% E3% 82% AF% E3% 82% BD% E3% 83% B3% E3% 81% AE% E6% A7% 8B% E6% 88% 90 % E6% B3% 95)))

[Bicomplex number]\ (a_0+a_1i)+(a_2+a_3i)j=a_0+a_1i+a_2j+a_3k

If $ h $ is represented by a matrix, it is a matrix obtained by multiplying the identity matrix by $ i $.

h↦iI
=i\left(\begin{matrix} 1& 0 \\ 0& 1 \end{matrix}\right)
= \left(\begin{matrix} i& 0 \\ 0& i \end{matrix}\right)

Since the identity matrix exchanges with other matrices, $ h $ is not anticommutative in biquaternions.

[Biaquaternion]\ hi=ih,\ hj=jh,\ hk=kh

Just as bicomplex numbers are different from quaternions, biquaternions are different from octonions. In octonions, $ h $ is treated in the same line as other elements and is anticommutative.

[Octonion]\ hi=-ih,\ hj=-jh,\ hk=-kh

Representation matrix

Check the representation matrix of the biquaternion.

\begin{align}
&a_0+a_1i+a_2j+a_3k+a_4h+a_5hi+a_6hj+a_7hk \\
&↦a_0\underbrace{\left(\begin{matrix} 1& 0 \\ 0& 1 \end{matrix}\right)}_{1}
 +a_1\underbrace{\left(\begin{matrix} 0&-i \\-i& 0 \end{matrix}\right)}_{i}
 +a_2\underbrace{\left(\begin{matrix} 0&-1 \\ 1& 0 \end{matrix}\right)}_{j}
 +a_3\underbrace{\left(\begin{matrix}-i& 0 \\ 0& i \end{matrix}\right)}_{k} \\
&\quad
 +a_4\underbrace{\left(\begin{matrix} i& 0 \\ 0& i \end{matrix}\right)}_{h}
 +a_5\underbrace{\left(\begin{matrix} 0& 1 \\ 1& 0 \end{matrix}\right)}_{hi}
 +a_6\underbrace{\left(\begin{matrix} 0&-i \\ i& 0 \end{matrix}\right)}_{hj}
 +a_7\underbrace{\left(\begin{matrix} 1& 0 \\ 0&-1 \end{matrix}\right)}_{hk} \\
&=\left(\begin{matrix} a_0-a_3i+a_4i+a_7 & -a_1i-a_2+a_5-a_6i \\ -a_1i+a_2+a_5+a_6i & a_0+a_3i+a_4i-a_7 \end{matrix}\right) \\
&=\left(\begin{matrix} (a_0+a_7)-(a_3-a_4)i & -\{(a_2-a_5)+(a_1+a_6)i\} \\ (a_2+a_5)-(a_1-a_6)i & (a_0-a_7)+(a_3+a_4)i \end{matrix}\right) \\
&=\left(\begin{matrix} \{(a_0+a_7)+(a_3-a_4)i\}^* & -\{(a_2-a_5)+(a_1+a_6)i\} \\ \{(a_2+a_5)+(a_1-a_6)i\}^* & (a_0-a_7)+(a_3+a_4)i \end{matrix}\right)
\end{align}
\underbrace{\left(\begin{matrix} 1& 0 \\ 0& 1 \end{matrix}\right)}_{1}
\xrightarrow{flip upside down}
\underbrace{\left(\begin{matrix} 0& 1 \\ 1& 0 \end{matrix}\right)}_{hi} \\
\underbrace{\left(\begin{matrix} 0&-1 \\ 1& 0 \end{matrix}\right)}_{j}
\xrightarrow{flip upside down}
\underbrace{\left(\begin{matrix} 1& 0 \\ 0&-1 \end{matrix}\right)}_{hk}

It became clear at this point, but I was thinking about the criteria for determining the representation matrix of quaternions, including biquaternions.

Python

Build a biquaternion representation matrix in Python. Make another element from the identity matrix and $ j $.

>>> from sympy import *
>>> _1=eye(2)
>>> j=Matrix([[0,-1],[1,0]])
>>> hi=_1[[1,0],:]
>>> hk=j[[1,0],:]
>>> h=I*_1
>>> hj=I*j
>>> i=-I*hi
>>> k=-I*hk
>>> a=symbols("a0:8")
>>> a
(a0, a1, a2, a3, a4, a5, a6, a7)
>>> A=a[0]*_1+a[1]*i+a[2]*j+a[3]*k+a[4]*h+a[5]*hi+a[6]*hj+a[7]*hk
>>> A
Matrix([
[ a0 - I*a3 + I*a4 + a7, -I*a1 - a2 + a5 - I*a6],
[-I*a1 + a2 + a5 + I*a6,  a0 + I*a3 + I*a4 - a7]])
A=\left(\begin{matrix} a_0-a_3i+a_4i+a_7 & -a_1i-a_2+a_5-a_6i \\ -a_1i+a_2+a_5+a_6i & a_0+a_3i+a_4i-a_7 \end{matrix}\right)

Separation of coefficients

The biquaternion representation matrix has intricate components. To separate the biquaternion coefficients from the components of the representation matrix, use the sign-inverted combination.

>>> (A[0,0]+A[1,1])/2
a0 + I*a4
>>> (A[0,0]-A[1,1])/2
-I*a3 + a7
>>> (A[1,0]+A[0,1])/2
-I*a1 + a5
>>> (A[1,0]-A[0,1])/2
a2 + I*a6
\begin{align}
\frac{1}{2}(A_{00}+A_{11})&=a_0+a_4i \\
\frac{1}{2}(A_{00}-A_{11})&=a_7-a_3i \\
\frac{1}{2}(A_{10}+A_{01})&=a_5-a_1i \\
\frac{1}{2}(A_{10}-A_{01})&=a_2+a_6i
\end{align}

Let me give you an example.

>>> B=A.subs([(a[i], i+1) for i in range(8)])
>>> B
Matrix([
[  9 + I,  3 - 9*I],
[9 + 5*I, -7 + 9*I]])
>>> b=[0]*8
>>> b[0],b[4]=((B[0,0]+B[1,1])/2).as_real_imag()
>>> b[7],b[3]=((B[0,0]-B[1,1])/2).conjugate().as_real_imag()
>>> b[5],b[1]=((B[1,0]+B[0,1])/2).conjugate().as_real_imag()
>>> b[2],b[6]=((B[1,0]-B[0,1])/2).as_real_imag()
>>> b
[1, 2, 3, 4, 5, 6, 7, 8]
\left(\begin{matrix} 9+i & 3-9i \\ 9+5i & -7+9i \end{matrix}\right) \\
↦1+2i+3j+4k+5h+6hi+7hj+8hk

The coefficients of the biquaternion cannot be found by just glancing at the representation matrix, but they are separated properly.

Pauli matrices

Representation matrix of $ hi, hj, hk $ [Pauli matrices](https://ja.wikipedia.org/wiki/%E3%83%91%E3%82%A6%E3%83%AA%E8%A1 It is called% 8C% E5% 88% 97).

σ_1,σ_2,σ_3:=
\underbrace{\left(\begin{matrix} 0& 1 \\ 1& 0 \end{matrix}\right)}_{hi},
\underbrace{\left(\begin{matrix} 0&-i \\ i& 0 \end{matrix}\right)}_{hj},
\underbrace{\left(\begin{matrix} 1& 0 \\ 0&-1 \end{matrix}\right)}_{hk}

With Pauli matrices as a starting point, you can build biquaternions smarter. According to it, $ hi, hj, hk $ can be interpreted as more fundamental than $ i, j, k $. For details, refer to the sequel Pauli matrices and biquaternions in Clifford algebra.

Related article

This time, I will only focus on the representation matrix for quaternions. For other properties, please refer to the following articles.

See the following articles for alternative representation matrices of quaternions and octonions.

reference

I used it as a reference for SymPy.

Hypercomplex number

The variations of Hypercomplex number are summarized.

Basic So Decomposition type Decomposition typeSo So曲 So対
Complex number 双Complexnumber 分解型Complexnumber
Quaternion 双Quaternion 分解型Quaternion 分解型双Quaternion 双曲Quaternion 双対Quaternion
Octonion 双Octonion 分解型Octonion
Sedenion

Recommended Posts

Quaternion considered in representation matrix
Bicomplex numbers considered in representation matrices
Matrix considered by function
Matrix multiplication in python numpy
Matrix representation with Python standard input
Draw a scatterplot matrix in python
When creating a matrix in a list