SymmetricMatrixQ

SymmetricMatrixQ[m]

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:
  • SameTestAutomaticfunction to test equality of expressions
    ToleranceAutomatictolerance 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  (1)

Test if a matrix is explicitly symmetric:

Scope  (5)

A real matrix:

A complex matrix:

A complex symmetric matrix has symmetric real and imaginary parts:

A dense matrix:

A sparse matrix:

An approximate MachinePrecision matrix:

An approximate arbitrary-precision matrix:

A symbolic matrix:

The matrix becomes symmetric when :

An explicitly symmetric matrix:

Options  (2)

SameTest  (1)

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

Use the option SameTest to get the correct answer:

Tolerance  (1)

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

Adjust the option Tolerance to accept this matrix as symmetric:

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

Applications  (12)

Any matrix generated from a symmetric function is symmetric:

The function is symmetric:

Using Table generates a symmetric matrix:

Many special matrices are symmetric, including FourierMatrix:

HadamardMatrix:

HankelMatrix:

HilbertMatrix:

Many filter kernel matrices are symmetric, including DiskMatrix:

CrossMatrix:

DiamondMatrix:

AdjacencyMatrix of an undirected graph is symmetric:

Adjacency matrices for different graphs:

KirchhoffMatrix of an undirected graph is symmetric:

Kirchhoff matrices for different graphs:

Several statistical measures are symmetric matrices, including Covariance:

Correlation:

AbsoluteCorrelation:

The Hessian matrix of a function is symmetric:

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

Determine if a sparse matrix is structurally symmetric:

The matrix is not symmetric:

But it is structurally symmetric:

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:

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

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

Check that a matrix drawn from GaussianOrthogonalMatrixDistribution is symmetric:

Check that a matrix drawn from CircularOrthogonalMatrixDistribution is both symmetric and unitary:

Find the symmetric part of each color channel of an image:

Properties & Relations  (8)

A matrix is symmetric if mTranspose[m]:

HermitianMatrixQ gives True for symmetric real-valued matrices:

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

Use AntisymmetricMatrixQ to test whether a matrix is antisymmetric:

A symmetric matrix is always a normal matrix:

Use NormalMatrixQ to test whether a matrix is normal:

Real-valued symmetric matrices have all real eigenvalues:

Use Eigenvalues to find eigenvalues:

This also means that their CharacteristicPolynomial has real coefficients:

Symmetric matrices have a complete set of eigenvectors:

Use Eigenvectors to find eigenvectors:

Matrix functions of symmetric matrices are symmetric, including MatrixExp and Inverse:

As well as general MatrixFunction:

A symmetric matrix is always diagonalizable as tested with DiagonalizableMatrixQ:

Possible Issues  (1)

A complex symmetric matrix is not Hermitian:

Neat Examples  (1)

Images of symmetric matrices including FourierMatrix:

Introduced in 2008
 (7.0)
 |
Updated in 2014
 (10.0)