[Maxima] simplify

Barton Willis willisb at unk.edu
Sat Sep 12 18:59:48 CDT 2009

```Sometime ago on this list (search "sfactor"), I suggested a symbolic Newton
method for
trying to do things like this; untested code:

(%i43) sfactor(p,x) := block([n, cf, s, d],
p : ratexpand(p),
n : hipow(p,x),
(if n <= 1 then p else (
cf : coeff(p,x,n),
s : x,
d : expand(cf * s^n - p),
while hipow(d,x) > 0 do (
d : ratexpand(first(divide(cf * s^n - p, n * cf * s^(n-1),x))),
s : s - d),
cf * s^n + sfactor(p - cf * s^n,x))))\$

(%i47) expand((x-1)^6 + (x-a)^4)\$

(%i48) sfactor(%,x);
(%o48) (x-a)^4+(x-1)^6

(%i49) sfactor(x^2 + 5*x - 42,x);
(%o49) (x+5/2)^2-193/4

(%i46) sfactor(x^5-14*x^4+94*x^3-264*x^2+409*x-242,x);
(%o46) (868681*x)/14625+(78*(x-556/585)^3)/5+
(x-14/5)^5-7251304382/128334375

Barton

-----maxima-bounces at math.utexas.edu wrote: -----

>Stavros Macrakis wrote: > .... > And of course many useful transformations
>will not be found anyway. > For instance, I don't know of any practical
>way to perform > "simplifications" like
>x^5-14*x^4+94*x^3-264*x^2+409*x-242 => > (x+1)^4+(x-3)^5. >

```