guessdegreereturns the minimal degree needed for a polynomial to approximate a function with a certain error on an interval.
Usage:
guessdegree(f,I,eps,w,bound) : (function, range, constant, function, constant) -> range
Parameters:
f is the function to be approximated.
I is the interval where the function must be approximated.
eps is the maximal acceptable error.
w (optional) is a weight function. Default is 1.
bound (optional) is a bound on the degree. Default is currently 128.
Description:
guessdegree tries to find the minimal degree needed to approximate f
on I by a polynomial with an error err=p*w-f whose infinity norm not
greater than eps. More precisely, it finds n minimal such that there exists
a polynomial p of degree n such that ||p*w-f|| < eps.
guessdegree returns an interval: for common cases, this interval is reduced
to a single number (i.e. the minimal degree). But in certain cases,
guessdegree does not succeed in finding the minimal degree. In such cases the
returned interval is of the form [n,p] such that:
no polynomial of degree n-1 gives an error less than eps.
there exists a polynomial of degree p giving an error less than eps.
The fifth optional argument bound is used to prevent guessdegree from
trying to find too large degrees. If guessdegree does not manage to find a
degree n satisfying the error and such that n<=bound, an interval of the
form [*, +Inf] is returned. Note that bound must be a positive integer.