I placed a new topoly (renamed to_poly) in CVS
to_poly returns a list with two members. The second list member gives
conditions on the variables
(%i1) e : to_poly(abs(x)-8);
(%o1) [[%g10-8,%g10^2-x^2],[carg(%g10)=0]]
Eliminating %g10 from the first list gives
(%i2) eliminate(first(e),[%g10]);
(%o2) [64-x^2]
Or solving 'e' for x & %g10 gives
(%i3) algsys(first(e),[x,%g10]);
(%o3) [[x=-8,%g10=8],[x=8,%g10=8]]
Both of these satisfy carg(%g10), so both x = -8 and x = 8 are solutions
to abs(x) - 8 = 0. Another example:
(%i10) e : to_poly(abs(x)+6);
(%o10) [[%g15+6,%g15^2-x^2],[carg(%g15)=0]]
This time neither solution of first(e) satisfies carg(%g15) = 0; there are
no solutions:
(%i11) algsys(first(e),[x,%g15]);
(%o11) [[x=6,%g15=-6],[x=-6,%g15=-6]]
Some other examples:
(%i3) to_poly(max(x,2*x)-1);
(%o3) [[(3*x+%g3-2)/2,%g3^2-x^2],[carg(%g3)=0]]
(%i4) algsys(first(%),listofvars(%));
(%o4) [[%g3=-1,x=1],[%g3=1/2,x=1/2]]
The first solution in (%o4) is spurious because carg(%g3) = carg(-1) = %pi
# 0.
And that is good because max(1,2) - 1 # 0. The second solution
satisfies carg(%g3) = 0. And max(1/2,1) - 1 = 0 (good).
Also, there is a new solver that uses to_poly.
(%i5) load("topoly_solver.mac")$
(%i6) to_poly_solve(max(x,2*x)-1,x);
(%o6) [[x=1/2]]
(%i7) [abs(6-abs(8-abs(x)))-8*y, y+sqrt(x)-5]$
(%i8) to_poly_solve(%,[x,y]);
(%o8) [[x=86-8*sqrt(2)*sqrt(5)*sqrt(7),y=9-sqrt(2)*sqrt(5)*sqrt(7)]]
Unrelated, but fun. Please enjoy a perfect day:
(%i9) perfect_p(n) := is(n = apply("+",
listify(disjoin(n,divisors(n)))))$
(%i10) map('perfect_p,[6,28]);
(%o10) [true,true]
Barton