Matrix Calculator
Perform dual-matrix operations A + B, A − B, and A × B, resize grids dynamically from 1×1 to 5×5, or compute single-matrix properties including determinants, matrix inverses A−¹, rank, trace, powers, and Reduced Row Echelon Form (RREF) with exact arithmetic.
Matrix A (3 × 3)
Matrix B (3 × 3)
How Matrix Operations & Multiplication Work
A matrix is an ordered rectangular array of numbers arranged into m rows and n columns. Matrix addition and subtraction require identical dimensions (m × n) and operate entry-wise. Matrix multiplication (A × B) requires the column count of A to equal the row count of B, producing an (m × p) product where each entry C[i,j] is the vector dot product of row i from A and column j from B.
What Is a Matrix?
A matrix is an ordered two-dimensional rectangular array of mathematical elements (numbers, variables, or functions) arranged into horizontal rows and vertical columns. Developed formally by 19th-century mathematicians Arthur Cayley, James Joseph Sylvester, and William Rowan Hamilton, matrix algebra serves as the primary computational language of modern engineering, 3D graphics rendering, statistical regression, quantum mechanics, and deep neural networks.
The dimensions of a matrix are stated as m × n (read "m by n"), where m is the number of rows and n is the number of columns. An individual entry located at row i and column j is denoted as aij or A[i, j]:
Equal rows and columns (m = n). Possesses determinants, traces, and potential inverses.
Diagonal entries are 1; all off-diagonal entries are 0. Acts as multiplicative unity: AI = IA = A.
Equal to its own transpose (A = Aᵀ). All eigenvalues are strictly real numbers.
Matrix Operations: Rules & Dimension Criteria
Matrix arithmetic operations depend strictly on dimensional compatibility. Violating dimensional criteria makes the operation mathematically undefined:
Addition, Subtraction & Scalar Scaling
- Matrix Addition (A + B): Both matrices must have identical dimensions (m × n). Entries are summed position by position: C[i,j] = A[i,j] + B[i,j].
- Matrix Subtraction (A − B): Requires matching dimensions (m × n): C[i,j] = A[i,j] − B[i,j].
- Scalar Multiplication (c × A): Any real scalar c multiplies every entry: (cA)[i,j] = c × A[i,j].
Matrix Multiplication (A × B)
Matrix multiplication is not entry-by-entry; it is row-by-column vector dot multiplication:
The number of columns in A must equal the number of rows in B (k = k). Each output cell C[i,j] is the sum of products: C[i,j] = Σ A[i,k] × B[k,j].
Matrix Operations Comparison Table
The table below summarizes the dimension rules, mathematical notation, algebraic properties, and computational complexity of standard matrix operations:
| Operation | Formula | Dimension Criteria | Commutative? | Complexity |
|---|---|---|---|---|
| Addition | A + B | Same (m × n) | Yes (A+B = B+A) | O(m × n) |
| Multiplication | A × B | Cols(A) = Rows(B) | No (AB ≠ BA) | O(m × k × n) |
| Scalar Scaling | c × A | Any (m × n) | Yes (cA = Ac) | O(m × n) |
| Transpose | Aᵀ | (m × n) → (n × m) | N/A (Unary) | O(m × n) |
| Determinant | det(A) | Square (n × n) | N/A (Scalar) | O(n³) via LU |
| Inverse | A−¹ | Square & det ≠ 0 | AA−¹ = A−¹A = I | O(n³) via Gauss |
| Trace | tr(A) | Square (n × n) | tr(AB) = tr(BA) | O(n) |
Step-by-Step Worked Examples
Given Matrix A = [[1, 2], [3, 4]] and Matrix B = [[5, 6], [7, 8]]:
Evaluate det(A) for A = [[3, 2, −1], [1, 6, 3], [2, −4, 0]] along Row 1:
Given A = [[4, 7], [2, 6]]:
Determinants, Invertibility & Singular Matrices
The determinant is a unique scalar property of square matrices that measures how the matrix scales space. In 2D, |det(A)| represents the area scaling factor of a unit square transformed by A; in 3D, it represents the volume scaling factor of a unit cube.
If det(A) ≠ 0, the transformation is bijective (one-to-one and onto). Space is not flattened. The columns of A form a complete basis, the rank is full (rank = n), and an inverse matrix A−¹ exists such that A A−¹ = I.
If det(A) = 0, the transformation collapses dimensions (e.g. squashing a 3D volume onto a flat 2D plane or line). Because multiple original vectors are mapped to the same output vector, the operation cannot be reversed. Consequently, no inverse exists.
Common Pitfalls & Misconceptions
1. Assuming Matrix Multiplication Commutes (AB = BA)
In general, AB ≠ BA. Reversing the order produces completely different dot products, and often results in undefined dimension mismatches.
2. Attempting to Invert a Singular Matrix
If det(A) = 0, the formula A−¹ = (1 / det) × adj(A) requires dividing by zero. A singular matrix has no inverse.
3. Conflating Dot Product Multiplication with Element-Wise Multiplication
Do not multiply matching entries together when computing A × B. Element-wise multiplication is the Hadamard product (A ⊙ B), whereas standard matrix multiplication requires row-by-column dot product summation.
4. Forgetting the Reversal Property of Transposes and Inverses
When transposing or inverting a matrix product, the order of multiplication reverses: (AB)ᵀ = Bᵀ Aᵀ and (AB)−¹ = B−¹ A−¹.
Real-World Applications in Graphics, AI & Physics
Video game engines and GPU shaders use 4×4 homogeneous transformation matrices (MVP: Model-View-Projection) to concatenate 3D rotation, translation, camera viewing angle, and perspective projection into a single high-speed matrix multiply.
Transformer neural networks execute multi-head self-attention via matrix multiplication: Attention(Q, K, V) = softmax(Q Kᵀ / √dk) V. Matrix multiply-accumulate (MAC) units on TPUs power modern generative AI.
In quantum algorithms, quantum state vectors Ψ evolve via unitary matrices (U U† = I). Basic quantum logic gates like the Hadamard, Pauli-X, and CNOT gates are represented by 2×2 and 4×4 complex matrices.
Linear Algebra Suite & Advanced Solvers
Explore our complete suite of browser-native linear algebra solvers and geometric transformers:
Row Echelon Form (REF)
Transform matrices into upper echelon form with step-by-step row elimination.
Dimension AnalysisMatrix Rank Calculator
Compute linear independence and column subspace dimensions.
Matrix FactorizationLU Decomposition
Factorize A = LU into lower and upper triangular components.
Spectral TheoryCharacteristic Polynomial
Solve det(A − λI) = 0 to extract eigenvalues and trace invariants.
Eigen DecompositionEigenvalues & Vectors
Calculate principal axes, scaling eigenvalues, and invariant eigenvectors.
Geometry Engine2D Vector Transform
Visualize rotation, scaling, reflection, and shearing transformations in real-time.
Lead Developer & Founder of Basic Math Tools. Specializes in browser-native computational algorithms and applied mathematics.
Mathematics & curriculum specialists. Audited against standard algebraic and arithmetic principles.