Consider the following code
randExpr[] :=
Together@Expand[(a - b - c - I RandomInteger[{10^3, 10^4}] d +
3/(a - b - c - d))^6];
test = randExpr[];
AbsoluteTiming[res1 = Apart[test, a];]
On my system (Fedora 22, Mathematica 10.3, i5-3320M) I get
{12.3737, Null}
Now with the following trivial workaround
myApart[expr_, x_] :=
Block[{i},
If[ FreeQ[expr, Complex],
Apart[expr, x],
Apart[expr /. Complex[0, a_] :> i a, x] /. i -> I
]
];
AbsoluteTiming[res2 = myApart[test, a];]
the output becomes
{0.387141, Null}
and of course
res1 === res2
returns True
. I would expect that Apart
should be intelligent enough to figure out this particular case automatically, instead of wasting computer time.
Do you think that the current is behavior is worth reporting to the support as a bug, or is it yet something one should expect and tolerate?
I would also be interested in other tricks to make Apart
work faster when complex numbers are involved.
P.S. The issue was originally discovered by Rolf Mertig, who provided the given example.
Apart
is rather an example for a function that didn't receive much love since many MMA versions. In particular it would be nice if it could partial fraction multivariate polynomials, like it was implemented here: github.com/F-Feng/APart $\endgroup$ – vsht Apr 11 '16 at 9:58