f-feng / apart Goto Github PK
View Code? Open in Web Editor NEWApart Package
Apart Package
Recently there was a question on Mathematica SE regarding the built-in Apart
. So I wanted to suggest the OP to use APart but it seems that APart requires ages to process the given expression
<< Apart`
exp = -((q qp^3 vq (I Abs[wn] +
qp v[-1]) (v[-1] - v[1])^2 (-I Abs[wn] + qp v[1]) (wn^2 +
q qp v[-1] v[1]) (-wn^2 + qp^2 v[-1] v[1]))/(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[1])^2 (qp + (I wn)/v[1])^2 v[1]^4 (I Abs[wn] + q v[1])))
ApartAll[exp, {qp}]
ApartAll2[exp_, vars_] :=
Module[{tmp, VF},
tmp = Distribute[VF[Expand[exp, Alternatives @@ vars]]];
tmp = tmp /. VF[ex_] :> ApartAll[ex, vars];
Return[tmp];]
res = ApartAll2[exp, {qp}]; // AbsoluteTiming
I gave up after waiting about 4 minutes on my ThinkPad T460p (i5-6440HQ and 32 GB RAM) with Mathematica 11.0.1.
Usually APart is very fast on similar polynomials, so i'm curious if the current behavior is expected or there is still some room for improvements in the code to make things work faster.
Cheers,
Vladyslav
Test case:
expr = (-128 a^2 - 112 a b - 248 a - 172 b + 90 c - 15)/(c ( a + c) (4 a + 2 b + 2 c + 1));
ApartAll[expr, {a, b, c}]
throws Error: -128 a^2-112 b a-248 a-172 b+90 c-15 is not Linear Polynomial of {a,b,c}
. With the previous version of Apart everything is ok:
$Apart[expr, {a, b, c}]
gives
-248 ($ApartIR[1/(
c (1 + 4 a + 2 b + 2 c)), {a, b, c}, {c,
1 + 4 a + 2 b + 2 c}, {-1, -1}] - $ApartIR[
1/((a + c) (1 + 4 a + 2 b + 2 c)), {a, b, c}, {a + c,
1 + 4 a + 2 b + 2 c}, {-1, -1}]) +
90 $ApartIR[
1/((a + c) (1 + 4 a + 2 b + 2 c)), {a, b, c}, {a + c,
1 + 4 a + 2 b + 2 c}, {-1, -1}] -
128 ($ApartIR[a/(
c (1 + 4 a + 2 b + 2 c)), {a, b, c}, {a, c,
1 + 4 a + 2 b + 2 c}, {1, -1, -1}] - $ApartIR[
a/((a + c) (1 + 4 a + 2 b + 2 c)), {a, b, c}, {a, a + c,
1 + 4 a + 2 b + 2 c}, {1, -1, -1}]) -
112 ($ApartIR[b/(
c (1 + 4 a + 2 b + 2 c)), {a, b, c}, {b, c,
1 + 4 a + 2 b + 2 c}, {1, -1, -1}] - $ApartIR[
b/((a + c) (1 + 4 a + 2 b + 2 c)), {a, b, c}, {b, a + c,
1 + 4 a + 2 b + 2 c}, {1, -1, -1}]) -
172 (1/2 $ApartIR[1/(c (a + c)), {a, b, c}, {c, a + c}, {-1, -1}] -
2 $ApartIR[1/(
c (1 + 4 a + 2 b + 2 c)), {a, b, c}, {c,
1 + 4 a + 2 b + 2 c}, {-1, -1}] + $ApartIR[
1/((a + c) (1 + 4 a + 2 b + 2 c)), {a, b, c}, {a + c,
1 + 4 a + 2 b + 2 c}, {-1, -1}] -
1/2 $ApartIR[1/(
c (a + c) (1 + 4 a + 2 b + 2 c)), {a, b, c}, {c, a + c,
1 + 4 a + 2 b + 2 c}, {-1, -1, -1}]) -
15 $ApartIR[1/(
c (a + c) (1 + 4 a + 2 b + 2 c)), {a, b, c}, {c, a + c,
1 + 4 a + 2 b + 2 c}, {-1, -1, -1}]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.