The factor function is a little bit silly.



I've 2 issues here:

FIRST: Halting problem in TM
------
The below symbolic example doesn't terminate after many minutes in
maxima-5.14.0 although the human solution is f(x)-g(x)-h(x):

factor(expand((f(x)-g(x)-h(x))^500));

To fix this problem in the future: better artificial sustitution in the
solving of factor or intelligent lazy computation as
factor(expand(Alpha)) => Alpha.

SECOND: Non-deterministic Memoization
-------
With

factor(expand((sqrt(x+a)+b)^10));

i got once the imprecise solution

10 b x^4 sqrt(x+a) + 120 b^3 x^3 sqrt(x+a) + ... + 45 a^4 b^2 + a^5

but i got many times (sqrt(x+a)+b)^10 .

I think that the maxima system uses memoization that remember some internal
answers of previous computations but it's non-deterministic.