Created
March 3, 2014 12:30
-
-
Save tueda/9324002 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
* Fast factoring out irrelevant factors. | |
* | |
* In a test environment, the first one takes about 50 seconds, while | |
* the second one takes < 0.01 seconds. | |
*) | |
Clear[NewIntegrate1]; | |
Clear[NewIntegrate2]; | |
NewIntegrate1[c_ f_., x_] := c NewIntegrate1[f, x] /; | |
FreeQ[c, x] && c =!= 1; | |
NewIntegrate2[a_Times, x_] := Block[{tried = True}, Module[{c, f}, | |
c = f = 1; | |
Scan[If[FreeQ[#, x], | |
c *= # | |
, | |
f *= # | |
]&, a]; | |
c NewIntegrate2[f, x] | |
]] /; !TrueQ[tried]; | |
ex = | |
( | |
(-(s*x^3))^z4* | |
((-s + s13 + s23)*x^4)^z5* | |
(x^6)^(ep + z1 + z2 + z3)* | |
(-(s*x^6))^z6* | |
(-(s*x^7))^z9* | |
((-s + s13 + s23)*x^7)^z7* | |
(s23*x^8)^z8* | |
(-(s*x^10))^(1 - 2*ep - z1 - z4 - z5 - z6 - z7 - z8 - z9)* | |
Gamma[-z4]* | |
Gamma[-z5]* | |
Gamma[-z6]* | |
Gamma[-z7]* | |
Gamma[-z8]* | |
Gamma[-z9]* | |
Gamma[3 + 2*ep + z1 + z4 + z5 + z6 + z7 + z8 + z9] | |
)/( | |
s^4* | |
x^43* | |
(x^4)^z3 | |
*(x^5)^z2 | |
); | |
res1 = NewIntegrate1[ex, x] // Timing; | |
res2 = NewIntegrate2[ex, x] // Timing; | |
res1 // Print; | |
res2 // Print; | |
res1[[2]] == res2[[2]] /. NewIntegrate2 -> NewIntegrate1 // Print; | |
(* vim: set ft=mma et ts=8 sts=2 sw=2: *) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment