1

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.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
drer
  • 719
  • 3
  • 9

2 Answers2

4

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}}$

Greg Hurst
  • 35,921
  • 1
  • 90
  • 136
  • 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. – drer Feb 02 '19 at 15:43
  • Interesting, I assume that approach required nesting an integral $\max{m_i}$ times? – Greg Hurst Feb 02 '19 at 15:53
  • 1
    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. – drer Feb 02 '19 at 16:34
  • @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! – Greg Hurst Feb 02 '19 at 16:36
  • @Chip Hurst How do I convert your code to either a dynamic module or Manipulate that accepts as input the rational function and outputs the result of your function FullApart – Stephen Mar 14 '20 at 14:07
0

Mathematica has a built-in Integrate`ComplexApart method.

List@@Integrate`ComplexApart[(x^2+3 x+1)/(x^2+3 x-5)^2,x]//FullSimplify//Tr

Which gives same result as @Greg's FullApart

$$ \scriptsize \frac{x^2+3 x+1}{\left(x^2+3 x-5\right)^2}=\frac{24}{29 \left(2 x+\sqrt{29}+3\right)^2}+\frac{34}{\sqrt{29} \left(58 x-29 \sqrt{29}+87\right)}+\frac{24}{29 \left(-2 x+\sqrt{29}-3\right)^2}-\frac{34}{29 \sqrt{29} \left(2 x+\sqrt{29}+3\right)}$$

See the definition:

Integrate`ComplexApart//GeneralUtilities`PrintDefinitions
Aster
  • 3,836
  • 1
  • 18
  • 44