🔢 Matrix Calculator

Free online matrix calculator for linear algebra: add, subtract, multiply, transpose, find determinant, inverse, powers, and solve Ax=b — with step-by-step results.

What is Matrix Calculator?

A complete linear algebra workbench in the browser. Perform matrix arithmetic (A+B, A−B, A×B with dimension checking), scalar multiplication, transpose, determinant (with full step-by-step expansion for 2×2 and 3×3), inverse via the adjugate method, integer powers using exponentiation by squaring, and solve linear systems Ax = b for invertible square coefficient matrices. Inputs are editable grids from 1×1 up to 5×5, results animate in proper bracket notation, and every output is one click to copy.

How to Use

  1. Choose the operation tab — arithmetic (A ± × B), scalar k·A, transpose Aᵀ, determinant, inverse A⁻¹, power Aⁿ, or solve Ax = b.
  2. Set the size of matrix A using the +/− steppers (square sizes are auto-locked for determinant, inverse, power, and solve).
  3. Type values into the grid cells; for binary operations enter matrix B, for scalar enter k, for power enter integer n, for solve enter vector b.
  4. The result matrix or scalar updates live below in proper bracket notation, with step-by-step expansion shown for 2×2 and 3×3 determinants.
  5. Click Copy to grab the result as tab-separated rows you can paste into a spreadsheet or document.

How matrix operations work

A matrix is a rectangular grid of numbers organized into rows and columns. Addition and subtraction operate element-wise and require both matrices to share the same dimensions. Multiplication is more subtle: the entry at row i, column j of A × B equals the dot product of A i-th row with B j-th column, which forces A.cols to equal B.rows. The transpose Aᵀ flips rows and columns. The determinant is a single scalar that captures whether a square matrix is invertible (non-zero) and how it scales volume. This calculator computes determinants by recursive cofactor expansion along the first row.

Inverse, powers, and solving Ax = b

For an invertible square matrix A, the inverse A⁻¹ satisfies A · A⁻¹ = I. We compute it via the adjugate formula: A⁻¹ = (1/det A) · adj(A). If det(A) is zero the matrix is singular and no inverse exists — the calculator surfaces this with a clear error. Integer powers Aⁿ are computed using exponentiation by squaring, the same O(log n) trick used for modular exponentiation. To solve a square linear system Ax = b, the calculator multiplies x = A⁻¹ · b — fast and exact for the small matrices supported here.

Why size is capped at 5×5

Cofactor-expansion determinants grow factorially: a 5×5 needs 120 base operations, a 6×6 needs 720, a 10×10 would need over three million. While Gaussian elimination scales much better (O(n³)), keeping the input size at 5×5 ensures the tool stays responsive and the step-by-step output stays human-readable. For larger matrices reach for NumPy, MATLAB, Octave, or a CAS like SymPy or Wolfram Alpha — those use optimized BLAS/LAPACK routines that handle thousands of dimensions efficiently.

Frequently Asked Questions

When is matrix multiplication NOT commutative?

In general, A × B ≠ B × A. Matrix multiplication is non-commutative for almost all matrices — equality only holds in special cases (e.g. when one is the identity, both are diagonal, or one is a scalar multiple of the other). Order always matters in linear algebra.

When does a matrix have no inverse?

A square matrix is non-invertible (singular) exactly when its determinant is zero. Geometrically, this means the matrix collapses space onto a lower-dimensional subspace — its rows or columns are linearly dependent. The calculator returns an error and reports the determinant in this case.

What can I use matrix operations for in real life?

Linear algebra powers computer graphics transforms (rotation, scaling, projection), 3D game engines, machine learning (every neural network layer is a matrix multiply), solving systems of equations in engineering and economics, statistics (covariance matrices, PCA), cryptography (Hill cipher), and quantum mechanics.

What is the computational complexity?

Standard matrix multiplication is O(n³), determinant via cofactor expansion is O(n!) (which is why this tool caps at 5×5), and Gauss-Jordan inverse is O(n³). For the 1×1 to 5×5 range here everything runs in microseconds; larger matrices need numerical libraries like NumPy or BLAS.

Why does A × B require A.cols = B.rows?

To compute element (i,j) of the product, you take the dot product of A row i with B column j — they must have the same length. So an m×n matrix can only multiply an n×p matrix, producing an m×p result. The calculator validates this and shows a clear error if dimensions do not match.

Related Tools

  • 🔬 Scientific Calculator — Free online scientific calculator with sin, cos, tan, log, sqrt, exponents, and history. Use as a math calcula
  • 📐 Triangle Calculator — Solve any triangle from 3 known values — supports SSS, SAS, ASA, AAS, and SSA (ambiguous case) with sides, ang
  • 📉 Statistics Calculator — Calculate mean, median, mode, standard deviation, variance, quartiles & more from any dataset. Live histogram
  • 🎲 Probability Calculator — Calculate single, multiple, and conditional probabilities, plus permutations (nPr) and combinations (nCr) — wi
  • 🎂 Age Calculator — Free age computation tool — calculate age from date of birth in years, months, days, hours, and minutes with f
  • % Percentage Calculator — Calculate percentages instantly — find X% of Y, percentage change, increase/decrease by %, and what percent X
  • 💔 Relationship Compatibility Calculator — REAL compatibility (not zodiac BS). Based on Gottman Institute's 97% divorce prediction research + attachment
  • 🏦 Loan Calculator — Calculate monthly loan payments, total interest, and amortization schedule. Free amortization calculator with

Related: matrix calculator, matrix multiplication calculator, determinant calculator, matrix inverse calculator, matrix transpose calculator, linear algebra calculator, matrix addition calculator, matrix subtraction calculator, scalar multiplication matrix, matrix power calculator, solve linear system calculator, Ax=b solver, 3x3 matrix calculator, 4x4 determinant, online matrix solver