%mathpiper,def="MaximumBound"

/** Maximum bound on the absolute value of the roots of a
  polynomial p in variable x, according to Knuth:

  Maximum( Abs(a[n-1]/a[n]) , Abs(a[n-2]/a[n])^(1/2), ... , Abs(a[0]/a[n])^(1/n) )

 As described in Davenport.
 */
 5 # MaximumBound(_p)_(IsZero(p Where x==0)) <-- MaximumBound(Simplify(p/x));
10 # MaximumBound(_p)_(Degree(p)>0) <--
[
  Local(an);
  an:=Coef(p,(Degree(p)-1) .. 0)/Coef(p,Degree(p));
  an := N(Eval(Abs(an)^(1/(1 .. Degree(p)))));
  Rationalize(2*Maximum(an));
];

20 # MaximumBound(_p) <-- Infinity;

%/mathpiper



%mathpiper_docs,name="MaximumBound",categories="User Functions;Solvers (Numeric)"
*CMD MaximumBound --- return upper bounds on the absolute values of real roots of a polynomial
*STD
*CALL
	MaximumBound(p)

*PARMS

{p} - a polynomial in $x$

*DESC

Return maximum bounds for the absolute values of the real
roots of a polynomial {p}. The polynomial has to be converted to one with
rational coefficients first, and be made square-free.
The polynomial must use the variable {x}.

*E.G.

In> p:=SquareFree(Rationalize((x-3.1)*(x+6.23)))
Result: (-40000*x^2-125200*x+772520)/870489;
In> MaximumBound(p)
Result: 10986639613/1250000000;
In> N(%)
Result: 8.7893116904;

*SEE MinimumBound, SquareFree, RealRootsCount, FindRealRoots, Factor
%/mathpiper_docs