Matrix Division Calculator
Explore matrix division through multiplication by an inverse matrix. Unlike ordinary scalar division, matrix division depends on the order of the operands and the existence of the required inverse.
A
B
Learn About Matrix Division
Why Standard Division Does Not Exist
In scalar arithmetic, division $\frac{a}{b}$ is uniquely defined because scalar multiplication is commutative ($a \cdot b = b \cdot a$). In linear algebra, matrix multiplication is non-commutative ($\mathbf{A}\mathbf{B} \ne \mathbf{B}\mathbf{A}$). Consequently, writing a simple fraction $\frac{\mathbf{A}}{\mathbf{B}}$ is mathematically ambiguous because multiplying by the inverse on the right yields a completely different result than multiplying on the left.
To resolve this ambiguity, linear algebra defines two distinct forms of matrix division: Right Division and Left Division.
The Two Modes of Matrix Division
- Right Division ($\mathbf{A} / \mathbf{B} = \mathbf{A}\mathbf{B}^{-1}$):
Right division represents the solution $\mathbf{X}$ to the matrix equation:
- Dimension Requirement: If $\mathbf{A}$ has dimension $m \times p$, matrix $\mathbf{B}$ must be a square $p \times p$ invertible matrix. The quotient $\mathbf{X}$ is an $m \times p$ matrix.
- Left Division ($\mathbf{B} \backslash \mathbf{A} = \mathbf{B}^{-1}\mathbf{A}$):
Left division represents the solution $\mathbf{X}$ to the matrix equation:
- Dimension Requirement: If $\mathbf{A}$ has dimension $m \times n$, matrix $\mathbf{B}$ must be a square $m \times m$ invertible matrix. The quotient $\mathbf{X}$ is an $m \times n$ matrix.
Existence Conditions
Matrix division is valid if and only if the denominator matrix $\mathbf{B}$ satisfies two conditions:
- $\mathbf{B}$ must be a square matrix.
- $\mathbf{B}$ must be invertible (nonsingular): $\det(\mathbf{B}) \ne 0$.
If $\det(\mathbf{B}) = 0$, matrix $\mathbf{B}$ is singular and has no inverse. Dividing by a singular matrix is the matrix equivalent of dividing by scalar zero, and the calculator rejects the calculation with a singular denominator error.
Worked Numerical Example (Right Division)
Compute Right Division $\mathbf{C} = \mathbf{A} / \mathbf{B} = \mathbf{A}\mathbf{B}^{-1}$ for:
- Calculate the Inverse $\mathbf{B}^{-1}$:
- Multiply $\mathbf{A}$ by $\mathbf{B}^{-1}$ on the Right:
- $c_{11} = (3)(3) + (4)(-5) = 9 - 20 = -11$
- $c_{12} = (3)(-1) + (4)(2) = -3 + 8 = 5$
- $c_{21} = (1)(3) + (2)(-5) = 3 - 10 = -7$
- $c_{22} = (1)(-1) + (2)(2) = -1 + 4 = 3$
1. Why does MATLAB use slash `/` and backslash `\` for division?
MATLAB and technical computing environments use forward slash `/` (`mrdivide`) specifically for right division ($\mathbf{A} / \mathbf{B} = \mathbf{A}\mathbf{B}^{-1}$), and backslash `\` (`mldivide`) for left division ($\mathbf{B} \backslash \mathbf{A} = \mathbf{B}^{-1}\mathbf{A}$). In linear systems $\mathbf{B}\mathbf{x} = \mathbf{a}$, writing `x = B \ a` solves the system via left division.
2. Can I divide two matrices element-by-element?
In pure linear algebra, element-by-element division ($a_{ij}/b_{ij}$) is not recognized as standard matrix division. However, in scientific programming (such as NumPy `np.divide` or MATLAB `A ./ B`), element-wise division is used for point-by-point data scaling, requiring non-zero entries in $\mathbf{B}$.
3. What if the denominator matrix $\mathbf{B}$ is rectangular?
An ordinary matrix inverse does not exist for rectangular matrices. However, generalized division can be performed using the Moore-Penrose pseudoinverse ($\mathbf{B}^+$):
- Right pseudodivision: $\mathbf{A} \mathbf{B}^+ = \mathbf{A} \mathbf{B}^T (\mathbf{B}\mathbf{B}^T)^{-1}$
- Left pseudodivision: $\mathbf{B}^+ \mathbf{A} = (\mathbf{B}^T\mathbf{B})^{-1} \mathbf{B}^T \mathbf{A}$
This provides the optimal least-squares solution to over- or under-determined systems.
1. In Practice, Numerical Algorithms Never Invert $\mathbf{B}$
While matrix division is defined mathematically as $\mathbf{A}\mathbf{B}^{-1}$ or $\mathbf{B}^{-1}\mathbf{A}$, production numerical software (like LAPACK or BLAS) never computes the explicit inverse $\mathbf{B}^{-1}$ to perform division. Computing an explicit inverse is numerically unstable and computationally expensive. Instead, division algorithms factor $\mathbf{B} = \mathbf{L}\mathbf{U}$ (LU decomposition) and solve the system via forward and backward triangular substitution in $O(n^3)$ time, yielding far superior numerical precision.
2. Associativity of Mixed Multiplications
Although division order matters ($\mathbf{A}\mathbf{B}^{-1} \ne \mathbf{B}^{-1}\mathbf{A}$), standard associative rules apply when chaining operations:
Parentheses can be shifted freely as long as the relative multiplication order is preserved.