# UnitaryMatrixQ

gives True if m is a unitary matrix, and False otherwise.

# Details and Options

• A p×q matrix m is unitary if pq and ConjugateTranspose[m].m is the q×q identity matrix, or pq and m.ConjugateTranspose[m] is the p×p identity matrix.
• UnitaryMatrixQ works for symbolic as well as numerical matrices.
• The following options can be given:
•  Normalized True test if matrix columns are normalized SameTest Automatic function to test equality of expressions Tolerance Automatic tolerance for approximate numbers
• For exact and symbolic matrices, the option SameTest->f indicates that two entries aij and bij are taken to be equal if f[aij,bij] gives True.
• For approximate matrices, the option Tolerance->t can be used to indicate that the norm γ=m.m-In satisfying γt is taken to be zero where In is the identity matrix.

# Examples

open allclose all

## Basic Examples(2)

Test if a 2×2 numerical matrix is unitary:

Test if a 3×3 symbolic matrix is explicitly unitary:

Verify the condition by hand:

## Scope(14)

### Basic Uses (6)

Test if a real matrix is unitary:

A real unitary matrix is also orthogonal:

Test if a complex matrix is unitary:

Test if an exact matrix is unitary:

Make the matrix unitary:

Use UnitaryMatrixQ with an arbitrary-precision matrix:

A random matrix is typically not unitary:

Use UnitaryMatrixQ with a symbolic matrix:

The matrix becomes unitary when and :

UnitaryMatrixQ works efficiently with large numerical matrices:

### Special Matrices (4)

Use UnitaryMatrixQ with sparse matrices:

Use UnitaryMatrixQ with structured matrices:

The identity matrix is unitary:

HilbertMatrix is not unitary:

### Rectangular Semi-unitary Matrices(4)

Test if a rectangular matrix is semi-unitary:

As there are more columns than rows, this indicates that the rows are orthonormal:

The columns are not orthonormal:

Test a matrix with more rows than columns:

The columns of the matrix are orthonormal:

The rows are not orthonormal:

Generate a random unitary matrix:

Any subset of its rows forms a rectangular semi-unitary matrix:

As does any subset of its columns:

Rectangular identity matrices are semi-unitary:

## Options(4)

### Normalized(2)

Symbolic unitary matrix columns are often not normalized to 1:

Avoid testing if the columns are normalized:

Multiply the second column of a unitary matrix by 2:

UnitaryMatrixQ with will still give True for m:

However, it will not give true for :

This is because is a diagonal matrix, but is not:

### SameTest(1)

This matrix is unitary for a positive real , but UnitaryMatrixQ gives False:

Use the option SameTest to get the correct answer:

### Tolerance(1)

Generate an orthogonal real-valued matrix with some random perturbation of order 10-14:

q.q is not exactly zero outside the main diagonal:

Adjust the option Tolerance for accepting the matrix as unitary:

Tolerance is applied to the following value:

## Applications(9)

### Sources of Unitary Matrices(4)

Any orthonormal basis for forms a unitary matrix:

The basis is orthonormal:

Putting the basis vectors in rows of a matrix forms a unitary matrix:

Putting them in columns also gives a unitary matrix:

Orthogonalize applied to linearly independent, complex vectors generates a unitary matrix:

The matrix does not need to be square, in which case the resulting matrix is semi-unitary:

But the starting matrix must have full rank:

Any permutation matrix is unitary:

Matrices drawn from CircularUnitaryMatrixDistribution are unitary:

So are matrices drawn from CircularOrthogonalMatrixDistribution:

As are matrices from CircularSymplecticMatrixDistribution:

### Uses of Orthogonal Matrices(5)

Unitary matrices preserve the standard inner product on . In other words, if is unitary and and are vectors, then :

This means the angles between the vectors are unchanged:

Since the norm is derived from the inner product, norms are preserved as well:

Unitary matrices play an important role in many matrix decompositions:

The matrix is always unitary for any nonzero vector :

is called a Householder reflection; as a pure reflection its determinant is :

It represents a reflection through a plane perpendicular to , sending to :

Any vector perpendicular to is unchanged by :

In matrix computations, is used to set to zero selected components of a given column vector :

In quantum mechanics, time evolution is represented by a 1-parameter family of unitary matrices . times the logarithmic derivative of is a Hermitian matrix called the Hamiltonian or energy operator . Its eigenvalues represent the possible energies of the system. For the following time evolution, compute the Hamiltonian and possible energies:

First, verify the matrices are, in fact, unitary:

Compute the logarithmic derivative:

This matrix is antihermitian:

Define the Hamiltonian:

Verify that the matrix is Hermitian:

Its real eigenvalues represent the possible energies:

The exponential MatrixExp[v] of an antihermitian matrix is unitary. Define a matrix function through its differential equation with initial value and show that the solution is unitary:

Solve and check that the resulting matrix is unitary at each time:

With default settings, you get approximately unitary matrices:

The matrix 2-norm of the solution is 1:

Plot the rows of the matrix:

Each row lies on the unit sphere:

## Properties & Relations(13)

A matrix is unitary if m.ConjugateTranspose[m]IdentityMatrix[n]:

For an approximate matrix, the identity is approximately true:

The inverse of a unitary matrix is its conjugate transpose:

Thus, the inverse, transpose, conjugate and conjugate transpose are all unitary matrices as well:

A unitary matrix preserves the standard inner product of vectors in :

As a consequence, unitary matrices preserve norms as well:

Any real-valued orthogonal matrix is unitary:

But a complex unitary matrix is typically not orthogonal:

Products of unitary matrices are unitary:

A unitary matrix is normal:

Unitary matrices have eigenvalues that lie on the unit circle:

Use Eigenvalues to find eigenvalues:

Verify they lie on the unit circle:

Unitary matrices have a complete set of eigenvectors:

As a consequence, they must be diagonalizable:

Use Eigenvectors to find eigenvectors:

The singular values are all 1 for a unitary matrix:

The absolute value of the determinant of a unitary matrix is 1:

The 2-norm of a unitary matrix is always 1:

Real powers of unitary matrices are unitary:

MatrixExp[I h] is unitary for any Hermitian matrix h:

Wolfram Research (2014), UnitaryMatrixQ, Wolfram Language function, https://reference.wolfram.com/language/ref/UnitaryMatrixQ.html.

#### Text

Wolfram Research (2014), UnitaryMatrixQ, Wolfram Language function, https://reference.wolfram.com/language/ref/UnitaryMatrixQ.html.

#### CMS

Wolfram Language. 2014. "UnitaryMatrixQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/UnitaryMatrixQ.html.

#### APA

Wolfram Language. (2014). UnitaryMatrixQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/UnitaryMatrixQ.html

#### BibTeX

@misc{reference.wolfram_2022_unitarymatrixq, author="Wolfram Research", title="{UnitaryMatrixQ}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/UnitaryMatrixQ.html}", note=[Accessed: 21-March-2023 ]}

#### BibLaTeX

@online{reference.wolfram_2022_unitarymatrixq, organization={Wolfram Research}, title={UnitaryMatrixQ}, year={2014}, url={https://reference.wolfram.com/language/ref/UnitaryMatrixQ.html}, note=[Accessed: 21-March-2023 ]}