I have reported work on a tool to generate automatically valid Maxima
expression which have a known value and are suitable to test the
simplifier more stringent.
I start with four expressions which represent the numbers -1, 0, 1, 2:
( 0 ((mplus) $x0 $x0))
( 1 ((mplus) $x0 $x1))
( 2 ((mplus) $x1 $x1))
(-1 ((mplus) $x0 ((mminus) $x1)))))
E.g. this is the most simple way to represent the imaginary unit in this
system:
((MEXPT) ((MPLUS) $X0 ((MMINUS) $X1))
((MQUOTIENT) ((MPLUS) $X0 $X1) ((MPLUS) $X1 $X1))))
or
(x0-x1)^((x0+x1)/(x1+x1))
The following expression is one of some thousands expressions which are
automatically generated in a few seconds:
((MEXPT)
((MEXPT) ((MPLUS) ((MPLUS) $X0 ((MMINUS) $X1)) ((MMINUS) ((MPLUS) $X1
$X1)))
((MPLUS) ((MPLUS) $X0 ((MMINUS) $X1)) ((MMINUS) ((MPLUS) $X1 $X1))))
((MPLUS) ((MQUOTIENT) ((MPLUS) $X0 ((MMINUS) $X1)) ((MPLUS) $X1 $X1))
((MMINUS) ((MPLUS) ((MPLUS) $X1 $X1) ((MPLUS) $X1 $X1)))))
or
((x0-x1-(x1+x1))^(x0-x1-(x1+x1)))^((x0-x1)/(x1+x1)-(x1+x1+(x1+x1)))
This expression is a complicated way to present the power of the numbers
-1/27 and -9/2. That is
(x0-x1-(x1+x1))^(x0-x1-(x1+x1))
represents the number -1/27 and
(x0-x1)/(x1+x1)-(x1+x1+(x1+x1))
represents the number -9/2. You see it if you insert the number one for
x1 and the number zero for x0. The power (-1/27)^(-9/2) simplifies to
-1*3^(27/2)*%i. This value is correct.
If we put this expression into the simplifier we get the following
expression back:
((MEXPT SIMP)
((MEXPT SIMP) ((MPLUS SIMP) $X0 ((MTIMES SIMP) -3 $X1))
((MPLUS SIMP) ((MTIMES SIMP) -1 $X0) ((MTIMES SIMP) 3 $X1)))
((MPLUS SIMP)
((MTIMES SIMP) ((RAT SIMP) -1 2) ((MPLUS SIMP) $X0 ((MTIMES SIMP) -1
$X1))
((MEXPT SIMP) $X1 -1))
((MTIMES SIMP) 4 $X1)))
or
((x0-3*x1)^(3*x1-x0))^(4*x1-(x0-x1)/(2*x1))
Now the value of the simplified expression is evaluated. This expression
represents the power of the values -27 and 9/2. The result is +3^(27/2)*
%i. The sign has changed. We have a simplification error.
The input to the simplifier is generated automatically. It represents a
number, but the simplifier does not know anything about this special
representation. Therefore, we have a more general simplification error.
The source of this error is the simplification of the power function in
simpexpt. It is clear that we get a lot of more examples of
simplification errors because of problems in simpexpt.
The tool I am working on generates thousands of expressions in a short
time. These expressions can be used to test the functions expand,
factor, ratsimp, ... too.
To be complete we have to generate expressions which contain symbols
like %e and %i too. To introduce e.g. symbols we can extend the initial
table from above. This way expressions which contain symbols are
generated too:
( 0 ((mplus) $x0 $x0))
( 1 ((mplus) $x0 $x1))
( 2 ((mplus) $x1 $x1))
(-1 ((mplus) $x0 ((mminus) $x1)))
($%e ((mplus) $x0 $%e))
($%i ((mplus) $x0 $%i))))
The main idea is to test the simplifier much better with an automatic
tool. The testsuite very often does not signal any problem.
Dieter Kaiser