Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Square Matrix Types Generator


Select a matrix size and type to see different matrix structures. The highlighted elements show the special characteristics of each matrix type. Click 'Clear' to reset the current matrix.










Key Terms

Square matrix — a matrix with as many rows as columns, n×nn \times n. Every type on this page is square; the main diagonal only makes sense when it is.

Main diagonal — the entries ai,ia_{i,i} from the top-left corner to the bottom-right. Most special types are defined by what sits on it and what sits off it.

Identity matrixInI_n, ones on the diagonal and zeros elsewhere; the matrix that changes nothing under multiplication.

Zero matrix — every entry 00; the matrix that changes nothing under addition.

Scalar matrixλI\lambda I, a single number λ\lambda repeated down the diagonal.

Diagonal matrix — any entries on the diagonal, zeros everywhere else.

Triangular matrix — zeros below the diagonal (upper) or above it (lower); the diagonal and one side are free.

Symmetric matrix — equal to its transpose, ai,j=aj,ia_{i,j} = a_{j,i}; a mirror across the diagonal.

Skew-symmetric matrix — the negative of its transpose, ai,j=aj,ia_{i,j} = -a_{j,i}, which forces every diagonal entry to 00.

Getting Started with the Generator

The generator builds a matrix of the type you choose at the size you choose, and explains what makes it that type.

• Pick a Matrix Size from the first dropdown; every type is square, so one number fixes both dimensions
• Pick a Matrix Type from the second dropdown: random, identity, zero, scalar, diagonal, upper triangular, lower triangular, symmetric, or skew-symmetric
• The matrix appears with its defining pattern coloured, so the forced entries and the free entries can be told apart at a glance
• Below it, a short explanation states the rule in words and in symbols, lists the properties that follow from it, and links to a fuller reference
Clear empties the display so a fresh type or size can be generated

Generate the same type at two or three sizes in a row. The pattern is what stays fixed; the numbers are incidental, and for the random type they are the whole point.

The Nine Types at a Glance

Every type is a rule about which entries are free and which are forced.

Identity and zero — no free entries at all. The identity is ones on the diagonal, the zero matrix is zeros everywhere
Scalar and diagonal — free only on the diagonal. Scalar repeats one number; diagonal allows any numbers
Triangular — free on the diagonal and on one side of it; the other side is zero
Symmetric and skew-symmetric — free on and above the diagonal, with the entries below determined by reflection, equal for symmetric and negated for skew-symmetric
Random — every entry free. The control case that shows what the other rules take away

Counting the free entries is a good exercise. At n×nn \times n: identity and zero have 00, scalar has 11, diagonal has nn, triangular and symmetric have n(n+1)/2n(n+1)/2, skew-symmetric has n(n1)/2n(n-1)/2, and random has n2n^2. The how the types relate section turns those counts into a family tree.

Identity and Zero

The identity matrix InI_n has 11 on every diagonal entry and 00 everywhere else. It is the multiplicative unit: IA=AI=AIA = AI = A for every matrix AA of compatible size, just as 1x=x1 \cdot x = x for numbers. Its determinant is 11, every eigenvalue is 11, and it is its own inverse and its own transpose.

The zero matrix 00 has every entry equal to 00. It is the additive unit: A+0=AA + 0 = A. Its determinant is 00, every eigenvalue is 00, its rank is 00, and multiplying anything by it gives the zero matrix again.

Between them these two matrices play the roles of 11 and 00 in ordinary arithmetic, and most identities about matrices are checked first on them. The identity is also the matrix of the transformation that leaves every vector where it is, and the zero matrix is the transformation that sends every vector to the origin.

Both are special cases of the scalar matrix: the identity with λ=1\lambda = 1, the zero matrix with λ=0\lambda = 0.
100010001
Identity, frozen

Size 3, type Identity. Ones on the diagonal, zeros off it, and the diagonal highlighted amber - the entries the type forces. Every other entry is fixed at 0, so nothing here is free.

000000000
Zero, frozen

Size 3, type Zero. Nothing is highlighted because nothing is distinguished: every entry is forced to 0, and no position carries information.

The two stills show the extremes of what the highlighting means. On the identity, three cells are amber and six are not, and the amber ones are the only positions the type says anything about. On the zero matrix nothing is amber at all, because the type constrains every entry equally and no position is distinguished from the rest.

Neither matrix has any free value: change one entry of either and it stops being that type. That is unusual. Of the nine types, only these two are a single fixed matrix at each size; the rest describe families.

Scalar and Diagonal

A scalar matrix is λI\lambda I: the same number λ\lambda on every diagonal entry, zeros elsewhere. Multiplying by it scales every vector by λ\lambda in every direction, and it commutes with every other matrix of the same size, (λI)A=A(λI)=λA(\lambda I) A = A (\lambda I) = \lambda A. Its determinant is λn\lambda^n and its only eigenvalue is λ\lambda.

A diagonal matrix drops the requirement that the diagonal entries agree: any numbers d1,,dnd_1, \ldots, d_n on the diagonal, zeros elsewhere. It scales each coordinate axis by its own factor, which is the simplest non-trivial linear transformation there is.

Diagonal matrices are the ones every computation is easiest for:

• The product of two diagonal matrices is diagonal, with the diagonal entries multiplied
• The determinant is the product d1d2dnd_1 d_2 \cdots d_n
• The eigenvalues are the diagonal entries themselves, with the standard basis vectors as eigenvectors
• The inverse exists exactly when no did_i is zero, and is the diagonal matrix of the reciprocals
• Powers are computed entry by entry, DkD^k has diagonal dikd_i^k

Much of linear algebra is the search for a change of basis that makes a given matrix diagonal, precisely because of that list.
300030003
Scalar, frozen

Size 3, type Scalar, with λ = 3. The same number repeats down the highlighted diagonal; one free value determines the whole matrix.

400070002
Diagonal, frozen

Size 3, type Diagonal, showing 4, 7 and 2. The highlight is the same as for scalar, but the three diagonal entries are now independent - three free values instead of one.

The two stills are highlighted identically, and that is the point: scalar and diagonal impose the same pattern of zeros, and differ only in how much freedom the amber cells have. The scalar still repeats one value, 33, three times; the diagonal still carries 44, 77 and 22 independently.

So the scalar matrices sit inside the diagonal matrices as the case d1==dnd_1 = \cdots = d_n, and the identity sits inside the scalar matrices as λ=1\lambda = 1. Three of the nine types are one nested family, distinguished only by how many values you are allowed to choose.

Triangular Matrices

An upper triangular matrix has every entry below the main diagonal equal to 00; the diagonal and everything above it are free. A lower triangular matrix is the mirror image, zeros above and freedom below. The transpose of one is the other.

Triangular matrices are where determinants and eigenvalues become readable:

• The determinant is the product of the diagonal entries, with no expansion needed
• The eigenvalues are the diagonal entries
• The matrix is invertible exactly when no diagonal entry is zero
• Products and inverses of upper triangular matrices are upper triangular, and likewise for lower

This is why so many algorithms aim for triangular form. Gaussian elimination reduces a matrix to upper triangular form so a system can be solved by back-substitution. The LU decomposition writes A=LUA = LU with LL lower and UU upper triangular, so that detA\det A is the product of the diagonal of UU and each new right-hand side costs two triangular solves. The QR and Cholesky decompositions have a triangular factor for the same reason.

A matrix that is both upper and lower triangular has zeros on both sides, so it is diagonal.
385062009
Upper triangular, frozen

Size 3, type Upper Triangular. The highlight covers the diagonal and everything above it, the six free entries; the three below the diagonal are forced to 0.

300860529
Lower triangular, frozen

Size 3, type Lower Triangular. The mirror image: the highlighted six sit on and below the diagonal, and the three above are forced to 0. Transposing one type gives the other.

Put the two stills side by side and the mirror symmetry is the whole definition. Each highlights six of the nine cells, the two highlighted regions overlap exactly on the diagonal, and reflecting either picture across that diagonal produces the other.

The count generalises: at size nn a triangular matrix has n(n+1)/2n(n+1)/2 free entries, a little over half of n2n^2. That is the saving every triangular algorithm is trading on — back-substitution touches only the highlighted half, which is why reaching triangular form is worth the elimination that gets you there.

Symmetric and Skew-Symmetric

A symmetric matrix equals its own transpose, A=ATA = A^T, so the entry at row ii, column jj equals the entry at row jj, column ii. The matrix mirrors across its main diagonal, and the generator colours matching pairs the same to show it.

Symmetric matrices have the best-behaved spectral theory of any class:

• Every eigenvalue is real
• Eigenvectors for different eigenvalues are perpendicular
• The matrix can be diagonalised by an orthogonal change of basis, A=QDQTA = Q D Q^T

They arise wherever a quantity depends symmetrically on two indices: covariance matrices, the Hessian of a function, the matrix of a quadratic form, adjacency matrices of undirected graphs.

A skew-symmetric matrix is the negative of its transpose, AT=AA^T = -A, so ai,j=aj,ia_{i,j} = -a_{j,i}. Setting i=ji = j gives ai,i=ai,ia_{i,i} = -a_{i,i}, which forces every diagonal entry to 00. The eigenvalues are purely imaginary or zero, and an odd-sized skew-symmetric matrix always has determinant 00. In three dimensions the skew-symmetric matrices are exactly the cross-product maps vω×vv \mapsto \omega \times v, which is why they describe angular velocity and infinitesimal rotations.

Every square matrix splits uniquely into a symmetric and a skew-symmetric part, A=12(A+AT)+12(AAT)A = \tfrac{1}{2}(A + A^T) + \tfrac{1}{2}(A - A^T).
472758286
Symmetric, frozen

Size 3, type Symmetric. The diagonal is yellow and each mirrored pair gets its own colour, so a₁₂ = a₂₁ = 7 share one colour and a₁₃ = a₃₁ = 2 another. Six free values: three on the diagonal, three above it.

072-708-2-80
Skew-symmetric, frozen

Size 3, type Skew-symmetric. The diagonal is unhighlighted because it is forced to 0, and each coloured pair differs by a sign: 7 against −7, 2 against −2, 8 against −8. Three free values.

These are the only two types the generator colours by pair rather than by position. Each mirrored pair gets its own colour, so the constraint being illustrated is a relation between two cells, not a property of one. In the symmetric still the paired cells hold equal values, 77 with 77 and 22 with 22; in the skew-symmetric still they hold opposite ones, 77 with 7-7.

The diagonal is where the two types part company. Symmetric leaves it free and marks it yellow, three values to choose. Skew-symmetric forces it to zero and leaves it unhighlighted, since ai,i=ai,ia_{i,i} = -a_{i,i} has only one solution. That is why the free-value counts differ: six against three at size 33.

Random Matrices

The random type fills every entry independently with a number drawn at random. It has no structure, and that is its use: it is the control against which the other eight types are seen.

Generate a random matrix and check the special properties fail. The transpose is a different matrix. The determinant is not the product of the diagonal. The eigenvalues bear no visible relation to the entries. Then generate a symmetric or triangular matrix of the same size and watch each property return.

Random matrices also matter in their own right. Almost every random square matrix is invertible, since singularity requires the exact cancellation detA=0\det A = 0. They are used to test algorithms, to initialise the weights of neural networks, and in random matrix theory, where the statistics of their eigenvalues turn out to be universal.
372519468
Random, frozen

Size 3, type Random - the same matrix the explanation panel prints. No highlighting, because no entry is constrained: all nine are free. This is the baseline the eight special types are departures from.

The still is the only one on this page with no colour in it, and the absence is the information. Nine free entries, no forced zeros, no mirrored pairs, nothing the type guarantees — so the generator has nothing to mark.

Read the other eight stills against this one and each is a statement about which of these nine cells stop being free. Identity and zero remove all nine, triangular removes three, symmetric and skew-symmetric tie six of them together in pairs. The colour in every other still is exactly the structure that this one lacks.

How the Types Relate

The types nest. Each rule below is a special case of the ones after it.

• The identity and the zero matrix are scalar matrices, with λ=1\lambda = 1 and λ=0\lambda = 0
• Every scalar matrix is diagonal
• Every diagonal matrix is both upper and lower triangular, and it is the only kind that is both
• Every diagonal matrix is symmetric, since it equals its transpose
• The zero matrix is the only matrix that is both symmetric and skew-symmetric, because ai,j=aj,ia_{i,j} = a_{j,i} and ai,j=aj,ia_{i,j} = -a_{j,i} together force every entry to 00

Some pairs are unrelated. A triangular matrix is symmetric only if it is diagonal. A symmetric matrix need not be invertible, and an invertible matrix need not be any of the special types.

The counts of free entries from the overview track the nesting: 01nn(n+1)/2n20 \le 1 \le n \le n(n+1)/2 \le n^2 as the rules loosen from identity through scalar, diagonal, and triangular or symmetric to random.

Determinants and Eigenvalues by Type

For most of the special types the determinant and the eigenvalues can be read off without computation, and the generator lists them with each matrix.

Identity: determinant 11, all eigenvalues 11
Zero: determinant 00, all eigenvalues 00
Scalar λI\lambda I: determinant λn\lambda^n, all eigenvalues λ\lambda
Diagonal: determinant the product of the diagonal, eigenvalues the diagonal entries
Triangular: the same as diagonal, product of the diagonal and eigenvalues on the diagonal, because the entries off the triangle contribute nothing to either
Symmetric: no shortcut for the values, but they are guaranteed real, and the determinant is their product
Skew-symmetric: eigenvalues purely imaginary or zero; determinant 00 when nn is odd, and a perfect square when nn is even
Random: nothing can be said in advance, which is the point of the type

The triangular case is the one to remember. It is why row reduction computes determinants, and why the eigenvalues of a matrix are found by bringing it to triangular form rather than by expanding a characteristic polynomial.

Where the Types Appear

Each special type is the answer to a question that comes up repeatedly.

Identity — the matrix of the do-nothing transformation, the target of every inverse computation, and the II in AλIA - \lambda I.

Diagonal — the goal of diagonalisation. A matrix that can be written PDP1P D P^{-1} has all its powers, exponentials and functions computed on the diagonal of DD.

Triangular — the output of Gaussian elimination and the factors in the LU, QR and Cholesky decompositions. Systems with triangular coefficient matrices are solved by substitution in n2n^2 operations.

Symmetric — covariance and correlation matrices in statistics, Hessians in optimisation, stiffness and mass matrices in mechanics, adjacency matrices of undirected graphs. Positive definiteness is a property only symmetric matrices have.

Skew-symmetric — angular velocity and the generators of rotations in physics, and the matrices of cross products in three dimensions.

Scalar — uniform scaling, and the centre of the matrix algebra: the only matrices that commute with everything.

Zero — the kernel of every homomorphism, and the matrix a nilpotent matrix eventually becomes under powers.

Common Mistakes

The rules are short, and the errors come from applying them loosely.

Confusing diagonal with triangular — a diagonal matrix has zeros on both sides of the diagonal; a triangular matrix has zeros on one side only
Reading symmetric as "looks balanced" — symmetry is the precise condition ai,j=aj,ia_{i,j} = a_{j,i} for every pair; one mismatched pair breaks it
Allowing a nonzero diagonal in a skew-symmetric matrix — the condition ai,i=ai,ia_{i,i} = -a_{i,i} forces every diagonal entry to 00
Calling every scalar multiple of a matrix a scalar matrix — a scalar matrix is a multiple of the identity specifically, λI\lambda I
Assuming special types are invertible — a diagonal or triangular matrix with a zero on the diagonal is singular, and a symmetric matrix can be singular too
Expecting the product of two symmetric matrices to be symmetric(AB)T=BTAT=BA(AB)^T = B^T A^T = BA, which equals ABAB only when the two commute
Applying these types to non-square matrices — the diagonal, and every rule built on it, needs a square matrix