a new to_poly



I committed a new version of to_poly. Let me know if you find bugs.

  (%i1) load("topoly.lisp")$
  (%i2) load("topoly_solver.mac")$

Recover a 2nd degree polynomial from one of its roots:

  (%i3) first(solve(x^2 + 5*x + 1,x));
  (%o3) x=-(sqrt(21)+5)/2
  (%i4) to_poly(%);
  (%o4) [[x+(%g0+5)/2,21=%g0^2],[-%pi/2<carg(%g0),carg(%g0)<=%pi/2]]

Eliminating %g0 from the first list gives x^2+5*x+1

  (%i5) elim_allbut(first(%),x);
  (%o5) [[x^2+5*x+1],[2*x+%g0+5]]

The second list in (%o5) is a list of the pivots used to eliminate
variables.
Solve an equation (try Maple on this one ...)

  (%i6) to_poly_solve(sqrt(max(1,x-5)) - 6 = 0,x);
  (%o6) [[x=41]]

  (%i7) to_poly_solve(max(1-x, 2*x-5, min(1-x/3,6)) = 9*
  abs(6-abs(7-x)),x);
  (%o7) [[x=16],[x=122/11],[x=12/13],[x=15/14]]

  (%i8) to_poly_solve([abs(abs(abs(x)-8)-6)-8*y,y+sqrt(x)-5],[x,y]);
  (%o8) [[x=86-8*sqrt(2)*sqrt(5)*sqrt(7),y=9-sqrt(2)*sqrt(5)*sqrt(7)]]

Unlike 'eliminate,' the function 'elim' saves the pivot equations;
eliminating
all the variables gives a triangular form of the equations:

  (%i11) elim([x+y=1,x-y=42],[x,y]);
  (%o11) [[],[2*y+41,y-x+42]]

The function 'elim' tries to be smart about the elimination order; try
eliminate on:

  (%i12) elim([x^3-y^2,x^7 + y+z*p,q*q-23+ x+y,p-q,x+y+z-5],[x,y,z,p]);
  (%o12)  <junk deleted>

Another recover the poly example

  (%i13) first(solve(x^3 + a*x + 1,x))$
  (%i14) to_poly(%)$

   Assuming that 6*(3^-(3/2)*sqrt(4*a^3+27)/2-1/2)^(1/3) # 0
  (%i15) elim_allbut(first(%),[x,a])$
  (%i16) factor(first(%));
  (%o16)
  [a*(x^3+a*x+1)*(x^6-a*x^4+2*x^3+a^2*x^2-a*x+1)*(27*x^6-27*x^3-a^3)*(27*x^6+216*x^3-64*a^3)]

OK -- we get degree 21 poly back ...

Barton