Algebra • Linear Algebra & Vector Spaces

Matrix Calculator

Perform dual-matrix operations A + B, A − B, and A × B, resize grids dynamically from 1×1 to 5×5, or compute single-matrix properties including determinants, matrix inverses A−¹, rank, trace, powers, and Reduced Row Echelon Form (RREF) with exact arithmetic.

|
Last Updated: September 2026
|
Linear Algebra & Numerical Analysis Verified

Matrix A (3 × 3)

Rows:
3
Cols:
3
[
]

Matrix B (3 × 3)

Rows:
3
Cols:
3
[
]
Select Operation:
Computed Result
[
]
Matrix A Key Invariants
Step-by-Step Derivation Exact Arithmetic Walkthrough
Direct Answer & Overview
Verified Educational Guide

How Matrix Operations & Multiplication Work

A matrix is an ordered rectangular array of numbers arranged into m rows and n columns. Matrix addition and subtraction require identical dimensions (m × n) and operate entry-wise. Matrix multiplication (A × B) requires the column count of A to equal the row count of B, producing an (m × p) product where each entry C[i,j] is the vector dot product of row i from A and column j from B.

Primary Mathematical Formula Universal Matrix Multiplication & Inversion Formulas
Standard Equation
ƒ(x)
Q.E.D.
Ci,j=∑k=1nAi,kBk,jandA−1=1det⁡(A)adj⁡(A)C_{i,j} = \sum_{k=1}^n A_{i,k} B_{k,j} \quad\text{and}\quad A^{-1} = \frac{1}{\det(A)} \operatorname{adj}(A)
Matrix multiplication is associative [A(BC) = (AB)C] and distributive [A(B + C) = AB + AC], but strictly non-commutative [AB ≠ BA].
Exact Formula
Input Parameters
Required
1
Matrix A: Dimensions (m × n) with numeric entries
2
Matrix B: Dimensions (n × p) for multiplication, or (m × n) for addition/subtraction
3
Target Operation: Addition, Multiplication, Inverse, Determinant, Trace, Rank, or RREF
Expected Outputs
Calculated
Resulting Matrix: Computed step-by-step with exact fractional or decimal arithmetic
Scalar Properties: Determinant det(A), Matrix Rank, and Matrix Trace tr(A)
Worked Numerical Example
Instant Verification
2×2 Determinant of [[3, 8], [4, 6]]
→ det(A) = (3 × 6) − (8 × 4) = 18 − 32 = −14
det(A) = −14 (Matrix is non-singular and invertible)

What Is a Matrix?

A matrix is an ordered two-dimensional rectangular array of mathematical elements (numbers, variables, or functions) arranged into horizontal rows and vertical columns. Developed formally by 19th-century mathematicians Arthur Cayley, James Joseph Sylvester, and William Rowan Hamilton, matrix algebra serves as the primary computational language of modern engineering, 3D graphics rendering, statistical regression, quantum mechanics, and deep neural networks.

Dimensions, Indexing & Notation

The dimensions of a matrix are stated as m × n (read "m by n"), where m is the number of rows and n is the number of columns. An individual entry located at row i and column j is denoted as aij or A[i, j]:

A = [ a11   a12   …   a1n ;   a21   a22   …   a2n ;   … ;   am1   am2   …   amn ]
Square Matrix

Equal rows and columns (m = n). Possesses determinants, traces, and potential inverses.

Identity Matrix (I)

Diagonal entries are 1; all off-diagonal entries are 0. Acts as multiplicative unity: AI = IA = A.

Symmetric Matrix

Equal to its own transpose (A = Aᵀ). All eigenvalues are strictly real numbers.

Matrix Operations: Rules & Dimension Criteria

Matrix arithmetic operations depend strictly on dimensional compatibility. Violating dimensional criteria makes the operation mathematically undefined:

Entry-Wise Arithmetic

Addition, Subtraction & Scalar Scaling

  • Matrix Addition (A + B): Both matrices must have identical dimensions (m × n). Entries are summed position by position: C[i,j] = A[i,j] + B[i,j].
  • Matrix Subtraction (A − B): Requires matching dimensions (m × n): C[i,j] = A[i,j] − B[i,j].
  • Scalar Multiplication (c × A): Any real scalar c multiplies every entry: (cA)[i,j] = c × A[i,j].
Vector Dot Products

Matrix Multiplication (A × B)

Matrix multiplication is not entry-by-entry; it is row-by-column vector dot multiplication:

(m × k) × (k × n) → (m × n)

The number of columns in A must equal the number of rows in B (k = k). Each output cell C[i,j] is the sum of products: C[i,j] = Σ A[i,k] × B[k,j].

Matrix Operations Comparison Table

The table below summarizes the dimension rules, mathematical notation, algebraic properties, and computational complexity of standard matrix operations:

Operation Formula Dimension Criteria Commutative? Complexity
Addition A + B Same (m × n) Yes (A+B = B+A) O(m × n)
Multiplication A × B Cols(A) = Rows(B) No (AB ≠ BA) O(m × k × n)
Scalar Scaling c × A Any (m × n) Yes (cA = Ac) O(m × n)
Transpose Aᵀ (m × n) → (n × m) N/A (Unary) O(m × n)
Determinant det(A) Square (n × n) N/A (Scalar) O(n³) via LU
Inverse A−¹ Square & det ≠ 0 AA−¹ = A−¹A = I O(n³) via Gauss
Trace tr(A) Square (n × n) tr(AB) = tr(BA) O(n)

Step-by-Step Worked Examples

Example 1: 2×2 Matrix Multiplication C = A × B

Given Matrix A = [[1, 2], [3, 4]] and Matrix B = [[5, 6], [7, 8]]:

C[1,1] = (1 × 5) + (2 × 7) = 5 + 14 = 19
C[1,2] = (1 × 6) + (2 × 8) = 6 + 16 = 22
C[2,1] = (3 × 5) + (4 × 7) = 15 + 28 = 43
C[2,2] = (3 × 6) + (4 × 8) = 18 + 32 = 50
Result: C = [ [19, 22], [43, 50] ]
Example 2: 3×3 Determinant via Laplace Expansion det(A) = −14

Evaluate det(A) for A = [[3, 2, −1], [1, 6, 3], [2, −4, 0]] along Row 1:

Minor 1: +3 × det([[6, 3], [−4, 0]]) = 3 × (0 − (−12)) = 3 × 12 = 36
Minor 2: −2 × det([[1, 3], [2, 0]]) = −2 × (0 − 6) = −2 × (−6) = +12
Minor 3: +(−1) × det([[1, 6], [2, −4]]) = −1 × (−4 − 12) = −1 × (−16) = +16
Total: 36 + 12 + 16 = 64
Example 3: Inverting a 2×2 Matrix A−¹ via Adjugate

Given A = [[4, 7], [2, 6]]:

1. Compute Determinant: det(A) = (4 × 6) − (7 × 2) = 24 − 14 = 10.
2. Construct Adjugate: Swap diagonal entries (4 ↔ 6) and negate off-diagonals: [[6, −7], [−2, 4]].
3. Multiply by 1 / det: (1 / 10) × [[6, −7], [−2, 4]].
Exact Inverse: [ [3/5, −7/10], [−1/5, 2/5] ] (Decimals: [ [0.6, −0.7], [−0.2, 0.4] ])

Determinants, Invertibility & Singular Matrices

The determinant is a unique scalar property of square matrices that measures how the matrix scales space. In 2D, |det(A)| represents the area scaling factor of a unit square transformed by A; in 3D, it represents the volume scaling factor of a unit cube.

Non-Singular Matrix (det ≠ 0)

If det(A) ≠ 0, the transformation is bijective (one-to-one and onto). Space is not flattened. The columns of A form a complete basis, the rank is full (rank = n), and an inverse matrix A−¹ exists such that A A−¹ = I.

Singular Matrix (det = 0)

If det(A) = 0, the transformation collapses dimensions (e.g. squashing a 3D volume onto a flat 2D plane or line). Because multiple original vectors are mapped to the same output vector, the operation cannot be reversed. Consequently, no inverse exists.

Common Pitfalls & Misconceptions

1. Assuming Matrix Multiplication Commutes (AB = BA)

In general, AB ≠ BA. Reversing the order produces completely different dot products, and often results in undefined dimension mismatches.

2. Attempting to Invert a Singular Matrix

If det(A) = 0, the formula A−¹ = (1 / det) × adj(A) requires dividing by zero. A singular matrix has no inverse.

3. Conflating Dot Product Multiplication with Element-Wise Multiplication

Do not multiply matching entries together when computing A × B. Element-wise multiplication is the Hadamard product (A ⊙ B), whereas standard matrix multiplication requires row-by-column dot product summation.

4. Forgetting the Reversal Property of Transposes and Inverses

When transposing or inverting a matrix product, the order of multiplication reverses: (AB)ᵀ = Bᵀ Aᵀ and (AB)−¹ = B−¹ A−¹.

Real-World Applications in Graphics, AI & Physics

3D Computer Graphics

Video game engines and GPU shaders use 4×4 homogeneous transformation matrices (MVP: Model-View-Projection) to concatenate 3D rotation, translation, camera viewing angle, and perspective projection into a single high-speed matrix multiply.

AI Large Language Models

Transformer neural networks execute multi-head self-attention via matrix multiplication: Attention(Q, K, V) = softmax(Q Kᵀ / √dk) V. Matrix multiply-accumulate (MAC) units on TPUs power modern generative AI.

Quantum Computing Gates

In quantum algorithms, quantum state vectors Ψ evolve via unitary matrices (U U† = I). Basic quantum logic gates like the Hadamard, Pauli-X, and CNOT gates are represented by 2×2 and 4×4 complex matrices.

Linear Algebra Suite & Advanced Solvers

Explore our complete suite of browser-native linear algebra solvers and geometric transformers:

Fact-Checked & Verified • Computational Accuracy Standards
Updated September 2026 • Editorial Policy
Authored By
Sanjay Samanta

Lead Developer & Founder of Basic Math Tools. Specializes in browser-native computational algorithms and applied mathematics.

Reviewed & Verified By
Academic Review Board

Mathematics & curriculum specialists. Audited against standard algebraic and arithmetic principles.

Found an error or have an improvement suggestion? Report a calculation issue

Frequently Asked Questions

What operations can this Matrix Calculator perform?
This calculator executes two-matrix operations including addition (A + B), subtraction (A − B), and multiplication (A × B) with dynamic grid dimensions from 1×1 to 5×5. For single matrices, it computes the determinant det(A), matrix inverse (A⁻¹), transpose (Aᵀ), matrix rank, trace tr(A), Reduced Row Echelon Form (RREF) via Gauss-Jordan elimination, scalar multiplication (c × A), and integer powers (Aᵏ).
What is the dimension requirement for matrix multiplication?
To multiply Matrix A by Matrix B, the number of columns in Matrix A must strictly equal the number of rows in Matrix B. If A has dimensions m × k and B has dimensions k × n, the resulting product matrix C = A × B has dimensions m × n. The shared inner dimension k cancels out during the row-by-column vector dot product accumulation.
Why is matrix multiplication non-commutative (A × B ≠ B × A)?
Matrix multiplication is fundamentally non-commutative because switching the order pairs different rows and columns during dot product computation. Furthermore, if Matrix A is 2 × 3 and Matrix B is 3 × 4, the product A × B is valid (yielding a 2 × 4 matrix), but B × A is mathematically undefined due to inner dimension mismatch (4 ≠ 2).
What is a singular matrix and why does it have no inverse?
A singular matrix is a square matrix whose determinant is exactly zero: det(A) = 0. Geometrically, multiplying by a matrix with det(A) = 0 collapses multidimensional space into a lower dimension (e.g. compressing a 2D plane into a 1D line or point), irreversibly losing information. Because no reverse linear transformation can reconstruct collapsed dimensions, a singular matrix has no multiplicative inverse A⁻¹.
What is Reduced Row Echelon Form (RREF)?
Reduced Row Echelon Form (RREF) is the standardized canonical echelon matrix produced by Gauss-Jordan elimination. In RREF: (1) every non-zero row begins with a leading 1 (a pivot); (2) every column containing a leading 1 has zeros in all other positions (both above and below); and (3) leading pivots move strictly to the right as you move down the rows. RREF directly exposes the solution set of linear systems.
What is the rank of a matrix and what does it tell you?
The rank of a matrix is the maximum number of linearly independent row vectors or column vectors it contains. It corresponds directly to the count of non-zero rows in its RREF. By the Rank-Nullity Theorem, Rank(A) + Nullity(A) = n (total columns), establishing the dimension of the column space and the dimension of the solution kernel.
How do you calculate the trace of a matrix?
The trace of an n × n square matrix, denoted tr(A), is the sum of its elements along the main diagonal from top-left to bottom-right: tr(A) = a₁₁ + a₂₂ + ... + aₙₙ. By the spectral theorem, the trace is invariant under basis changes and equals the sum of all complex eigenvalues of the matrix.