Skip to main content

Matrix Operations With Step-by-Step Output

Perform matrix operations including add, subtract, multiply, transpose, determinant, inverse, eigenvalues, SVD, and more

Last Updated: February 13, 2026

The operations the page runs: addition (defined when shapes match), scalar multiplication, matrix multiplication AB (defined when columns of A equal rows of B, output shape rows-of-A × cols-of-B), transpose, determinant (square only), inverse via adjugate or LU (square and non-singular only), and reduction to RREF for solving Ax = b.

Two operations get confused most often. Matrix multiplication isn't commutative. AB ≠ BA in general, and a dimension mismatch makes one of them undefined entirely. And inversion fails silently in floating point: if det(A) is small relative to ‖A‖, the matrix is ill-conditioned and the "inverse" you compute is dominated by roundoff. The page reports the determinant alongside any inverse so you can see when you're in that regime. For solving linear systems specifically, prefer RREF on [A | b] over computing A⁻¹b explicitly. RREF is both faster and more numerically stable. The standard reason to compute A⁻¹ outright is when you need to apply it to many right-hand sides; even then, an LU factorization beats a full inverse. For matrix properties (rank, eigenvalues, condition number), see the linear algebra helper.

Matrix Size and Input Format Guide

Specify rows and columns before entering values. A 3×4 matrix has three rows and four columns—the first number always indicates rows. Row-major order means filling left to right, top to bottom: a₁₁, a₁₂, a₁₃, a₁₄, then a₂₁, and so on.

Square matrices (n×n) unlock operations unavailable to rectangular ones: determinant, trace, eigenvalues, and inverse. A 2×3 matrix has neither determinant nor inverse—these concepts require equal row and column counts. Check your matrix shape before selecting operations.

Paste data from spreadsheets using tab or comma separation. The parser splits input by tabs first, then commas. Scientific notation (1.5e-3) works for very large or small entries. Blank cells default to zero, which may silently affect results if unintended.

Formatting tip: For a 2×2 matrix [[1, 2], [3, 4]], enter row 1 as "1, 2" and row 2 as "3, 4"—or paste directly from Excel if columns align properly.

Multiply, Add, and Transpose Without Errors

Matrix addition and subtraction require identical dimensions. A 3×2 plus a 3×2 yields a 3×2; a 3×2 plus a 2×3 throws an error. Each element adds independently: (A + B)ᵢⱼ = Aᵢⱼ + Bᵢⱼ.

Matrix multiplication demands that inner dimensions match. For A (m×n) times B (p×q), you need n = p. The result is m×q. AB ≠ BA in general—order matters. To compute Cᵢⱼ, take the dot product of row i from A with column j from B.

Transpose flips rows to columns: (Aᵀ)ᵢⱼ = Aⱼᵢ. A 2×5 becomes 5×2 after transposition. Useful identity: (AB)ᵀ = BᵀAᵀ—note the reversed order. Symmetric matrices satisfy A = Aᵀ, meaning the matrix equals its own transpose.

For multiplication AB:

• A is m×n, B is n×p → result is m×p

• Each entry: Cᵢⱼ = Σₖ Aᵢₖ Bₖⱼ

Determinant and Inverse: When They Exist

Determinant applies only to square matrices. For 2×2 [[a, b], [c, d]], det = ad − bc. For larger matrices, expansion by cofactors or LU decomposition computes the value. Geometrically, |det(A)| measures how much the transformation scales area (2D) or volume (3D).

If det(A) = 0, the matrix is singular—no inverse exists. Rows are linearly dependent, collapsing space onto a lower dimension. The equation Ax = b has either no solution or infinitely many, never exactly one.

When det(A) ≠ 0, the inverse A⁻¹ exists and satisfies AA⁻¹ = A⁻¹A = I (identity). Computing A⁻¹ explicitly is numerically risky for large or ill-conditioned matrices—prefer solving Ax = b via LU or QR decomposition instead.

2×2 inverse formula:

A⁻¹ = (1/det) × [[d, −b], [−c, a]]

where det = ad − bc ≠ 0

RREF and Solving Linear Systems

Reduced Row Echelon Form (RREF) transforms any matrix into a standard shape: leading 1 in each pivot row, zeros above and below each pivot. RREF reveals rank, identifies pivot and free variables, and exposes solution structure for Ax = b.

Augment the coefficient matrix with the right-hand side: [A | b]. Apply row operations—swap rows, scale rows, add multiples of one row to another—until reaching RREF. Pivot columns correspond to basic variables; non-pivot columns yield free variables.

No solution exists if a row reads [0 0 ... 0 | c] with c ≠ 0—the system is inconsistent. Infinitely many solutions arise when free variables exist (more unknowns than pivots). A unique solution emerges when every variable is a pivot variable and no contradiction appears.

Rank from RREF: Count the number of non-zero rows (equivalently, pivot positions). Rank equals the dimension of the column space and determines solution count.

Computing eigenvalues from the characteristic polynomial

Eigenvalues λ satisfy Av = λv for non-zero vector v. The matrix A stretches or shrinks direction v by factor λ without rotating it. Find eigenvalues by solving det(A − λI) = 0, the characteristic polynomial.

A 2×2 matrix has at most two eigenvalues; an n×n matrix has at most n (counting multiplicity). Eigenvalues may be real or complex—even for a real matrix. Complex eigenvalues appear in conjugate pairs when the matrix is real.

Key relationships: trace(A) = sum of eigenvalues; det(A) = product of eigenvalues. If any eigenvalue is zero, the determinant is zero and the matrix is singular. Positive eigenvalues mean stretching along that direction; negative eigenvalues flip orientation.

For 2×2 matrix A:

λ = [trace ± √(trace² − 4·det)] / 2

Discriminant < 0 → complex eigenvalues

Common matrix-operation questions

Why does multiplication fail when inner dimensions differ?

Each entry of the product comes from a dot product between a row of A and a column of B. If A has 3 columns but B has 4 rows, those vectors have different lengths and no dot product exists. The operation is mathematically undefined.

What does a zero determinant actually mean?

It means the transformation collapses space—some dimension gets squashed to zero. Rows (or columns) are linearly dependent, so the matrix cannot be inverted. The system Ax = b either has no solution or infinitely many.

Can I multiply a 3×2 by a 2×4 matrix?

Yes. Inner dimensions match (2 = 2). The result is 3×4. You take outer dimensions from the first and second matrices respectively.

How do I check if my inverse is correct?

Multiply A by A⁻¹. The result should be the identity matrix (1s on diagonal, 0s elsewhere). Small floating-point errors (like 1e-15 instead of 0) are normal and ignorable.

Why are my eigenvalues complex?

Rotation matrices and matrices with oscillatory behavior produce complex eigenvalues. The imaginary part indicates rotational components. Real matrices can still have complex eigenvalues if the characteristic polynomial's discriminant is negative.

Limitations of these matrix operations

Conditioning matters more than people realize: if det(A) is small relative to ‖A‖, the matrix is ill-conditioned and the inverse you compute is dominated by floating-point roundoff. Compute κ = σ_max / σ_min. Above ~10⁶, treat the inverse as suspect. Above ~10¹², treat it as garbage.

Non-commutativity: matrix multiplication isn't commutative. AB ≠ BA in general, and a dimension mismatch makes one of them undefined entirely.

Solving Ax = b: prefer RREF on [A | b] or LU factorization to computing A⁻¹b. Both are faster and more numerically stable. Compute A⁻¹ explicitly only when you need to apply it to many right-hand sides.

Educational scale: matrices on this page are small (up to about 10×10). Production-scale problems (thousands of dimensions) need NumPy.linalg or MATLAB with BLAS/LAPACK underneath.

Note: Trefethen & Bau's "Numerical Linear Algebra" is the standard reference for the numerical issues (conditioning, stability, the QR and SVD algorithms). Strang's "Introduction to Linear Algebra" is the standard introductory reference for theory.

Sources & References

Formulas and methods follow standard linear algebra references:

Matrix operations: working questions

Why isn't AB equal to BA?

Matrix multiplication composes linear transformations, and composition order matters. Apply A then B is generally different from apply B then A. Concrete example: rotate 90° counterclockwise then reflect across x-axis is not the same as reflect first then rotate. Special cases where AB = BA: if A and B share an eigenbasis (e.g., diagonal matrices), if one is the identity or a scalar multiple, or if they're powers of the same matrix. The non-commutativity is what makes matrix multiplication useful for modeling sequential transformations; if it commuted, ordering wouldn't carry information.

How do I tell if a matrix is invertible without computing the inverse?

Three equivalent checks. Determinant: det(A) ≠ 0. Rank: rank(A) = n (full rank). Eigenvalues: no eigenvalue equals 0. The determinant check is the most direct and runs in O(n³) via LU. For large matrices, computing the rank via SVD or checking the smallest singular value is more numerically stable than the determinant, which can underflow to zero for nearly-singular matrices. If det(A) = 1.2 × 10⁻¹⁵, the matrix is technically invertible but you should treat the inverse as garbage; condition number is the right diagnostic in that regime.

What does the determinant actually mean?

The signed volume scaling factor. A 2×2 determinant is the signed area of the parallelogram with the matrix columns as sides. A 3×3 determinant is the signed volume of the parallelepiped. det(A) = 0 means the columns lie in a lower-dimensional subspace (the transformation collapses volume to zero). Negative determinant means the transformation flips orientation (mirror image). |det(A)| = 1 means the transformation preserves volume (orthogonal matrices, shear matrices). For solving Ax = b, the determinant tells you whether the system has a unique solution (det ≠ 0) or not (det = 0).

RREF vs row echelon form, what's the difference?

Row echelon form (REF) is upper triangular with leading 1s and zeros below. RREF goes further: also zeros above each leading 1, and each pivot column is a column of the identity. REF is what you get from forward elimination only; RREF is REF plus back-substitution. For solving Ax = b, REF is sufficient (you back-substitute manually). RREF makes the solution readable directly: pivot variables sit on the right-hand side, free variables appear as parameters. Computationally, RREF is what most calculators output because it makes the result immediately interpretable.

How do I solve Ax = b without computing A inverse?

Almost always preferred. Compute the LU factorization PA = LU once, then solve Ly = Pb (forward substitution) and Ux = y (back substitution). Both are O(n²) given the O(n³) factorization. Total: same complexity as computing the inverse but more numerically stable. NumPy's np.linalg.solve, MATLAB's backslash A\b, and R's solve(A, b) all use this approach. Compute A⁻¹ explicitly only when you need to apply it to many right-hand sides and you have time to amortize the cost; even then, LU stored once and reused is usually faster.

How do I compute eigenvalues by hand?

Solve det(A − λI) = 0, the characteristic polynomial. For 2×2 [[a, b], [c, d]], it's λ² − (a + d)λ + (ad − bc) = 0, with the trace and determinant as the coefficients. Quadratic formula gives λ = (trace ± √(trace² − 4·det)) / 2. For 3×3, the characteristic polynomial is cubic; use the determinant expansion or Cayley-Hamilton. Above 4×4, no closed form exists in general (Abel-Ruffini), so numerical methods (QR algorithm) are required. NumPy's np.linalg.eig handles it.

Transpose properties worth knowing?

(A^T)^T = A. (A + B)^T = A^T + B^T. (cA)^T = c·A^T. The non-obvious one: (AB)^T = B^T·A^T (note the order swap). For invertible A: (A⁻¹)^T = (A^T)⁻¹. A matrix equals its transpose (A = A^T) iff it's symmetric, which has consequences: all eigenvalues are real, eigenvectors corresponding to distinct eigenvalues are orthogonal, and the matrix can be diagonalized by an orthogonal change of basis (spectral theorem). Most matrices in statistics that come from quadratic forms (covariance, X^T·X) are symmetric for this reason.

Matrix-vector vs matrix-matrix multiplication, what's the difference?

Same operation, different shapes. A matrix-vector product Ax treats x as a column matrix and produces a column vector; you can read it as a linear combination of A's columns weighted by x's entries. A matrix-matrix product AB treats B as a block of column vectors and applies A to each one. The dimensions: A is m×n, x is n×1, Ax is m×1; A is m×n, B is n×p, AB is m×p. The inner dimension must match in both cases. Computationally, matrix-vector is O(mn); matrix-matrix is O(mnp).

Related Math & Linear Algebra Calculators