Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Operations on Matrices






Manipulating Matrices

Matrices support a family of operations — addition, scalar multiplication, matrix multiplication, transposition, and exponentiation — each with its own rules and dimension requirements. Matrix multiplication stands apart from the rest: it is not commutative, it demands compatible dimensions, and it admits several geometric and algebraic interpretations that make it one of the richest operations in all of mathematics.



Matrix Addition

Two matrices of the same size can be added entry by entry. If AA and BB are both m×nm \times n, their sum is the m×nm \times n matrix with entries

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

For example,

Matrix Addition
(14−2305)+(3−1602−4)=(434321)\begin{pmatrix} 1 & 4 \\ -2 & 3 \\ 0 & 5 \end{pmatrix} + \begin{pmatrix} 3 & -1 \\ 6 & 0 \\ 2 & -4 \end{pmatrix} = \begin{pmatrix} 4 & 3 \\ 4 & 3 \\ 2 & 1 \end{pmatrix}

If the dimensions do not match, the sum is undefined — there is no way to add a 2×32 \times 3 matrix to a 3×23 \times 2 matrix.

RULE
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 OO of the same size serves as the additive identity (A+O=AA + O = A), and the additive inverse of AA is −A=(−aij)-A = (-a_{ij}), so A+(−A)=OA + (-A) = O.
A2×3a1,1a1,2a1,3a2,1a2,2a2,3+B2×3b1,1b1,2b1,3b2,1b2,2b2,3=C2×3a1,1+b1,1a1,2+b1,2a1,3+b1,3a2,1+b2,1a2,2+b2,2a2,3+b2,3
A + B, every entry settled

Each entry of the result came from the one pair sitting in the same position, and from nothing else. That is why the two matrices must have identical shapes and why the sum keeps that shape — there is no mechanism here for a row to reach a different row. Run it entry by entry, or switch to subtraction, on the matrix addition visualizer.

Subtraction and scaling in the next two sections work the same way, one position at a time, which is why they share addition's shape rules.

Matrix Notation

Notation

Matrix Notation

Capital letters, double subscripts in a fixed order, multiplication with no symbol at all — and the two reserved letters every matrix equation leans on.
Bold vectors and their components — vector notation; ATA^{T} in row-times-column form — dot product notation.
A=(aij)A = (a_{ij}), an m×nm \times n matrix
The matrix A with entries a-i-j; m by n
Capital letter for the whole array, lowercase with a double subscript for one entry — row first, column second, always: a23a_{23} sits in row 22, column 33. The size m×nm \times n reads “mm by nn” and obeys the same order: rows, then columns.
CasesSubscripts extract from any matrix expression: (A+B)ij(A + B)_{ij} names one entry of the sum, the device the definitions on this page are written in. The ×\times in m×nm \times n is a dimension separator — a third job for the glyph, after arithmetic and the cross product, and this one multiplies nothing.
Also written[aij][a_{ij}] with square brackets — many American texts; this site sets matrices in parentheses. The two bracket styles are pure typography.
Do not confuseReversed subscripts. aija_{ij} and ajia_{ji} name different entries unless the matrix is symmetric — and the transpose is exactly the operation that swaps them.
ABAB
A times B — written with no symbol
Matrix multiplication is written by juxtaposition — no dot, no cross. The bare notation hides a shape contract: (m×n)(n×p)(m \times n)(n \times p) works only because the inner dimensions agree, and delivers m×pm \times p.
CasesOrder is load-bearing: AB≠BAAB \neq BA in general, so the language splits into premultiplying and postmultiplying. Powers stack the juxtaposition: AnA^n for square AA, with A0=IA^0 = I by convention — the identity II (subscripted InI_n when size matters) is the matrix world's 11, and OO its 00, as in Matrix Addition above.
Also writtenA⋅BA \cdot B with an explicit dot, in some European school texts — never with ×\times, which would collide with dimensions and cross products.
Do not confuseScalar habits. From AB=ACAB = AC nothing cancels; (A+B)2(A+B)^2 is A2+AB+BA+B2A^2 + AB + BA + B^2, four terms — the notation looks like ordinary algebra and refuses to behave like it.
ATA^{T}
A transpose
The superscript TT is a label, not an exponent: flip rows and columns, so (AT)ij=aji(A^{T})_{ij} = a_{ji}. The operation itself is The Transpose below.
CasesIt reverses products — (AB)T=BTAT(AB)^{T} = B^{T}A^{T}, order flipped — and characterizes whole matrix types in one equation: A=ATA = A^{T} is symmetry, AT=−AA^{T} = -A skew-symmetry, QTQ=IQ^{T}Q = I orthogonality.
Also writtenA⊤A^{\top} with the sans-serif glyph; A′A' in econometrics and older texts — the prime again, moonlighting far from derivatives.
Do not confuseA power. ATA^{T} multiplies nothing TT times; the same corner of the symbol carries AnA^{n} (a genuine power), A−1A^{-1} (the inverse) and ATA^{T} (a flip) — three superscripts, three unrelated jobs.

Matrix Subtraction

Subtraction is defined as addition of the negative:

Matrix Subtraction
A−B=A+(−B)A - B = A + (-B)

Entry by entry, (A−B)ij=aij−bij(A - B)_{ij} = a_{ij} - b_{ij}. The same dimension requirement applies — both matrices must have identical shapes. There is nothing deeper here than combining addition and negation, but it appears often enough to warrant its own notation.

Scalar Multiplication

Multiplying a matrix by a scalar cc scales every entry:

Scalar Multiplication of Matrices
(cA)ij=c⋅aij(cA)_{ij} = c \cdot a_{ij}

For example,

Scalar Multiplication
−2(13−4052)=(−2−680−10−4)-2 \begin{pmatrix} 1 & 3 & -4 \\ 0 & 5 & 2 \end{pmatrix} = \begin{pmatrix} -2 & -6 & 8 \\ 0 & -10 & -4 \end{pmatrix}

RULE
Scalar multiplication distributes over matrix addition (c(A+B)=cA+cBc(A + B) = cA + cB), distributes over scalar addition ((c+d)A=cA+dA(c + d)A = cA + dA), associates with itself (c(dA)=(cd)Ac(dA) = (cd)A), and has 11 as its identity (1⋅A=A1 \cdot A = A).

Multiplying by 00 produces the zero matrix.
k·A2×3a1,1a1,2a1,3a2,1a2,2a2,3=C2×3k·a1,1k·a1,2k·a1,3k·a2,1k·a2,2k·a2,3
kA, entry by entry

Every entry of the result is the scalar times the entry in the same position: k·a11, k·a12, and so on across all six cells. Nothing moves and nothing mixes — the shape of A is kept exactly. Watch the cells fill one at a time on the matrix scalar multiplication visualizer.

Because the scalar reaches every entry alike, scaling never changes a matrix's shape or the pattern of its zeros.

Linear Combinations of Matrices

Given matrices A1,A2,…,AkA_1, A_2, \dots, A_k of the same size and scalars c1,c2,…,ckc_1, c_2, \dots, c_k, the expression

Linear Combinations of Matrices
c1A1+c2A2+⋯+ckAkc_1 A_1 + c_2 A_2 + \cdots + c_k A_k

is a linear combination of matrices.

THEOREM
Addition and scalar multiplication together give the set of all m×nm \times n matrices the structure of a vector space.

The dimension of this space is mnmn — one degree of freedom for each entry. The standard basis consists of the mnmn matrices that have a single 11 in one position and zeros everywhere else.
α·A2×3α·a1,1α·a1,2α·a1,3α·a2,1α·a2,2α·a2,3+β·B2×3β·b1,1β·b1,2β·b1,3β·b2,1β·b2,2β·b2,3=C2×3α·a1,1+β·b1,1α·a1,2+β·b1,2α·a1,3+β·b1,3α·a2,1+β·b2,1??
αA + βB, the final sweep

A linear combination of matrices runs in two moves: scale each matrix, then add position by position. This frame is the adding sweep — the already-scaled αA and βB are combined cell by cell, some cells finished, one in progress, the rest still waiting. It is the same pattern as a linear combination of vectors, with a grid in place of a list. Run all three sweeps on the matrix linear combination visualizer.

That is why the m × n matrices behave as a vector space: every linear combination stays inside the same size.

Matrix Multiplication — Definition

For AA of size m×nm \times n and BB of size n×pn \times p, the product ABAB is an m×pm \times p matrix whose (i,j)(i,j) entry is the dot product of row ii of AA with column jj of BB:

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

The number of columns of AA must equal the number of rows of BB. If this compatibility condition fails, the product is undefined.

Worked Example


Matrix Multiplication — Definition
(1032−14)(512−306)\begin{pmatrix} 1 & 0 & 3 \\ 2 & -1 & 4 \end{pmatrix} \begin{pmatrix} 5 & 1 \\ 2 & -3 \\ 0 & 6 \end{pmatrix}

The left matrix is 2×32 \times 3 and the right is 3×23 \times 2, so the product is 2×22 \times 2. Computing each entry:

Matrix Multiplication — Definition
(1)(5)+(0)(2)+(3)(0)=5,(1)(1)+(0)(−3)+(3)(6)=19(1)(5) + (0)(2) + (3)(0) = 5, \quad (1)(1) + (0)(-3) + (3)(6) = 19

Matrix Multiplication — Definition
(2)(5)+(−1)(2)+(4)(0)=8,(2)(1)+(−1)(−3)+(4)(6)=29(2)(5) + (-1)(2) + (4)(0) = 8, \quad (2)(1) + (-1)(-3) + (4)(6) = 29

Matrix Multiplication — Definition
AB=(519829)AB = \begin{pmatrix} 5 & 19 \\ 8 & 29 \end{pmatrix}

Fact: Seven products instead of eight
In 1969 Volker Strassen multiplied two 2×22 \times 2 matrices with 77 multiplications instead of 88, at the cost of extra additions. His formulas never use ab=baab = ba, so they also work on blocks of a large matrix, and applied again and again they cut a 1024×10241024 \times 1024 product from about 1.07 billion multiplications to about 282 million.

Each entry required n=3n = 3 multiplications and n−1=2n - 1 = 2 additions. The full product required m×p=4m \times p = 4 such computations.

The same count works for any sizes. Each of the mpmp entries of the product needs nn multiplications, so multiplying an m×nm \times n matrix by an n×pn \times p matrix straight from the definition takes mnpmnp multiplications in all. For two square n×nn \times n matrices that is n3n^3: 88 for 2×22 \times 2 matrices, 10001000 for 10×1010 \times 10 matrices, and a million for 100×100100 \times 100 matrices.

Pitfall: Multiplying entry by entry
Multiplying matching positions turns (1234)(5678)\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}\begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix} into (5122132)\begin{pmatrix} 5 & 12 \\ 21 & 32 \end{pmatrix}, the Hadamard product, not ABAB. The row-by-column rule gives (19224350)\begin{pmatrix} 19 & 22 \\ 43 & 50 \end{pmatrix}.

Every entry of the product draws on a whole row of the left factor and a whole column of the right factor. The entry 2929, in row 22 and column 22, combines the second row (2,−1,4)(2, -1, 4) of the left matrix with the second column (1,−3,6)(1, -3, 6) of the right one: three products, added together. The same pattern produces the other three entries, and it works the same way whatever the sizes of the two factors.
A2×3a1,1a1,2a1,3a2,1a2,2a2,3×B3×2b1,1b1,2b2,1b2,2b3,1b3,2=C2×2c1,1c1,2c2,1c2,2
One entry of AB, from a row and a column

The highlighted entry is being built by pairing the marked row of A with the marked column of B, multiplying term by term and summing. Every entry of the product costs one such pass, which is where the shape rule comes from: the row and the column have to be the same length or the pairing runs out. Switch between the row-column, column, and outer-product readings on the matrix multiplication visualizer.

This single-entry view is the definition; the column and row readings later on the page are the same arithmetic grouped differently.

Matrix Multiplication — Properties

Matrix multiplication obeys several familiar algebraic rules and violates one that is deeply ingrained from scalar arithmetic.

Associativity holds whenever all products are defined:

Matrix Multiplication Associativity
(AB)C=A(BC)(AB)C = A(BC)

Distribution holds on both sides:

Matrix Multiplication Distributivity
A(B+C)=AB+AC,(A+B)C=AC+BCA(B + C) = AB + AC, \quad (A + B)C = AC + BC

Scalars pass through freely: c(AB)=(cA)B=A(cB)c(AB) = (cA)B = A(cB). The identity matrix satisfies AI=IA=AAI = IA = A whenever the dimensions are compatible.

Commutativity, however, fails:

Matrix Multiplication Non-Commutativity
AB≠BA in generalAB \neq BA \text{ in general}

Even when both products happen to be defined, they generally produce different results. For a concrete counterexample, take A=(1200)A = \begin{pmatrix} 1 & 2 \\ 0 & 0 \end{pmatrix} and B=(0034)B = \begin{pmatrix} 0 & 0 \\ 3 & 4 \end{pmatrix}. Then AB=(6800)AB = \begin{pmatrix} 6 & 8 \\ 0 & 0 \end{pmatrix} while BA=(0036)BA = \begin{pmatrix} 0 & 0 \\ 3 & 6 \end{pmatrix}.

Two further properties distinguish matrix multiplication from scalar multiplication. The product of two nonzero matrices can be zero: if A=(1224)A = \begin{pmatrix} 1 & 2 \\ 2 & 4 \end{pmatrix} and B=(2−4−12)B = \begin{pmatrix} 2 & -4 \\ -1 & 2 \end{pmatrix}, then AB=OAB = O even though neither AA nor BB is zero. Cancellation also fails: AB=ACAB = AC does not imply B=CB = C unless AA is invertible.
Matrix · multiplication

Which laws survive the product

Matrix multiplication inherits most of scalar arithmetic and breaks three rules that are deeply ingrained from it. Every entry states its condition; every failure exhibits the pair that breaks it.

08laws
Unconditional5
i
Associativity(AB)C=A(BC)(AB)C = A(BC)
Lets you drop parentheses entirely in a chain of products — the reason matrix powers are well…
Unconditional
Requires
all products defined

Lets you drop parentheses entirely in a chain of products — the reason matrix powers are well defined without bracketing.

ii
Left distributionA(B+C)=AB+ACA(B + C) = AB + AC
Unconditional
Requires
B,CB, C same shape
iii
Right distribution(A+B)C=AC+BC(A + B)C = AC + BC
Left and right distribution are separate statements and each must be checked, precisely because…
Unconditional
Requires
A,BA, B same shape

Left and right distribution are separate statements and each must be checked, precisely because the product does not commute.

iv
Scalar passagec(AB)=(cA)B=A(cB)c(AB) = (cA)B = A(cB)
Unconditional
Requires
any scalar cc
v
IdentityAI=IA=AAI = IA = A
The one place commutativity is guaranteed — I commutes with everything its shape allows.
Unconditional
Requires
conformable dimensions

The one place commutativity is guaranteed — II commutes with everything its shape allows.

Fails or undefined3
vi
CommutativityAB≠BAAB \neq BA in general
The most consequential failure in the subject.
Fails
Holds when
both diagonal, or B=A−1B = A^{-1}, or B=IB = I

The most consequential failure in the subject. It is why the transpose reverses order and why similarity rather than equality is the working notion of "same transformation".

WitnessA = [[1, 2], [0, 0]], B = [[0, 0], [3, 4]]
AB = [[6, 8], [0, 0]]
BA = [[0, 0], [3, 6]]
vii
Zero-product lawAB=O⇏A=OAB = O \nRightarrow A = O or B=OB = O
Matrices are not an integral domain.
Fails
Holds when
either factor invertible

Matrices are not an integral domain. Two nonzero matrices can annihilate each other — which is what a nontrivial null space means at the level of the whole product.

WitnessA = [[1, 2], [2, 4]], B = [[2, −4], [−1, 2]]
AB = O, with neither factor zero
viii
CancellationAB=AC⇏B=CAB = AC \nRightarrow B = C
Fails
Holds when
AA invertible
Fails when
AA singular
WitnessA = [[1, 0], [0, 0]]
B = [[1, 1], [1, 1]], C = [[1, 1], [2, 2]]
AB = AC = [[1, 1], [0, 0]] but B ≠ C
Unconditional
Fails or undefined
AssociativityUnconditional
(AB)C=A(BC)(AB)C = A(BC)
Requires
all products defined
Lets you drop parentheses entirely in a chain of products — the reason matrix powers are well defined without bracketing.
Left distributionUnconditional
A(B+C)=AB+ACA(B + C) = AB + AC
Requires
B,CB, C same shape
Right distributionUnconditional
(A+B)C=AC+BC(A + B)C = AC + BC
Requires
A,BA, B same shape
Left and right distribution are separate statements and each must be checked, precisely because the product does not commute.
Scalar passageUnconditional
c(AB)=(cA)B=A(cB)c(AB) = (cA)B = A(cB)
Requires
any scalar cc
IdentityUnconditional
AI=IA=AAI = IA = A
Requires
conformable dimensions
The one place commutativity is guaranteed — II commutes with everything its shape allows.
CommutativityFails
AB≠BAAB \neq BA in general
Holds when
both diagonal, or B=A−1B = A^{-1}, or B=IB = I
The most consequential failure in the subject. It is why the transpose reverses order and why similarity rather than equality is the working notion of "same transformation".
WitnessA = [[1, 2], [0, 0]], B = [[0, 0], [3, 4]]
AB = [[6, 8], [0, 0]]
BA = [[0, 0], [3, 6]]
Zero-product lawFails
AB=O⇏A=OAB = O \nRightarrow A = O or B=OB = O
Holds when
either factor invertible
Matrices are not an integral domain. Two nonzero matrices can annihilate each other — which is what a nontrivial null space means at the level of the whole product.
WitnessA = [[1, 2], [2, 4]], B = [[2, −4], [−1, 2]]
AB = O, with neither factor zero
CancellationFails
AB=AC⇏B=CAB = AC \nRightarrow B = C
Holds when
AA invertible
Fails when
AA singular
WitnessA = [[1, 0], [0, 0]]
B = [[1, 1], [1, 1]], C = [[1, 1], [2, 2]]
AB = AC = [[1, 1], [0, 0]] but B ≠ C
Three of eight fail. Each failure traces back to the same root — a matrix can collapse directions, and a collapsed direction cannot be recovered. That is what invertibility restores, and why every "holds when" below names it.
Which laws survive the product·/linear-algebra/matrix/operationsLearn Math Class

Matrix Multiplication — Column and Row Interpretations

The entry-by-entry formula is the most common way to define matrix multiplication, but two alternative viewpoints often provide sharper insight.

The column interpretation says that column jj of ABAB is obtained by multiplying AA times column jj of BB:

Matrix Multiplication — Column and Row Interpretations
AB=(Ab1Ab2⋯Abp)AB = \begin{pmatrix} A\mathbf{b}_1 & A\mathbf{b}_2 & \cdots & A\mathbf{b}_p \end{pmatrix}

Each column of the product is a linear combination of the columns of AA, with weights given by the corresponding column of BB. This is the view that connects matrix multiplication to linear transformations: the product ABAB applies the transformation AA to each column of BB independently.

The row interpretation says that row ii of ABAB equals row ii of AA times the entire matrix BB. Each row of the product is a linear combination of the rows of BB, weighted by the entries in the corresponding row of AA.

A third perspective writes the product as a sum of rank-one outer products:

Matrix Multiplication — Column and Row Interpretations
AB=∑k=1n(column k of A)(row k of B)AB = \sum_{k=1}^{n} (\text{column } k \text{ of } A)(\text{row } k \text{ of } B)

Each term is an m×pm \times p matrix of rank at most one, and their sum is the full product. This decomposition appears in low-rank approximation theory and in the analysis of the singular value decomposition.
Matrix · multiplication

Four ways to read the same product

Every row computes ABAB and every row gives the same answer. What differs is the unit being assembled — a scalar, a column, a row, or a whole rank-one matrix — and each unit makes a different fact obvious.

4readings
One number at a time1
Entry view§ 5the definition
assembled froma single scalar (AB)ij(AB)_{ij}
formula(AB)ij=∑kaikbkj(AB)_{ij} = \sum_k a_{ik}b_{kj}
natural wherehand computation, proofs
Row ii of AA dotted with column jj of BB. Correct and unilluminating — it says how to get a number out but not what the product is, which is why the three readings below exist.
One vector at a time2
Column view§ 7read BB column by column
assembled froma column of ABAB
formulacolumn jj of AB=AbjAB = A\mathbf{b}_j
natural wherecolumn space, transformations
Each column of the product is AA applied to the corresponding column of BB — so every column of ABAB is a linear combination of the columns of AA. This is why Col⁡(AB)⊆Col⁡(A)\operatorname{Col}(AB) \subseteq \operatorname{Col}(A), and hence why the rank of a product is bounded.
Row view§ 7read AA row by row
assembled froma row of ABAB
formularow ii of AB=aiBAB = \mathbf{a}_i B
natural whererow space, elimination
The mirror statement: every row of ABAB is a combination of the rows of BB. This is the reading that explains why row operations — which are left multiplications — preserve the row space.
One matrix at a time1
Outer product sum§ 7pair column kk of AA with row kk of BB
assembled froma rank-one matrix
formulaAB=∑kakbkTAB = \sum_k \mathbf{a}_k \mathbf{b}_k^{\mathsf{T}}
natural whereSVD, low-rank approximation
The product as a sum of rank-one pieces. Truncating that sum is exactly what low-rank approximation does, which makes this the reading that matters most in practice and the one taught last.
The definition is the entry view, but it is the one that explains least. Each of the other three is the same sum regrouped, and each is the natural reading somewhere else in the subject — the column view for linear combinations, the outer product for low-rank approximation.
Four ways to read the same product·/linear-algebra/matrix/operationsLearn Math Class
The two vector readings are worth holding together, because between them they explain the rank bound. Every column of ABAB is a combination of the columns of AA, so the column space of the product sits inside that of AA; every row is a combination of the rows of BB, so the row space sits inside that of BB. Rank is the dimension of either, so rank⁡(AB)\operatorname{rank}(AB) cannot exceed the smaller of the two — which is the inequality stated without proof on the rank page.
510-22468v1r1v2r2v3r3vᵀA
The product assembled from the rows

Every piece drawn here is a row of the right-hand factor scaled by an entry of the left-hand row, laid tail to head until the row of the product is reached. Read this way the product never mentions a single entry: one whole row is consumed per step, which is what the row interpretation above claims and what makes the count of steps equal to the number of rows rather than to the number of entries. Follow one row at a time on the row picture visualizer.

The outer-product form below is the third reading of the same product, assembling it from whole columns and rows at once rather than one at a time.

The Transpose

The transpose of an m×nm \times n matrix AA is the n×mn \times m matrix ATA^T obtained by converting rows into columns:

Transpose Definition
(AT)ij=aji(A^T)_{ij} = a_{ji}

For example,

The Transpose
A=(123456)⟹AT=(142536)A = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatrix} \quad \Longrightarrow \quad A^T = \begin{pmatrix} 1 & 4 \\ 2 & 5 \\ 3 & 6 \end{pmatrix}

Applying the transpose twice recovers the original matrix:

Transpose Involution
(AT)T=A(A^T)^T = A

The transpose distributes over addition:

Transpose of Sum
(A+B)T=AT+BT(A + B)^T = A^T + B^T

and commutes with scalar multiplication:

Transpose of Scalar Multiple
(cA)T=c AT(cA)^T = c\, A^T

The product rule reverses the order:

Transpose of Product
(AB)T=BTAT(AB)^T = B^T A^T

This reversal is a frequent source of errors and is worth memorizing as a pattern: transposing a product is like reading it backward.

A matrix satisfying A=ATA = A^T is called symmetric.

COROLLARY
For any matrix AA of any shape, the products ATAA^T A and AATAA^T are both symmetric — this is immediate from the product rule, since (ATA)T=AT(AT)T=ATA(A^T A)^T = A^T (A^T)^T = A^T A.
A3×4a1,1a1,2a1,3a1,4a2,1a2,2a2,3a2,4a3,1a3,2a3,3a3,4→AT4×3a1,1a2,1a3,1a1,2a2,2a3,2a1,3a2,3a3,3a1,4a2,4a3,4
Reflection across the main diagonal

Every entry has swapped places with its mirror image across the diagonal, and the entries sitting on the diagonal have not moved at all. Read that way the transpose is one reflection rather than a rule about indices, and it explains at a glance why transposing twice returns the original. Watch it run cell by cell instead on the transpose visualizer.

Because the diagonal is fixed, a matrix equal to its own transpose is exactly one that is symmetric about that line.

Matrix Powers

For a square matrix AA, powers are defined by repeated multiplication:

Matrix Power
A0=I,A1=A,Ak=A⋅A⋯A⏟k factorsA^0 = I, \quad A^1 = A, \quad A^k = \underbrace{A \cdot A \cdots A}_{k \text{ factors}}

RULE
The usual exponent laws hold: AjAk=Aj+kA^j A^k = A^{j+k} and (Aj)k=Ajk(A^j)^k = A^{jk}.

When AA is invertible, negative powers are defined as A−k=(A−1)kA^{-k} = (A^{-1})^k, extending the exponent laws to all integers.

One rule from scalar arithmetic does not carry over. Since matrix multiplication is not commutative, the identity (AB)k=AkBk(AB)^k = A^k B^k is false in general. Expanding (AB)2=ABAB(AB)^2 = ABAB, there is no way to rearrange this into A2B2=AABBA^2 B^2 = AABB without commutativity.

Pitfall: Squaring a sum as with numbers
Writing (A+B)2=A2+2AB+B2(A + B)^2 = A^2 + 2AB + B^2 merges ABAB and BABA. With AA and BB from the commutativity counterexample, it gives (13181216)\begin{pmatrix} 13 & 18 \\ 12 & 16 \end{pmatrix}, but (A+B)2=A2+AB+BA+B2=(7101522)(A + B)^2 = A^2 + AB + BA + B^2 = \begin{pmatrix} 7 & 10 \\ 15 & 22 \end{pmatrix}.

Squaring a sum is where this matters most often. The square (A+B)2(A + B)^2 is the product (A+B)(A+B)(A + B)(A + B), and it is expanded with the two distributive laws from the properties section, exactly as a product of two different sums would be. Only after the expansion is it clear which of the resulting terms can be combined.

Powers of specific matrix types are particularly well-behaved. For a diagonal matrix D=diag(d1,…,dn)D = \text{diag}(d_1, \dots, d_n), the kk-th power is Dk=diag(d1k,…,dnk)D^k = \text{diag}(d_1^k, \dots, d_n^k) — each diagonal entry is raised to the kk-th power independently. This simplicity is one of the main reasons diagonalization is so useful: writing A=PDP−1A = PDP^{-1} gives Ak=PDkP−1A^k = PD^kP^{-1}, reducing an expensive matrix power to a cheap diagonal power.
A²2×2a1,1​a1,1​+a1,2​a2,1​a1,1​a1,2​+a1,2​a2,2​a2,1​a1,1​+a2,2​a2,1​a2,1​a1,2​+a2,2​a2,2​·A2×2a1,1a1,2a2,1a2,2·A2×2a1,1a1,2a2,1a2,2
A⁴ one product at a time

A⁴ is four copies of A multiplied together. The first product has already been carried out here: A² is written out cell by cell, and it still has to be multiplied by A twice more. Each step is an ordinary matrix product, which is why a power needs a square matrix — every factor must fit the next. Collapse the chain step by step on the matrix power visualizer.

Associativity is what lets the chain be collapsed in any grouping and still give the same A⁴.

Elementary Matrices

An elementary matrix is the result of performing a single row operation on the identity matrix. There are three types, corresponding to the three row operations: swapping two rows, multiplying a row by a nonzero scalar, and adding a multiple of one row to another.

The key property is that left-multiplying a matrix AA by an elementary matrix EE performs the corresponding row operation on AA. If EE swaps rows 22 and 33 of the identity, then EAEA swaps rows 22 and 33 of AA. If EE scales row 11 of the identity by 55, then EAEA scales row 11 of AA by 55.

THEOREM
Every elementary matrix is invertible, and its inverse is another elementary matrix of the same type: the inverse of a row swap is the same row swap, the inverse of scaling by kk is scaling by 1/k1/k, and the inverse of adding cc times row ii to row jj is subtracting cc times row ii from row jj.

Pitfall: Multiplying on the wrong side
Writing AEAE instead of EAEA for the row swap E=(0110)E = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} and A=(1234)A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} gives (2143)\begin{pmatrix} 2 & 1 \\ 4 & 3 \end{pmatrix}, with the columns swapped. The row swap is EA=(3412)EA = \begin{pmatrix} 3 & 4 \\ 1 & 2 \end{pmatrix}.

This leads to a structural result: every invertible matrix can be written as a product of elementary matrices. Since Gaussian elimination reduces an invertible matrix to the identity through a sequence of row operations, each operation corresponds to an elementary matrix, and reversing the sequence expresses the original matrix as their product. This factorization is more conceptual than computational, but it underpins the theoretical foundations of the determinant and the inverse.

Every row operation is a left multiplication by an elementary matrix, so Gaussian elimination is a chain of matrix products.

Matrix Decompositions

A matrix decomposition (or factorization) expresses a matrix as a product of simpler matrices with known structure. Decompositions are among the most powerful tools in computational linear algebra, converting hard problems into sequences of easy ones.

The LU decomposition writes A=LUA = LU where LL is lower triangular and UU is upper triangular. It captures the essence of Gaussian elimination in matrix form and makes solving linear systems with multiple right-hand sides efficient: once LL and UU are known, each system reduces to two triangular solves.

The QR decomposition writes A=QRA = QR where QQ is orthogonal and RR is upper triangular. It is the foundation of least-squares computation and several eigenvalue algorithms.

The Cholesky decomposition writes A=LLTA = LL^T for symmetric positive definite matrices, achieving the work of LU in roughly half the computation by exploiting symmetry.

The eigendecomposition writes A=PDP−1A = PDP^{-1} where DD is diagonal, placing the eigenvalues on the diagonal and the eigenvectors in the columns of PP. It applies only to diagonalizable matrices.

The singular value decomposition writes A=UΣVTA = U\Sigma V^T where UU and VV are orthogonal and Σ\Sigma is diagonal with nonnegative entries. Unlike the eigendecomposition, the SVD exists for every matrix of every shape. It reveals the rank, the fundamental subspaces, and the best low-rank approximation to AA, making it one of the most broadly applicable tools in the subject.

Each of these decompositions has its own page with full derivations and worked examples.
Decomposition Form Requires Primary use
LU A = LU (L lower, U upper triangular) any square matrix (with pivoting) solving Ax = b for many right-hand sides
QR A = QR (Q orthogonal, R upper triangular) any matrix least squares, eigenvalue algorithms
Cholesky A = LLᵀ symmetric positive definite half-cost LU for SPD systems
Eigendecomposition A = PDP⁻¹ (D diagonal) diagonalizable square matrix matrix powers, spectral analysis
SVD A = UΣVᵀ (U, V orthogonal; Σ diagonal ≥ 0) any matrix of any shape rank, fundamental subspaces, best low-rank approximation

Two More Products: Hadamard and Outer

Two products sit outside the main family but appear often enough to deserve their own rules.

The Hadamard product A∘BA \circ B, also written A⊙BA \odot B, multiplies entry by entry: (A∘B)ij=aij bij(A \circ B)_{ij} = a_{ij}\,b_{ij}. Both matrices must share the same m×nm \times n shape, and the result has that shape too. Because positions never mix, it inherits the arithmetic of ordinary numbers: it is commutative, associative, and distributes over addition. It has nothing to do with ABAB. For a 2×22 \times 2 matrix, A∘IA \circ I keeps only the diagonal of AA, while AI=AAI = A.

The outer product uvT\mathbf{u}\mathbf{v}^T is ordinary matrix multiplication applied to a column with mm entries and a row with nn entries. The inner dimensions are both 11, so the product exists for any two lengths and gives an m×nm \times n matrix with entries uivju_i v_j:

Two More Products: Hadamard and Outer
uvT=(12)(345)=(3456810)\mathbf{u}\mathbf{v}^T = \begin{pmatrix} 1 \\ 2 \end{pmatrix} \begin{pmatrix} 3 & 4 & 5 \end{pmatrix} = \begin{pmatrix} 3 & 4 & 5 \\ 6 & 8 & 10 \end{pmatrix}

Every column is a multiple of u\mathbf{u} and every row a multiple of vT\mathbf{v}^T, so the result has rank one whenever both vectors are non-zero. The dot product is the same two vectors multiplied in the other order, vTu\mathbf{v}^T\mathbf{u}, which collapses to a single number; the outer product spreads them into a table instead.

Both products have their own visual tools: the Hadamard product and the outer product.

Dimension Summary

Fact: Same product, ten times the work
For AA of size 10×10010 \times 100, BB of size 100×5100 \times 5 and CC of size 5×505 \times 50, the route (AB)C(AB)C passes through the small 10×510 \times 5 matrix ABAB and takes 5,000 + 2,500 = 7,500 multiplications. The route A(BC)A(BC) passes through the 100×50100 \times 50 matrix BCBC and takes 25,000 + 50,000 = 75,000.

The dimension requirements for each operation are worth collecting in one place. Addition and subtraction require both matrices to share the same m×nm \times n dimensions, and the result is m×nm \times n. Scalar multiplication imposes no restriction and preserves the original dimensions. The product ABAB requires the column count of AA to match the row count of BB — if AA is m×nm \times n and BB is n×pn \times p, the result is m×pm \times p. The transpose of an m×nm \times n matrix is n×mn \times m. Powers AkA^k require AA to be square and produce a matrix of the same size.

A common source of confusion is the product rule. The product of two n×nn \times n matrices is n×nn \times n, but the product of a 2×32 \times 3 matrix with a 3×53 \times 5 matrix is 2×52 \times 5. The "inner" dimensions must match and are consumed; the "outer" dimensions survive into the result.
Operation Input requirement Result size Key property
Addition / subtraction A and B both m × n m × n commutative; additive identity O
Scalar multiplication A is m × n; c any scalar m × n distributes over both matrix and scalar sum
Linear combination all Aᵢ same m × n shape m × n turns m × n matrices into a vector space of dimension mn
Matrix multiplication A is m × n, B is n × p  (inner dims match) m × p associative, NOT commutative; inner dim consumed
Transpose A is m × n (no other restriction) n × m (Aᵀ)ᵀ = A; (AB)ᵀ = BᵀAᵀ (order reverses)
Power Aᵏ A square (n × n), k ≥ 0 (or k ∈ ℤ if invertible) n × n Aʲ Aᵏ = Aʲ⁺ᵏ; (AB)ᵏ ≠ Aᵏ Bᵏ in general

Common Pitfalls

Four mistakes account for many wrong answers in matrix arithmetic. Three are marked with a box where they happen in the sections above, and the fourth, the order of a transposed product, is flagged in the transpose section. Here each is worked through in full, with the wrong and the right working side by side.

Multiplying entry by entry

The product ABAB is computed by multiplying the entries that sit in the same position, the way matrices are added. Rows and columns are never combined.

Wrong working:
(1234)(5678)=(1⋅52⋅63⋅74⋅8)=(5122132)\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}\begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix} = \begin{pmatrix} 1 \cdot 5 & 2 \cdot 6 \\ 3 \cdot 7 & 4 \cdot 8 \end{pmatrix} = \begin{pmatrix} 5 & 12 \\ 21 & 32 \end{pmatrix}


Right working: each entry is a row of the left matrix times a column of the right matrix.
(1234)(5678)=(1⋅5+2⋅71⋅6+2⋅83⋅5+4⋅73⋅6+4⋅8)=(19224350)\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}\begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix} = \begin{pmatrix} 1 \cdot 5 + 2 \cdot 7 & 1 \cdot 6 + 2 \cdot 8 \\ 3 \cdot 5 + 4 \cdot 7 & 3 \cdot 6 + 4 \cdot 8 \end{pmatrix} = \begin{pmatrix} 19 & 22 \\ 43 & 50 \end{pmatrix}


Why it happens: addition, subtraction and scalar multiplication really do work position by position, and the entry-by-entry product exists as an operation of its own, the Hadamard product. The pattern is carried over to ABAB.

How to check: multiply by the identity matrix, which must return the matrix unchanged. With the row-times-column rule, AI=AAI = A. Entry by entry, (1234)\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} and II give (1004)\begin{pmatrix} 1 & 0 \\ 0 & 4 \end{pmatrix}, only the diagonal.

Keeping the order when transposing a product

The transpose is applied to each factor of a product, but the factors are left in their original order: (AB)T(AB)^T is written as ATBTA^T B^T.

Wrong working: take the matrices of the worked example, A=(1032−14)A = \begin{pmatrix} 1 & 0 & 3 \\ 2 & -1 & 4 \end{pmatrix} and B=(512−306)B = \begin{pmatrix} 5 & 1 \\ 2 & -3 \\ 0 & 6 \end{pmatrix}. Then ATA^T is 3×23 \times 2, BTB^T is 2×32 \times 3, and
ATBT=(7−412−13−619−624)A^T B^T = \begin{pmatrix} 7 & -4 & 12 \\ -1 & 3 & -6 \\ 19 & -6 & 24 \end{pmatrix}

a 3×33 \times 3 matrix, although ABAB is 2×22 \times 2.

Right working: the order reverses.
(AB)T=BTAT=(581929)(AB)^T = B^T A^T = \begin{pmatrix} 5 & 8 \\ 19 & 29 \end{pmatrix}

which is exactly AB=(519829)AB = \begin{pmatrix} 5 & 19 \\ 8 & 29 \end{pmatrix} with its rows and columns exchanged.

Why it happens: the transpose distributes over a sum, (A+B)T=AT+BT(A + B)^T = A^T + B^T, with no change of order, and the same pattern is carried over to products.

How to check: compare sizes. If AA is m×nm \times n and BB is n×pn \times p, then (AB)T(AB)^T is p×mp \times m. The product BTATB^T A^T has that size, while ATBTA^T B^T is defined only when m=pm = p, and even then it is n×nn \times n.

Squaring a sum as with numbers

(A+B)2(A + B)^2 is expanded with the formula from ordinary algebra, and the two middle terms ABAB and BABA are merged into 2AB2AB.

Wrong working: with A=(1200)A = \begin{pmatrix} 1 & 2 \\ 0 & 0 \end{pmatrix} and B=(0034)B = \begin{pmatrix} 0 & 0 \\ 3 & 4 \end{pmatrix} from the commutativity counterexample,
A2+2AB+B2=(1200)+(121600)+(001216)=(13181216)A^2 + 2AB + B^2 = \begin{pmatrix} 1 & 2 \\ 0 & 0 \end{pmatrix} + \begin{pmatrix} 12 & 16 \\ 0 & 0 \end{pmatrix} + \begin{pmatrix} 0 & 0 \\ 12 & 16 \end{pmatrix} = \begin{pmatrix} 13 & 18 \\ 12 & 16 \end{pmatrix}


Right working: distribute without reordering, so both ABAB and BABA appear.
(A+B)2=A2+AB+BA+B2(A + B)^2 = A^2 + AB + BA + B^2

=(1200)+(6800)+(0036)+(001216)=(7101522)= \begin{pmatrix} 1 & 2 \\ 0 & 0 \end{pmatrix} + \begin{pmatrix} 6 & 8 \\ 0 & 0 \end{pmatrix} + \begin{pmatrix} 0 & 0 \\ 3 & 6 \end{pmatrix} + \begin{pmatrix} 0 & 0 \\ 12 & 16 \end{pmatrix} = \begin{pmatrix} 7 & 10 \\ 15 & 22 \end{pmatrix}


Why it happens: the formula (a+b)2=a2+2ab+b2(a + b)^2 = a^2 + 2ab + b^2 is so familiar that the step ba=abba = ab hidden inside it goes unnoticed.

How to check: add first, then square. A+B=(1234)A + B = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}, and its square is (7101522)\begin{pmatrix} 7 & 10 \\ 15 & 22 \end{pmatrix}, the same as the four-term expansion. The two-term middle 2AB2AB is correct only when AB=BAAB = BA.

Multiplying on the wrong side

To perform a row operation, the elementary matrix is placed to the right of AA. Multiplying on the right acts on the columns, so the operation lands on the columns instead of the rows.

Wrong working: with E=(0110)E = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}, the identity with its two rows swapped, and A=(1234)A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix},
AE=(2143)AE = \begin{pmatrix} 2 & 1 \\ 4 & 3 \end{pmatrix}

The two columns of AA have traded places; the rows have not.

Right working:
EA=(3412)EA = \begin{pmatrix} 3 & 4 \\ 1 & 2 \end{pmatrix}

which is AA with rows 11 and 22 swapped.

Why it happens: the operation is done to AA, so AA is written first and EE is attached after it. For a row swap the slip is hard to see, because the same EE is also the identity with two columns swapped.

How to check: every row of a row-swapped matrix must be a row of AA. The first row of AEAE is (2,1)(2, 1), which is not a row of AA; the rows of EAEA are (3,4)(3, 4) and (1,2)(1, 2).

Matrix Operations FAQ

Does a23a_{23} mean row 2 column 3, or row 3 column 2?

+
Row first, column second, always: a23a_{23} sits in row 22, column 33. The size m×nm \times n follows the same order, rows then columns. Reversing the pair names a different entry, since aija_{ij} and ajia_{ji} agree only when the matrix is symmetric, and swapping them is precisely what the transpose does.Read more →

Is (A+B)2(A + B)^2 equal to A2+2AB+B2A^2 + 2AB + B^2?

+
No. Expanding gives four terms, A2+AB+BA+B2A^2 + AB + BA + B^2, and they cannot be merged because ABAB and BABA are generally different matrices. The same warning applies to cancellation: from AB=ACAB = AC nothing follows about BB and CC. The notation borrows the look of ordinary algebra without the behaviour.Read more →

Why is matrix multiplication written with no symbol at all?

+
Juxtaposition is the convention: ABAB, with no dot and no cross. The bare notation hides a shape contract, since an m×nm \times n times an n×pn \times p works only because the inner dimensions agree, producing m×pm \times p. Note that the ×\times in m×nm \times n is a dimension separator and multiplies nothing.Read more →