3
$\begingroup$

It has been known that matrix A is equivalent to matrix B, and I want to find the possible value of parameter a (the answer is a = 2). This question is slightly different from that of this post.

A = {{1, 2, a}, {1, 3, 0}, {2, 7, -a}}; 
B = {{1, a, 2}, {0, 1, 1}, {-1, 1, 1}}; 
Solve[MatrixRank[A] == MatrixRank[B], a]

The above code can not output the correct results, I need your help.

Besides, I have another question. I find that RowReduce-function can't make the matrix with parameters into row simplest type:

RowReduce[{{1, a, 2}, {0, 1, 1}, {-1, 1, 1}}]

The row simplest form of matrix $\left(\begin{array}{ccc} 1 & a & 2 \\ 0 & 1 & 1 \\ -1 & 1 & 1 \end{array}\right)$ should be $\left(\begin{array}{ccc} 1 & -1 & -1 \\ 0 & 1 & 1 \\ 0 & a-2 & 0 \end{array}\right)$ instead of $\left(\begin{array}{lll} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{array}\right)$. I wonder if this error is a bug in the RowReduce function.

In addition, sometimes it is necessary to deal with the following non square matrix equation:

A = {{1, -1, -1}, {2, a, 1}, {-1, 1, a}}; B = {{2, 2}, {1, 
   a}, {-a - 1, -2}}; 
Solve[MatrixRank[A] == 
    MatrixRank[Join[A, B, 2]], a, Reals]
$\endgroup$
5
  • 2
    $\begingroup$ To address the last question: This is not a bug in RowReduce (nor is it an error). $\endgroup$ Commented Aug 5, 2020 at 14:50
  • 2
    $\begingroup$ 1. There is no bug here. 2. You should know by now that the bugs tag is not to be applied unless other people have confirmed that what you've seen is a bug. $\endgroup$ Commented Aug 5, 2020 at 14:51
  • 1
    $\begingroup$ @DanielLichtblau If it's not a bug I would argue, though, that the documentation does a pretty bad job at explaining this limitation. Would it be feasible for RowReduce to have a GenerateConditions option to at least be able to keep track of the conditions that that make the reduced form valid? $\endgroup$ Commented Aug 20, 2020 at 8:42
  • 2
    $\begingroup$ @SjoerdSmit (1) I don't think such an option is likely to be added but in theory it is feasible. One way to obtain such information is to augment the matrix with an identity matrix on the right (as though finding a matrix inverse as taught in linear algebra), then row reduce, then take denominators in the augmented section as nonvanishing conditions. $\endgroup$ Commented Aug 20, 2020 at 14:20
  • 2
    $\begingroup$ @SjoerdSmit (2) See also this old response to a similar question, for adapting the ZeroTest option. $\endgroup$ Commented Aug 20, 2020 at 14:22

3 Answers 3

5
+150
$\begingroup$

It looks like RowReduce and MatrixRank implicitly assume that a does not have a particular value that reduces the rank of the matrix. They can detect that matrix A is degenerate for any value of a, but not that B is degenerate for a == 2.

I think you might be able to get around this with SingularValueList, which seems to handle the problem better:

Assuming[a \[Element] Reals,
  Simplify[Reduce[Simplify[#] == 0] & /@ SingularValueList[A]]
]
Assuming[a \[Element] Reals,
  Simplify[Reduce[Simplify[#] == 0] & /@ SingularValueList[B]]
]

{False, False}

{a == 2, False, False}

From this you can see that A always has rank 2 while B has rank 3 any value of a other than 2.

Edit

Here's a quick attempt to do what you asked directly:

symbolicMatrixRank[mat_, assumptions_] := Assuming[assumptions,
   Simplify @ Total @ Simplify[
     Boole[!Reduce[Simplify[#] == 0]] & /@ SingularValueList[mat]
   ]
];
Solve[symbolicMatrixRank[A, a ∈ Reals] == symbolicMatrixRank[B, a ∈ Reals]]

{{a -> 2}}

or similarly:

symbolicMatrixRank[mat_, assumptions_] := Assuming[assumptions,
  Simplify @ Total @ Map[
    Boole @ Simplify @ Reduce[ConditionalExpression[#, $Assumptions] != 0]&,
    SingularValueList[mat]
  ]
];

As noted in a comment, Solve doesn't not always seem to deal with these sort of piecewise equations too well. Resolve is more adapt at solving them.

$\endgroup$
10
  • $\begingroup$ Your answer is great, but how to deal with the following non square matrix equation:A = {{1, -1, -1}, {2, a, 1}, {-1, 1, a}}; B = {{2, 2}, {1, a}, {-a - 1, -2}}; Solve[symbolicMatrixRank[A, Element[a, Reals]] == symbolicMatrixRank[Join[A, B, 2], Element[a, Reals]]]. $\endgroup$ Commented Aug 9, 2020 at 7:46
  • 1
    $\begingroup$ @Montevideo For some reason Solve doesn't handle this very well. Try Reduce instead. It should give you 2 + a != 0. $\endgroup$ Commented Aug 10, 2020 at 19:18
  • 1
    $\begingroup$ @Montevideo Try the second form of symbolicMatrixRank I put in my answer. That one works here. Depending on the returned value of SingularValueList, you may need to wrangle a little with how you call Reduce and Simplify. I won't claim that these functions work for every imaginable matrix. $\endgroup$ Commented Aug 16, 2020 at 19:26
  • 1
    $\begingroup$ @Montevideo Please ask a new question. The comments aren't the right place for this. $\endgroup$ Commented Aug 20, 2020 at 8:25
  • 1
    $\begingroup$ @Montevideo I'm a bit busy atm, but I'll have a look when I have time. $\endgroup$ Commented Aug 20, 2020 at 12:57
2
$\begingroup$

I have made a MatrixRankSym feature with symbolic computation here. And we can use it directly:

For your first equation:

A = {{1, 2, a}, {1, 3, 0}, {2, 7, -a}};
B = {{1, a, 2}, {0, 1, 1}, {-1, 1, 1}};
Reduce[MatrixRankSym[A] == MatrixRankSym[B], a]

a == 2

For your second non square matrix equation:

A = {{1, -1, -1}, {2, a, 1}, {-1, 1, a}};
B = {{2, 2}, {1, a}, {-a - 1, -2}};
Reduce[MatrixRankSym[A] == MatrixRankSym[Join[A, B, 2]], a, Reals]

a < -2 || a > -2

$\endgroup$
1
$\begingroup$

We now have UpperTriangularDecomposition in the Wolfram Function Repository. It returns an upper-triangularized form and the corresponding conversion matrix. Also it attempts to avoid creating fractions. It can be applied here like so:

aA = {{1, 2, a}, {1, 3, 0}, {2, 7, -a}};
bB = {{1, a, 2}, {0, 1, 1}, {-1, 1, 1}};
aUpper = ResourceFunction["UpperTriangularDecomposition"][aA][[1]]
bUpper = ResourceFunction["UpperTriangularDecomposition"][bB][[1]]

(* Out[150]= {{1, 3, 0}, {0, 1, -a}, {0, 0, 0}}

Out[151]= {{-1, 1, 1}, {0, 1, 1}, {0, 0, -2 + a}} *)

From here one can see that aA has rank 2, and bB also has rank 2 iff a==2.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.