Matrix Calculator

Result
Next

Enter one or two matrices of any dimension and the calculator performs the operation you pick, addition, subtraction, scalar or matrix multiplication, transpose, inverse, determinant, rank, trace, and shows the intermediate work where it matters. Useful for linear-algebra homework, engineering checks, computer-graphics transforms and any time you don’t want to hand-crank row reduction on a calculator with tiny buttons.

How to compute on matrices

  1. 1

    Set dimensions

    Rows and columns for matrix A (and B if the operation needs a second operand).

  2. 2

    Enter values

    Click into each cell. Decimals, negatives and fractions (`1/3`) are accepted.

  3. 3

    Pick the operation

    A+B, A−B, AB, kA, A^T, A^−1, det(A), rank, trace.

  4. 4

    Read result and steps

    Output matrix plus the formula used and any intermediate row operations.

Operations and their dimension rules

Operation Rule Result dimensions
A + B Same dimensions m×n
A − B Same dimensions m×n
k · A Any A same as A
A · B columns(A) = rows(B) rows(A)×cols(B)
A^T (transpose) Any A n×m
A^−1 (inverse) A is square and det(A) ≠ 0 n×n
det(A) A is square scalar
rank(A) Any A scalar
trace(A) A is square scalar

Why matrix multiplication isn’t commutative

For general matrices A and B, AB ≠ BA even when both products are defined. Each entry of AB is a dot product of a row of A with a column of B; swapping the order dots different rows and columns. Commuting matrices are the exception (multiples of identity, diagonal matrices with distinct entries, some rotations that share an axis).

Invertibility quick test

  • A square matrix is invertible iff det(A) ≠ 0.
  • Invertible ⇔ full rank ⇔ columns are linearly independent ⇔ trivial null space.
  • For a 2×2: A^−1 = 1/det(A) · [[d, −b], [−c, a]].
  • For larger matrices, Gauss-Jordan elimination (augment with I, row-reduce to [I | A^−1]) is what the calculator uses.

Common gotchas

  • Dimension mismatches. The most common error. The calculator flags these early and tells you exactly which dimensions don’t agree.
  • Round-off in the inverse. Double-precision arithmetic accumulates small errors. A matrix that is nearly singular (determinant near zero) produces an inverse that’s wildly inaccurate. Check the condition number if precision matters.
  • Non-integer fractions. Enter 1/3 and the calculator keeps it exact where possible; it falls back to floats once the operation introduces irrational numbers.

Uses outside homework

  • Computer graphics: 4×4 transform matrices for translation, rotation, scaling in 3D.
  • Physics: stress and inertia tensors.
  • Machine learning: weight matrices in dense layers; covariance matrices; PCA.
  • Networking and Markov models: transition matrices and their powers.
  • Economics: input-output models (Leontief).

Frequently Asked Questions

Hundreds of rows and columns work but become slow for operations with O(n³) complexity (multiplication, inverse, determinant). Beyond ~500×500, use a numerical library (NumPy, Octave) with BLAS-backed routines.

For simple operations (add, subtract, scalar multiply, transpose), yes. For inverse and determinant, the calculator can either stay rational (slow for large matrices) or use double-precision floats (fast but with round-off). You can toggle the mode.

Gauss-Jordan elimination: augment A with the identity, row-reduce to reduced row-echelon form. If the left half becomes I, the right half is A^−1; if not, A is singular and has no inverse.

No, this calculator is real-only. For complex matrices, use a dedicated complex-matrix tool.

No. All arithmetic runs in your browser.

Related Tools

Tool available in other languages