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.

  • 1
    $\begingroup$ 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. $\endgroup$
    – heropup
    Feb 4, 2014 at 7:53
  • $\begingroup$ @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). $\endgroup$ Feb 4, 2014 at 7:59
  • 1
    $\begingroup$ 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. $\endgroup$ Apr 20, 2016 at 6:58

1 Answer 1


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


Now that MaximalBy is available

wPade[F_, x_, xo_, a_, b_, n_] := MinimalBy[Last][
     {m, n - m}
     , NIntegrate[
      Abs[F - PadeApproximant[F, {x, xo, {m, n - m}}]], {x, a, b}]
    , {m, 1, n}
   ][[1, 1]]
  • 1
    $\begingroup$ Thanks a lot. This is exactly what I was looking for. $\endgroup$ Feb 5, 2014 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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