What are the Unitary Matrix and its exciting properties?
The unitary matrix transformation is used in some concepts like linear algebra and quantum mechanics. The unitary matrix can transform data while preserving some properties of the data matrix such as inner products or singular values. In this article, we will dive deep into some properties of the unitary matrix via mathematical expression and Python code.
What is the Unitary matrix?
The first thing, we will talk about is the unitary matrix. The unitary has some conditions to be.
Next, I will give you an example. In quantum computing, there is an important unitary matrix called “Hadamard Gate”. I will show you this gate in Python.
import numpy as np
# Define the Hadamard gate matrix
Hadamard = 1/np.sqrt(2) * np.array([[1, 1],
[1, -1]])
# Try to prove its property
print(Hadamard.T @ Hadamard)
print(Hadamard @ Hadamard.T)
[[1. 0.]
[0. 1.]]
[[1. 0.]
[0. 1.]]
The result of taking the dot product of the transpose (or conjugate transpose) of the gate with the gate is the identity matrix, in accordance with the property mentioned above.
The determinant of the Unitary matrix.
The determinant of the matrix in the geometry perspective shows the volumes or area of the column vectors in the matrix. This section will show you the absolute of determinant of the unitary matrix = 1.
Let’s prove it in code.
np.round(np.abs(np.linalg.det(Hadamard)))
1.0
The Eigenvalues of the Unitary matrix.
In the normal term, a matrix rotates and scales an arrow vector. In special cases, some arrow vectors cannot be rotated by the matrix and just are scaled. These arrows are called eigenvectors and the scalers of arrows are called eigenvalues. We can summarize them in mathematical terms.
Let’s show the results in code:
np.linalg.eigvals(Hadamard)
array([ 1., -1.])
Preservation of Inner Product
The inner product between two vectors relates to the angle of both. When you apply a unitary transformation to a pair of vectors, the angle between the vectors and their inner product remains unchanged.
Let's make the vectors to test the rule.
# create the samples vector u and v
u = np.array([[1],
[0]])
v = np.array([[0],
[1]])
# find the inner product value
np.dot(u.T, v)
array([[0]])
Apply Hadamard gate to them.
# Apply the unitary matrix
Uu = Hadamard @ u
Uv = Hadamard @ v
# find the inner product value
np.dot(Uu.T, Uv)
array([[0]])
Thank you for reading ❤