Math & Science

Matrix Calculator

Perform addition, subtraction, multiplication, scalar operations, transpose, determinant, inverse, rank, trace, power, Hadamard product and dot product — up to 5×5 matrices with step-by-step solutions.

Instant Results
Up to 5×5 Matrices
Step-by-Step
100% Free

Matrix Calculator

Choose an operation, set size, enter values and calculate instantly

Add A + B
Subtract A − B
✖️Multiply A × B
🔢Scalar × k × A
🔄Transpose Aᵀ
📐Determinant det(A)
🔁Inverse A⁻¹
📏Trace tr(A)
🏆Rank rank(A)
💥Power Aⁿ
🔵Hadamard A ∘ B
🎯Dot Product A · B
2×2
3×3
4×4
5×5
A
Matrix A
3 × 3
B
Matrix B
3 × 3
Error
✅ Result
Step-by-Step Solution
Share Result

What Is a Matrix?

Understanding matrices, key operations, and why they are fundamental to science and engineering

The Language of Linear Algebra

A matrix is a rectangular array of numbers arranged in rows and columns. An m×n matrix has m rows and n columns. Matrices are the backbone of linear algebra — used to represent linear transformations, solve systems of equations, describe graphs, encode images, and power machine learning algorithms.

A matrix where m = n is called a square matrix — only square matrices have determinants, inverses, and traces. A 1×n matrix is a row vector; an n×1 matrix is a column vector. The identity matrix has 1s on the diagonal and 0s elsewhere — it's the matrix equivalent of the number 1.

🧩 Key multiplication rule: Matrix A (m×n) can only multiply Matrix B (n×p) — the inner dimensions must match. The result is an m×p matrix. Matrix multiplication is not commutative: A×B ≠ B×A in general. This makes matrix algebra fundamentally different from scalar arithmetic.

This calculator supports 12 matrix operations on square matrices up to 5×5: addition, subtraction, multiplication, scalar multiply, transpose, determinant, inverse, trace, rank, matrix power, Hadamard product, and dot product.

📐
Determinant
A scalar encoding the matrix's "volume scaling factor". det = 0 means singular (no inverse). For 2×2: det = ad − bc. Larger matrices use cofactor/Laplace expansion. det(AB) = det(A) × det(B).
🔁
Inverse
A⁻¹ satisfies A × A⁻¹ = I (identity). Only square matrices with non-zero determinant are invertible. Used for solving Ax = b via x = A⁻¹b. Computed here by Gauss-Jordan elimination.
🔄
Transpose
Aᵀ flips rows ↔ columns: element (i,j) becomes (j,i). If A is m×n, Aᵀ is n×m. A symmetric matrix satisfies A = Aᵀ — these appear in covariance matrices and physics tensors.
🏆
Rank
The rank is the number of linearly independent rows (or columns). Full-rank n×n means invertible. rank < n means the matrix is singular. Computed here via row reduction (Gaussian elimination).

Operation Reference

All 12 operations with formulas, dimension rules and use cases

Every Operation Explained
OperationSymbolDimension RuleResult TypeUse Case
AdditionA + BSame size m×nm×n matrixCombining linear transformations
SubtractionA − BSame size m×nm×n matrixDifference of transformations
MultiplicationA × BA is m×n, B is n×pm×p matrixComposing transformations
Scalar Multiplyk × AAny A, scalar kSame size as AUniform scaling of all elements
TransposeAᵀAny m×nn×m matrixSymmetry, dot products, covariance
Determinantdet(A)Square n×n onlyScalarInvertibility, volume scaling
InverseA⁻¹Square, det ≠ 0n×n matrixSolving linear systems Ax = b
Tracetr(A)Square n×n onlyScalarSum of diagonal = sum of eigenvalues
Rankrank(A)Any m×nIntegerDimension of column/row space
Matrix PowerAⁿSquare, n ≥ 0n×n matrixMarkov chains, graph walks
Hadamard ProductA ∘ BSame size m×nm×n matrixElement-wise weighting, neural nets
Dot ProductA · BRow 1 of A · Col 1 of BScalarAngle between vectors, projections

How to Use the Matrix Calculator

Step-by-step guide for students and professionals

From Inputs to Results in Seconds
  • 1
    Choose Your Operation

    Select from the 12 operation tiles. Operations that use only Matrix A — Determinant, Inverse, Transpose, Trace, Rank, Scalar, Power — automatically hide Matrix B. Two-matrix operations show both grids side by side.

  • 2
    Set the Matrix Size

    Choose 2×2, 3×3, 4×4 or 5×5 using the size chips. The grids rebuild instantly. All cells reset to blank — previous values are cleared when you change size.

  • 3
    Enter Values or Use Presets

    Click each cell and type a number (decimals and negatives supported). Press Tab to move right. Hit the Random button for random integers −9 to 9. Use sidebar presets to fill Identity, Zeros, Ones, or Diagonal matrices in one click.

  • 4
    Calculate and Review

    Press Calculate Matrix. Matrix results display as a formatted green grid. Scalar results (determinant, trace, rank) show as a single large number. The operation name always appears in the result header.

  • 5
    Expand Step-by-Step Solution

    Click the Step-by-Step panel to see the full working. Multiplication shows each dot product. Determinants show cofactor expansion. Inverses show the Gauss-Jordan method. Share or copy results using the buttons below the result.

💡 Pro Tip: Use the Random button on both matrices, switch to Multiply and hit Calculate to instantly see a worked 3×3 multiplication example with all 9 dot products computed. Matrix grids persist when you switch operations — no need to re-enter values.

Matrices in the Real World

How matrix operations power technology, science and everyday life

Matrices Are Everywhere
🤖
Neural Networks Are Matrix Multiplications

Every layer in a deep learning model is a matrix multiply: output = activation(W × input + b). GPUs are optimised to do billions of these per second. All of modern AI is linear algebra — matrix multiplication is the most important computation in the world today.

🎬
3D Graphics Use 4×4 Matrices

Every rotation, translation and scaling in games and movies is a 4×4 transformation matrix. The GPU multiplies millions of vertex vectors by these matrices per frame to render the image you see. OpenGL and DirectX are fundamentally matrix multiplication engines.

🌐
Google PageRank Is an Eigenvector

Google's original ranking algorithm finds the dominant eigenvector of the web's link matrix — a trillion-node graph. The vector scores every page by "importance". Solving this required new iterative methods (power iteration) to handle a matrix too large to store explicitly.

📡
Fourier Transform Is Matrix Multiplication

The DFT is F = W × x, where W is the complex DFT matrix. The FFT algorithm factorises W into sparse matrices for O(n log n) efficiency. Used in audio (MP3), images (JPEG), communications (5G), and MRI reconstruction.

🚀
Kalman Filters in GPS and Aerospace

The Kalman filter updates state estimates via recursive matrix operations. Used in GPS, self-driving cars, spacecraft navigation, and missile guidance systems. It optimally combines noisy sensor measurements using covariance matrices to track moving objects in real time.

💡
Quantum Computing Runs on Matrices

In quantum mechanics, every quantum gate is a unitary matrix, and the state of n qubits is a 2ⁿ-dimensional complex vector. Quantum computation is literally matrix-vector multiplication in exponentially large spaces — harnessing interference to solve problems faster than classical computers.

📊
PCA Finds Eigenvectors of Covariance Matrices

Principal Component Analysis computes the covariance matrix of data, then finds its eigenvectors. These principal components are the "natural axes" of the data — directions of maximum variance. Used in face recognition, genomics, finance, and dimensionality reduction of billions of features.

💊
Medical Imaging Solves Matrix Equations

CT scans reconstruct 3D images by solving a huge system of linear equations — essentially inverting a massive matrix that maps X-ray measurements to tissue density. MRI uses the Fourier transform (also a matrix operation) to convert k-space frequency data into spatial images.

Frequently Asked Questions

Common questions about matrix operations and linear algebra

Why can't I multiply any two matrices together?
Matrix multiplication A×B requires the number of columns in A to equal the number of rows in B. A 2×3 matrix can multiply a 3×4 (giving 2×4), but two 2×3 matrices can't be multiplied directly because inner dimensions don't match. This calculator uses same-size square matrices for simplicity — for non-square multiplication, the size selection maps to the common inner dimension.
What does a zero determinant mean?
det(A) = 0 means the matrix is singular — it has no inverse. Geometrically, the linear transformation collapses space to a lower dimension (rows or columns are linearly dependent). A system Ax = b has no unique solution when det(A) = 0. You'll see an error if you try to invert a singular matrix.
Is matrix multiplication commutative?
No — in general, A×B ≠ B×A. Matrix multiplication is associative (A×(B×C) = (A×B)×C) and distributive (A×(B+C) = A×B + A×C), but not commutative. There are special cases where AB = BA — for instance, a matrix always commutes with its own inverse and with the identity matrix.
What is the Hadamard product vs matrix multiplication?
Matrix multiplication (A×B) computes dot products of rows and columns — a sum of products per output element. The Hadamard product (A∘B) simply multiplies matching elements: (A∘B)ᵢⱼ = Aᵢⱼ × Bᵢⱼ. Hadamard requires same-size matrices. It's used in neural network gating (LSTM), element-wise masking, and image processing.
How is the inverse computed for larger matrices?
For 2×2: A⁻¹ = (1/det)[[d,−b],[−c,a]]. For 3×3+, this calculator uses Gauss-Jordan elimination with partial pivoting — augmenting [A|I] and row-reducing to [I|A⁻¹]. This is more numerically stable than the cofactor/adjugate formula for 4×4 and 5×5 matrices.
What does matrix rank tell you practically?
Rank tells you the "effective dimensionality" of the matrix's transformation. A full-rank n×n matrix (rank = n) maps n-dimensional space to n-dimensional space with no collapsing — it's invertible. A rank-deficient matrix collapses space: rank 2 out of 3 means the image is a 2D plane in 3D space. In systems of equations, rank determines whether a unique solution, infinite solutions, or no solution exists.