WOLFRAM

gives True if m is explicitly symmetric, and False otherwise.

Details and Options

  • A matrix m is symmetric if m==Transpose[m].
  • SymmetricMatrixQ works for symbolic as well as numerical matrices.
  • The following options can be given:
  • SameTest Automaticfunction to test equality of expressions
    Tolerance Automatictolerance for approximate numbers
  • For exact and symbolic matrices, the option SameTest->f indicates that two entries mij and mkl are taken to be equal if f[mij,mkl] gives True.
  • For approximate matrices, the option Tolerance->t can be used to indicate that all entries Abs[mij]t are taken to be zero.
  • For matrix entries Abs[mij]>t, equality comparison is done except for the last bits, where is $MachineEpsilon for MachinePrecision matrices and for matrices of Precision .

Examples

open allclose all

Basic Examples  (2)Summary of the most common use cases

Test if a 2×2 numeric matrix is explicitly symmetric:

Out[1]=1

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

Out[1]=1

Scope  (10)Survey of the scope of standard use cases

Basic Uses  (6)

Test if a real machine-precision matrix is symmetric:

Out[2]=2

A real symmetric matrix is also Hermitian:

Out[3]=3

Test if a complex matrix is symmetric:

Out[2]=2

A complex symmetric matrix has symmetric real and imaginary parts:

Out[3]=3

Test if an exact matrix is symmetric:

Out[2]=2

Make the matrix symmetric:

Out[3]=3

Use SymmetricMatrixQ with an arbitrary-precision matrix:

Out[1]=1

A random matrix is typically not symmetric:

Out[2]=2

Use SymmetricMatrixQ with a symbolic matrix:

Out[1]=1

The matrix becomes symmetric when :

Out[2]=2

SymmetricMatrixQ works efficiently with large numerical matrices:

Out[2]=2
Out[3]=3

Special Matrices  (4)

Use SymmetricMatrixQ with sparse matrices:

Out[1]=1
Out[2]=2

Use SymmetricMatrixQ with structured matrices:

Out[1]=1
Out[2]=2

Use with a QuantityArray structured matrix:

Out[3]=3
Out[4]=4

The identity matrix is symmetric:

Out[1]=1

HilbertMatrix is symmetric:

Out[1]=1

Options  (2)Common values & functionality for each option

SameTest  (1)

This matrix is symmetric for a positive real , but SymmetricMatrixQ gives False:

Out[19]=19

Use the option SameTest to get the correct answer:

Out[20]=20

Tolerance  (1)

Generate a real-valued symmetric matrix with some random perturbation of order 10-14:

Out[4]=4

Adjust the option Tolerance to accept this matrix as symmetric:

Out[5]=5

The norm of the difference between the matrix and its transpose:

Out[6]=6

Applications  (13)Sample problems that can be solved with this function

Generating Symmetric Matrices  (4)

Any matrix generated from a symmetric function is symmetric:

The function is symmetric:

Out[2]=2

Using Table generates a symmetric matrix:

Out[3]=3

SymmetrizedArray can generate matrices (and general arrays) with symmetries:

Out[1]=1
Out[2]=2

Convert back to an ordinary matrix using Normal:

Out[3]=3

Check that matrices drawn from GaussianOrthogonalMatrixDistribution are symmetric:

Out[1]=1

Matrices drawn from CircularOrthogonalMatrixDistribution are symmetric and unitary:

Out[2]=2

Every Jordan matrix is similar to a symmetric matrix. Since any square matrix is similar to its Jordan form, this means that any square matrix is similar to a symmetric matrix. Define a function for generating an Jordan block for eigenvalue :

For example, here is the Jordan matrix of dimension 4 for the eigenvalue :

Define a function for generating a corresponding complex similarity transformation:

The matrix is a sum of times the identity matrix and times the backward identity matrix:

Then s(n).j(lambda,n).TemplateBox[{{s, (, n, )}}, Inverse] is symmetric, which shows that the Jordan matrix is similar to a symmetric matrix:

Confirm the matrix is symmetric:

Out[6]=6

Examples of Symmetric Matrices  (5)

The Hessian matrix of a function is symmetric:

Out[2]=2
Out[3]=3

Many special matrices are symmetric, including FourierMatrix:

Out[1]=1

HadamardMatrix:

Out[2]=2

HankelMatrix:

Out[3]=3

And HilbertMatrix:

Out[4]=4

Visualize the matrix types:

Out[5]=5

Many filter kernel matrices are symmetric, including DiskMatrix:

Out[1]=1

CrossMatrix:

Out[2]=2

DiamondMatrix:

Out[3]=3

Visualize the matrices:

Out[4]=4

AdjacencyMatrix of an undirected graph is symmetric:

Out[1]=1
Out[2]=2

As is KirchhoffMatrix:

Out[3]=3
Out[4]=4

Visualize adjacency and Kirchhoff matrices for different graphs:

Out[5]=5

Several statistical measures are symmetric matrices, including Covariance:

Out[2]=2

Correlation:

Out[3]=3

AbsoluteCorrelation:

Out[4]=4

Uses of Symmetric Matrices  (4)

A positive-definite, real symmetric matrix or metric defines an inner product by :

Verify that is in fact symmetric and positive definite:

Out[3]=3

Orthogonalize the standard basis of TemplateBox[{}, Reals]^n to find an orthonormal basis:

Out[4]=4

Confirm that this basis is orthonormal with respect to the inner product :

Out[5]=5

The moment of inertia tensor is the equivalent of mass for rotational motion. For example, kinetic energy is , with taking the place of the mass and angular velocity taking the place of linear velocity in the formula . can be represented by a positive-definite symmetric matrix. Compute the moment of inertia for a tetrahedron with endpoints at the origin and positive coordinate axes:

Verify that the matrix is symmetric:

Out[2]=2

Compute the kinetic energy if its angular velocity is :

Out[3]=3

The kinetic energy is positive as long as is nonzero, showing the matrix was positive definite:

Out[4]=4

Determine if a sparse matrix is structurally symmetric:

Out[1]=1

The matrix is not symmetric:

Out[2]=2

But it is structurally symmetric:

Out[3]=3

Use a different method for symmetric matrices, with failover to a general method:

Construct real-valued matrices for testing:

For a non-symmetric matrix m, the function myLS just uses Gaussian elimination:

Out[3]=3

For a symmetric indefinite matrix ms, try Cholesky and continue with Gaussian elimination:

Out[5]=5

For a symmetric positive-definite matrix mpd, try Cholesky, which succeeds:

Out[7]=7
Out[8]=8

Properties & Relations  (14)Properties of the function, and connections to other functions

SymmetricMatrixQ[x] trivially returns False for any x that is not a matrix:

Out[1]=1

A matrix is symmetric if mTranspose[m]:

Out[2]=2

A real-valued symmetric matrix is Hermitian:

Out[2]=2

But a complex-valued symmetric matrix may not be:

Out[4]=4

Use Symmetrize to compute the symmetric part of a matrix:

Out[2]=2

This equals the average of m and Transpose[m]:

Out[3]=3

Any matrix can be represented as the sum of its symmetric and antisymmetric parts:

Out[2]=2

Use AntisymmetricMatrixQ to test whether a matrix is antisymmetric:

Out[3]=3

If is a symmetric matrix with real entries, then is antihermitian:

Out[2]=2

MatrixExp[I m] for real symmetric m is unitary:

Out[2]=2

A real-valued symmetric matrix is always a normal matrix:

Out[2]=2

A complex-valued symmetric matrix need not be normal:

Out[4]=4

Real-valued symmetric matrices have all real eigenvalues:

Out[2]=2

Use Eigenvalues to find eigenvalues:

Out[3]=3

Note that a complex-valued symmetric matrix may have both real and complex eigenvalues:

Out[4]=4

CharacteristicPolynomial[m,x] for real symmetric m can be factored into linear terms:

Out[2]=2

Real-valued symmetric matrices have a complete set of eigenvectors:

Out[2]=2

As a consequence, they must be diagonalizable:

Out[3]=3

Use Eigenvectors to find eigenvectors:

Note that a complex-valued symmetric matrix need not have these properties:

Out[6]=6

The inverse of a symmetric matrix is symmetric:

Out[2]=2

Matrix functions of symmetric matrices are symmetric, including MatrixPower:

Out[2]=2

MatrixExp:

Out[3]=3

And any univariate function representable using MatrixFunction:

Out[4]=4

SymmetricMatrix can be used to explicitly construct symmetric matrices:

Out[1]=1

These satisfy SymmetricMatrixQ:

Out[2]=2

Possible Issues  (1)Common pitfalls and unexpected behavior

SymmetricMatrixQ uses the definition TemplateBox[{m}, Transpose]=m for both real- and complex-valued matrices:

Out[2]=2

These complex matrices need not be normal or possess many properties of self-adjoint (real symmetric) matrices:

Out[3]=3

HermitianMatrixQ tests the condition TemplateBox[{m}, ConjugateTranspose]=m for self-adjoint matrices:

Out[4]=4

Alternatively, test if the entries are real to restrict to real symmetric matrices:

Out[6]=6

Neat Examples  (1)Surprising or curious use cases

Images of symmetric matrices including FourierMatrix:

Out[2]=2
Out[3]=3
Wolfram Research (2008), SymmetricMatrixQ, Wolfram Language function, https://reference.wolfram.com/language/ref/SymmetricMatrixQ.html (updated 2014).
Wolfram Research (2008), SymmetricMatrixQ, Wolfram Language function, https://reference.wolfram.com/language/ref/SymmetricMatrixQ.html (updated 2014).

Text

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

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

CMS

Wolfram Language. 2008. "SymmetricMatrixQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/SymmetricMatrixQ.html.

Wolfram Language. 2008. "SymmetricMatrixQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/SymmetricMatrixQ.html.

APA

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

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

BibTeX

@misc{reference.wolfram_2025_symmetricmatrixq, author="Wolfram Research", title="{SymmetricMatrixQ}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/SymmetricMatrixQ.html}", note=[Accessed: 10-July-2025 ]}

@misc{reference.wolfram_2025_symmetricmatrixq, author="Wolfram Research", title="{SymmetricMatrixQ}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/SymmetricMatrixQ.html}", note=[Accessed: 10-July-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_symmetricmatrixq, organization={Wolfram Research}, title={SymmetricMatrixQ}, year={2014}, url={https://reference.wolfram.com/language/ref/SymmetricMatrixQ.html}, note=[Accessed: 10-July-2025 ]}

@online{reference.wolfram_2025_symmetricmatrixq, organization={Wolfram Research}, title={SymmetricMatrixQ}, year={2014}, url={https://reference.wolfram.com/language/ref/SymmetricMatrixQ.html}, note=[Accessed: 10-July-2025 ]}