8
$\begingroup$

I need to row-reduce the following matrix,

{{a, b, 0, 0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, a1, b1, 0, 0, 1},
 {0, 0, c, d, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0, 0, c1 ,d1, 1}, 
 {0, b1, 0, -d1, a, 0, -c, 0, 0}, {-b1, 0, d1, 0, b, 0, -d, 0, 0}, 
 {0, -a1, 0, c1, 0, a, 0, -c, 0}, {a1, 0, -c1, 0, 0, b, 0, -d, 0}}

After Mathematica does the computation, the bottom row is a row of zeros. This is to be expected (based on my problem). However, the second to bottom row is a row of zeros with a 1 at the end. When the algebra is done "by hand", one really should obtain a row of zeros with some linear combination of the variables involved instead of 1. Mathematica divides by this expression. This expression could be zero, and in my problem, I want that last matrix entry to be zero. How can I tell Mathematica not to simplify?

If you be kind,can you also upload the answer you are getting, so I can double-check with mine?

$\endgroup$
10
  • $\begingroup$ From what you write it seems likely that you have given values to the variables in question at some time previous to your matrix calculation. You should clear those variables before making the computation. $\endgroup$
    – m_goldberg
    Commented Jul 1, 2017 at 6:30
  • $\begingroup$ When the algebra is done "by hand" Can you show the hand solution then which is different from Mathematica solution? $\endgroup$
    – Nasser
    Commented Jul 1, 2017 at 7:05
  • $\begingroup$ @Nasser Yes. Set a = a1 = 1, b = b1 = 0, c = c1 = 0, d = d1 = 1. Get a different answer. Mathematica makes a mistake because it divides by zero in the general variable case. $\endgroup$ Commented Jul 1, 2017 at 7:09
  • 1
    $\begingroup$ I am not sure I understand. But you can try (RowReduce[mat, ZeroTest -> (PossibleZeroQ[Simplify[#]] &)]) // MatrixForm if you want to see the content not simplified. But your question is not clear. Are you saying the second row from the bottom is supposed to be all zeros and not have 1 as it last entry? $\endgroup$
    – Nasser
    Commented Jul 1, 2017 at 7:14
  • 1
    $\begingroup$ I do not think it is possible to tell M that x/x is not 1 when x is symbol with no value. At least I do not know how to do it. Assuming[x == 0, Simplify[x/x]] gives 1 always. I think the front end replaces x/x by 1 before the kernel even gets hold of it. But I am not sure. $\endgroup$
    – Nasser
    Commented Jul 1, 2017 at 7:37

2 Answers 2

6
$\begingroup$

You can choose a different ZeroTest option:

RowReduce[
    {
    {a,b,0,0,0,0,0,0,1},
    {0,0,0,0,a1,b1,0,0,1},
    {0,0,c,d,0,0,0,0,1},
    {0,0,0,0,0,0,c1,d1,1},
    {0,b1,0,-d1,a,0,-c,0,0},
    {-b1,0,d1,0,b,0,-d,0,0},
    {0,-a1,0,c1,0,a,0,-c,0},
    {a1,0,-c1,0,0,b,0,-d,0}
    },
    ZeroTest->PossibleZeroQ
] //TeXForm

$\left( \begin{array}{ccccccccc} 1 & 0 & 0 & 0 & 0 & \frac{b}{\text{a1}} & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & -\frac{a}{\text{a1}} & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & \frac{d}{\text{c1}} & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & -\frac{c}{\text{c1}} & 0 \\ 0 & 0 & 0 & 0 & 1 & \frac{\text{b1}}{\text{a1}} & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & \frac{\text{d1}}{\text{c1}} & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & \text{a1} \text{c1} (\text{b1} c (\text{a1} b c \text{c1}-a \text{a1} \text{c1} d)-c (a \text{a1} d-\text{a1} b c) (\text{a1} \text{d1}-\text{b1} \text{c1}))-\text{a1}^2 c (\text{a1} b c \text{c1}-a \text{a1} \text{c1} d) \text{d1} & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & \text{a1} \text{c1} \left(b \text{b1} c^2 (\text{a1} b c \text{c1}-a \text{a1} \text{c1} d)-c (a \text{a1} d-\text{a1} b c) (a \text{a1} d \text{d1}-b \text{b1} c \text{c1})\right)-a \text{a1}^2 c d (\text{a1} b c \text{c1}-a \text{a1} \text{c1} d) \text{d1} & 0 \\ \end{array} \right)$

$\endgroup$
0
$\begingroup$

We now have ResourceFunction["UpperTriangularDecomposition"] in the Wolfram Function Repository. It returns an upper-triangulated form and the corresponding conversion matrix as {uu,conv}. It effectively shows the parameter functions that must not vanish in order to get the "generic" reduced echelon form. These appear as pivots in the upper triangular part.

mat = {{a, b, 0, 0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, a1, b1, 0, 0, 1}, {0,
     0, c, d, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0, 0, c1, d1, 1}, {0, b1, 
    0, -d1, a, 0, -c, 0, 0}, {-b1, 0, d1, 0, b, 0, -d, 0, 0}, {0, -a1,
     0, c1, 0, a, 0, -c, 0}, {a1, 0, -c1, 0, 0, b, 0, -d, 0}};
{uu, conv} = ResourceFunction["UpperTriangularDecomposition"][mat]

(* Out[129]= {{{a, b, 0, 0, 0, 0, 0, 0, 1}, {0, -a1, 0, c1, 0, a, 0, -c, 
   0}, {0, 0, c, d, 0, 0, 0, 0, 1}, {0, 0, 
   0, -a b1 c1 + a a1 d1, -a^2 a1, -a^2 b1, a a1 c, a b1 c, 0}, {0, 0,
    0, 0, a1, b1, 0, 0, 1}, {0, 0, 0, 0, 0, 0, c1, d1, 1}, {0, 0, 0, 
   0, 0, 0, 0, 
   0, -a1^2 b c^2 c1 + a a1 b c c1^2 + a1^2 b1 c c1^2 - a a1 b1 c1^3 +
     a a1^2 c c1 d - a^2 a1 c1^2 d - a1^3 c c1 d1 + 
    a a1^2 c1^2 d1}, {0, 0, 0, 0, 0, 0, 0, 0, 0}}, {{1, 0, 0, 0, 0, 0,
    0, 0}, {0, 0, 0, 0, 0, 0, 1, 0}, {0, 0, 1, 0, 0, 0, 0, 0}, {0, 0, 
   0, 0, -a a1, 0, -a b1, 0}, {0, 1, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 
   0, 0, 0, 0}, {a1^2 b1 c c1^2 - a1^3 c c1 d1, 
   a a1 b c c1^2 - a^2 a1 c1^2 d, -a a1 b1 c1^3 + 
    a a1^2 c1^2 d1, -a1^2 b c^2 c1 + a a1^2 c c1 d, -a1^2 b c c1^2 + 
    a a1^2 c1^2 d, 0, 
   a a1 b1 c1^2 d - a1^2 b c c1 d1, -a a1 b1 c c1^2 + 
    a a1^2 c c1 d1}, {a1 b b1 c c1^2 - a1 b1^2 c1^3 - a a1 b1 c1^2 d -
     a1^2 b c c1 d1 + 2 a1^2 b1 c1^2 d1 + a a1^2 c1 d d1 - 
    a1^3 c1 d1^2, 
   a1 b^2 c^2 c1 - a1 b b1 c c1^2 - 2 a a1 b c c1 d + a a1 b1 c1^2 d +
     a^2 a1 c1 d^2 + a1^2 b c c1 d1 - 
    a a1^2 c1 d d1, -a1 b b1 c c1^2 + a1 b1^2 c1^3 + a a1 b1 c1^2 d + 
    a1^2 b c c1 d1 - 2 a1^2 b1 c1^2 d1 - a a1^2 c1 d d1 + 
    a1^3 c1 d1^2, -a1 b^2 c^2 c1 + a1 b b1 c c1^2 + 2 a a1 b c c1 d - 
    a a1 b1 c1^2 d - a^2 a1 c1 d^2 - a1^2 b c c1 d1 + 
    a a1^2 c1 d d1, -a1 b^2 c c1^2 + a1 b b1 c1^3 + a1^2 b c c1 d + 
    a a1 b c1^2 d - a1^2 b1 c1^2 d - a a1^2 c1 d^2 - a1^2 b c1^2 d1 + 
    a1^3 c1 d d1, -a1^2 b c^2 c1 + a a1 b c c1^2 + a1^2 b1 c c1^2 - 
    a a1 b1 c1^3 + a a1^2 c c1 d - a^2 a1 c1^2 d - a1^3 c c1 d1 + 
    a a1^2 c1^2 d1, 
   a1 b b1 c c1 d - a1 b1^2 c1^2 d - a a1 b1 c1 d^2 - a1 b^2 c c1 d1 +
     a1 b b1 c1^2 d1 + a a1 b c1 d d1 + a1^2 b1 c1 d d1 - 
    a1^2 b c1 d1^2, -a1 b b1 c^2 c1 + a1 b1^2 c c1^2 + 
    a a1 b1 c c1 d + a a1 b c c1 d1 - a1^2 b1 c c1 d1 - 
    a a1 b1 c1^2 d1 - a^2 a1 c1 d d1 + a a1^2 c1 d1^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.