Matrix Calculator

Products, determinants, inverses and linear systems with AI-powered step-by-step working
[[1,2],[3,4]] * [[0,1],[1,0]]
inverse of [[4,7],[2,6]]
Solve 2x + 3y = 8, x - y = -1 using matrices
trace of [[3,1,0],[2,5,4],[1,1,7]]

The Operations and Their Rules

A matrix is a rectangular array of numbers with a shape, written rows × columns. The shape decides what is legal.

  • Addition and subtraction work entry by entry and require identical shapes.
  • Scalar multiplication multiplies every entry: 2A2A doubles each one.
  • Matrix multiplication needs the inner dimensions to agree: an m×nm \times n matrix times an n×pn \times p matrix gives an m×pm \times p result. Entry (i,j)(i, j) of the product is the dot product of row ii of the first matrix with column jj of the second.
  • Transpose ATA^{T} flips rows into columns.
  • Trace is the sum of the main-diagonal entries, defined only for square matrices.
  • Determinant of a 2×22 \times 2 matrix is det(abcd)=adbc\det\begin{pmatrix} a & b \\ c & d \end{pmatrix} = ad - bc.

Matrix multiplication is not commutative: ABAB and BABA are usually different matrices, and one may not even be a legal product.

A 1×n1 \times n matrix is a row vector and an n×1n \times 1 matrix is a column vector. That is exactly why an entire system of equations can be written as one compact matrix equation.

Solving a Linear System with Matrices

Any linear system can be written as Ax=bA\mathbf{x} = \mathbf{b}, where AA holds the coefficients, x\mathbf{x} the unknowns and b\mathbf{b} the right-hand sides. The system

2x+3y=8,xy=12x + 3y = 8, \quad x - y = -1

becomes (2311)(xy)=(81)\begin{pmatrix} 2 & 3 \\ 1 & -1 \end{pmatrix}\begin{pmatrix} x \\ y \end{pmatrix} = \begin{pmatrix} 8 \\ -1 \end{pmatrix}.

If detA0\det A \neq 0 the matrix has an inverse and the solution is x=A1b\mathbf{x} = A^{-1}\mathbf{b}. For 2×22 \times 2 matrices:

A1=1adbc(dbca)A^{-1} = \frac{1}{ad - bc}\begin{pmatrix} d & -b \\ -c & a \end{pmatrix}

Swap the diagonal entries, negate the off-diagonal ones, divide by the determinant.

When detA=0\det A = 0 there is no inverse, and the system either has no solution or infinitely many — the same two degenerate cases you meet with substitution and elimination.

Common Mistakes to Avoid

  • Assuming AB=BAAB = BA. Order matters. (1234)(0110)\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}\begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} swaps columns; reversing the order swaps rows instead.
  • Multiplying entry by entry. Matrix product entries are dot products of a row with a column, not products of matching positions.
  • Checking the wrong dimensions. A 2×32 \times 3 times a 2×32 \times 3 is undefined; the columns of the first must equal the rows of the second.
  • Forgetting to divide by the determinant when writing an inverse. The adjugate alone is not A1A^{-1}.
  • Solving Ax=bA\mathbf{x} = \mathbf{b} as bA1\mathbf{b}A^{-1}. The inverse must be applied on the left: A1bA^{-1}\mathbf{b}.
  • Sign slips in adbcad - bc. With negative entries, write each product out before subtracting.

Examples

Step 1: Both are 2×22 \times 2, so the product is 2×22 \times 2.
Step 2: Row 1 with column 1: 1(0)+2(1)=21(0) + 2(1) = 2. Row 1 with column 2: 1(1)+2(0)=11(1) + 2(0) = 1.
Step 3: Row 2 with column 1: 3(0)+4(1)=43(0) + 4(1) = 4. Row 2 with column 2: 3(1)+4(0)=33(1) + 4(0) = 3.
Step 4: Assemble the entries in place.
Answer: (2143)\begin{pmatrix} 2 & 1 \\ 4 & 3 \end{pmatrix} — the columns of the first matrix have been swapped

Step 1: detA=adbc=(4)(6)(7)(2)=2414=10\det A = ad - bc = (4)(6) - (7)(2) = 24 - 14 = 10.
Step 2: Since detA=100\det A = 10 \neq 0, the inverse exists.
Step 3: Swap the diagonal and negate the off-diagonal: (6724)\begin{pmatrix} 6 & -7 \\ -2 & 4 \end{pmatrix}.
Step 4: Divide by the determinant: A1=110(6724)A^{-1} = \frac{1}{10}\begin{pmatrix} 6 & -7 \\ -2 & 4 \end{pmatrix}.
Step 5: Check: 110(4(6)+7(2)4(7)+7(4)2(6)+6(2)2(7)+6(4))=110(100010)=I\frac{1}{10}\begin{pmatrix} 4(6) + 7(-2) & 4(-7) + 7(4) \\ 2(6) + 6(-2) & 2(-7) + 6(4) \end{pmatrix} = \frac{1}{10}\begin{pmatrix} 10 & 0 \\ 0 & 10 \end{pmatrix} = I
Answer: detA=10\det A = 10 and A1=(0.60.70.20.4)A^{-1} = \begin{pmatrix} 0.6 & -0.7 \\ -0.2 & 0.4 \end{pmatrix}

Step 1: Write A=(2311)A = \begin{pmatrix} 2 & 3 \\ 1 & -1 \end{pmatrix}, b=(81)\mathbf{b} = \begin{pmatrix} 8 \\ -1 \end{pmatrix}.
Step 2: detA=(2)(1)(3)(1)=23=5\det A = (2)(-1) - (3)(1) = -2 - 3 = -5.
Step 3: A1=15(1312)=(0.20.60.20.4)A^{-1} = \frac{1}{-5}\begin{pmatrix} -1 & -3 \\ -1 & 2 \end{pmatrix} = \begin{pmatrix} 0.2 & 0.6 \\ 0.2 & -0.4 \end{pmatrix}.
Step 4: x=0.2(8)+0.6(1)=1.60.6=1x = 0.2(8) + 0.6(-1) = 1.6 - 0.6 = 1.
Step 5: y=0.2(8)+(0.4)(1)=1.6+0.4=2y = 0.2(8) + (-0.4)(-1) = 1.6 + 0.4 = 2.
Step 6: Check: 2(1)+3(2)=82(1) + 3(2) = 8 ✓ and 12=11 - 2 = -1
Answer: x=1x = 1, y=2y = 2

Frequently Asked Questions

Only when the number of columns in the first matrix equals the number of rows in the second. A 2x3 matrix can multiply a 3x4 matrix, giving a 2x4 result. If the inner dimensions do not match, the product simply does not exist.

The trace is the sum of the entries on the main diagonal, from top left to bottom right, and it is defined only for square matrices. It equals the sum of the eigenvalues, which is why it appears so often in linear algebra even though it is trivial to compute.

Because its determinant is zero, which means the rows are linearly dependent — one is a multiple or combination of the others. For a linear system that signals either no solution or infinitely many, so no single point can be recovered by inverting.

For two equations, substitution or elimination is usually quicker by hand. Matrices pay off with three or more equations, and especially when you have to solve the same coefficient matrix against several different right-hand sides, since the inverse is computed only once.

Related Solvers

Related Guides

Try AI-Math for Free

Get step-by-step solutions to any math problem. Upload a photo or type your question.

Start Solving