mrdivide, /
Symbolic matrix right division
Syntax
Description
solves the symbolic system of linear equations in matrix form, X
= B
/A
X*A =
B
for X
. The matrices A
and
B
must contain the same number of columns. The right
division of matrices B/A
is equivalent to
(A'\B')'
.
If the solution does not exist or if it is not unique, the /
operator issues a warning.
A
can be a rectangular matrix, but the equations must be
consistent. The symbolic operator /
does not compute
least-squares solutions.
Examples
System of Equations in Matrix Form
Solve a system of linear equations specified by a square matrix of coefficients and a vector of right sides of equations.
Create a matrix containing the coefficient of equation terms, and a vector containing the right sides of equations.
A = sym(pascal(4)) b = sym([4 3 2 1])
A = [ 1, 1, 1, 1] [ 1, 2, 3, 4] [ 1, 3, 6, 10] [ 1, 4, 10, 20] b = [ 4, 3, 2, 1]
Use the operator /
to solve this system.
X = b/A
X = [ 5, -1, 0, 0]
Rank-Deficient System
Create a matrix containing the coefficient of equation terms, and a vector containing the right sides of equations.
A = sym(magic(4))' b = sym([0 1 1 0])
A = [ 16, 5, 9, 4] [ 2, 11, 7, 14] [ 3, 10, 6, 15] [ 13, 8, 12, 1] b = [ 0, 1, 1, 0]
Find the rank of the system. This system contains four equations, but its rank is
3
. Therefore, the system is rank-deficient. This means that
one variable of the system is not independent and can be expressed in terms of other
variables.
rank(vertcat(A,b))
ans = 3
Try to solve this system using the symbolic /
operator. Because
the system is rank-deficient, the returned solution is not unique.
b/A
Warning: Solution is not unique because the system is rank-deficient. ans = [ 1/34, 19/34, -9/17, 0]
Inconsistent System
Create a matrix containing the coefficient of equation terms, and a vector containing the right sides of equations.
A = sym(magic(4))' b = sym([0 1 2 3])
A = [ 16, 5, 9, 4] [ 2, 11, 7, 14] [ 3, 10, 6, 15] [ 13, 8, 12, 1] b = [ 0, 1, 2, 3]
Try to solve this system using the symbolic /
operator. The
operator issues a warning and returns a vector with all elements set to
Inf
because the system of equations is inconsistent, and
therefore, no solution exists. The number of elements equals the number of equations
(rows in the coefficient matrix).
b/A
Warning: Solution does not exist because the system is inconsistent. ans = [ Inf, Inf, Inf, Inf]
Find the reduced row echelon form of this system. The last row shows that one of
the equations reduced to 0 = 1
, which means that the system of
equations is inconsistent.
rref(vertcat(A,b)')
ans = [ 1, 0, 0, 1, 0] [ 0, 1, 0, 3, 0] [ 0, 0, 1, -3, 0] [ 0, 0, 0, 0, 1]
Input Arguments
Output Arguments
Tips
Matrix computations involving many symbolic variables can be slow. To increase the computational speed, reduce the number of symbolic variables by substituting the given values for some variables.
When dividing by zero,
mrdivide
considers the numerator’s sign and returnsInf
or-Inf
accordingly.syms x [sym(1)/sym(0), sym(-1)/sym(0), x/sym(0)]
ans = [ Inf, -Inf, Inf*x]