-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFeynGKZ.wl
1854 lines (1257 loc) · 71.6 KB
/
FeynGKZ.wl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(* ::Package:: *)
(* ::Title:: *)
(*FeynGKZ.wl*)
(* ::Subtitle:: *)
(*a Mathematica package for solving Feynman Integrals using GKZ hypergeometric systems*)
(* ::Text:: *)
(*B. Ananthanarayan, Sumit Banik, Souvik Bera, Sudeepan Datta*)
(* ::Section:: *)
(*Package initiation*)
SetOptions[EvaluationNotebook[], CommonDefaultFormatTypes -> {"Output" -> StandardForm}];
BeginPackage["FeynGKZ`"];
Block[{Print},Get["AMBREv2.1.1.m"]//Quiet];
Block[{Print},Get["Olsson.wl"]//Quiet];
LastUpdate="\!\(\*SuperscriptBox[\(2\), \(nd\)]\) November, 2022";
(* ::Section::Closed:: *)
(*Author credits and loading dependencies*)
If[$VersionNumber<12.1, Print[Style["Mathematica version incompatible, please upgrade to version 12.1 or later",Red]]; Abort[];]
If[$VersionNumber>=12.1,Print[Style["FeynGKZ 1.0",Blue,14,FontFamily->"Courier",Bold],Style[" - a Mathematica package for solving Feynman Integrals using GKZ hypergeometric systems",Blue,14,FontFamily->"Courier"]];
Print[Style["Authors: ",Black,Bold],Style[" B. Ananthanarayan, Sumit Banik, Souvik Bera, Sudeepan Datta",Brown,Bold,12.5]];
Print[Style["Last updated: ",Black,Bold], LastUpdate];]
(* ::Section::Closed:: *)
(*Global Variables*)
Global`FeynGKZPath::usage="Set this variable such that it points to the directory
containing \"FeynGKZ.wl\" and its dependencies \"AMBREv2.1.1.m\" and \"Olsson.wl\".
Note: the path must be passed as a string.
By default, it points to \"NotebookDirectory[]\".";
Global`PolyMakePath::usage="Set this variable such that it points to the directory
containing the \"polymake\" executable.
Note: the path must be passed as a string.
By default, it points to \"/usr/bin\".";
Global`TOPCOMPath::usage="Set this variable such that it points to the directory
containing the \"points2triangs\" executable from TOPCOM.
Note: the path must be passed as a string.
By default, it points to \"/usr/local/bin\".";
Dim::usage="Space-time dimension of the Feynman integral.";
n::"usage"="Summation indices.";
\[ScriptZ]::"usage"="Generic coefficients of the toric G-polynomial.";
(* ::Section:: *)
(*External Modules Usage of Triangulation Method*)
FindAMatrix::usage="FindAMatrix[{MomentumRep, LoopMomenta, InvariantList, Dim, Prefactor}]
or,
FindAMatrix[{{U, F, PropagatorPowers}, LoopNumber, InvariantList, Dim,
Prefactor}]
Below, we provide details about the input arguments for FindAMatrix.
\[Bullet] MomentumRep: A list containing information about all the propagators in the Feynman inte-
gral. It consists of multiple sub-lists, each of which has the following pattern:
{Propagator-Momentum, Propagator-Mass, Propagator-Power}.
\[Bullet] U: The first Symanzik polynomial corresponding to the given Feynman integral.
\[Bullet] F: The second Symanzik polynomial corresponding to the given Feynman integral.
\[Bullet] PropagatorPowers: A list containing all the powers of the propagators of the Feynman
integral.
\[Bullet] LoopMomenta: A list containing the loop-momenta for the given Feynman integral.
\[Bullet] LoopNumber: The number of loops appearing in the given Feynman integral. It must be an
positive integer.
\[Bullet] InvariantList: A list of kinematic substitutions.
\[Bullet] Dim: the space-time dimension.
\[Bullet] Prefactor: An overall factor that is independent of the loop-momenta.
\[Bullet] Options:
\[Dash] UseMB: This option accepts a boolean value. Its default value is False. When set True,
FindAMatrix calls AMBRE v2.1.1 to obtain the MB-representation corresponding to the
given Feynman integral, and uses it to compute the \[ScriptCapitalA]-matrix.
"
FindTriangulations::usage="FindTriangulations[FindAMatrixOut]
This external module computes unimodular regular triangulations corresponding to the \[ScriptCapitalA]-matrix
generated by FindAMatrix using TOPCOM. Below, we provide details about the input arguments for
FindTriangulations.
\[Bullet] FindAMatrixOut: Result returned by FindAMatrix.
\[Bullet] Options:
\[Dash] MaxRegularTriangs: This option can take either of the two values: \!\(\*
StyleBox[\"All\",\nFontSlant->\"Italic\"]\), or some
positive integer. Its default value is \!\(\*
StyleBox[\"All\",\nFontSlant->\"Italic\"]\). When set to \!\(\*
StyleBox[\"All\",\nFontSlant->\"Italic\"]\), FindTriangulations
tries to find all possible regular triangulations. When set to a positive integer \!\(\*
StyleBox[\"n\",\nFontSlant->\"Italic\"]\),
FindTriangulations stops after obtaining upto \!\(\*
StyleBox[\"n\",\nFontSlant->\"Italic\"]\) regular triangulations and then scans
for unimodular regular triangulations.
\[Dash] PrintRegularTriangs: This option accepts a boolean value. By default, this option is
set to False. When set to True, FindTriangulations prints the regular triangulations
in addition to the unimodular regular triangulations.
\[Dash] RunInParallel: This option accepts a boolean value. By default, this option is set to
False. When set to True, Mathematica\[CloseCurlyQuote]s native parallelization features are used.
\[Dash] Docker: This option accepts a boolean value. By default, this option is set to False.
When set to True, one can call TOPCOM from a Docker container having the name
\"topcom\", to obtain the regular triangulations. This option might come in handy, should
one fail to install TOPCOM natively on their system."
SeriesRepresentation::usage="SeriesRepresentation[Triangulations, TriangNum]
or,
SeriesRepresentation[Ideals, IdealNum]
where, the input arguments are as follows:
\[Bullet] Triangulations: Result returned by FindTriangulations.
\[Bullet] TriangNum: Serial number of the unimodular regular triangulation for which the correspond-
ing series solution is to be derived
\[Bullet] Ideals: Result returned by FindInitialIdeals.
\[Bullet] IdealNum: Serial number of the square-free initial ideal for which the corresponding series
solution is to be derived.
\[Bullet] Options:
\[Dash] SubstituteScales: This option accepts a boolean value. By default, this option is set
to True. When set to True, all the indeterminate generic coefficients \!\(\*SubscriptBox[\(\[ScriptZ]\), \(i\)]\) , are substituted
with their appropriate kinematic counterparts while constructing the series solution for
the given non-generic Feynman integral. When False, this substitution is not done.
\[Dash] ParameterValue: This option accepts a list of parameter substitutions.
By default, this option is assigned an empty list."
GetClosedForm::usage="GetClosedForm[MySeries]
which has the following input arguments:
\[Bullet] MySeries: Result returned by SeriesRepresentation.
\[Bullet] Options:
\[Dash] ParameterValue: This option accepts a list of parameter substitutions.
By default, this option is assigned an empty list."
NumericalSum::usage="NumericalSum[MySeries, SubstitutionRules, SumLim]
with the following input arguments:
\[Bullet] MySeries: Result returned by the SeriesRepresentation or GroebnerDeformation.
\[Bullet] SubstitutionRules: This a list to substitute numerical values to parameters and scales
of MySeries before numerical summation.
\[Bullet] SumLim: The upper-limit for summing over the summation variables. The same upper-limit
is mainatined for each summation variable.
\[Bullet] Options:
\[Dash] NumericalPrecision: This option accepts a positive integer.
It is used to set the precision of the numerical summation. By default,
this option is set to MachinePrecision.
\[Dash] RunInParallel: This option accepts a boolean value. By default, this option is set to
False. When set to True, Mathematica\[CloseCurlyQuote]s native parallelization features are used.
\[Dash] Docker: This option accepts a boolean value. By default, this option is set to False."
(* ::Section::Closed:: *)
(*External Modules Usage of Groebner Deformation Method*)
FindInitialIdeals::usage="FindInitialIdeals[FindAMatrixOut]
This external module generates all possible square-free initial ideals corresponding to the
\[ScriptCapitalA]-matrix generated by FindAMatrix. Below, we provide details about its input arguments.
\[Bullet] FindAMatrixOut: Result returned by FindAMatrix."
GroebnerDeformation::usage="GroebnerDeformation[FindAMatrixOut]
with the following input arguments:
\[Bullet] FindAMatrixOut: result returned by FindAMatrix.
\[Bullet] Options:
\[Dash] InitialIdeal: Serial number of the square-free initial ideal for which the corresponding
series solution is to be derived. Its default value is False.
\[Dash] Weight: This option accepts a list of non-negative integers, whose length is same as the
number of columns of the \[ScriptCapitalA]-matrix. Its default value is False.
\[Dash] AllInitialIdeals: This option accepts a boolean value. Its default value is False.
When set to True, this module yields series solutions for all the possible square-free
initial ideals sequentially.
\[Dash] ParameterValue: This option accepts a list of parameter substitutions. By default,
this option is assigned an empty list."
TriangulationToIdeal::usage="TriangulationToIdeal[Triangulations, TriangNum]
where, the input arguments are as follows:
\[Bullet] Triangulations: Result returned by FindTriangulations.
\[Bullet] TriangNum: Serial number of the unimodular regular triangulation for which the correspond-
ing square-free initial ideal is to be derived."
IdealToTriangulation::usage="IdealToTriangulation[Ideals, IdealNum]
where, the input arguments are as follows:
\[Bullet] Ideals: Result returned by FindInitialIdeals.
\[Bullet] IdealNum: Serial number of the square-free initial ideal for which the corresponding unimod-
ular regular triangulation is to be derived.
"
(* ::Section::Closed:: *)
(*Usage of Options*)
UseMB::usage = "This is an option of FindAMatrix, which accepts a boolean value. Its default value is False. When set True,
FindAMatrix calls AMBRE v2.1.1 to obtain the MB-representation corresponding to the
given Feynman integral, and uses it to compute the \[ScriptCapitalA]-matrix."
NumericalPrecision::usage = "This is an option of NumericalSum, which accepts a positive integer.
It is used to set the precision of the numerical summation. By default,
this option is set to MachinePrecision."
RunInParallel::usage = "This is an option of FindTriangulations and NumericalSum, which accepts a boolean value.
By default, this option is set to False. When set to True, Mathematica\[CloseCurlyQuote]s native parallelization features are used.";
Docker::usage="This is an option of FindTriangulations, which accepts a boolean value. By default, this option is set to False.
When set to True, one can call TOPCOM from a Docker container having the name
\"topcom\", to obtain the regular triangulations. This option might come in handy, should
one fail to install TOPCOM natively on their system.";
MaxRegularTriangs::usage="This is an option of FindTriangulations, which can take either of the two values: \!\(\*
StyleBox[\"All\",\nFontSlant->\"Italic\"]\), or some
positive integer. Its default value is \!\(\*
StyleBox[\"All\",\nFontSlant->\"Italic\"]\). When set to All, FindTriangulations
tries to find all possible regular triangulations. When set to a positive integer \!\(\*
StyleBox[\"n\",\nFontSlant->\"Italic\"]\),
FindTriangulations stops after obtaining upto \!\(\*
StyleBox[\"n\",\nFontSlant->\"Italic\"]\) regular triangulations and then scans
for unimodular regular triangulations.";
PrintRegularTriangs::usage="This is an option of FindTriangulations, which accepts a boolean value. By default, this option is
set to False. When set to True, FindTriangulations prints the regular triangulations
in addition to the unimodular regular triangulations.";
SubstituteScales::usage="This is an option of FindTriangulations, which accepts a boolean value. By default, this option is set
to True. When set to True, all the indeterminate generic coefficients \!\(\*SubscriptBox[\(\[ScriptZ]\), \(i\)]\) , are substituted
with their appropriate kinematic counterparts while constructing the series solution for
the given non-generic Feynman integral. When False, this substitution is not done.";
ParameterValue::usage="This is an option of FindTriangulations and GroebnerDeformation, which accepts a
list of parameter substitutions. By default, this option is assigned an empty list.";
InitialIdeal::usage="This is an option of GroebnerDeformation, which accepts the serial number of the
square-free initial ideal for which the corresponding series solution is to be derived. Its default value is False.";
Weight::usage="This is an option of GroebnerDeformation, which accepts a list of non-negative integers,
whose length is same as the number of columns of the \[ScriptCapitalA]-matrix. Its default value is False.";
AllInitialIdeals::usage="This is an option of GroebnerDeformation, which accepts a boolean value. Its default value is False.
When set to True, this module yields series solutions for all the possible square-free
initial ideals sequentially.";
(* ::Section::Closed:: *)
(*Triangulation Method*)
Begin["Private`"]
(* ::Subsection::Closed:: *)
(*Setting Paths*)
If[!ValueQ@(Global`FeynGKZPath),Global`FeynGKZPath=NotebookDirectory[]];
If[!ValueQ@(Global`TOPCOMPath),Global`TOPCOMPath="/usr/local/bin"];
GKZGeom`topcomPath=Global`TOPCOMPath;
If[!ValueQ@(Global`PolyMakePath),Global`PolyMakePath="/usr/bin"];
(* ::Subsection::Closed:: *)
(*Constructing the Symanzik polynomials (Written by A. Smirnov)*)
UF[xx_, yy_, z_] := Module[{degree, coeff, i, t2, t1, t0, zz},
zz = Map[Rationalize[##,0]&, z, {0, Infinity}];
degree = -Sum[yy[[i]]*Global`x[i], {i, 1, Length[yy]}];
coeff = 1;
For[i = 1, i <= Length[xx], i++,
t2 = Coefficient[degree, xx[[i]], 2];
t1 = Coefficient[degree, xx[[i]], 1];
t0 = Coefficient[degree, xx[[i]], 0];
coeff = coeff*t2;
degree = Together[t0 - ((t1^2)/(4 t2))];
];
degree = Together[-coeff*degree] //. zz;
coeff = Together[coeff] //. zz;
{coeff, Expand[degree], Length[xx]}
];
(* ::Subsection:: *)
(*Finding the A - matrix*)
(* ::Subsubsection::Closed:: *)
(*Preparation A - matrix from the Lee - Pomeransky polynomial*)
Amatrix[poly_,var_List]:=Module[{},
Return[{Join[{Table[1,{i,1,Length[#]}]},Transpose[#[[All,1]]]],#[[All,2]]}
&@Sort[CoefficientRules[Expand[poly],var],Lexicographic]]];
(* ::Subsubsection::Closed:: *)
(*Preparation A - matrix from the Mellin - Barnes representation*)
findVar[expr_,var_]:=Module[{temp},temp=Hold[expr]/. var->0;
If[temp===Hold[expr],Nothing,var]];
findMBMatrix[MBIn_]:=Module[{A,IdentityA,NumDen=MBIn[[1]],IntVar=MBIn[[2]],NumCof,MBFold},MBFold=Length@IntVar;
NumCof=Table[Coefficient[NumDen[[i]],IntVar],{i,1,Length@NumDen}];
IdentityA=IdentityMatrix[(Length@NumDen)];
A=ArrayFlatten[{{NumCof,IdentityA}}];
Return[A]];
findA[MBOut_]:=Module[{MBList,MBListDen,MBListNum,MBVar,MBIntVar,MBNum,MBDen,Num,
Den,NumDen,NumDenTrimmed,MBMatIn,A,MBListNumFactors,MBListDenFactors,IntVar,Prefactor,MBScales,ConstantNum={},
ConstantDen={},PowerNum={},PowerDen={},RemovePos,CoDim},
MBList=List@@(MBOut);
MBListDen=Denominator[#]&/@MBList;
MBListNum=Numerator[#]&/@MBList;
MBListNumFactors=(FactorList[#])&/@MBListNum//Flatten//DeleteDuplicates;
MBListDenFactors=(FactorList[#])&/@MBListDen//Flatten//DeleteDuplicates;
MBListNumFactors=Table[ConstantArray@@#&/@FactorList[i]//Flatten,{i,MBListNum}]//Flatten;
MBListDenFactors=Table[ConstantArray@@#&/@FactorList[i]//Flatten,{i,MBListDen}]//Flatten;
IntVar=ToExpression@(("z"<>ToString@#)&/@(Range@100));
MBIntVar=findVar[MBOut,#]&/@IntVar;
Print[Style["Obtained an MB representation of ",Blue],Length@MBIntVar,Style[" fold.",Blue]];
If[Length@MBIntVar===0,Print[Style["As MB representation is of 0-fold no \[ScriptCapitalA]-matrix can be associated to it.",Red]];Abort[];];
ConstantNum={};
ConstantDen={};
PowerNum={};
PowerDen={};
Do[If[And@@(FreeQ[i,#]&/@MBIntVar),AppendTo[ConstantNum,i],If[Head@i===Power,AppendTo[PowerNum,i]]],{i,MBListNumFactors}];
Do[If[And@@(FreeQ[i,#]&/@MBIntVar),AppendTo[ConstantDen,i],If[Head@i===Power,AppendTo[PowerDen,i]]],{i,MBListDenFactors}];
Prefactor=Times@@ConstantNum/Times@@ConstantDen;
MBScales=Table[Times@@(Select[PowerNum,!FreeQ[#,MBIntVar[[i]]]&])/Times@@(Select[PowerDen,!FreeQ[#,MBIntVar[[i]]]&])/. {MBIntVar[[i]]->1},{i,Length@MBIntVar}]//Flatten;
Print[Style["The scales of the MB representation are ",Blue],MBScales,"."];
If[Length[Select[MBScales,NumberQ]]>0,Print[Style["The package cannot find the GKZ system for this MB yet.",Red]];Abort[];];
MBNum=Delete[#,0]&/@(Select[MBListNumFactors,Head[#]==Gamma&]);
MBDen=Delete[#,0]&/@(Select[MBListDenFactors,Head[#]==Gamma&]);
Num=Table[If[!And@@(FreeQ[i,#]&/@MBIntVar),i,Nothing],{i,MBNum}];
Den=Table[If[!And@@(FreeQ[i,#]&/@MBIntVar),i,Nothing],{i,MBDen}];
NumDen=Join[Num,-Den];
(*NumDenTrimmed=DeleteElements[NumDen,1->(-MBIntVar)];*)
RemovePos=Table[Last@Position[NumDen,i,1],{i,-MBIntVar}];
NumDenTrimmed=Delete[NumDen,RemovePos];
If[(Length@NumDen-Length@NumDenTrimmed)===Length@MBIntVar,Nothing,Print[" Some Issues! "];Abort[]];
MBMatIn=Append[{NumDenTrimmed},MBIntVar];
A=findMBMatrix@MBMatIn;
CoDim = (Length@(Transpose@A)-Length@A );
Print[Style["The associated \[ScriptCapitalA]-matrix \[Rule] ",Blue],A//MatrixForm,Style[", which has codim = ", Blue],CoDim,Style[".",Blue]];
Return[{Transpose@A,MBScales,MBIntVar,Prefactor,Num,Den}]];
(* ::Subsubsection::Closed:: *)
(*Interfacing with PolyMake (Inspired from a private notebook of Ren\[EAcute] P.Klausen)*)
CalcPolytopeVol[Amat_,OptionsPattern[{PolymakePath->Global`PolyMakePath}]]:=Module[{NormEuclVol},
Off[CreateFile::eexist];
SetDirectory[NotebookDirectory[]];
CreateFile["AforPOLYMAKE.dat"];
FileData=StringReplace[ToString[Amat[[1]]],{"}, {"->"\n","{{"->"","}}"->"",","->""}];
Export["AforPOLYMAKE.dat",FileData,OverwriteTarget->True];
Export["polytopevol.dat","use application \"polytope\";
open(INPUT, \"< AforPOLYMAKE.dat\");
my $points=new Matrix(<INPUT>);
close(INPUT);
my $polytope = new Polytope(POINTS=>$points);
my $normvol = $polytope->LATTICE_VOLUME;
print $normvol;
exit();"];
RenameFile["polytopevol.dat","polytopevol.perl",OverwriteTarget->True];
polymakescript="\""<>NotebookDirectory[]<>"polytopevol.perl\"";
NormEuclVol=RunProcess[$SystemShell,"StandardOutput",OptionValue[PolymakePath]<>"/polymake --script "<>polymakescript];
Print[Style["Normalized Volume of the associated Newton Polytope \[Rule] ",Blue],NormEuclVol];
Return[NormEuclVol];
];
(* ::Subsubsection::Closed:: *)
(*External Module*)
Options[FindAMatrix]={UseMB->False};
FindAMatrix[Standardform_,OptionsPattern[]]:=Module[{input,UFform, sympols, var, replacements, G, Amat, genAmat, Atransp,
mom, prop, kinsub,MBout,FindAReturn,findAReturn,LoopNum,MBOut,IntVarSub1,IntVarSub2,MBVarChange,PropagatorPowers,PrefactorCorrection,
UFFormat=False,TimeTaken,CoDim,Invariants=Standardform[[3]],PropPowers,ReturnValue},
TimeTaken=AbsoluteTiming[
Dim=Standardform[[4]];
Which[
ListQ@Standardform[[2]],
PropPowers=#[[3]]&/@(Standardform[[1]]);
UFform=Range[3];
UFform[[1]]=Standardform[[2]];
LoopNum=Length@UFform[[1]];
UFform[[2]]=Table[-(First@Standardform[[1]][[i]])^2+Part[Standardform[[1]][[i]],2]^2,{i,Length@Standardform[[1]]}];
UFform[[3]]=Standardform[[3]];
{mom,prop,kinsub}=UFform;
sympols=UF[mom,prop,kinsub];
replacements=Table[Global`x[i]->Subscript[Global`x, i],{i,Length@DeleteDuplicates@Cases[sympols[[1]],_Symbol[_Integer],\[Infinity]]}];
sympols=sympols/.replacements/.Invariants;
sympols=Expand@sympols/.Invariants;
,!ListQ@Standardform[[2]],
PropPowers=(Standardform[[1]])[[3]];
UFFormat=True;
LoopNum=Standardform[[2]];
input=Standardform;
sympols=(Standardform[[1]])[[{1,2}]];
sympols=sympols/.Invariants;
sympols=Expand@(Expand@sympols/.Invariants);
];
G=Total[sympols[[{1,2}]]];
Print[Style["The Symanzik polynomials \[Rule] U = ",Blue],Style[sympols[[1]]],Style[", F = ",Blue],Style[sympols[[2]]]];
Print[Style["The Lee-Pomeransky polynomial \[Rule] G = ",Blue],Style[G]];
Which[OptionValue[UseMB]===False
,
var=DeleteDuplicates@Cases[sympols[[1]],Subscript[_Symbol, _Integer],\[Infinity]];
Global`CoeffSubList=Table[Sort[CoefficientRules[Expand[G],var],Lexicographic][[i]][[2]],{i,Length[Sort[CoefficientRules[Expand[G],var],Lexicographic]]}];
genAmat=Amatrix[G,DeleteDuplicates@Cases[sympols[[1]],Subscript[_Symbol, _Integer],\[Infinity]]];
Atransp=genAmat[[1]];
Amat=Transpose@Atransp;
CoDim = (Length@(Transpose@Atransp)-Length@Atransp);
Print[Style["The associated \[ScriptCapitalA]-matrix \[Rule] ",Blue],Atransp//MatrixForm,Style[", which has codim = ", Blue],CoDim,Style[".",Blue]];
FindAReturn={Amat,OptionValue@UseMB};
, OptionValue[UseMB]===True,
SetDirectory[Global`FeynGKZPath];
Block[{Print},Get["AMBREv2.1.1.m"]//Quiet];
If[UFFormat,Print[Style["To use MB, please provide the momentum-representation of the Feynman integral.",Red]];Abort[]];
MBVarChange=ToExpression@((("AMBRE`z" <> ToString@#) <>"->" <> ("z" <> ToString@#)) & /@ (Range@100));
prop=Times@@(PR@@#&/@Standardform[[1]]);
LoopNum=Length@Standardform[[2]];
d=Standardform[[4]];
invariants=Standardform[[3]];
PropagatorPowers=#[[3]]&/@Standardform[[1]];
PrefactorCorrection=Times @@ ((-1)^-PropagatorPowers);
Block[{Print},MBOut=MBrepr[{Standardform[[5]]},{prop},Standardform[[2]]][[1]];];
MBOut=(MBOut*PrefactorCorrection)/.MBVarChange;
Print[Style["The Mellin-Barnes representation \[Rule] ",Blue],MBOut];
findAReturn=findA@MBOut;
FindAReturn=Append[findAReturn,OptionValue@UseMB];
];
If[!OptionValue@UseMB,
CalcPolytopeVol[FindAReturn]];
];
Print[Style["Time Taken ",Blue],Style[TimeTaken[[1]],Black],Style[" seconds",Blue]];
ReturnValue=Insert[FindAReturn,LoopNum,-2];
ReturnValue=Insert[ReturnValue,PropPowers,-2];
Return[ReturnValue];
];
(* ::Subsection::Closed:: *)
(*Finding Triangulations*)
(* ::Subsubsection::Closed:: *)
(*Finding Regular Triangulations*)
findRegularTriangulations[Amat_,OptionsPattern[{UseDocker->False, TopcomPath->Global`TOPCOMPath,
Triangulations->AllPossible, DoInParallel->False, RegTriangs->False}]]:= Module[{Count,ShellInput,Atri,List1,List2,
List3,List4={},RegPrintStatus},
Off[CreateFile::eexist];
SetDirectory[NotebookDirectory[]];
RegPrintStatus=OptionValue@RegTriangs;
While[Length@List4===0,
CreateFile["AforTOPCOM.dat"];
Export["AforTOPCOM.dat",ToString@Amat];
Which[OptionValue[UseDocker]===False
,Block[{Print},RunProcess[$SystemShell,"StandardOutput",
"tr \'{}\' \'\[\]\' < \""<>NotebookDirectory[]<>"AforTOPCOM.dat\" | tee \""<>NotebookDirectory[]<>"AforTOPCOM.dat\""
];
];
If[Head[OptionValue[Triangulations]]===Integer,
Count=ToString@OptionValue[Triangulations];
(*Print["Finding upto "<>Count<>" regular triangulations"];*)
Which[StringTake[$OperatingSystem,3]==="Mac"
,RunProcess[$SystemShell,"StandardOutput","export PATH=\""<>OptionValue[TopcomPath]<>":$PATH\" && points2triangs --regular --affine < \""<>NotebookDirectory[]<>"AforTOPCOM.dat\" | head -n "<>Count<>" > \""<>NotebookDirectory[]<>"Atri.txt\""];
,StringTake[$OperatingSystem,3]==="Uni"
,ShellInput="export PATH=\""<>OptionValue[TopcomPath]<>":$PATH\" && points2triangs --regular --affine < "<>NotebookDirectory[]<>"AforTOPCOM.dat | head -n "<>Count<>" > "<>NotebookDirectory[]<>"Atri.txt";
Export["RunTopcom.txt",ShellInput,OverwriteTarget->True];
RenameFile["RunTopcom.txt","RunTopcom.sh",OverwriteTarget->True];
Run["sh RunTopcom.sh"];
];
,(*Print["Finding all regular triangulations"];*)
Block[{Print},RunProcess[$SystemShell,"StandardOutput","export PATH=\""<>OptionValue[TopcomPath]<>":$PATH\" && points2triangs --regular --affine < \""<>NotebookDirectory[]<>"AforTOPCOM.dat\" | tee \""<>NotebookDirectory[]<>"Atri.txt\""];];
];
Atri=Import[NotebookDirectory[]<>"Atri.txt"];
,OptionValue[UseDocker]===True
,Block[{Print},RunProcess[$SystemShell,"StandardOutput",
"export PATH=\"/usr/local/bin:$PATH\" &&
docker cp \""<>NotebookDirectory[]<>"/AforTOPCOM.dat\" topcom:/home &&
docker exec topcom sh -c \"tr \'{}\' \'\[\]\' < AforTOPCOM.dat | tee AforTOPCOM.dat\""
];
];
If[Head[OptionValue[Triangulations]]===Integer,
Count=ToString@OptionValue[Triangulations];
(*Print["Finding upto "<>Count<>" regular triangulations"];*)
Block[{Print},RunProcess[$SystemShell,"StandardOutput","export PATH=\"/usr/local/bin:$PATH\" && docker exec topcom sh -c \"points2triangs --regular --affine < AforTOPCOM.dat | head -n "<>Count<>" > Atri.txt\""];];,
(*Print["Finding all regular triangulations"];*)
Block[{Print},RunProcess[$SystemShell,"StandardOutput","export PATH=\"/usr/local/bin:$PATH\" && docker exec topcom sh -c \"points2triangs --regular --affine < AforTOPCOM.dat | tee Atri.txt\""];];
];
Atri=RunProcess[$SystemShell,"StandardOutput","export PATH=\"/usr/local/bin:$PATH\" && docker exec topcom sh -c \"cat Atri.txt\""];
RunProcess[$SystemShell,"StandardOutput"," export PATH=\"/usr/local/bin:$PATH\" && docker exec topcom sh -c \"rm *.dat *.txt\""];
];
List1=Map[First,StringPosition[Atri,":"]]+1;
List2=Map[First,StringPosition[Atri,";"]]-2;
List3=Table[{List1[[2 i]],List2[[i]]},{i,Length@List2}];
Which[
OptionValue[DoInParallel]===False
,
List4=ToExpression@(StringJoin[StringPart[Atri,Range[Sequence@@#]]]&/@List3)+1;
,
OptionValue[DoInParallel]===True
,
List4=ToExpression[ParallelMap[StringJoin[StringPart[Atri,Range[Sequence@@#]]]&,List3]]+1;
];
List4=Sort[List4,Length[#1]<Length[#2]&];
];
If[Length@List4!=0,
If[Head[OptionValue[Triangulations]]===Integer
,Print[Style["Finding upto ",Blue],OptionValue[Triangulations],Style[" regular triangulations ...",Blue]]
,Print[Style["Finding all regular triangulations ... ",Blue]];
];];
Count=0;
(*If[OptionValue@RegTriangs, Do[Print[Style[++Count,Bold]," :: ",i],{i,List4}]];*)
Return[List4]
];
(* ::Subsubsection::Closed:: *)
(*Finding Unimodular Regular Triangulations*)
findUnimodularRegularTriangulations[A_,AllTri_,\[Delta]_,RegPrintStatus_]:=
Module[{Count=0,DetList,AUT},
AUT={};
Do[DetList=Abs[Det[A[[#]]]]/\[Delta]&/@i; If[ContainsOnly[DetList,{1}],AppendTo[AUT,i](*,Print["Could not find any unimodular triangulation"]*)],{i,AllTri}];
AUT=Sort[AUT,Length[#1]<Length[#2]&];
If[AUT!={}
,
Print[Style["Found ",Blue],Length@AllTri,Style[" Regular Triangulations, out of which ",Blue],Length@AUT,Style[" are Unimodular.",Blue]];
If[RegPrintStatus,
Print[Style["The ",Blue],Length@AllTri,Style[" Regular Triangulations \[Rule] ",Blue]];
Do[Print[Style[++Count,Bold]," :: ",i],{i,AllTri}]];
Print[Style["The ",Blue],Length@AUT,Style[" Unimodular Regular Triangulations \[Rule] ",Blue]];
Count=0;
Do[Print[Style[++Count,Bold]," :: ",i],{i,AUT}];
Return@AUT;
,
Print[Style["Could not find any Unimodular Regular Triangulation. Please extend the range of Regular Triangulations to be computed if possible.",Red]];
Abort[];];];
(* ::Subsubsection::Closed:: *)
(*External Module*)
Options[FindTriangulations]={Docker->False,MaxRegularTriangs->All,RunInParallel->False,PrintRegularTriangs->False};
FindTriangulations[findAOut_,OptionsPattern[]]:=
Module[{minors,RegTri,Amat=findAOut[[1]],UniTri,\[Delta],FindTriOut,TimeTaken},
TimeTaken=AbsoluteTiming[
RegTri=findRegularTriangulations[Amat,UseDocker->OptionValue@Docker,Triangulations->OptionValue@MaxRegularTriangs, DoInParallel->OptionValue@RunInParallel,RegTriangs->OptionValue@PrintRegularTriangs];
minors=DeleteCases[Minors[Transpose@Amat,Length@Transpose@Amat][[1]],0];
\[Delta]=GCD[#]&@@minors;
UniTri=findUnimodularRegularTriangulations[Amat,RegTri,\[Delta],OptionValue@PrintRegularTriangs];
FindTriOut=Prepend[findAOut,UniTri];
];
Print[Style["Time Taken ",Blue],Style[TimeTaken[[1]],Black],Style[" seconds",Blue]];
Return[FindTriOut];
];
(* ::Subsection:: *)
(*Finding Series Solutions*)
(* ::Subsubsection::Closed:: *)
(*Internal Module*)
Kvm = KeyValueMap[If[#,
Times @@ Power @@@ #2,
KeyValueMap[(Times @@ #2)^# &] @
GroupBy[#2, #[[1, 2]] &, Map[#[[1, 1]]^#[[2]] &]]] &];
GroupByExponents[exp_] := Module[{fl = FactorList @ PowerExpand @ exp},Times @@ Prepend[Power @@ First[fl]] @Flatten[Kvm @ GroupBy[Rest @ fl, NumericQ @ #[[1, 1]] &]]];
(* ::Subsubsection::Closed:: *)
(*External Module*)
Options[SeriesRepresentation]={SubstituteScales->True,ParameterValue->{}};
SeriesRepresentation[findTriangulationOut_,TriangulationNum_Integer,OptionsPattern[]]:=
Module[{AUT=findTriangulationOut[[1]],Amat=findTriangulationOut[[2]],zsubs,fl,Argument,ExpNum,ExpDenom,Summand,
exp,UT,s,sb,As,Asb,M1,M2,Fac1,Fac2,Fac3,PochRes1,PochRes2,SerRes,Res,
Scales,Prefactor,MBUsed=Last@findTriangulationOut,MBScales,MBIntVar,Prefac,MBNum,MBDen,NumLen,DenLen,UTComplement,
UTDenoFree,MBFold,RowNum,ColNum,MBIntSolve,
FactorialFunc,MBNumComplement,MBNumSub,MBDenSub,MBNumDenSub,
MBIntSol, NewScales, SumVarCof, ScaleFactor, ConstantFactor,MBIntSolConstant,LoopNum,SumVar,SumPar,
minors,\[Delta],ReplacementRules=Rationalize[OptionValue@ParameterValue],TimeTaken,PropPowers=findTriangulationOut[[4]],a},
TimeTaken=AbsoluteTiming[
minors=DeleteCases[Minors[Transpose@Amat,Length@Transpose@Amat][[1]],0];
\[Delta]=GCD[#]&@@minors;
Which[
TriangulationNum <= Length@AUT
,
UT=AUT[[TriangulationNum]];
Summand={};
Res={};
,TriangulationNum > Length@AUT
,
Print[Style["Error! Given serial number of triangulation has exceeded the total number of triangulations found.",Red]];
Abort[];];
Print[Style["Unimodular Triangulation \[Rule] ",Blue],TriangulationNum];
If[MBUsed,
{MBScales,MBIntVar,Prefac,MBNum,MBDen,LoopNum}=findTriangulationOut[[3;;8]];
NumLen=Length@MBNum;
DenLen=Length@MBDen;
MBFold=Length@MBIntVar;
SumVar=Subscript[n, #]&/@(Range@MBFold);
FactorialFunc=Product[1/Gamma[1+i],{i,SumVar}];
Print[Style["Number of summation variables \[Rule] ",Blue],Length@SumVar];
UTComplement=Complement[Range@(NumLen+DenLen), #] & /@ UT;
UTDenoFree=Select[UTComplement, ContainsOnly[#, Range@NumLen] &];
Do[
MBIntSolve=Solve[MBNum[[i]]==-SumVar,MBIntVar]//Flatten;
MBNumComplement=Complement[Range@NumLen,i];
MBNumSub=MBNum[[MBNumComplement]]/.MBIntSolve//Expand;
MBDenSub=MBDen/.MBIntSolve//Expand;
MBIntSol=MBIntVar/.MBIntSolve;
NewScales=Table[SumVarCof=Coefficient[MBIntSol,i];-Times@@(MBScales^SumVarCof),{i,(SumVar)}];
ScaleFactor=Times@@(NewScales^(SumVar));
MBIntSolConstant=MBIntSol/.({#->0}&/@(SumVar)//Flatten)//Expand;
ConstantFactor=Times@@(MBScales^MBIntSolConstant);
MBNumDenSub=Prefac*ConstantFactor*ScaleFactor*FactorialFunc*Times@@(Gamma[#]&/@MBNumSub)/Times@@(Gamma[#]&/@MBDenSub);
AppendTo[Res,MBNumDenSub];
,{i,UTDenoFree}]
, (* If MB not used *)
LoopNum=findTriangulationOut[[3]];
fl={};
ColNum=Length@Amat;
RowNum=Length@(Transpose@Amat);
exp=Join[{Subscript[a, 0]},PropPowers];
zsubs=Table[Subscript[\[ScriptZ], i],{i,ColNum}];
SumPar=Subscript[\[ScriptZ], #]&/@Range@ColNum;
Which[RowNum==ColNum
,UT=AUT;
Argument=(Inverse@Transpose@Amat . exp);
ExpNum=Times@@Gamma[Argument];
ExpDenom=Abs[Det[Amat]]/\[Delta];
Res=ExpNum/ExpDenom Times@@(zsubs^-Argument);
Res={Res};
Print[Style["No summation involved.",Blue]];
,RowNum>ColNum
,Print[Style["Incorrect \[ScriptCapitalA]-matrix. Please make sure that the number or rows doesn't exceed the number of columns. ",Red]];
,RowNum<ColNum
,Res={};
Summand={};
Do[
s=UT[[j]];
sb=Complement[Range@ColNum,s];
SumVar=Subscript[n, #]&/@Range[Length@sb];
As=Amat[[s]];
Asb=Amat[[sb]];
M1=Inverse@Transpose@As;
M2=M1 . Transpose@Asb;
Fac1=Times@@((SumPar[[s]])^-M1 . exp);
Fac2=Times@@(Gamma[#]&/@(M1 . exp+M2 . SumVar));
Fac3=Times@@((SumPar[[sb]])^SumVar)/Times@@((-SumPar[[s]])^(M2 . SumVar));
AppendTo[fl,FactorList @ PowerExpand @ Fac3];
Fac3=GroupByExponents@Fac3;
AppendTo[Summand,(Fac1*Fac2*Fac3)/Times@@(Gamma[1+#]&/@SumVar)];
,{j,Length@UT}];
AppendTo[Res,Summand];
Print[Style["Number of summation variables \[Rule] ",Blue],Length@SumVar];
];
(*Now let's put back the prefactor that we had ignored earlier*)
Prefactor=1/(Gamma[(LoopNum+1)Subscript[a, 0]-Total@DeleteCases[exp,Subscript[a, 0]]]Times@@Gamma@DeleteCases[exp,Subscript[a, 0]]);
Res= Prefactor*Res;
Res=Res/.ReplacementRules/.{Subscript[a, 0]-> Dim/2};
If[OptionValue@SubstituteScales,
zsubs=Table[SumPar[[i]]->Global`CoeffSubList[[i]],{i,Length@Global`CoeffSubList}];
Print[Style["Non-generic limit \[Rule] ",Blue],zsubs];
Scales=DeleteDuplicates@Flatten@Table[Kvm[GroupBy[Rest @ fl[[i]], NumericQ @ #[[1, 1]] &]][[2]]/.{Power[x_,y_]:>x},{i,Length@fl}];
Res=Res/.zsubs/.ReplacementRules,
Print[Style["We use generic scales denoted by ",Blue],zsubs];];
];
Res=Expand//@Res;
Print[Style["The series solution is the sum of following ",Blue],Length@Flatten[Res//Simplify],Style[" terms.",Blue]];
Table[Print[Style["Term ",Bold],i," :: \n",Flatten[Res][[i]]],{i,Length@Flatten[Res]}];
];
Print[Style["Time Taken ",Blue],Style[TimeTaken[[1]],Black],Style[" seconds",Blue]];
Return[{Flatten[Res//Simplify],Length@SumVar}];
];
Options[GetClosedForm]={ParameterValue->{}};
GetClosedForm[Ser_,OptionsPattern[]]:=Module[{SerRes,PochRes1,PochRes2,SerRep=Ser[[1]],NumSum=Ser[[2]],
SumVar=Subscript[n, #]&/@Range[Ser[[2]]],SubstitutionRules=OptionValue@ParameterValue,TimeTaken,a},
TimeTaken=AbsoluteTiming[
Which[NumSum==0,
SerRes=SerRep/.SubstitutionRules;
Print[Style["Solution involves no summation. ",Blue]];
Print[Style["Solution \[Rule] ",Blue],SerRes[[1]]];
,
NumSum===1,
{
SerRes=Sum[#,{Subscript[n, 1],0,Infinity}]&/@SerRep;
SerRes=SerRes/.SubstitutionRules;
Print[Style["Closed form found! ",Blue]];
Table[Print[Style["Term ",Bold],i," :: \n",SerRes[[i]]],{i,Length@SerRes}];
}
,
NumSum===2,
{
PochRes1=SerRep/.{Subscript[a, 0] -> Dim/2}//.Olsson`gammatoPoch[SumVar];
PochRes2=Olsson`Olsson[1,SumVar,#,Olsson`sim->True]&/@PochRes1;
SerRes=Olsson`serrecog2var[SumVar,#/.Pochhammer[1,m_]->m!]&/@PochRes2;
SerRes=SerRes/.SubstitutionRules;
Print[Style["Closed form found with Olsson! ",Blue]];
(*Print[SerRes];*)
Table[Print[Style["Term ",Bold],i," :: \n",SerRes[[i]]],{i,Length@SerRes}];
},
NumSum>=3,
{
SerRes=SerRes/.SubstitutionRules;
Print[Style["No closed form could be found using this package. ",Red]];}
];
];
Print[Style["Time Taken ",Blue],Style[TimeTaken[[1]],Black],Style[" seconds",Blue]];
Return[SerRes/.SubstitutionRules;];
];
(* ::Subsection:: *)
(*Finding Numerical Result*)
(* ::Subsubsection::Closed:: *)
(*External Module*)
Options[NumericalSum]={NumericalPrecision->MachinePrecision,RunInParallel->False};
NumericalSum[Ser_,ParamSub_,Lim_,OptionsPattern[]]:=
Module[{SerRep=Ser[[1]],NumSum=Ser[[2]],SumLim,SumCommand,SumToList,SeriesSub,NumRes={},TimeTaken,a,
ParamSubRationalized=Rationalize@ParamSub,ReturnNumericalVal},
If[!IntegerQ@NumSum,Print[Style["Input series not in correct format!",Red]];Abort[];];
TimeTaken=AbsoluteTiming[
SeriesSub=SerRep/.{Subscript[a, 0]->(Global`d0-2 Global`\[Epsilon])/2}/.ParamSubRationalized;
Which[
NumSum===0,
SumCommand=N,
OptionValue[RunInParallel]===False,
SumCommand=Sum;Off[General::munfl];
Off[General::stop],
OptionValue[RunInParallel]===True,
SumCommand=ParallelSum;
ParallelEvaluate[Off[General::munfl]];
ParallelEvaluate[Off[General::stop]];
];
SumLim=Table[{Subscript[n, i],0,Lim},{i,NumSum}];
Table[
With[{Summand=SeriesSub[[j]]},
NumRes=Insert[NumRes,SumCommand[Summand,Evaluate[Sequence@@SumLim]],-1]]
,{j,Length@SeriesSub}];
Print[Style["Numerical result = ",Blue],N[Total@NumRes,OptionValue[NumericalPrecision]]];
ReturnNumericalVal=N[NumRes,OptionValue[NumericalPrecision]];
];
Print[Style["Time Taken ",Blue],Style[TimeTaken[[1]],Black],Style[" seconds",Blue]];
Return[ReturnNumericalVal];
];
(* ::Section:: *)
(*Groebner Deformation Method*)
(* ::Subsection::Closed:: *)
(*Setting Default Directories*)
templatepath=NotebookDirectory[]<>"templates/";
outputpath=NotebookDirectory[];
(* ::Subsection::Closed:: *)
(*Generating Temporary Files*)
(* ::Input::Initialization:: *)