Subtraction of Two Matrices Calculator
Subtract a 2×2 or 3×3 matrix B from matrix A element by element. Enter the values of both matrices and get the resulting matrix C = A − B instantly, with the formula and a worked example.
Matrix Subtraction Solver
Matrix Subtraction Formula
Where:
- \(A\) and \(B\) — matrices of the same size \(m \times n\) (here 2×2 or 3×3)
- \(C\) — the resulting matrix of the same size \(m \times n\)
- \(a_{ij}\), \(b_{ij}\) — the elements of \(A\) and \(B\) in row \(i\), column \(j\)
Each element of the result is found by subtracting the corresponding element of \(B\) from the corresponding element of \(A\): \(c_{ij} = a_{ij} - b_{ij}\).
Subtraction of Two Matrices – Calculation Example
Example: subtract the identity matrix \(B\) from a 3×3 matrix \(A\) using the calculator's default values.
\[ A = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix}, \quad B = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} \]
\[ C = A - B = \begin{bmatrix} 1-1 & 2-0 & 3-0 \\ 4-0 & 5-1 & 6-0 \\ 7-0 & 8-0 & 9-1 \end{bmatrix} = \begin{bmatrix} 0 & 2 & 3 \\ 4 & 4 & 6 \\ 7 & 8 & 8 \end{bmatrix} \]
Result: \( C = \begin{bmatrix} 0 & 2 & 3 \\ 4 & 4 & 6 \\ 7 & 8 & 8 \end{bmatrix} \)
How to Use the Subtraction of Two Matrices Calculator
- Select the Matrix Size — either 2 × 2 or 3 × 3. The input fields adjust automatically.
- Enter the elements of Matrix A in the fields \(a_{11}, a_{12}, \ldots\). The first index is the row, the second is the column.
- Enter the elements of Matrix B in the fields \(b_{11}, b_{12}, \ldots\), in the same positions.
- The Result appears instantly as a table showing the matrix \(C = A - B\).
- Change any value and the result updates automatically — no button to press.
What Is Matrix Subtraction?
Matrix subtraction is one of the basic operations of linear algebra. Two matrices can be subtracted only when they have the same dimensions: an \(m \times n\) matrix can be subtracted from another \(m \times n\) matrix, and the result is again an \(m \times n\) matrix. The operation is performed element by element, so each entry of the answer depends only on the two entries in the same position of the original matrices.
It is worth remembering that subtraction is not commutative: in general \(A - B \neq B - A\). In fact, \(B - A = -(A - B)\), so reversing the order gives the negated result. If you subtract a matrix from itself, you get the zero matrix, in which every element is 0.
Matrix subtraction appears wherever matrices model data or transformations: solving systems of linear equations, comparing datasets (for example, subtracting an expected image from an observed one), computing residuals in statistics, physics simulations, computer graphics, and machine learning. It is also the inverse of matrix addition — adding \(B\) back to \(C = A - B\) recovers \(A\).
When interpreting the result, read it position by position: the element in row \(i\), column \(j\) of \(C\) tells you how much smaller (or larger, if negative) the entry of \(B\) is than the entry of \(A\) at that position. Positive and negative entries can be mixed freely in the same result.
Assumptions, Limitations and Tips
- Same dimensions required: this calculator works with square matrices of size 2×2 and 3×3. Subtracting a 2×2 matrix from a 3×3 matrix is mathematically undefined.
- Order matters: the calculator computes \(A - B\), not \(B - A\). To get \(B - A\), swap the values between the two input blocks.
- Decimals and negatives: fractional and negative values are accepted; results are shown rounded to two decimal places.
- Watch the signs: a common manual mistake is subtracting a negative entry incorrectly — \(a_{ij} - (-b_{ij}) = a_{ij} + b_{ij}\).
- Subtraction of determinants is not the same: in general \(\det(A - B) \neq \det(A) - \det(B)\). Be careful not to confuse matrix operations with operations on determinants.
Related Calculators
To add matrices instead of subtracting, use the Addition of Two Matrices calculator. For products of matrices, see the Matrix Multiplication calculator, and to square a single matrix, try Matrix Squared. If your next step involves inverting a 3×3 matrix, the Inverse Matrix 3×3 calculator will help.
Frequently Asked Questions
How do I subtract two matrices by hand?
Write both matrices side by side and subtract entry by entry, matching row and column positions. For example, the top-left result is \(a_{11} - b_{11}\), the entry next to it is \(a_{12} - b_{12}\), and so on. Work through every position, being careful with signs when \(b_{ij}\) is negative, since \(a_{ij} - (-b_{ij}) = a_{ij} + b_{ij}\). Finally, double-check a few entries against the calculator to catch arithmetic slips.
Can I subtract matrices that are not square, like 2×3 or 3×2?
Yes, mathematically any two matrices of identical dimensions can be subtracted, including rectangular ones such as \(2 \times 3\) or \(3 \times 2\). This particular calculator only offers 2×2 and 3×3 square matrices, but the element-by-element rule is exactly the same for rectangular shapes: \(c_{ij} = a_{ij} - b_{ij}\). Only the number of entries you must process changes.
How can I verify my matrix subtraction is correct?
The quickest check is to add matrix \(B\) back to your result: since subtraction is the inverse of addition, \((A - B) + B\) must equal \(A\) exactly. If any entry differs, you made an arithmetic error in that position. You can also test the reverse order: computing \(B - A\) should give the negated result, meaning every entry has the opposite sign of your answer.
Can I subtract more than two matrices at once?
Yes, as long as all matrices share the same dimensions. Subtraction is performed left to right, for example \(A - B - C = (A - B) - C\). With this calculator, subtract two matrices first, then enter the result as your new Matrix A and subtract the next matrix from it. Repeat until all matrices are processed — the order in which you subtract them affects the final answer.
What does subtracting the identity matrix do?
Subtracting the identity matrix \(I\) leaves the diagonal entries reduced by 1 while all off-diagonal entries stay unchanged, since \(I\) has 1s on the diagonal and 0s elsewhere. This is why \(A - I\) appears often when working with eigenvalues: for example, solving \(\det(A - \lambda I) = 0\) uses exactly this kind of shifted diagonal subtraction.
Does the order of rows and columns matter when entering values?
Yes. The first index of each label is the row and the second is the column, so \(a_{21}\) means row 2, column 1. Entering values in the wrong orientation effectively transposes the matrix, which produces a different result because subtraction happens position by position. Double-check that each value sits in the field matching its position in your original matrix.
What happens when the result contains negative numbers or zeros?
Nothing special — negative and zero entries are perfectly valid in the result. A negative entry \(c_{ij}\) simply means the value in matrix \(B\) was larger than the corresponding value in matrix \(A\) at that position. If every entry comes out zero, the two matrices were identical, since \(A - A\) always equals the zero matrix.