Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Matrix Calculator

How to use Matrix Calculator
  1. Pick a card on the first screen, Single Matrix, Two Matrices or Scalar Operations, then an operation in the Category column on the left. Learn more about choosing an operation
  2. Set Rows and Cols (1 to 10); every matrix takes the size, and square-only operations grey out while the two differ. Learn more about the matrix size
  3. Type the cells of Matrix A (and Matrix B), or use Random, Clear, Fill All and Diagonal with the Value box; for scalar operations type the Scalar value. Learn more about entering matrices
  4. Click Execute Operation; a red box lists any problem, otherwise the Result box shows a number, a matrix or the three matrices of a decomposition. Reset All returns to the first screen. Learn more about the result
  5. Read the panel on the right: the operation's description, the Calculation Steps after an Execute, and the History of this visit. Learn more about the panel

Professional matrix operations calculator

Select Operation Type








Choosing a Category and an Operation

DemoA category, an operation, another category
Step 0 of 3
The calculator opens on Select Operation Type with three cards: Single Matrix (determinant, transpose, inverse, trace, rank), Two Matrices (addition, subtraction, multiplication and more) and Scalar Operations (scalar multiplication, addition, power). Clicking a card moves to the input screen, which has three columns: the Category list on the left with the operations of the chosen category under it, the Matrix Input card in the middle and the explanation panel on the right. One matrix is created for a single-matrix or scalar category, two for the two-matrix category, all at the current size.

Click an operation in the left column to select it; a dot marks the choice, the panel heading takes the operation's name, and any earlier result is cleared. Click another category in the same column to switch; the operation list changes and the matrices are rebuilt, so values typed for the old category are lost. Operations that need a square matrix are greyed out while the size boxes differ. Reset All at the top right returns to the first screen with the size back at 3×33 \times 3. What each category contains is explained in Single-Matrix Operations, Two-Matrix Operations and Scalar Operations.

Setting the Matrix Size

Demo2×2, then 2×3, then Reset All
Step 0 of 3
The Rows and Cols boxes above the matrices set the size of every matrix at once, from 11 to 1010 each; the heading Matrix Input (3×3) and the note under the boxes repeat the size. Changing a box rebuilds the grids immediately: cells that still fit keep their values and new cells arrive empty. A value outside 11 to 1010 is refused with "Rows must be between 1 and 10" or "Columns must be between 1 and 10" and the grids are left as they were.

When the two boxes differ an orange note, "Some operations require square matrices", appears, and the determinant, inverse, trace and LU decomposition buttons grey out; multiplication of two matrices needs the columns of AA to equal the rows of BB, which with one shared size means a square matrix as well. For two-matrix operations both matrices always share the size set here, so a product of a 2×32 \times 3 by a 3×23 \times 2 matrix cannot be entered. Why the shape matters is explained in Matrix Multiplication and Matrix Determinant.

Entering the Matrices

DemoTyping A and B, then Random, Fill All and Diagonal
Step 0 of 4
Each matrix is a card headed Matrix A or Matrix B with a grid of number boxes; type one number per cell, decimals and negatives included, and use Tab to move on. Above the grid, Random fills the matrix with whole numbers from −10-10 to 1010 and Clear empties it. Below the grid the Value box feeds two buttons: Fill All writes the value into every cell (with an empty box, 00) and Diagonal writes it on the main diagonal with zeros elsewhere (with an empty box, 11, which gives the identity matrix). Each matrix has its own buttons, so AA and BB are filled separately.

An empty cell is reported at Execute time as "Matrix A has empty cells", and a cell that is not a number as "Matrix A contains invalid numbers". For scalar operations the Scalar value box sits under the matrix; it must hold a number or Execute answers "Please enter a valid scalar value". For a two-matrix operation with more than five columns, the two grids fold into accordions that open with a click on their header. The entries are indexed as in Matrix Addition, row first and column second.

Calculating and Reading the Result

DemoA determinant, an inverse, an error
Step 0 of 3
Click Execute Operation under the matrices; the button is grey until an operation is selected. The calculator first checks the input, listing every problem in a red box: empty or invalid cells, a non-square matrix for an operation that needs one, mismatched sizes ("Matrices must have the same dimensions for this operation", "For multiplication, columns of A must equal rows of B") or a missing scalar. When the input passes, the button shows "Calculating..." for a moment and the Result box fills.

The shape of the result follows the operation: a single number with its name for the determinant, trace or rank, for example "Determinant" and −2-2 for A=(1234)A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}; a matrix with its size for the transpose, inverse, sums and products, such as (−211.5−0.5)\begin{pmatrix} -2 & 1 \\ 1.5 & -0.5 \end{pmatrix} for the inverse; and three labelled matrices PP, LL and UU for the LU decomposition. A singular matrix makes the inverse fail with a message in the result box. Decimals are shown rounded. Reset All clears everything and returns to the first screen. The operations behind the results start with Matrix Transpose.

The Explanation Panel, Steps and History

DemoThe panel text, the steps, the history
Step 0 of 3
The panel on the right of the input card carries the heading of the selected operation and a short text on what it computes, with a link to the section of this page that explains it; before an operation is chosen it describes the category. After a successful Execute, Calculation Steps appears under the text with the arithmetic for your numbers, for example the row-by-column products of a multiplication or the cofactors of a determinant, and a History accordion lists every computation of this visit with its time, inputs and result; Clear history empties it.

The panel changes as soon as you click another operation, and the steps disappear until the next Execute, so the text always matches the operation that is selected rather than the last one computed. Reset All clears the steps but not the history. The operations the panel describes are explained in the theory sections, grouped in Single-Matrix Operations, Two-Matrix Operations and Scalar Operations.

Single-Matrix Operations

The Single Matrix category works on one matrix AA and offers six operations: Matrix Transpose, Matrix Determinant, Matrix Inverse, Matrix Trace, Matrix Rank and LU Decomposition. Transpose and rank accept any shape; determinant, inverse, trace and LU decomposition need a square matrix and are greyed out while the size boxes differ.

All six read the same cells, so one matrix can be examined from every side: for A=(1234)A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} the transpose is (1324)\begin{pmatrix} 1 & 3 \\ 2 & 4 \end{pmatrix}, the determinant −2-2, the inverse (−211.5−0.5)\begin{pmatrix} -2 & 1 \\ 1.5 & -0.5 \end{pmatrix}, the trace 55 and the rank 22; the determinant being non-zero is what makes the inverse exist and the rank full. The lesson hub summarises these quantities in The inverse of a matrix and Rank and trace.

Matrix Transpose

The transpose of a matrix AA swaps its rows and columns. If AA is an m×nm \times n matrix, then ATA^T is n×mn \times m, with each entry satisfying (AT)ij=Aji(A^T)_{ij} = A_{ji}.

AijT=AjiA^T_{ij} = A_{ji}


Key properties include (AT)T=A(A^T)^T = A, (AB)T=BTAT(AB)^T = B^T A^T, and (A+B)T=AT+BT(A + B)^T = A^T + B^T. A matrix equal to its own transpose is called symmetric. The transpose is fundamental in computing dot products, defining orthogonal matrices, and constructing the normal equation for least squares problems.

The lesson covers it in The transpose, and the symmetric case in Symmetric matrices.

Matrix Determinant

The determinant is a scalar value computed from a square matrix that captures essential properties of the transformation it represents. A matrix is invertible if and only if its determinant is nonzero.

For a 2×22 \times 2 matrix:

det⁡(A)=a11a22−a12a21\det(A) = a_{11}a_{22} - a_{12}a_{21}


For larger matrices, the determinant is computed via cofactor expansion or row reduction. Geometrically, ∣det⁡(A)∣|\det(A)| measures the factor by which the matrix scales areas or volumes. Key properties: det⁡(AB)=det⁡(A)det⁡(B)\det(AB) = \det(A)\det(B), det⁡(AT)=det⁡(A)\det(A^T) = \det(A), and det⁡(cA)=cndet⁡(A)\det(cA) = c^n \det(A) for an n×nn \times n matrix.

See The 2×2 formula, The 3×3 formula and Singular and nonsingular matrices in the determinants lesson.

Matrix Inverse

The inverse of a square matrix AA, denoted A−1A^{-1}, satisfies AA−1=A−1A=IAA^{-1} = A^{-1}A = I. A matrix has an inverse only when its determinant is nonzero.

A−1=1det⁡(A)adj(A)A^{-1} = \frac{1}{\det(A)} \text{adj}(A)


The calculator finds the inverse using Gauss-Jordan elimination on the augmented matrix [A∣I][A | I]. Row operations transform the left side into II, and the right side becomes A−1A^{-1}. The inverse is used to solve linear systems (x=A−1bx = A^{-1}b), compute matrix equations, and analyze transformations.

See Definition of the inverse, Computing the inverse by row reduction and When does the inverse exist.

Matrix Trace

The trace of a square matrix is the sum of its diagonal elements:

tr(A)=∑i=1naii\text{tr}(A) = \sum_{i=1}^{n} a_{ii}


The trace has several important properties. It is linear: tr(A+B)=tr(A)+tr(B)\text{tr}(A + B) = \text{tr}(A) + \text{tr}(B) and tr(cA)=c⋅tr(A)\text{tr}(cA) = c \cdot \text{tr}(A). It is cyclic: tr(ABC)=tr(BCA)=tr(CAB)\text{tr}(ABC) = \text{tr}(BCA) = \text{tr}(CAB). The trace equals the sum of the eigenvalues of the matrix, making it useful in spectral analysis and matrix diagnostics.

See Definition, Linearity, The cyclic property and Trace and eigenvalues in the trace lesson.

Matrix Rank

The rank of a matrix is the number of linearly independent rows or columns. It equals the dimension of the column space (or row space) and is found by reducing the matrix to row echelon form and counting pivot positions.

rank(A)≤min⁡(m,n)\text{rank}(A) \leq \min(m, n)


A matrix with rank equal to its smaller dimension has full rank. Rank determines whether a linear system Ax=bAx = b has a unique solution, infinitely many solutions, or no solution. The rank-nullity theorem states rank(A)+nullity(A)=n\text{rank}(A) + \text{nullity}(A) = n where nn is the number of columns.

See What rank measures, Computing rank via row reduction and The rank-nullity theorem.

LU Decomposition

LU decomposition factors a square matrix into a product of a lower triangular matrix LL and an upper triangular matrix UU, with a permutation matrix PP tracking row swaps:

PA=LUPA = LU


LL has ones on the diagonal with elimination multipliers below. UU is the result of Gaussian elimination. This factorization is efficient for solving multiple systems with the same coefficient matrix but different right-hand sides, since forward and back substitution are much cheaper than full elimination. LU decomposition is also used to compute determinants efficiently: det⁡(A)=det⁡(L)⋅det⁡(U)⋅det⁡(P)\det(A) = \det(L) \cdot \det(U) \cdot \det(P).

See What LU decomposition is, Partial pivoting: PA = LU and Solving systems with LU.

Two-Matrix Operations

The Two Matrices category combines AA and BB with seven operations: Matrix Addition, Matrix Subtraction, Matrix Multiplication, the Element-wise (Hadamard) Product, the Kronecker Product, the Commutator and the Anti-commutator. Addition, subtraction and the Hadamard product need equal shapes; multiplication needs the columns of AA to match the rows of BB; the commutators need square matrices of one size. The calculator checks these before computing and names the problem in a red box.

With A=(1234)A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} and B=(5678)B = \begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix}: A+B=(681012)A + B = \begin{pmatrix} 6 & 8 \\ 10 & 12 \end{pmatrix}, AB=(19224350)AB = \begin{pmatrix} 19 & 22 \\ 43 & 50 \end{pmatrix} while BA=(23343146)BA = \begin{pmatrix} 23 & 34 \\ 31 & 46 \end{pmatrix}, so [A,B]=(−4−12124)[A, B] = \begin{pmatrix} -4 & -12 \\ 12 & 4 \end{pmatrix}. The products are defined in Matrix multiplication: definition and compared in Matrix arithmetic at a glance.

Matrix Addition

Matrix addition sums corresponding elements of two matrices with identical dimensions. If AA and BB are both m×nm \times n:

(A+B)ij=aij+bij(A + B)_{ij} = a_{ij} + b_{ij}


Addition is commutative (A+B=B+AA + B = B + A) and associative ((A+B)+C=A+(B+C)(A + B) + C = A + (B + C)). The zero matrix acts as the additive identity. Subtraction works identically, replacing each sum with a difference: (A−B)ij=aij−bij(A - B)_{ij} = a_{ij} - b_{ij}. Both operations preserve matrix dimensions.

See Matrix addition and Matrix arithmetic at a glance.

Matrix Subtraction

Matrix subtraction computes the element-wise difference between two matrices of the same dimensions:

(A−B)ij=aij−bij(A - B)_{ij} = a_{ij} - b_{ij}


Subtraction is equivalent to adding the negation: A−B=A+(−B)A - B = A + (-B). Unlike addition, subtraction is not commutative: A−B≠B−AA - B \neq B - A in general. The result has the same dimensions as both input matrices. Subtraction is used in computing residuals, error matrices, and the commutator operation [A,B]=AB−BA[A, B] = AB - BA.

See Matrix subtraction in the operations lesson.

Matrix Multiplication

Matrix multiplication combines an m×nm \times n matrix AA with an n×pn \times p matrix BB to produce an m×pm \times p result. The number of columns in AA must equal the number of rows in BB. Try which sizes fit.

(AB)ij=∑k=1naikbkj(AB)_{ij} = \sum_{k=1}^{n} a_{ik} b_{kj}


Each entry is the dot product of a row from AA with a column from BB. Multiplication is associative and distributive over addition, but not commutative: AB≠BAAB \neq BA in general. Matrix multiplication models composition of linear transformations and is the core operation in systems of equations, computer graphics, and machine learning.

See Matrix multiplication: definition, Matrix multiplication: properties and the column and row interpretations.

Element-wise (Hadamard) Product

The Hadamard product, denoted A⊙BA \odot B, multiplies corresponding elements of two matrices with the same dimensions:

(A⊙B)ij=aij⋅bij(A \odot B)_{ij} = a_{ij} \cdot b_{ij}


Unlike standard matrix multiplication, the Hadamard product is commutative (A⊙B=B⊙AA \odot B = B \odot A) and preserves dimensions. It appears in signal processing, neural network computations (gradient masking, attention mechanisms), and statistics. The Schur product theorem states that if AA and BB are both positive semidefinite, then A⊙BA \odot B is also positive semidefinite.

The lesson treats it in Two more products: Hadamard and outer.

Kronecker Product

The Kronecker product A⊗BA \otimes B replaces each element aija_{ij} of AA with the block aij⋅Ba_{ij} \cdot B. If AA is m×nm \times n and BB is p×qp \times q, the result is mp×nqmp \times nq.

The Kronecker product is bilinear and associative but not commutative. Key properties include (A⊗B)(C⊗D)=(AC)⊗(BD)(A \otimes B)(C \otimes D) = (AC) \otimes (BD) when dimensions allow, and det⁡(A⊗B)=det⁡(A)q⋅det⁡(B)m\det(A \otimes B) = \det(A)^q \cdot \det(B)^m for square matrices. It is used in quantum computing (tensor product of state spaces), control theory, and signal processing.

The Kronecker product is the block-matrix cousin of the outer product in Two more products: Hadamard and outer; the products it is built from are in Matrix multiplication: definition.

Commutator

The commutator of two square matrices is defined as:

[A,B]=AB−BA[A, B] = AB - BA


When [A,B]=0[A, B] = 0 (the zero matrix), AA and BB commute, meaning their multiplication order does not matter. The commutator is antisymmetric: [A,B]=−[B,A][A, B] = -[B, A] and satisfies the Jacobi identity: [A,[B,C]]+[B,[C,A]]+[C,[A,B]]=0[A, [B, C]] + [B, [C, A]] + [C, [A, B]] = 0. The commutator is fundamental in Lie algebra, quantum mechanics (where it relates to the uncertainty principle), and differential geometry.

Why ABAB and BABA differ is in Matrix multiplication: properties; the trace of a commutator is always zero, see Trace of commutators.

Anti-commutator

The anti-commutator of two square matrices is defined as:

{A,B}=AB+BA\{A, B\} = AB + BA


It is the symmetric counterpart of the commutator. The anti-commutator is always symmetric: {A,B}={B,A}\{A, B\} = \{B, A\}. In quantum mechanics, anti-commutation relations define fermionic operators (particles obeying the Pauli exclusion principle), while commutation relations define bosonic operators. The anti-commutator also appears in Clifford algebras and Jordan algebras.

See Matrix multiplication: properties and, for the trace of the two orders, Trace of commutators.

Scalar Operations

The Scalar Operations category combines one matrix with one number cc, typed in the Scalar value box: Scalar Multiplication, Scalar Addition, Scalar Subtraction and Matrix Power, where the scalar is the exponent. Multiplication, addition and subtraction work on any shape; the power needs a square matrix and a non-negative whole exponent.

For A=(1234)A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} and c=2c = 2: 2A=(2468)2A = \begin{pmatrix} 2 & 4 \\ 6 & 8 \end{pmatrix}, A+2=(3456)A + 2 = \begin{pmatrix} 3 & 4 \\ 5 & 6 \end{pmatrix} and A2=(7101522)A^2 = \begin{pmatrix} 7 & 10 \\ 15 & 22 \end{pmatrix}. Only scalar multiplication is one of the standard vector-space operations; the other three are conveniences. See Scalar multiplication and Matrix powers.

Scalar Multiplication

Scalar multiplication multiplies every element of a matrix by a single number cc:

(cA)ij=c⋅aij(cA)_{ij} = c \cdot a_{ij}


This scales the entire matrix uniformly. For the determinant, det⁡(cA)=cndet⁡(A)\det(cA) = c^n \det(A) where nn is the matrix size. Scalar multiplication is commutative (cA=AccA = Ac), associative (c(dA)=(cd)Ac(dA) = (cd)A), and distributes over matrix addition (c(A+B)=cA+cBc(A + B) = cA + cB). Geometrically, it scales the linear transformation represented by the matrix.

See Scalar multiplication and Linear combinations of matrices.

Scalar Addition and Subtraction

Scalar addition adds a constant cc to every element of a matrix:

(A+c)ij=aij+c(A + c)_{ij} = a_{ij} + c


Scalar subtraction works the same way with a minus sign. Note that this is different from adding cIcI (scalar times identity), which only affects diagonal elements. Scalar addition shifts all entries by the same amount and is used in data normalization, bias adjustments, and preprocessing steps in numerical computation.

The two operations have their own sections: Scalar Addition and Scalar Subtraction. The ordinary arithmetic they sit next to is summarised in Matrix arithmetic at a glance.

Scalar Addition

Scalar addition adds the same number cc to every entry: (A+c)ij=aij+c(A + c)_{ij} = a_{ij} + c. For A=(1234)A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} and c=1c = 1 the result is (2345)\begin{pmatrix} 2 & 3 \\ 4 & 5 \end{pmatrix}. The operation keeps the shape of AA and shifts every entry by the same amount, which is what a spreadsheet does when a constant is added to a whole block of cells.

It is not the same as A+cIA + cI, which adds cc to the diagonal only; the calculator's Scalar Addition changes all four entries, so the determinant and the eigenvalues do not follow a simple rule. The common mistake is to mix the two up when a textbook writes A+cA + c as shorthand for A+cIA + cI. The arithmetic it sits next to is in Matrix arithmetic at a glance and Linear combinations of matrices.

Scalar Subtraction

Scalar subtraction takes the same number cc from every entry: (A−c)ij=aij−c(A - c)_{ij} = a_{ij} - c. For A=(1234)A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} and c=1c = 1 the result is (0123)\begin{pmatrix} 0 & 1 \\ 2 & 3 \end{pmatrix}; it is scalar addition with −c-c, so the two operations undo each other.

As with scalar addition, this is an entry-wise shift and not A−cIA - cI, which only touches the diagonal; the latter is the matrix whose determinant gives the characteristic polynomial. The common mistake is to expect the trace to drop by cc when it drops by ncnc for an n×nn \times n matrix, since every diagonal entry moves. See Matrix arithmetic at a glance and Scalar multiplication for the operations that do follow the usual rules.

Matrix Power

Matrix power raises a square matrix to a non-negative integer exponent through repeated multiplication:

An=A⋅A⋯A⏟n timesA^n = \underbrace{A \cdot A \cdots A}_{n \text{ times}}


By convention, A0=IA^0 = I (the identity matrix). The calculator uses exponentiation by squaring for efficiency, reducing the cost from O(n)O(n) multiplications to O(log⁡n)O(\log n). Matrix powers appear in Markov chains (transition probabilities over nn steps), solving linear recurrences, graph theory (counting paths of length nn), and computing the matrix exponential.

See Matrix powers and, for the identity A0=IA^0 = I, The identity matrix.