Fix bug #2709: `letsimp' is wrong if `ratexpand' is called
This is an ancient bug that was present in Macsyma.
When NISLETSIMPRAT was given a CRE c it would perform actions on the
numerator and denominator of c separately. It first constructed a
new CRE based on the numerator of c, then it disrepped this new CRE
and then it called NISLETSIMP with this result. After that it did
the same thing with the denominator of c.
The problem is that the construction of the new CREs would use the
current value of VARLIST and GENVAR, and NISLETSIMP can change these
values. So even though the numerator and denominator both came from
the same CRE, they could be constructed and disrepped in different
VARLIST and GENVAR contexts.
(%i1) let (U, T)$
(%i2) letsimp (U / n); /* correct */
(%o2) T/n
(%i3) ratexpand (a * b * c)$
(%i4) letsimp (U / n); /* wrong */
(%o4) 1
The use of ratexpand simply changes the global VARLIST and GENVAR in
such a way that this bug shows up. ratexpand isn't special; other
functions such as rat could cause the same problem.
Now the numerator and denominator are both constructed and disrepped
in the same VARLIST and GENVAR context, namely the one given by the
original CRE c. Both of these are done before calling NISLETSIMP on
the results.
No problems with the test suite or share test suite. New tests have
been added to rtest12.