Skip to content

Instantly share code, notes, and snippets.

@tueda
Created April 20, 2023 07:29
Show Gist options
  • Save tueda/298e289cf4f913881bdc42f3165ee102 to your computer and use it in GitHub Desktop.
Save tueda/298e289cf4f913881bdc42f3165ee102 to your computer and use it in GitHub Desktop.
FORM vs. Wolfram: simple examples
* Example:
* form -D M=10 -D N=15 test11.frm
Symbol x1,...,x`M';
Local F = (x1+...+x`M')^`N';
.end
(*
* Example:
* wolframscript -f test11.m 10 15
*)
m = $ScriptCommandLine[[2]] // ToExpression;
n = $ScriptCommandLine[[3]] // ToExpression;
f = Sum[Symbol["x" <> ToString[i]], {i, 1, m}]^n;
Print["Input: ", f];
{t, f} = f // Expand // Timing;
Print["Timing: ", t, " seconds"]
Print["Number of terms: ", f // Length];
Print["Bytes used :", f // ByteCount];
* Example:
* form -D N=12 test21.frm
Index j; * fermion line
Auto Index mu; * Lorentz indices
Local F = g_(j,mu1,...,mu`N');
Print +s;
.sort:input;
tracen j;
*Print +s;
*.sort:result;
.end
(*
* Example:
* wolframscript -f test21.m 12
*)
n = $ScriptCommandLine[[2]] // ToExpression;
$FeynCalcStartupMessages = False;
<< FeynCalc`;
f = GAD @@ Table[
Symbol["mu" <> ToString[i]], {i, 1, n}
];
Print["Input: ", f];
{t, f} = Tr[f] // Expand // Timing;
Print["Timing: ", t, " seconds"];
Print["Number of terms: ", f // Length];
Print["Bytes used :", f // ByteCount];
* Example:
* form -D N=12 test31.frm
Index j; * fermion line
Symbol D,[D-4],ep;
Dimension D:[D-4];
Auto Index mu; * Lorentz indices
Local F = g_(j,mu1,...,mu`N',mu1,...,mu`N');
Print +s;
.sort:input;
tracen j;
.sort
id D = 4 - 2 * ep;
id [D-4] = - 2 * ep;
Print;
.sort:result;
.end
(*
* Example:
* wolframscript -f test31.m 12
*)
n = $ScriptCommandLine[[2]] // ToExpression;
$FeynCalcStartupMessages = False;
<< FeynCalc`;
f = Table[
Symbol["mu" <> ToString[i]], {i, 1, n}
];
f = GAD @@ Join[f, f];
Print["Input: ", f];
{t, f} = Tr[f] /. D -> 4 - 2 ep // Expand // Timing;
Print["Result: ", f];
Print["Timing: ", t, " seconds"];
Print["Number of terms: ", f // Length];
Print["Bytes used :", f // ByteCount];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment