UnitaryMatrix[umat]
converts the unitary matrix umat to a structured array.
UnitaryMatrix
UnitaryMatrix[umat]
converts the unitary matrix umat to a structured array.
Details and Options
- Unitary matrices, when represented as structured arrays, allow for a convenient specification and more efficient operations, including Inverse and LinearSolve.
- Matrix decompositions that use unitary matrices include QR, Hessenberg, Schur and singular value decompositions. »
- A square unitary matrix
is a matrix whose conjugate transpose is equal to its inverse; that is, it satisfies the relation
. Consequently, the inverse of a square unitary matrix is also unitary. » - For a tall unitary matrix
, the column vectors
are orthonormal so that
. For a wide orthogonal matrix
, the row vectors
are orthonormal so that
for
. For a square matrix, both statements are true. » - Equivalently to the preceding definition, a matrix
of dimensions
is orthogonal if
and
is the
identity matrix, or if
and
is the
identity matrix. » - Square unitary matrices are closed under matrix multiplication, so
is again a unitary matrix. - For a UnitaryMatrix sa, the following properties "prop" can be accessed as sa["prop"]:
-
"Matrix" unitary matrix, represented as a full array "Properties" list of supported properties "Structure" type of structured array "StructuredData" internal data stored by the structured array "StructuredAlgorithms" list of functions with special methods for the structured array "Summary" summary information, represented as a Dataset - Normal[UnitaryMatrix[…]] gives the unitary matrix as an ordinary matrix.
- OrthogonalMatrix takes the following option:
-
TargetStructure Automatic structure to return - Possible settings for the option TargetStructure include:
-
Automatic automatically choose the representation returned "Dense" represent the matrix as a dense matrix "Structured" represent the matrix as a structured array - UnitaryMatrix[…,TargetStructureAutomatic] is equivalent to UnitaryMatrix[…,TargetStructure"Structured"].
Examples
open all close allBasic Examples (1)
um = UnitaryMatrix[{{(1/2), (1/2), (1/2), (1/2)}, {(1/2), (I/2), -(1/2), -(I/2)}, {(1/2), -(1/2), (1/2), -(1/2)}, {(1/2), -(I/2), -(1/2), (I/2)}}]MatrixForm[um]Normal can convert a UnitaryMatrix to its ordinary representation:
Normal[um]Scope (5)
Complex reflection matrices are both unitary and Hermitian:
rm = ReflectionMatrix[{I, -1, -I}]{UnitaryMatrix[rm], HermitianMatrix[rm]}um = UnitaryMatrix[{{(1/3), (1/3), (1/3), (1/3)}, {(1/3), (1/3) E^(2 I π/9), (1/3) E^(4 I π/9), (1/3) E^(2 I π/3)}, {(1/3), (1/3) E^(4 I π/9), (1/3) E^(8 I π/9), (1/3) E^-(2 I π/3)}, {(1/3), (1/3) E^(2 I π/3), (1/3) E^-(2 I π/3), (1/3)}, {(1/3), (1/3) E^(8 I π/9), (1/3) E^-(2 I π/9), (1/3) E^(2 I π/3)}, {(1/3), (1/3) E^-(8 I π/9), (1/3) E^(2 I π/9), (1/3) E^-(2 I π/3)}, {(1/3), (1/3) E^-(2 I π/3), (1/3) E^(2 I π/3), (1/3)}, {(1/3), (1/3) E^-(4 I π/9), (1/3) E^-(8 I π/9), (1/3) E^(2 I π/3)}, {(1/3), (1/3) E^-(2 I π/9), (1/3) E^-(4 I π/9), (1/3) E^-(2 I π/3)}}]Its conjugate transpose is also unitary:
ConjugateTranspose[um]UnitaryMatrix objects include properties that give information about the matrix:
um = UnitaryMatrix[(| | | |
| ---------------- | ---------------- | ---------------- |
| (1/5) - (2 I/5) | -(1/5) - (3 I/5) | (1/5) + (3 I/5) |
| -(1/5) - (3 I/5) | (1/5) - (2 I/5) | -(1/5) - (3 I/5) |
| (1/5) + (3 I/5) | -(1/5) - (3 I/5) | (1/5) - (2 I/5) |)]um["Properties"]
The "Summary" property gives a brief summary of information about the matrix:
um["Summary"]The "StructuredAlgorithms" property lists the functions that have structured algorithms:
um["StructuredAlgorithms"]Create random unitary matrices using different matrix distributions:
Table[UnitaryMatrix[RandomVariate[dist[3]]], {dist, {CircularUnitaryMatrixDistribution, CircularOrthogonalMatrixDistribution, CircularSymplecticMatrixDistribution, CircularQuaternionMatrixDistribution}}]Create a wide unitary matrix by selecting rows from a square unitary matrix:
square = UnitaryMatrix[RandomVariate[CircularSymplecticMatrixDistribution[3]]]square[[{1, 3, 4, 6}]]Create another wide unitary matrix by selecting rows from this wide matrix:
%[[2 ;; 3]]Create a tall unitary matrix by extracting columns from a square unitary matrix:
square[[All, {1, 3, 4, 6}]]Create another tall unitary matrix by selecting rows from this tall matrix:
square[[All, 2 ;; 3]]Options (1)
TargetStructure (1)
Return the unitary matrix as a dense matrix:
UnitaryMatrix[(| | | |
| -------- | -------- | ------- |
| -(1/3) | -(2 I/3) | -(2/3) |
| -(2 I/3) | (1/3) | (2 I/3) |
| -(2/3) | (2 I/3) | -(1/3) |), TargetStructure -> "Dense"]Return the unitary matrix as a structured array:
UnitaryMatrix[(| | | |
| -------- | -------- | ------- |
| -(1/3) | -(2 I/3) | -(2/3) |
| -(2 I/3) | (1/3) | (2 I/3) |
| -(2/3) | (2 I/3) | -(1/3) |), TargetStructure -> "Structured"]Applications (5)
Matrices drawn from CircularUnitaryMatrixDistribution are unitary:
UnitaryMatrix[RandomVariate[CircularUnitaryMatrixDistribution[9]]]Matrices drawn from CircularOrthogonalMatrixDistribution are unitary:
UnitaryMatrix[RandomVariate[CircularOrthogonalMatrixDistribution[9]]]The Pauli matrices are unitary matrices:
PauliMatrix[Range[3], TargetStructure -> "Unitary"]The matrix exponentials are also unitary:
UnitaryMatrix[MatrixExp[I (π/4)#]]& /@ %Unitary matrices preserve the standard inner product on
. In other words, if
is unitary and
and
are vectors, then
:
u = UnitaryMatrix[RandomVariate[CircularUnitaryMatrixDistribution[3], WorkingPrecision -> 16]]{v, w} = RandomComplex[1, {2, 3}, WorkingPrecision -> 16];UnitaryMatrixQ[u] && v.w == (u.v).(u.w)This means the angles between the vectors are unchanged:
VectorAngle[v, w] == VectorAngle[u.v, u.w]Since the norm is derived from the inner product, norms are preserved as well:
Norm[v] == Norm[u.v]Norm[w] == Norm[u.w]Unitary matrices play an important role in many matrix decompositions:
m = RandomComplex[{-1. - I, 1. + I}, {5, 5}];
{q, r} = QRDecomposition[m, TargetStructure -> "Structured"]{u, w, v} = SingularValueDecomposition[m, TargetStructure -> "Structured"]{s, t} = SchurDecomposition[m, TargetStructure -> "Structured"]{p, h} = HessenbergDecomposition[m, TargetStructure -> "Structured"]The matrix
is always unitary for any nonzero vector
:
n = 5;
Subscript[ℋ, v_] := UnitaryMatrix[IdentityMatrix[n] - 2 vv / v.v];
v = RandomComplex[1. + I, n];
Subscript[ℋ, v]
is called a Householder reflection; as a pure reflection, its determinant is
:
Det[Subscript[ℋ, v]]//ChopIt represents a reflection through a plane perpendicular to
, sending
to
:
Subscript[ℋ, v].v == -vAny vector perpendicular to
is unchanged by
:
perp = Block[{w = RandomComplex[1 + n, n]}, w - Projection[w, v]];
Subscript[ℋ, v].perp == perpIn matrix computations,
is used to set to zero selected components of a given column vector
:
x = RandomComplex[1. + I, n];v = x - x[[1]] / Abs[x[[1]]] Norm[x]UnitVector[n, 1];
Subscript[ℋ, v].{x}//ChopProperties & Relations (8)
The conjugate transpose of a UnitaryMatrix is equivalent to the inverse of the original matrix:
u = UnitaryMatrix[(| | | |
| -------- | -------- | ------- |
| -(1/3) | -(2 I/3) | -(2/3) |
| -(2 I/3) | (1/3) | (2 I/3) |
| -(2/3) | (2 I/3) | -(1/3) |)]ConjugateTranspose[u] === Inverse[u]u.u == u.u == IdentityMatrix[3]Consequently, the conjugate transpose of a square orthogonal matrix is also orthogonal:
uA unitary matrix obeys PseudoInverse[u]==ConjugateTranspose[u]:
s = UnitaryMatrix[StructuredArray`StructuredData[{6, 6},
{{{-0.19665427320299816 + 0.3257050760438751*I, -0.08142044396720215 + 0.3562941865027246*I,
-0.4232375709542902 - 0.3485102420127663*I, -9.63473015912038*^-18 -
2.103481091668693 ... 67364204979036 + 0.06586858771678668*I, -1.3979445080043728*^-17 +
1.2994812920792802*^-17*I, -0.42323757095429015 - 0.3485102420127663*I,
0.6637784419884503 + 0.15190412739202258*I, 0.20833810440259037 + 0.28346900867337493*I}}, 0}]];
PseudoInverse[s] == ConjugateTranspose[s]Unlike the relationship to Inverse, this is true irrespective of shape:
t = UnitaryMatrix[StructuredArray`StructuredData[{6, 3},
{{{-0.19665427320299816 + 0.3257050760438751*I, -0.21861404394503506 + 0.16080225211266183*I,
0.4286429712255619 - 0.10991562838068897*I}, {-0.08142044396720215 + 0.3562941865027246*I,
... 2*^-18 +
2.4899088734557086*^-17*I, -0.4937373782758394 - 0.12027708112946925*I},
{0.2514094595579911 + 0.4321265116809822*I, 0.4937373782758393 + 0.12027708112946918*I,
-2.3507200259499506*^-17 - 2.908703945482714*^-17*I}}, 0}]];
PseudoInverse[t] == ConjugateTranspose[t]w = UnitaryMatrix[StructuredArray`StructuredData[{3, 6},
{{{-0.19665427320299816 + 0.3257050760438751*I, -0.08142044396720215 + 0.3562941865027246*I,
-0.4232375709542902 - 0.3485102420127663*I, -9.63473015912038*^-18 -
2.103481091668693 ... 714877250814 + 0.2107327384991615*I,
0.20833810440259037 + 0.283469008673375*I, -0.2514094595579911 - 0.4321265116809822*I,
-0.4937373782758394 - 0.12027708112946925*I, -2.3507200259499506*^-17 -
2.908703945482714*^-17*I}}, 0}]];
PseudoInverse[w] == ConjugateTranspose[w]For a tall
orthogonal matrix
, the columns
are orthonormal, i.e.
for
:
{t = UnitaryMatrix[(| | |
| ------------ | ----------- |
| (1/Sqrt[3]) | (I/Sqrt[3]) |
| (-1/Sqrt[3]) | (I/Sqrt[3]) |
| (1/Sqrt[3]) | 0 |
| 0 | (1/Sqrt[3]) |)], w = t}Table[Conjugate[Subscript[t, [[All, i]]]].Subscript[t, [[All, j]]] == KroneckerDelta[ij], {i, 2}, {j, 2}]For a wide orthogonal matrix, it is instead the rows that are orthonormal:
Table[Conjugate[Subscript[w, [[i]]]].Subscript[w, [[j]]] == KroneckerDelta[ij], {i, 2}, {j, 2}]A matrix
of dimensions
is orthogonal if
and
is the
identity matrix:
w = RandomVariate[CircularUnitaryMatrixDistribution[3], WorkingPrecision -> 4][[1 ;; 2]]//UnitaryMatrixw.w == IdentityMatrix[2]Note that
is well defined, but not an identity matrix as
:
w.w//MatrixFormIf
, then
is orthogonal if
is the
identity matrix:
t = RandomVariate[CircularUnitaryMatrixDistribution[4], WorkingPrecision -> 4][[All, 1 ;; 3]]//UnitaryMatrixt.t == IdentityMatrix[3]Again, the product in the opposite order is well defined but not an identity matrix:
t.t//MatrixFormThe product of two square unitary matrices is another unitary matrix:
{u1, u2} = UnitaryMatrix /@ RandomVariate[CircularSymplecticMatrixDistribution[3], 2]u1.u2A real orthogonal matrix is also a unitary matrix:
u = UnitaryMatrix[(| | | |
| ------ | ------ | ------ |
| -(1/3) | (2/3) | -(2/3) |
| -(2/3) | (1/3) | (2/3) |
| -(2/3) | -(2/3) | -(1/3) |)]{UnitaryMatrixQ[u], OrthogonalMatrixQ[u] && MatrixQ[u, RealValuedNumberQ]}Convert from one type of matrix to the other:
OrthogonalMatrix[u]PolarDecomposition by default returns a UnitaryMatrix object when the input is complex:
PolarDecomposition[RandomComplex[1 + I, {3, 3}]]OrderedSchurDecomposition by default returns a UnitaryMatrix object when the input is complex:
OrderedSchurDecomposition[RandomComplex[1 + I, {3, 3}]]Related Guides
History
Text
Wolfram Research (2024), UnitaryMatrix, Wolfram Language function, https://reference.wolfram.com/language/ref/UnitaryMatrix.html.
CMS
Wolfram Language. 2024. "UnitaryMatrix." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/UnitaryMatrix.html.
APA
Wolfram Language. (2024). UnitaryMatrix. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/UnitaryMatrix.html
BibTeX
@misc{reference.wolfram_2026_unitarymatrix, author="Wolfram Research", title="{UnitaryMatrix}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/UnitaryMatrix.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_unitarymatrix, organization={Wolfram Research}, title={UnitaryMatrix}, year={2024}, url={https://reference.wolfram.com/language/ref/UnitaryMatrix.html}, note=[Accessed: 13-June-2026]}