I would like to have a tool for partial fraction expansion of polynomial quotient $$\frac{P(z)}{Q(z)},$$ where the order of the polynomial $P(z)$ is less than that of $Q(z)$.

The output of the function is expected to be the coefficients $c_{ij}$ of the expansion: $$ \sum_i\sum_{j=1}^{m_i}\frac{c_{ij}}{(z-\zeta_i)^j}, $$ where the sum runs over all distinct roots $\zeta_i$ (with multiplicity $m_i$) of the polynomial $Q(z)$.

Is there a built-in function in Mathematica which is suitable for performing the task? For a symbolic computation the list of roots of the polynomial $Q(z)$ can be supplied.


We can factor the denominator completely and feed the result into Apart:

FullApart[expr_, x_] :=
  Block[{num, den, coeff, roots},
    {num, den} = Through[{Numerator, Denominator}[Together[expr]]];
      coeff = Coefficient[den, x, Exponent[den, x]];
      roots = x /. Solve[den == 0, x];

      Apart[num/(coeff Times @@ (x - roots)), x]

    ) /; PolynomialQ[num, x] && PolynomialQ[den, x]

Some examples:

FullApart[(x^2 + 3 x + 1)/(x^2 + 3 x - 5)^2, x]

$\displaystyle \scriptsize -\frac{34}{29 \sqrt{29} \left(2 x+\sqrt{29}+3\right)}+\frac{24}{29 \left(2 x+\sqrt{29}+3\right)^2}-\frac{34}{29 \sqrt{29} \left(-2 x+\sqrt{29}-3\right)}+\frac{24}{29 \left(-2 x+\sqrt{29}-3\right)^2}$

FullApart[(x^2 + 3 x + 1)/(x^5 + 3 x - 5), x] // N // Chop

$\scriptsize {\displaystyle -\frac{0.329077\, -0.0459113 i}{x-0.639573\, -1.20691 i}}-{\displaystyle \frac{0.329077\, +0.0459113i}{x-0.639573\, +1.20691 i}}+{\displaystyle \frac{0.0658591\, -0.0529159 i}{x+1.19386\, -0.996095i}}+{\displaystyle \frac{0.0658591\, +0.0529159 i}{x+1.19386\, +0.996095i}}+{\displaystyle \frac{0.526436}{x-1.10858}}$

  • $\begingroup$ Wow. I would never think that it is enough to represent the denominator as the product to force Apart work "correctly". Meanwhile I have solved the problem by brute force (using Residue) but of course your solution is much better. $\endgroup$ – drer Feb 2 at 15:43
  • $\begingroup$ Interesting, I assume that approach required nesting an integral $\max\{m_i\}$ times? $\endgroup$ – Chip Hurst Feb 2 at 15:53
  • 1
    $\begingroup$ I am not quite sure that I correctly understand your question. The main part was done as Table[{zi=zz[[i,1]],mi=zz[[i,2]];Table[Residue[f[z] (z-zi)^(k-1),{z,zi}],{k,mi}]},{i,Length[zz]}], where zz is the list of {root,multiplicity} elements and f[z] is the polynomial quotient. $\endgroup$ – drer Feb 2 at 16:34
  • $\begingroup$ @drer you could integrate your input to move the order -2 term to become order -1 and so on. Your way is much cleaner and a standard approach, I’m just rusty! $\endgroup$ – Chip Hurst Feb 2 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.