How to compute the rational approximant of a polynomial?

given the chebyshev series expansion up to the fourth order $$f(z)= \sum_{0}^4 c_k T_k(z)$$ with some fixed $$c_k$$

i need to find the coefficients of the rational approximant (2,1)

$$R_{2,1}= \frac{a_0 + a_1z + a_2 z^2}{1+b_1 z}$$

defined so that

$$R_{2,1}= \sum_{0}^4 c_k T_k(z)$$

I tried with

 chebyc0c1c2c3c4 =   (c0*ChebyshevT[0, z]+c1*ChebyshevT[1, z]+c2*ChebyshevT[2, z]+c3*ChebyshevT[3, z]+c4*ChebyshevT[4, z])

chebya0a1a2b1 =  (a0*ChebyshevT[0, z]+(a1*ChebyshevT[1, z])+(a2*ChebyshevT[2, z])+(a3*ChebyshevT[3, z])+(a4*ChebyshevT[4, z]))/ (1 +     b1*z)


and then try

 Solve[{chebya0a1a2 == chebyc0c1c2c3c4}, {b1,a0, a1, a2}]


but it gives

but i get

""Solve::svars: Equations may not give solutions for all "solve" variables."

how can i solve it?

• TL,DR; I would say, please make an effort to show a minimal working example of your problem, avoid using Subscript for anything other than display . Jan 20, 2023 at 13:47
• You say "but what gives me trouble is trying to find $a_i$ and $b_1$", but what trouble? Please focus and be explicit. Jan 20, 2023 at 13:53
• @rhermans if i had a working example i would not ask how to do the last step. i found the c_k and i am stuck with the second part. when i try to do Solve[{chebya0a1a2 == chebyc0c1c2c3c4}, {Subscript[b, 1], Subscript[a, 0], Subscript[a, 1], Subscript[a, 2]}] i get "Solve::svars: Equations may not give solutions for all "solve" variables." i can add this line to the question but it really add nothing Jan 20, 2023 at 13:58
• …It's of course good to simplify the question, but you've overdone it. Since you've removed gdl etc., Daniel's answer below almost doesn't make sense now. Jan 27, 2023 at 3:41

Here is how I would do this. First use memoisation to speed things up:

c[0] = 1/\[Pi]*Integrate[gdl[z]*w[z]*ChebyshevT[0, z], {z, -1, 1}]

c[n_] := c[n] = 2/\[Pi]*Integrate[gdl[z]*w[z]*ChebyshevT[n, z], {z, -1, 1}]


Then define the target function:

target[z_] = Sum[c[i] ChebyshevT[i, z], {i, 0, 4}]


Finally calculate the Padde approximant:

padde23= PadeApproximant[target[z], {z, 0, {2, 3}}] // Simplify


BTW: your results contains constants that do not appear in the problem.

• ah yes the c/H_0. that's because it's a screenshot of the full solution, but they are not a problem. I don't know if, aside from the constant, the two solutions agree but after a quick look at PadèApproximant i think they do. wait, why padè 2,3? Jan 20, 2023 at 14:30
• Sorry, my fault, should be Pade2,1 Jan 20, 2023 at 14:39

You have already been given the answer using PadeApproximant[]. If this function hadn't been built-in (like in earlier versions), the way to do it is to use SolveAlways[]:

cofs = Array[C, 4, 0] /.
First[SolveAlways[Series[(a[0] + a[1] z + a[2] z^2)/(1 + b[1] z), {z, 0, 3}] -
Sum[C[k] ChebyshevT[k, z], {k, 0, 4}] == 0, z]];

(a[0] + a[1] z + a[2] z^2)/(1 + b[1] z) /.
First[Solve[Thread[Array[C, 4, 0] == cofs], {a[0], a[1], a[2], b[1]}]]


and you should get an answer equivalent to the one from PadeApproximant[].