Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let suppose that I have a function $f[x]$ I want to approximate using a Padé 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.

share|improve this question
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
No need for Mathematica in this case; it is known (see e.g. this or this) that the "diagonal" approximants (numerator and denominator degrees differ by at most 1) are usually the best approximants of a given function in the Padé table. Thus, if the number of series terms is even, use half that number for the numerator and denominator degrees. If you have an odd number of terms, you can have the numerator or denominator have the higher degree; you will have to check that for yourself. – J. M. Apr 20 at 6:58
up vote 1 down vote accepted

This is very slow but here it goes:

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]]
wPade[Sin[x], x, 0, 0, 1, 5]

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

share|improve this answer
Thanks a lot. This is exactly what I was looking for. – Claude Leibovici Feb 5 '14 at 9:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.