From Mathematica References. I just find the Pade approximant for a real function in one point

Example :

PadeApproximant[Exp[x], {x, 0, {2, 3}}]


which is an approximation of the exponential function on $$0$$

Is there any way to find Padé approximant in two points, for example, if we want to obtain the Padé approximant of the Exponential function in $$0$$ and $$1$$

• not exactely, I would like to obtain an explicit expression. I already tried this code but the output gives nothing May 21 at 11:12
• Maybe you can also mention it in the post, so others can see that as well. May 21 at 11:15
• And another quick question: are you aware that the command works for arbitrary parameters? What I mean is that PadeApproximant[Exp[x], {x, a, {2, 3}}] returns a result and you can sub for a any value you want May 21 at 11:16
• @DiSp0sablE_H3r0 "PadeContFraction" seems not foolproof. Try e.g.: f[x_] = Sinc[2 x]; pts = Transpose@Table[{x, f[x]}, {x, 0, Pi, Pi/2}]; f1[x_] = PadeContFraction @@ pts and you see that PadeContFraction throws 1/0 errors. May 21 at 13:09

Here is an idea how you could proceed:

Let's take your example of f[x_]=Exp[x] and you would like a 2 point approx. at x=0 and x=1. Toward this aim, you could make a Pade approximation at x=0 and x=1 with a numerator degree of m (e.g.2) and denominator degree of n (e.g. 2). This gives you two rational functions, one for x=0 and one for x=1. Now, you could interpolate the coefficients of these function (in this example linear) to get a better approximation. Here is the proceeding:

First we get the Pade approximation and separate numerator and denominator:

n = 3; m = 2;
t1 = PadeApproximant[Exp[x], {x, 0, {n, m}}];
t2 = PadeApproximant[Exp[x], {x, 1, {n, m}}];
t1 = NumeratorDenominator[t1];
t2 = NumeratorDenominator[t2];


Next we get the coefficients of the numerator and denominator polynomials:

t1 = CoefficientList[#, x] & /@ t1;
t2 = CoefficientList[#, x] & /@ t2;


Now, for the interpolation we need to add the x parts:

t1 = Map[{0, #} &, t1, {2}];
t2 = Map[{1, #} &, t2, {2}];


Now we are ready for interpolation:

t3 = Interpolation[#, x, InterpolationOrder -> 1] & /@ Transpose[{t1[[1]], t2[[1]]}];
t4 = Interpolation[#, x, InterpolationOrder -> 1] & /@ Transpose[{t1[[2]], t2[[2]]}];


Finally we get the approximation:

approx[x_] = t3.x^Range[0, n]/ t4.x^Range[0, m];
Plot[{approx[x], Exp[x]}, {x, 0, 1}]


Now it is interesting to compare the error of our approximation to the error of the Pade approximant at x=0:

errpad[x_] = Exp[x] - PadeApproximant[Exp[x], {x, 0, {n, m}}];
Plot[{Exp[x] - approx[x], errpad[x]}, {x, 0, 1}]


It is obvious that the error at x=0 and x=1 is zero and not bad in between.

If you do not want to use "Interpolation" you may do the interpolation "by hand":

n = 3; m = 2;
t1 = PadeApproximant[Exp[x], {x, 0, {n, m}}];
t2 = PadeApproximant[Exp[x], {x, 1, {n, m}}];
t1 = NumeratorDenominator[t1];
t2 = NumeratorDenominator[t2];
t1 = CoefficientList[#, x] & /@ t1;
t2 = CoefficientList[#, x] & /@ t2;

t3 = (1 - x) (t1[[1]] . x^Range[0, n]) + x (t2[[1]] . x^Range[0, n]);
t4 = (1 - x) t1[[2]] . x^Range[0, m] + x t2[[2]] . x^Range[0, m];

approx[x_] = t3/t4 // Simplify;


===============================================

I realized that a much simpler approach is:

n = 3; m = 2;
t1 = PadeApproximant[Exp[x], {x, 0, {n, m}}];
t2 = PadeApproximant[Exp[x], {x, 1, {n, m}}];
approx[x_] = (1 - x) t1 + x t2 // Simplify

• Thanks, @Daniel Huber for this solution. but what I need to see as the output is a mathematical expression of the padé approximate I don't know too much in Mathematica but could this give as the mathematical expression of the padé approximate ? May 22 at 10:22
• A Pade approximant is a rational function. My answer is actually a rational function in disguise. The reason is that for simplicity I used "Interpolation" with order=1. This returns an "InterpolatingFunction" object, that is nothing else than a linear function. If you need it, I will make an add to my answer and write the interpolation explicitly. May 22 at 10:29
• just another question when you take t1 = CoefficientList[#, x] & /@ t1; t2 = CoefficientList[#, x] & /@ t2; What I dont understand that you extract the coefficient of a fraction or I am mistaken ? May 22 at 10:58
• Look at my answer, I added the explicit interpolation. Further, t1 and t2 are lists containing the numerator and denominator at x=0 and x=1 of the rational approximant. I then extract the coefficients of the numerator and denominator polynomials. May 22 at 13:07

I'm not sure what is meant by a two-point Padé approximant. I'm not familiar with multipoint Padé approximants, and there seem to be a variety of types. One definition is that the series expansion of the rational approximant should agree with the series of expansion of the function to be approximated at each point to individually specified orders. This seems a good definition (or at least an easy definition) and it produces a remarkably good approximant in the case at hand.

nn = 3; mm = 2; (* degrees of num., den. resp. *)
obj[x_] = Sum[a[n] x^n, {n, 0, nn}]/(1 + Sum[b[n] x^n, {n, 1, mm}]);

aa = 2; bb = 2; (* orders of approx. at 0, 1 resp. *)
TrueQ[aa + bb + 2 == mm + nn + 1] (* check on degrees *)
CoefficientList[#, x] & /@ (
Series[obj[x], {x, 0, aa}] == Series[Exp[x], {x, 0, aa}]
),
CoefficientList[#, x] & /@ (
Series[obj[x], {x, 1, bb}] == Series[Exp[x], {x, 1, bb}]
)} // Flatten];
pa[x_] = obj[x] /. First@coeffs

Plot[pa[x] - Exp[x], {x, 0, 1}]

• Thanks@Michael E2 for this really nice approximation. could you modify your code in order that can work for any function? I have tried to do for example f[x_]:=Cos[x]. but in this line Series[obj[x], {x, 0, aa}] == Series[f[x], {x, 0, aa}] My Code don't work May 23 at 15:59
• @user745750 I wonder what you did, because if I replace all Exp instances (there are three, including the Plot), it works: Mathematica output -- Maybe you need a ClearAll[f]; before the definition of f. Sometimes previous definitions are causing trouble. May 23 at 16:06
• @user745750 If you could post your input and output (in an image like I did), I might know how to fix it. You might need list the coefficient in Solve[..., {a[0], a[1], a[2], a[3], b[1], b[2]}]. What version do you have? May 23 at 16:48
• @ Michael E2 I will post it as an answer because i don't know how to post it like you. I have version 11.3 many thanks May 23 at 16:58