I wrote a function 'elim' that might be a replacement for 'eliminate.'
One difference between 'eliminate' and 'elim' is that 'elim' doesn't
try to solve for the last variable when the number of equations equals the
number of unknowns. Another difference is that elim saves the
pivot polynomials and returns them in a list. This gives a triangular
form to the polynomials.
In this example, Maxima solves for z; one solution is z = 4, but there are
other
solutions. But eliminate returns only one solution:
(%i2) eliminate([x + x*y + z-4, x+y+z-12, x^2 + y^2 + z^2=7],[x,y,z]);
(%o2) [4]
(%i3) elim([x + x*y + z-4, x+y+z-12, x^2 + y^2 + z^2=7],[x,y,z]);
(%o3) [[],[2*y^4-22*y^3+99*y^2+160*y+128,y*z+y^2-11*y-8,z+y+x-12]]
The second list in (%o3) is a list of the pivots.
Another problem is that when solve fails, a user doesn't know
what happened: Huh?
(%i4) eliminate([x+y-1,x+y-8],[x,y]);
Argument to `last' is empty.
(%i5) elim([x+y-1,x+y-8],[x,y]);
(%o5) [[1],[y+x-8]]
The first list in (%o5) tells us that the equations are inconsistent.
Finally, the function eliminate can take a very long time: try
(%i21) eliminate([x^3-y^2,x^7 + y+z*p,q*q-23+ x+y,p-q,x+y+z-5],[x,y,z,p]);
Elim does this in about 0.3 seconds on my machine. (The function elim
uses two heuristics to deciding the elimination order. I think this
accounts for the speed advantage. I do not know of any results about
the best order for elimination. If somebody pointed me towards such
research, I'd try to use it.)
Question: What do you all think? Are we wed to the solve feature of
eliminate?
After more testing, I could invent a goofy name for eliminate (I don't
care for the name 'elim,' but I've out of ideas) and place my code in
/src/elim. But
src/elim.lisp is translated from /share/simplification/elim.mac. So
appending
code to /src/elim.lisp isn't all that polite. I could put my code in a
folder
along with elim.mac (say elim2.mac). Or I could do nothing :)
If you all would like to test my code, I'll send it to you. Stavros (thank
you!)
identified some bugs in an earlier version that I've fixed.
Barton