1
$\begingroup$

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.

$\endgroup$
1
  • 1
    $\begingroup$ (1) The Wolfram Function Repository has ExtendedApart and ApartAll. (2) A question like this should come complete with at least one specific input and desired result. $\endgroup$ May 25, 2022 at 15:56

2 Answers 2

4
$\begingroup$

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

$\endgroup$
5
  • $\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, 2019 at 15:43
  • $\begingroup$ Interesting, I assume that approach required nesting an integral $\max\{m_i\}$ times? $\endgroup$
    – Greg Hurst
    Feb 2, 2019 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, 2019 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$
    – Greg Hurst
    Feb 2, 2019 at 16:36
  • $\begingroup$ @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 $\endgroup$
    – Stephen
    Mar 14, 2020 at 14:07
0
$\begingroup$

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
$\endgroup$

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