Linear algebra
Matrix and vector calculator
Set the size and values of matrices A and B, then pick an operation: the result updates instantly and you can send it back into A, into B, or save it to history.
What matrix and vector operations are used for
Matrix and vector operations are the foundation of linear algebra: they're used to solve systems of equations, describe geometric transformations (rotation, scaling, projection), process images and signals, and they're the language behind most computer graphics and machine learning algorithms.
Addition and subtraction require two matrices of the same size and work element by element. Matrix multiplication, on the other hand, is only defined when the number of columns in the first matrix equals the number of rows in the second, and the result generally isn't commutative: A × B differs from B × A even when both products can be computed.
The determinant is only defined for square matrices and indicates, among other things, whether the matrix is invertible: a determinant of zero means the associated linear system has no unique solution. The dot product and magnitude, on the other hand, apply to vectors (matrices with a single row or column) and are the basis for computing angles, projections and distances.
Common mistakes
- Confusing matrix multiplication with element-by-element multiplication: A × B requires A's columns to match B's rows in count, and the result has A's rows and B's columns.
- Forgetting that matrix multiplication isn't commutative: computing A × B instead of B × A can give a completely different result, or may not even be computable.
- Trying to compute the determinant of a non-square matrix: the operation is only defined when the number of rows equals the number of columns.
Frequently asked questions
What's the difference between matrix addition and multiplication?
Addition works element by element and requires two matrices of the same size. Multiplication combines rows of the first matrix with columns of the second: the number of columns in A must equal the number of rows in B, and the result has as many rows as A and as many columns as B.
How is the determinant of a 3×3 or larger matrix calculated?
This calculator uses Laplace (cofactor) expansion along the first column: the determinant is recursively broken down into the determinants of the minors obtained by removing one row and one column at a time, down to 2×2 matrices.
What's the dot product of two vectors?
It's the sum of the products of corresponding components of two vectors of equal length, whether row or column. Geometrically it relates to the cosine of the angle between the two vectors: if the dot product is zero, the vectors are orthogonal.
Can I save and reuse the matrices I've calculated?
Yes: any matrix or result can be saved to history, stored only in your browser with no account needed, and reloaded into A or B from there. You can also share a link with matrices A and B already filled in.
How these operations work
Addition and subtraction: (A ± B)[i,j] = A[i,j] ± B[i,j], defined when A and B have the same dimensions. Multiplication: (A × B)[i,j] = Σₖ A[i,k] × B[k,j], defined when A's number of columns equals B's number of rows. Transpose: Aᵀ[i,j] = A[j,i]. Determinant, by Laplace expansion along the first column: det(A) = Σᵢ (−1)ⁱ × A[i,0] × det(minorᵢ), with the base case for a 2×2 matrix: det = A[0,0]×A[1,1] − A[1,0]×A[0,1]. Dot product of vectors: a · b = Σᵢ aᵢ × bᵢ. Magnitude of a vector: |a| = √(Σᵢ aᵢ²).
Related calculators
Determinant and inverse
Determinant, rank and inverse of a square matrix up to 12 × 12.
Systems of linear equations
Gauss-Jordan elimination: unique solution, infinitely many solutions or no solution.
Eigenvalues and eigenvectors
Characteristic polynomial, real and complex eigenvalues, eigenvectors and trace.
Vector mathematics
Dot and cross products, the angle between two vectors, projection and areas.