-
Dear experts, Mathematica is taking too long to handle relatively easy tasks. I'm not sure if it is related to my poorly efficient code (and I have a chance to improve it) or to Mathematica/Feyncalc itself. After evaluating the trace and doing some expansion in my (tow-loop) amplitude I have ~150 terms. One simplification I want to do (before integrating) is removing the terms with an odd number of loop momenta in the numerator. I made a custom function called To my surprise, the time it takes is not proportional to the number of terms. For instance, applying it to 100 and 50 terms, Number of terms: 100 -> 72; time: 10.2s Do you know why this happens? I attach a simplified notebook showing this with 100 terms of my amplitude. (I had to put it in .txt to upload it.) removeOddK.txt Another question: Is there a built-in function in FeynCalc that does this? I couldn't get FCMultiLoopTID to only remove the odd number of loop momenta. I would also appreciate if you see something clearly inefficient in my code. Here only the part with
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The only question here which really has to do with FeynCalc is whether there is built in functionality to do this, so I will address that first. If I understand you correctly you want to remove a term if and only if there is an odd number of the momenta k1, k2 in the numerator. If so, here is a possible solution: ( replaceAllRestricted[expr_, rules_List, heads_List] :=
expr /. Join[a : Blank[#] :> a & /@ heads, rules];
replaceAllRestricted[
test,
{Momentum[k1, D] -> a * Momentum[k1, D], Momentum[k2, D] -> a * Momentum[k2, D]},
{FeynAmpDenominator}] /. a^n_Integer :> If[EvenQ[n], 1, 0] For me this uses just 15 milliseconds for the 100 term expression. Explanation: About your code: |
Beta Was this translation helpful? Give feedback.
The only question here which really has to do with FeynCalc is whether there is built in functionality to do this, so I will address that first.
I don't think it has, and I don't think it needs it, as this is already covered quite conveniently by Mathematica itself.
If I understand you correctly you want to remove a term if and only if there is an odd number of the momenta k1, k2 in the numerator. If so, here is a possible solution: (
test
is your expression)