Matrix Subtraction Calculator
Subtract one matrix from another by taking the difference between corresponding entries. Matrix subtraction requires both matrices to have identical dimensions and is generally not commutative, meaning the order of the matrices matters.
A
B
Learn About Matrix Subtraction
Definition and Element-Wise Difference
Matrix subtraction is the operation of computing the difference between two matrices of identical dimensions by subtracting each entry of the second matrix from the corresponding entry of the first. For two $m \times n$ matrices $\mathbf{A} = [a_{ij}]$ and $\mathbf{B} = [b_{ij}]$, their difference $\mathbf{C} = \mathbf{A} - \mathbf{B}$ is defined by:
Algebraically, subtraction is equivalent to adding the additive inverse (negation) of matrix $\mathbf{B}$:
Dimension Matching Requirement
Subtraction is defined if and only if both matrices share the exact same number of rows and columns:
Subtracting matrices of differing dimensions is undefined. When dimensions differ, the calculator returns a validation error.
Anti-Commutativity and Key Properties
Unlike matrix addition, matrix subtraction is not commutative:
Instead, matrix subtraction is anti-commutative:
Reversing the operand order produces the exact negation of the resulting matrix.
Additional algebraic properties include:
- Non-Associativity: $(\mathbf{A} - \mathbf{B}) - \mathbf{C} \ne \mathbf{A} - (\mathbf{B} - \mathbf{C})$ in general, because $\mathbf{A} - (\mathbf{B} - \mathbf{C}) = \mathbf{A} - \mathbf{B} + \mathbf{C}$
- Self-Subtraction (Zero Matrix): $\mathbf{A} - \mathbf{A} = \mathbf{0}_{m \times n}$
- Zero Right Identity: $\mathbf{A} - \mathbf{0} = \mathbf{A}$, but $\mathbf{0} - \mathbf{A} = -\mathbf{A}$
- Transpose Distribution: $(\mathbf{A} - \mathbf{B})^T = \mathbf{A}^T - \mathbf{B}^T$
- Trace Linearity: $\operatorname{tr}(\mathbf{A} - \mathbf{B}) = \operatorname{tr}(\mathbf{A}) - \operatorname{tr}(\mathbf{B})$ (for square matrices)
Worked Numerical Example
Given matrices $\mathbf{A}$ and $\mathbf{B}$ in $\mathbb{R}^{2 \times 2}$:
Subtract corresponding entries:
1. Why does the order of matrices matter in subtraction?
Because scalar subtraction is non-commutative ($a - b \ne b - a$), element-wise subtraction inherits this property. Subtracting $\mathbf{B}$ from $\mathbf{A}$ yields entries $a_{ij} - b_{ij}$, whereas subtracting $\mathbf{A}$ from $\mathbf{B}$ yields $b_{ij} - a_{ij} = -(a_{ij} - b_{ij})$. Thus, swapping operand order negates the entire result.
2. Can I subtract a scalar number from a matrix?
Directly writing $\mathbf{A} - c$ is mathematically undefined because scalars and matrices are different algebraic entities. In applications like computing characteristic equations, one subtracts a scalar multiple of the identity matrix: $\mathbf{A} - \lambda \mathbf{I}$, which subtracts $\lambda$ only from the main diagonal entries.
3. Does matrix subtraction preserve diagonal or triangular structures?
Yes. If both matrices are diagonal, their difference is diagonal. If both are upper triangular, their difference remains upper triangular. Similarly, the difference between any two symmetric matrices remains symmetric: $(\mathbf{A} - \mathbf{B})^T = \mathbf{A}^T - \mathbf{B}^T = \mathbf{A} - \mathbf{B}$.
1. Generating Skew-Symmetric Matrices via Subtraction
Any real square matrix $\mathbf{M}$ can be uniquely decomposed into the sum of a symmetric matrix $\mathbf{S}$ and a skew-symmetric matrix $\mathbf{K}$ using matrix addition and subtraction:
The subtraction term $\mathbf{K} = \frac{1}{2}(\mathbf{M} - \mathbf{M}^T)$ produces a matrix that equals the negative of its own transpose ($\mathbf{K}^T = -\mathbf{K}$), forming the mathematical foundation for rotational velocities in rigid-body mechanics.
2. Matrix Subtraction in Digital Image Processing
In computer vision and motion detection, background subtraction computes the element-wise difference between successive video frames: $\mathbf{D} = |\mathbf{F}_{t} - \mathbf{F}_{t-1}|$. Pixels where illumination is static evaluate to zero, instantaneously isolating moving foreground objects from static backgrounds.