# Apart expression returns unevaluated

I want to perform a partial fraction expansion in the variable qp by treating all other variables as constants (some real, others complex). My code, shown below, does not seem to give me anything.

Apart[
-((q qp^3 vq (I Abs[wn] + qp v[-1]) (v[-1] - v)^2 (-I Abs[wn] + qp v)
(wn^2 + q qp v[-1] v) (-wn^2 + qp^2 v[-1] v)) /
(2 π^2 (q + qp) (-q1 + qp) β (qp - (I wn)/v[-1]) (qp + (I wn)/v[-1])
v[-1]^2 (-I Abs[wn] + q v[-1]) (2 vq v[-1] + π v[-1]^2)
(qp - (Sqrt[π] wn)/Sqrt[-v[-1] (2 vq + π v[-1])])
(qp + (Sqrt[π] wn)/Sqrt[-v[-1] (2 vq + π v[-1])])
(qp - (I wn)/v)^2 (qp + (I wn)/v)^2 v^4 (I Abs[wn] + q v))),
qp]

• I'll look into it next week. I agree this behavior seems weird, not yet sure if it is a bug though. My guess is Apart is thrown off by having algebraics (radicals) present in the input, even though they do not involve the variable of interest. – Daniel Lichtblau May 27 '17 at 16:36
• I think it now works to specifications. Gives a fairly large result though. – Daniel Lichtblau Apr 2 '18 at 17:45

You could use the APart package by Feng Feng (https://github.com/F-Feng/APart)

<< Apart

InnerCollectFunction = Identity;

exp = -((q qp^3 vq (I Abs[wn] +
qp v[-1]) (v[-1] - v)^2 (-I Abs[wn] + qp v) (wn^2 +
q qp v[-1] v) (-wn^2 + qp^2 v[-1] v))/(2 \[Pi]^2 (q +
qp) (-q1 +
qp) \[Beta] (qp - (I wn)/v[-1]) (qp + (I wn)/
v[-1]) v[-1]^2 (-I Abs[wn] +
q v[-1]) (2 vq v[-1] + \[Pi] v[-1]^2) (qp - (Sqrt[\[Pi]] wn)/
Sqrt[-v[-1] (2 vq + \[Pi] v[-1])]) (qp + (Sqrt[\[Pi]] wn)/
Sqrt[-v[-1] (2 vq + \[Pi] v[-1])]) (qp - (I wn)/
v)^2 (qp + (I wn)/v)^2 v^4 (I Abs[wn] + q v)))

ApartAll2[exp_, vars_] :=
Module[{tmp, VF},
tmp = Distribute[VF[Expand[exp, Alternatives @@ vars]]];
tmp = tmp /. VF[ex_] :> ApartAll[ex, vars];
Return[tmp];]

AbsoluteTiming[res = ApartAll2[exp, {qp}];]

res // RemoveApart


The evaluation requires less than one 30 seconds. However, one should say that by default APart would also have troubles with this expression. By setting InnerCollectFunction = Identity;` we skip the simplification of fairly complicated prefactors and hence can obtain the final result faster.