# Modified Rational approximant of a polynomial (v2)

ok this time I will try to post only the essential information, I hope it doesn't end like the previous thread.
the objective is similar to the previous one but now I cannot use the Padèapproximant function due to a small change in the numerator.

given the Taylor expansion

gdl[z_] := t1 z + t2 z^2 + t3 z^3 + t4 z^4


with the coefficients

t1 = 1;

t2 = 1/2 (1 - q0);

t3 = -1/6 (1 - q0 - 3 q0^2 + j0);

t4 = 1/24*( 2 - 2 q0 - 15 q0^2 - 15 q0^3 + 5 j0 + 10 q0*j0 + s0);


and defined the coefficients $$c_k$$

w[z_] :=    (1 - z^2)^(-1/2)
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}]


I need to find the coefficients $$a_0,a_1 ,a_2, b_1$$ of

$$R_{2,1}=\frac{a_0+a_1*T_1+a_2*T_2}{(1+b_1*T_1)}$$

so that $$R_{2,1} = \sum_0^4 c_k T_k$$ where $$T_k$$ are the Chebyshev polynomial of order k.

Since the term $$z^2$$ has been switched with $$2 z^2- 1$$ i cannot use the Padè approximant.

disclaimer: no working minimal example after this point---------

I TRIED to modify the solution posted by j.m. but 1) i honestly didn't understand it completely, and thus i fail to modify it correctly 2) it doesn't work because SolveAlways gives a solution for $$q_0$$ and $$j_0$$ which is not what i want.

Clear["Global*"]

t[1] = 1;
t[2] = 1/2 (1 - q0);
t[3] = -1/6 (1 - q0 - 3 q0^2 + j0);
t[4] = 1/24*(2 - 2 q0 - 15 q0^2 - 15 q0^3 + 5 j0 + 10 q0*j0 + s0);

gdl[z_] = (t /@ Range[4]) . z^Range[4] // Simplify;

w[z_] := (1 - z^2)^(-1/2)

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

(* 1/64 (18 + 5 j0 (1 + 2 q0) - 3 q0 (6 + 5 q0 (1 + q0)) + s0) *)

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


Compute the coefficients

c /@ Range[4];

R[2, 1] = (a[0] + a[1]*z + a[2]*(2 z^2 - 1))/(1 + b[1]*z);

eqn = R[2, 1] == Sum[c[k]*ChebyshevT[k, z], {k, 0, 4}] // Simplify

(* (a[0] + z a[1] + (-1 + 2 z^2) a[2])/(1 + z b[1]) ==
1/24 z (24 - 12 (-1 + q0) z -
4 (1 + j0 - q0 - 3 q0^2) z^2 + (2 - 2 q0 - 15 q0^2 - 15 q0^3 +
5 j0 (1 + 2 q0) + s0) z^3) *)


Make both sides polynomials

eqn2 = Assuming[Denominator[eqn[[1]]] != 0,
MultiplySides[eqn, Denominator[eqn[[1]]]]]

(* a[0] + z a[1] + (-1 + 2 z^2) a[2] ==
1/24 z (24 - 12 (-1 + q0) z -
4 (1 + j0 - q0 - 3 q0^2) z^2 + (2 - 2 q0 - 15 q0^2 - 15 q0^3 +
5 j0 (1 + 2 q0) + s0) z^3) (1 + z b[1]) *)


The coefficients of the RHS of eqn2

cRHS = CoefficientList[eqn2[[-1]], z];


The coefficients of the LHS of eqn2

cLHS = PadRight[CoefficientList[eqn2[[1]], z], Length@cRHS];


Equating the coefficients and solving for {a[0], a[1], a[2], b[1]}

sol = Solve[Thread[cLHS == cRHS], {a[0], a[1], a[2], b[1]},
Reals, MaxExtraConditions -> All] // FullSimplify


Verifying the solutions,

eqn /. sol // Simplify


The condition on the second solution is

eqn3 = Values[sol[[2]]][[All, -1]] // Union

(* {1 + j0 == q0 + 3 q0^2 &&
2 + 5 j0 + 10 j0 q0 + s0 == q0 (2 + 15 q0 (1 + q0)) && q0 != 1} *)


This requires

Solve[eqn3, {j0, s0}][[1]]

(* {j0 -> -1 + q0 + 3 q0^2, s0 -> 3 + 7 q0 - 10 q0^2 - 15 q0^3} *)
`