0

I want to conduct partial fraction decomposition to rational function on $\mathbb C$ and tried this

PFD[R_, x_] := 
 Apart[Numerator[Simplify@R]/
   Factor[Denominator[Simplify@R], Extension -> All], x]

Normally it works fine like this

In[1]:=PFD[(2 (-1 + x^2) (6 x - 3))/((1 + x^2)^2 (3 + x^2)^3), x]

Out[1]:=-((3/2 - 3 I)/(-I + x)^2) + (6 + (3 I)/2)/(-I + x) - ( 3/2 + 3 I)/(I + x)^2 + (6 - (3 I)/2)/(I + x) - ( Sqrt[3] (I + 2 Sqrt[3]))/(-I Sqrt[3] + x) - ( Sqrt[3] (-I + 2 Sqrt[3]))/(I Sqrt[3] + x)

However, when the denominator has multiple complicated complex roots, Apart will automatically simplify the result

In[2]:=PFD[( x^4 (1 + x^2 + x^4 + x^6))/((-1 + x^2)^4 (1 + x^16)), x]

Out[2]:=2/(-1 + x^2)^4 - 1/(-1 + x^2)^3 - 14/(-1 + x^2)^2 + 43/( 2 (-1 + x^2)) + ( 65 + 77 x^2 + 77 x^4 + 65 x^6 + 43 x^8 + 15 x^10 - 15 x^12 - 43 x^14)/(2 (1 + x^16))

rather than leaving the parts of different poles alone. In other cases, it will output a tremendously long expression

In[3]:=PFD[ (x^4) /((-1 + x^2)^4 (1 + x^5)), x]

Out[3]:=(too long for here)

but it turns out to be not that long after simplification

In[4]:=FullSimplify /@ % // ToRadicals

Out[4]:=1/(32 (-1 + x)^4) - 1/(64 (-1 + x)^3) - 13/(128 (-1 + x)^2) + 41/( 256 (-1 + x)) + 1/(80 (1 + x)^5) - 3/(160 (1 + x)^3) - 3/( 160 (1 + x)^2) - 1/(6400 (1 + x)) + ( 2 (5 I + Sqrt[5 (5 + 2 Sqrt[5])]))/( 25 (Sqrt[50 - 10 Sqrt[5]] - 5 I (-3 + Sqrt[5]) - 4 Sqrt[5 (5 - 2 Sqrt[5])] x)) - (-2 + Sqrt[5])/( 5 (1 + (-1)^(1/5)) (2 - 4 (-1)^(1/5) + (-1)^(2/5) + 2 (-1)^(3/5) + I Sqrt[5 (5 - 2 Sqrt[5])] x)) + ( 2 (-I (-2 + Sqrt[5]) + 1/Sqrt[85 + 38 Sqrt[5]]))/( 5 (Sqrt[250 - 110 Sqrt[5]] - 5 I (-1 + Sqrt[5]) + 4 Sqrt[5 (5 - 2 Sqrt[5])] x)) + (5 + Sqrt[5])/( 25 (5 - Sqrt[5] + (-Sqrt[5] - I Sqrt[5 (5 - 2 Sqrt[5])]) x))

Question Is there away to stop Apart from simplifying the complex expression and output a nice result efficiently?

In addition, I would be grateful if anyone could that tell me there exist a readily made PFD package.

Thanks in advance.

Po1ynomial
  • 153
  • 4
  • is there a reason why you can't just called Apart? as in expr = (2 (-1 + x^2) (6 x - 3))/((1 + x^2)^2 (3 + x^2)^3); Apart[expr, x] gives Mathematica graphics What is the purpose of your PFD function? – Nasser Mar 17 '23 at 06:09
  • Note the first line. I am trying to factor on complex numbers, that is, the denominator should be of the form $(x-z)^n$ where $z$ is one of its complex root (no quadratic terms in the power). – Po1ynomial Mar 17 '23 at 09:55
  • I originally supposed Apart also has the Extension option but found none. – Po1ynomial Mar 17 '23 at 09:56
  • OK, so why can't you always just use FullSimplify /@ % // ToRadicals afterwords like you showed if this fixes it and gives you the desired simplified output now? I also do not know of method to make it work automatically over complex. Maple does have one such method, but not Mathematica as builtin. – Nasser Mar 17 '23 at 14:11

1 Answers1

3

Maybe something like this?

ResourceFunction["ExtendedApart"][(x^4)/((-1 + x^2)^4 (1 + x^5)), x]

(* Out[480]= (1 + (-1)^(1/5) + (-1)^(2/5))/(25 (-1)^(1/5) - 25 x) + ( 1 - (-1)^(1/5) + (-1)^(3/5))/(25 (-1)^(3/5) - 25 x) + 1/( 32 (-1 + x)^4) - 1/(64 (-1 + x)^3) - 13/(128 (-1 + x)^2) + 41/( 256 (-1 + x)) + 1/(80 (1 + x)^5) - 3/(160 (1 + x)^3) - 3/( 160 (1 + x)^2) - 1/(6400 (1 + x)) + (-1 + (-1)^(2/5) - (-1)^(4/5))/( 25 ((-1)^(2/5) + x)) + (-1 + (-1)^(3/5) + (-1)^(4/5))/( 25 ((-1)^(4/5) + x)) *)

Daniel Lichtblau
  • 58,970
  • 2
  • 101
  • 199