HomeMath › Matrix Calculator

Matrix Calculator

Build two matrices up to 6×6, then add, subtract, multiply, scale, transpose, or find the determinant, inverse, or a matrix power. Sizes update the input grid live and every result renders as its own grid, with a rounding note for any decimal answer.

Matrix A
Matrix B
Status
Result

What matrices are used for

A matrix is a rectangular grid of numbers arranged in rows and columns, written as m×n for m rows and n columns. Matrices show up anywhere a system needs to track many linked numbers at once — 3D graphics transforms, systems of linear equations, population models, and machine-learning weight tables all lean on the same handful of operations covered here: addition, multiplication, transposition, and inversion.

How it’s calculated

Addition/subtraction combine matching positions (must be the same size). Multiplication A×B takes the dot product of each row of A with each column of B (A’s column count must equal B’s row count). The determinant uses Gaussian elimination with partial pivoting, multiplying the diagonal of the reduced upper-triangular form and tracking the sign from row swaps. The inverse uses Gauss-Jordan elimination on [A | I] until the left block becomes the identity matrix; if a pivot column can’t be made nonzero, A is singular and has no inverse. A power An repeatedly multiplies A by itself (only defined for square A).

Only square matrices (equal rows and columns) have a determinant, inverse, or power. Decimal results are shown rounded; the underlying math uses standard double-precision arithmetic.

Worked example

With A = [[1,2],[3,4]] and B = [[5,6],[7,8]]: A + B = [[6,8],[10,12]], A − B = [[−4,−4],[−4,−4]], and A × B = [[19,22],[43,50]] (row 1 of A · col 1 of B = 1×5 + 2×7 = 19). The determinant of A is 1×4 − 2×3 = −2, so A is invertible: A−1 = [[−2, 1], [1.5, −0.5]]. Squaring A gives A2 = [[7,10],[15,22]].

Common mistakes

  • Trying to multiply A×B when A’s columns don’t match B’s rows — a 2×3 can multiply a 3×4, but not a 4×3.
  • Assuming A×B equals B×A — matrix multiplication is not commutative in general, and one order may not even be defined.
  • Trying to invert a non-square matrix, or a square one whose determinant is zero (singular).
  • Forgetting that scalar multiplication scales every entry, while matrix multiplication combines rows and columns.

Where it is used

  • Linear algebra and engineering coursework — checking hand-worked systems of equations.
  • Computer graphics: rotation, scaling, and projection transforms are matrices.
  • Statistics and machine learning: covariance matrices, regression coefficients, and neural-network weights.
  • Economics and operations research: input-output models and Markov transition matrices.

Frequently asked questions

What size matrices can this calculator handle?

Each matrix can be sized from 1×1 up to 6×6 using the row and column steppers. Addition, subtraction, and multiplication require compatible sizes — same dimensions for +/−, and A’s column count must equal B’s row count for A×B — and the calculator flags it clearly if they don’t match.

How is the determinant calculated?

For a 2×2 matrix it’s ad − bc. For larger square matrices this calculator uses Gaussian elimination with partial pivoting: it reduces the matrix to upper-triangular form, tracking row swaps, then multiplies the diagonal. That is the standard efficient method and matches the textbook cofactor-expansion answer for every size.

Why does it say a matrix is “singular”?

A singular matrix has a determinant of zero, which means it has no inverse — the same way you can’t divide a number by zero. This happens when one row (or column) is a combination of the others. The calculator detects this during elimination and reports “singular” instead of a wrong or infinite answer.

How does the calculator find the inverse?

It uses Gauss-Jordan elimination: the matrix is placed beside an identity matrix of the same size, then row operations that reduce the left side to the identity are applied simultaneously to the right side. What remains on the right is the inverse. If elimination hits a zero pivot with no row to swap in, the matrix is singular.

Why do some results show many decimal places?

Inverses and determinants are computed with standard floating-point arithmetic, so a clean fraction like 1/3 can appear as 0.3333333333. Results are rounded to 6 significant decimal places for display — enough for any practical use — and a note below the results flags this rounding.