The rank
function can return an inaccurate result if the rank calculation requires further simplification or has applied conditions or assumptions. In this case, you can investigate the solutions of a system of equations defined by the input matrix to better understand the rank of the matrix. For example, create a matrix and calculate its rank.
Here, rank
returns the full rank, which is 3. However, this result may not apply to all values of s
.
To better understand the rank of the matrix, solve the system of equations by using solve
and setting the ReturnConditions
name-value argument to true
to return any parameters and conditions of the solutions. According to the Rouché–Capelli theorem, a system of equations with variables in has at least one solution if and only if the rank of the coefficient matrix is equal to the rank of the augmented matrix . If the system has solutions, they form an affine subspace of of dimension . In other words, the solution is unique if and only if . Otherwise, the system has infinitely many solutions (the system is underdetermined) and the solutions have free parameters.
sols = struct with fields:
x1: -2*z
x2: -s*z
x3: (3*z)/2
x4: z
parameters: z
conditions: s ~= -1 & s ~= 1 & s ~= -1i & s ~= 1i
Here, solve
returns nonunique solutions for the four variables in x
with one free parameter, where specific conditions must be satisfied by the solutions of x
. Therefore, if all the conditions for the variable s
in the solutions are satisfied, the rank of the matrix is 4 – 1 = 3.
Next, investigate the condition where s = -1
. Substitute this value in the matrix A
and solve another system of equations defined by the substituted matrix.
sols2 = struct with fields:
x1: -2*z
x2: z
x3: (3*z)/2
x4: z
parameters: z
conditions: symtrue
Here, solve
returns different solutions for the substituted matrix. The solutions have one free parameter, which is z
, and has no additional conditions. Therefore, the rank of the substituted matrix where s = -1
is 4 – 1 = 3.
Next, investigate the condition where s = -1i
. Substitute this value in the matrix A
and solve another system of equations defined by the substituted matrix.
sols3 = struct with fields:
x1: - z - z1/2
x2: z*1i - (z1*1i)/2
x3: z
x4: z1
parameters: [z z1]
conditions: symtrue
Here, solve
returns different solutions with two free parameters, which are z
and z1
, and no additional conditions. Therefore, the rank of this substituted matrix where s = -1i
is 4 – 2 = 2.