# Trying to find the best Pade approximant for a given numer of terms

Let suppose that I have a function $f[x]$ I want to approximate using a Pade expansion and that I decide what would be maximum number of terms to be used.

Is there any way with Mathematica to find what have to be the degrees of numerator and denominator in order to have the best approximation over a given range of $x$ ?

Doing this manually is, as one could expect, quite tedious. Any help and suggestion will be really appreciated.

-
I'm not really sure how this question can be well-posed, because it's not clear what you mean by "best." Is that maximum absolute deviation? Mean deviation? And then, how do you reconcile that with the fact that the order $(n,d)$ Padé approximant generally improves with increasing $n$ and $d$? If your condition is to fix the sum of polynomial degrees, then it then becomes a computational exercise to go through all the approximants and measure the "goodness" by whatever metric you want. – heropup Feb 4 '14 at 7:53
@heropup. I said that $n+d$ if fixed as well as the interval of $x$. What I would like is to be able to "automate" the process. The "best" could be defined the manner you want (say : lowest maximum absolute deviation). – Claude Leibovici Feb 4 '14 at 7:59

wPade[F_, x_, xo_, a_, b_, n_] := Sort[Table[{{m, n - m}, NIntegrate[Abs[F - PadeApproximant[F, {x, xo, {m, n - m}}]], {x, a, b}]} , {m, 1, n}] , #1[[2]] < #2[[2]] &][[1, 1]]

where F is the function, x the variable, xo where the approximation is about, a and b the limits of the region, and n the sum of the upper and lower degrees