### 5.48.4  Minimax polynomial approximation: minimax

The function minimax is called by entering :

minimax(expr,var=a..b,n,[limit=m])

where expr is an univariate expression (e.g.  f(x) ) to approximate, var is a variable (e.g.  x ), [a,b]⊂ℝ and n∈ℕ . Expression expr must be continuous on [a,b] . The function returns minimax polynomial (e.g.  p(x) ) of degree n or lower that approximates expr on [a,b] . The approximation is found by applying Remez algorithm.

If the fourth argument is specified, m is used to limit the number of iterations of the algorithm. It is unlimited by default.

The largest absolute error of the approximation p(x) , i.e.  maxaxb|f(x)−p(x)| , is printed in the message area.

Since the coefficients of p are computed numerically, one should avoid setting n unnecessary high as it may result in a poor approximation due to the roundoff errors.

Input :

minimax(sin(x),x=0..2*pi,10)

Output :

5.8514210172e-06+0.999777263385*x+0.00140015265723*x`^`2
-0.170089663733*x`^`3+0.0042684304696*x`^`4+
0.00525794766407*x`^`5+0.00135760214958*x`^`6
-0.000570502074548*x`^`7+6.07297119422e-05*x`^`8
-2.14787414001e-06*x`^`9-2.97767481643e-15*x`^`10

The largest absolute error of this approximation is 5.85234008632× 10−6 .