So, this is a follow-up post on my previous post where we used perturbation theory to calculate the real root of x5+x=1. In today’s post, we will, again, use perturbation theory to solve the same problem, but this time we will introduce the ϵ factor in front of x5. Concretely, we will try to solve:

ϵx5+x=1

This change might seem innocuous at first sight, but it turns out very “violent” because by letting ϵ=0, we vanish the term x5 and, therefore, the other 4 complex roots of the equation. This intervention drastically changes the underlying structure of the problem, and you shall see how it will complicate things later on. Instead of doing the calculations by hand, we will indulge ourselves with Mathematica this time.

ClearAll["Global`*"];
(* Note how epsilon factor is in front of x^5 *)
f[x_] := e*x^5 + x
vars = {a, b, c, r, s, t, u, v};
ans[e_] = 1 + Sum[vars[[k]]*e^k, {k, 1, Length@vars}];
expanded = f[ans[e]] // Expand;
getCoeff[n_] := CoefficientList[expanded, e][[n]]
sols = Table[getCoeff[k] == 0, {k, 2, Length@vars + 1}] // Solve;
f[e_] = ans[e] //. Flatten@sols

By running the code above, we get the following power series representation of the answer x(ϵ):

x(ϵ)=1e+5e235e3+285e42530e5+23751e6231880e7+2330445e8

However, if we proceed like before and set ϵ=1 to retrieve the answer to our particular problem, we get a result that is way off:

x(1)=2120041

Adding more terms to the series won’t help as the sums will continue to diverge. How can we penetrate this barrier, if at all? Enter Padé approximation. I won’t go into much detail, but the idea is to rewrite x(ϵ) as a ratio of two polynomials. In the general case we have a power series:

A(x)=n=0anxn

Even if A(x) is divergent, it may still be possible to approximate A(x) with a ratio of two polynomials, PL(x) and QM(x), of degree L and M, respectively. I’ll let this sink for a moment. Even if a power series A(x) diverges, its coefficients an contain information on how to rewrite A(x) in a way that it converges. How awesome is that?! Without loss of generality we let q0=1 and, therefore:

A(x)=PL(x)QM(x)=Ln=0pnxn1+Mn=1qnxn

So, all we have to do is to determine the L+M+1 coefficients of the polynomials PL and QM, i.e. to determine the coefficients p0,p1,p2,,pL and q1,q2,,qM (recall that we let q0=1):

A(x)QM(x)PL(x)=0

If we expand A(x),QM(x),PL(x) we get:

(a0+a1x+a2x2+)A(x)(1+q1x+q2x2++qMxM)QM(x)(p0+p1x+p2x2++pLxL)PL(x)=0

If we gather the coefficients and require them to be zero, we get a system of linear equations:

a0p0=0a0q1+a1p1=0a1q1+a0q2+a2p2=0a2q1+a1q2+a0q3+a3p3=0

The a0,a1,a2, are known. They are the coefficients of the divergent series A(x) that we want to re-express in a form that converges. Let’s see how this goes in our example.

P[m_, x_] := Sum[Subscript[p, j]*x^j, {j, 0, m}]
Q[n_, x_] := 1 + Sum[Subscript[q, j]*x^j, {j, 1, n}]
R[m_, n_, x_] := P[m, x]/Q[n, x]
A[n_, x_] := Sum[Subscript[a, j]*x^j, {j, 0, n}]
getACoeff[n_] := CoefficientList[f[e], e][[n]]
as = Table[Subscript[a, n - 1] -> getACoeff[n], {n, 1, Length@CoefficientList[f[x], x]}]
lhs[n_] := CoefficientList[A[Length@as, x] * Q[n, x] - P[n, x] // Expand, x]
deg = 4;
sol = Table[lhs[deg][[n]] == 0 /. as, {n, 1, 2*deg + 1}] // NSolve
padeApprox[x_] = R[deg, deg, x] /. sol[[1]]
x(ϵ)=1+22.1451ϵ+153.425ϵ2+348.996ϵ3+153.528ϵ41+23.1451ϵ+171.57ϵ2+439.841ϵ3+260.596ϵ4

Finally, we set ϵ=1 and we get:

x(1)=0.757789

Which is pretty close to the precise solution x=0.754878, corresponding to a relative error about 0.4%. That’s quite an improvement over our first attempt that yielded x(1)=2120041.

Padé approximation of the exponential function

Let’s, for the fun of it, calculate the Padé approximation of the exponential function exp(x). First, we need to write exp(x) as a power series A(x).

exps = Series[Exp[x], {x, 0, 20}];
getACoeff[n_] := CoefficientList[exps, x][[n]]
as = Table[Subscript[a, n - 1] -> getACoeff[n], {n, 1, Length@CoefficientList[exps, x]}]

The code above gives the coefficients of the Taylor series expansion of the exponential function. Mind that the Taylor series is convergent, but we will approximate it with Padé nonetheless:

{a01,a11,a212,a316,a4124,a51120,a61720,a715040,a8140320,}
lhs[n_] := CoefficientList[A[Length@as, x]*Q[n, x] - P[n, x] // Expand, x]
deg = 3;
sol = Table[lhs[deg][[n]] == 0 /. as, {n, 1, 2*deg + 1}] // Solve

The solution to the system provides us with the coefficients of polynomials P3(x) and Q3(x):

exp(x)=1+x2+x210+x31201x2+x210x3120

Here we plot the value of exp(x) along with the Padé 3/3 approximation vs. a Taylor series with 7 terms.

Padé vs taylor series for exponential function