Matrix Calculator
Perform matrix addition, subtraction, multiplication, determinants, inverses, eigenvalues, decompositions, and advanced linear algebra operations with step-by-step solutions.
Matrix A
Rows
4Cols
4Matrix B
Rows
4Cols
4Operations
Binary operations (use both A and B)
Operations on Matrix A
Operations on Matrix B
Advanced linear algebra (Matrix A)
Linear system solver
Linear-system solver treats A as the coefficient matrix and B as the right-hand side (one or more constant columns). For a single equation system use a single-column B.
Live properties dashboard
Matrix A
4 × 4
Matrix B
4 × 4
What is a Matrix Calculator?
A matrix calculator performs every operation in introductory and advanced linear algebra on rectangular grids of numbers. This tool handles two matrices up to 10 × 10 and covers the full operations spectrum: addition (A + B), subtraction (A − B), multiplication in both directions (A × B and B × A), scalar multiplication, transpose (Aᵀ, Bᵀ), integer powers (Aⁿ, Bⁿ), determinant det(A), inverse A⁻¹ via Gauss-Jordan, rank, trace, Frobenius and max norms, eigenvalues via the shifted QR algorithm, LU decomposition with partial pivoting, Householder QR, Cholesky factorisation, and full linear-system solving Ax = b with unique / infinite / no-solution detection.
Every operation comes with a one-line equation caption, a verification panel where applicable, a live properties dashboard (rank, trace, determinant, norms, symmetry, orthogonality, positive-definiteness, triangularity), and heatmap visualisations for both operands. Pair it with the scientific calculator, distance calculator (for vector norms), or the slope calculator for 2D linear analysis.
How matrix operations are computed
Addition & subtraction are component-wise
(A + B)ᵢⱼ = Aᵢⱼ + Bᵢⱼ. Both matrices must have identical dimensions. Subtraction is the same operation with B replaced by −B.
Multiplication is row-by-column dot product
Multiply an m×n matrix by an n×p matrix. Entry (i, j) of the product is Σₖ AᵢₖBₖⱼ. The inner dimensions must match, and AB ≠ BA in general.
Transpose flips rows ↔ columns
(Aᵀ)ᵢⱼ = Aⱼᵢ. It satisfies (AB)ᵀ = Bᵀ Aᵀ and (Aᵀ)ᵀ = A. Symmetric matrices are exactly the ones equal to their own transpose.
Determinant via LU decomposition
Factor A = PLU. Then det(A) = sign(P) × ∏ Uᵢᵢ. This is O(n³) and the standard numerical method. A zero diagonal entry in U means A is singular.
Inverse via Gauss-Jordan on [A | I]
Reduce [A | I] to [I | A⁻¹]. Works only when A is square and non-singular. Numerically stable with partial pivoting.
Eigenvalues via shifted QR
Repeatedly apply Q, R = QR(H − μI) and form H′ = RQ + μI. With Wilkinson shifts, the subdiagonals tend to zero and eigenvalues appear on the diagonal (or in 2×2 blocks for complex pairs).
6 ways to use the Matrix Calculator
Solve linear systems Ax = b
Put coefficients in A and constants in B (a single column), then click Solve A·x = B. The result panel shows the unique solution, an infinite family, or proves no solution exists.
Verify a textbook inverse
Compute A⁻¹, then A × A⁻¹ — it should return the identity matrix within rounding tolerance. Use the Copy → B action to set up the verification multiplication in one click.
Find principal axes via eigenvalues
Eigenvalues of a covariance or stiffness matrix reveal principal directions, vibration modes, and PCA components. Spectral radius indicates stability of iterative schemes.
Test for positive-definiteness
Try a Cholesky factorisation. If it succeeds (no negative square-root), A is symmetric positive-definite — exactly the condition for unique optimisation and Gaussian likelihoods.
Factor for repeated solves
LU is computed once in O(n³) and then every subsequent Ax = b costs only O(n²). Useful when the same matrix appears with many right-hand sides — finite-element loads, time-stepped simulations, batch inversions.
Homework, exams, competition prep
Step-equation captions and verification matrices let you cross-check every step of a manual solution. Heatmaps make sparsity, symmetry, and dominant-diagonal structure obvious at a glance.
Best practices for accurate matrix work
Confirm dimensions before multiplying. An m×n times n×p product needs the inner dimensions to match. A common error is multiplying A × B when only B × A is defined; this calculator flags the mismatch with an exact error message.
Prefer LU over computing A⁻¹ for solves. Forming A⁻¹ then multiplying by b is slower and numerically worse than a single Gaussian elimination on [A | b]. Use the linear-system solver for one-off solves and LU for repeated solves with different right-hand sides.
Use the determinant as a quick singularity check. If det(A) is exactly 0 (or within tolerance), the inverse does not exist and the linear system has either no solution or infinitely many — exactly the cases the solver detects.
Watch for ill-conditioning. When det(A) is tiny but non-zero, small input changes can swing the result hugely. The Frobenius norm of A times the Frobenius norm of A⁻¹ approximates the condition number — a value over 10⁶ is a red flag.
Symmetric + positive entries does NOT mean positive-definite. The Cholesky tool is the definitive test: it succeeds exactly when A is symmetric positive-definite. The dashboard chip toggles automatically as you edit.
Identity check finds typos fast. If you intended an identity matrix, the dashboard's Identity chip will glow only when every off-diagonal entry is zero and every diagonal entry is one. Useful when sanity-checking products like A × A⁻¹.
Why matrices matter
Matrices are the universal language of linear systems. Every 3D rotation in computer graphics, every fully-connected layer in a neural network, every PageRank computation behind a search engine, every Kalman filter onboard a spacecraft, and every finite-element simulation that designs a bridge ultimately reduces to a small set of matrix operations: multiplication, inversion, decomposition, and eigendecomposition.
Fluency with the determinant, inverse, rank, and eigenvalues lets you switch between coordinate systems, separate signal from noise, recognise when a model is degenerate, and predict the long-term behaviour of dynamical processes. The properties dashboard above turns this fluency into a real-time feedback loop while you edit.
Tricky cases worth knowing
Singular matrices
A square matrix with det = 0 has no inverse. The linear-system solver returns either 'no solution' (inconsistent right-hand side) or 'infinite solutions' (free variables) — never a unique answer.
Complex eigenvalues
Even real matrices can have complex eigenvalues; they always come in conjugate pairs. The calculator displays them as a ± bi and plots both on the complex plane.
Non-diagonalisable matrices
Some matrices have fewer linearly independent eigenvectors than eigenvalues (defective matrices). Eigenvalues are still well-defined and useful, but Jordan-form analysis is required for a full picture.
Floating-point noise
Round-off can leave tiny non-zero entries where exact zeros should appear (e.g. below the diagonal in U after LU). The display rounds values smaller than 10⁻¹² to 0 to keep results readable.
Cholesky failure ≠ bad matrix
If Cholesky fails, the matrix may still be invertible — it just isn't positive-definite. Use LU or QR for non-SPD matrices instead.
Core formulas library
Addition / subtraction
(A ± B)ᵢⱼ = Aᵢⱼ ± Bᵢⱼ
Multiplication
(A × B)ᵢⱼ = Σₖ Aᵢₖ Bₖⱼ
Transpose
(Aᵀ)ᵢⱼ = Aⱼᵢ (AB)ᵀ = BᵀAᵀ
Power
Aⁿ = A · A · … · A (n factors)
Determinant (Leibniz)
det(A) = Σ_{σ ∈ Sₙ} sgn(σ) · ∏ᵢ Aᵢ,σ(i)
Inverse
A⁻¹ = adj(A) / det(A), A A⁻¹ = I
Eigenvalue equation
A v = λ v, det(A − λI) = 0
Trace
tr(A) = Σᵢ Aᵢᵢ = Σ λᵢ
Rank
rank(A) = number of pivots in RREF(A)
Frobenius norm
‖A‖_F = √( Σᵢⱼ Aᵢⱼ² )
LU decomposition
P A = L U (L unit lower, U upper)
QR decomposition
A = Q R (Qᵀ Q = I, R upper)
Cholesky
A = L Lᵀ (A symmetric pos-def)
SVD
A = U Σ Vᵀ (Σ diag of singular values)
Common mistakes to avoid
- ✗Assuming AB = BA — matrix multiplication is not commutative; A × B and B × A often differ and may not even have the same dimensions.
- ✗Confusing A⁻¹ with Aᵀ — they coincide only for orthogonal matrices.
- ✗Dividing by a matrix — there is no matrix division; instead multiply by the inverse on the correct side.
- ✗Treating det(A + B) as det(A) + det(B) — the determinant is multiplicative, not additive: det(AB) = det(A) det(B).
- ✗Using row reduction to find an inverse without tracking the identity side — you'll get rref(A) but not A⁻¹.
- ✗Forgetting that powers require a square matrix — Aⁿ is only defined when A is n×n.
- ✗Reading 'trace' as 'determinant' — trace is the sum of diagonal entries (and the sum of eigenvalues); determinant is the product of eigenvalues.
Special matrices reference
| Type | Defining property | Example (3×3) |
|---|---|---|
| Identity | Aᵢⱼ = δᵢⱼ (Kronecker) | [[1,0,0],[0,1,0],[0,0,1]] |
| Diagonal | Aᵢⱼ = 0 for i ≠ j | [[3,0,0],[0,−1,0],[0,0,7]] |
| Symmetric | Aᵢⱼ = Aⱼᵢ | [[2,1,4],[1,5,0],[4,0,6]] |
| Orthogonal | AᵀA = I (rotation/reflection) | [[cosθ,−sinθ,0],[sinθ,cosθ,0],[0,0,1]] |
| Upper triangular | Aᵢⱼ = 0 for i > j | [[2,5,7],[0,3,1],[0,0,4]] |
| Lower triangular | Aᵢⱼ = 0 for i < j | [[2,0,0],[5,3,0],[7,1,4]] |
| Permutation | Single 1 in each row and column | [[0,1,0],[0,0,1],[1,0,0]] |
| Skew-symmetric | Aᵀ = −A (diagonal = 0) | [[0,2,−1],[−2,0,3],[1,−3,0]] |
Applications across science and engineering
Machine learning
Every neural-network layer is a matrix multiply (W · x + b). Convolutions, attention, and embeddings are all dense or sparse matrix operations. SVD powers PCA, recommender systems, and noise reduction.
Computer graphics
3D rotations, translations, projections, and skinning are 4×4 matrix multiplications. Inverse and transpose of the model matrix give the normal matrix used for correct lighting after non-uniform scaling.
Engineering & physics
Finite-element method assembles a global stiffness matrix; structural analysis reduces to K u = f. Eigenvalues give vibration modes; the spectral radius decides stability of explicit time-steppers.
Statistics & economics
Linear regression solves the normal equations Xᵀ X β = Xᵀ y. Covariance matrices, principal components, and Leontief input-output models all live in matrix algebra.
Cryptography & coding
Hill ciphers, lattice-based cryptosystems, and error-correcting codes (Hamming, Reed-Solomon) use matrices over finite fields. The determinant must be coprime to the modulus for invertibility.
Robotics & control
Forward kinematics chains 4×4 homogeneous transforms; inverse kinematics solves them. The Jacobian links joint velocities to end-effector velocities; its rank tells you when you're at a singularity.
Methodology and references
Algorithms follow the standard references for numerical linear algebra: Matrix Computations by Golub & Van Loan (4th ed.), Numerical Linear Algebra by Trefethen & Bau, and Linear Algebra and Its Applications by Gilbert Strang. Determinant uses LU with partial pivoting, inverse uses Gauss-Jordan, QR uses Householder reflections, and eigenvalues use the shifted QR algorithm with Wilkinson shifts. Where exact zeros are expected (below the diagonal of R after Householder QR, off the diagonal of a diagonal matrix), values smaller than 10⁻¹² are rounded to zero for display.
Frequently asked questions
Related Calculators
More math and linear-algebra companions that pair with matrix work.
- Scientific CalculatorAdvanced trig, log, exponent, root, factorial, and memory functions.
- Distance Calculator2D, 3D, lat/lng, map, vector, and geometry distance — six tools, step-by-step solutions, interactive visualisations.
- Slope CalculatorSlope, angle, distance, midpoint, intercepts, and the line equation with an interactive coordinate-plane graph.
- Triangle CalculatorSolve any triangle (SSS, SAS, ASA, AAS, SSA) for sides, angles, area, altitudes, medians, inradius, circumradius and centres.
- Exponent CalculatorSolve y = bˣ for any unknown with expanded multiplication, logarithm derivation, and property breakdown.
- Permutation and Combination CalculatorExact nPr and nCr with factorial breakdowns, step-by-step working, the bridge identity, and worked examples.