EDIT
This question is completely wrong and useless. It is mathematically incorrect. I think something like Series
is sufficient if you're trying to do something similar.
Given a general polynomial ansatz constructed using methods described in this SE post, which looks something like
expr=(Ca1[1] + Ca1[2] x[1] + Ca1[3] x[1]^2)/(1 + Da1[2] x[1] +
Da1[3] x[1]^2)
or perhaps easier to read, I can state my input as
$\dfrac{c_1 + c_2x+c_3x^2}{1+d_1x+d_2x^2} . $
I am attempting to use this ansatz and attempt to solve for the various coefficients in my problem, by using Collect
. For the case where my ansatz was simply a polynomial, this was trivial to use.
I think it might be useful to instead attempt to separate this out into a polynomial in powers of x
immediately. In particular, for one free variable x
and only up to order two in the polynomial, I am expecting to find the result (in more legible notation).
$c_1 + c_2x+c_3x^2 + \\ \dfrac{c_1}{d_1} \dfrac{1}{x} + \dfrac{c_2}{d_1} + \dfrac{c_3}{d_1}x + \\ \dfrac{c_1}{d_2} x^2 + \dfrac{c_2}{d_2}x + \dfrac{c_3}{d_2} $.
Importantly, I then want to collect into relevant powers of x
and solve for the coefficients, probably using Collect
to collate the corresponding powers. Below I have stated my desired output.
$ (c_1 + \dfrac{c_2}{d_1} + \dfrac{c_3}{d_2}) + (c_2 + \dfrac{c_3}{d_1}+ \dfrac{c_2}{d_2})x + (c_3 + \dfrac{c_1}{d_2})x^2 + \dfrac{c_1}{d_1} x^{-1} + \dfrac{c_1}{d_2} x^{-2} $
I attempted to do this using replacement rules, like
expr//.{a__/(b_+c_):>a/b+a/c,(a_+b_)/c_:>a/c+b/c}
and then collect appropriately, but it ended up giving me a very weird form which wasn't useful to me. Any suggestions would be appreciated. As a summary, I am hoping to take a rational function of polynomials, and simplify the out to look more like a power series in orders of x, as described above.