# [Maxima] ratsimp and the order of terms

Dieter Kaiser drdieterkaiser at web.de
Fri Mar 20 14:22:46 CDT 2009

```Very often I have the problem, that expressions which look equivalent do
not pass the test_suite. Today, I have observed an issue with \$ratsimp.

An example with symbols only:

(%i8) x:a+s+d+f+g+h+j+k+l;
(%o8) s + l + k + j + h + g + f + d + a

This is the internal order of the symbols:

(%i9) :lisp \$x
((MPLUS SIMP) \$A \$D \$F \$G \$H \$J \$K \$L \$S)

Now the order after a call to ratsimp. The order of the symbols is
reverse:

(%i10) :lisp (\$ratsimp \$x)
((MPLUS RATSIMP) \$S \$L \$K \$J \$H \$G \$F \$D \$A)

So, when I do an alike1 between the expression and the result of ratsimp
the expressions seems to be different:

(%i10) :lisp (alike1 \$X (\$ratsimp \$x))
NIL

I have detected this with the following expression:

(%i16) integral:laplace(sinh(a*t)/a,t,s);
(%o16) 1/(s^2-a^2)
(%i17) result:1/(s^2-a^2);
(%o17) 1/(s^2-a^2)

The display of the values of INTEGRAL and RESULT look identically, but
they are not alike:

(%i18) :lisp (alike1 \$integral \$result)
NIL

The expressions have a different internal order of the terms:

(%i18) :lisp \$integral
((MEXPT SIMP RATSIMP)
((MPLUS RATSIMP) ((MEXPT RATSIMP) \$S 2)
((MTIMES RATSIMP) -1 ((MEXPT RATSIMP) \$A 2)))
-1)
(%i18) :lisp \$result
((MEXPT SIMP)
((MPLUS SIMP) ((MTIMES SIMP) -1 ((MEXPT SIMP) \$A 2)) ((MEXPT SIMP) \$S
2)) -1)

I do not know much about ratsimp. But is it the expected behavior that
the order in expressions with the ratsimp-flag is reverse?

Dieter Kaiser

```