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.
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 yourPFD
function? $\endgroup$Apart
also has theExtension
option but found none. $\endgroup$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. $\endgroup$