4
$\begingroup$

Could anyone please help in writing the code for the following diagram in Mathematica?

enter image description here

Note: I want a simple code in Mathematica without using an external package.

$\endgroup$
1
  • 7
    $\begingroup$ Ok, you didn't like a perfectly reasonable answer by Nasser, but are not willing to show what have you tried yourself. Can you explain why can't you just use Arrow and Line inside Graphics? $\endgroup$
    – rhermans
    Commented May 10, 2022 at 9:38

3 Answers 3

15
$\begingroup$

Use MaTeX?

MaTeX["\\feynmandiagram[horizontal=a to b] {i1--[anti fermion] 
a--[anti fermion] i2,a--[photon] b};", Magnification -> 2]

Mathematica graphics

Note that this needs lualatex and not pdflatex, which is the default used by MaTeX. I do not know how to tell MaTeX to use lualatex instead of pdflatex as the default compiler, so I cheated a little. You need to do the following before issuing the above command.

Needs["MaTeX`"]

ConfigureMaTeX["pdfLaTeX" ->"C:\\Users\\Owner\\AppData\\Local\\Programs\\MiKTeX\\miktex\\bin\\x64\\lualatex.exe"];

SetOptions[MaTeX, "Preamble" -> {"\\usepackage{tikz}\\usepackage{tikz-feynman}"}]

And now you can issue the command.

Mathematica graphics

There is also FeynCalc which is is a Mathematica package for symbolic evaluation of Feynman diagrams but I never used it myself and do not have it installed. You could look at it.

There is also old FeynArts https://library.wolfram.com/infocenter/Articles/1638/ this paper describes the Mathematica package FeynArts used for the generation and visualization of Feynman diagrams

Update

Note: I want a simple code in Mathematica without using an external package.

The above was added later. Here is a quick plot using standard Mathematica Graphics. Feel free to adjust as needed

Graphics[{First@Plot[1/2 Sin[3*x], {x, 0, 3*Pi}, PlotStyle -> Black],
  {Arrowheads[{0, 0, 0.05, 0}], Arrow[{{0, 0}, {-2, 2}}]},
  {Arrowheads[{0, 0, 0.05, 0}], Arrow[{{-2, -2}, {0, 0}}]}}]

Mathematica graphics

Also could you please label say a, b, c all of the three lines

One option is to use Textand adjust the location as needed.

Graphics[{First@
   Plot[1/2 Sin[3*x], {x, 0, 3*Pi}, 
    PlotStyle -> Black], {Arrowheads[{0, 0, 0.05, 0}], 
   Arrow[{{0, 0}, {-2, 2}}]}, {Arrowheads[{0, 0, 0.05, 0}], 
   Arrow[{{-2, -2}, {0, 0}}]},
  Text[Style["a", Red, 16], {-1.5, -1.8}],
  Text[Style["b", Red, 16], {-1.5, 1.9}],
  Text[Style["c", Red, 16], {3, .8}]
  }
 ]

Mathematica graphics

$\endgroup$
7
  • $\begingroup$ that's fine, but I want a simple code in Mathematica without using an external package. $\endgroup$
    – SciJewel
    Commented May 10, 2022 at 8:43
  • $\begingroup$ 2nd, Why one not use tikz-Feynman directly in Latex rather than using in Mathematica! $\endgroup$
    – SciJewel
    Commented May 10, 2022 at 8:47
  • 4
    $\begingroup$ Why one not use tikz-Feynman directly in Latex rather than using in Mathematica! Well, you said yourself you wanted the diagram in Mathematica diagram in Mathematica I assumed as part of your other notebook diagrams. If you do not need it in Mathematica, then why not just Latex directly? You are asking this in Mathematica forum. MaTeX is very useful package that allows one to use Latex functionality from inside Mathematica. $\endgroup$
    – Nasser
    Commented May 10, 2022 at 8:50
  • $\begingroup$ Thanks for your effort and great help! I wanted the second and I think the direct Mathematica code is much easier to modify. $\endgroup$
    – SciJewel
    Commented May 10, 2022 at 12:51
  • $\begingroup$ Also could you please label say a, b, c all of the three lines $\endgroup$
    – SciJewel
    Commented May 10, 2022 at 14:32
10
$\begingroup$

The arrows can be drawn using "Arrow" and for the wiggly line we use a Bezier curve.

For the Bezier curve some control points are needed. We choose control points at a distance of +/-0.5 above/below the y and 0.5 spaced along the x axis:

dx = 0.3;
dy = 0.5;
n = 7;
ctrl = Table[{i dx, Mod[i, 3, -1] dy}, {i, n}]

With this we can now draw the diagram:

gr=Graphics[{Thickness[0.01]
  , Arrowheads[0.1], Arrow[{{-1, -1}, {0, 0}}, 0.5], 
  Line[{{-1, -1}, {0, 0}}]
  , Arrow[{{0, 0}, {-1, 1}}, 0.5], Line[{{-1, 1}, {0, 0}}]
  , BezierCurve[Join[{{0, 0}}, ctrl, {{++n dx, 0}}]]
  }]

enter image description here

$\endgroup$
3
  • $\begingroup$ Thanks a lot! Could you please draw another diagram in addition to the above with a dot/blob instead of the wavy line? Second, how to label all the lines. $\endgroup$
    – SciJewel
    Commented May 10, 2022 at 12:55
  • 5
    $\begingroup$ What about trying yourself? Using my example you should be able to change it accordingly. If you run into a problem, you can still ask. $\endgroup$ Commented May 10, 2022 at 15:51
  • $\begingroup$ I have already done that. I was confused about the defined ctrl function, but I replaced that part with the point now. Thanks! $\endgroup$
    – SciJewel
    Commented May 10, 2022 at 18:36
0
$\begingroup$

Here is a part of my package for performing calculations with Feynman diagrams:

1.1 Define a set of Feynman diagrams

Clear[f, G, V]
f[0, 1][a_, b_, c_, d_] = 
 diag[g[a, i[1]], g[b, i[2]], g[i[1], c], g[i[2], d], v[i[1], i[2]]]
f[0, 2][a_, b_, c_, d_] = 
 diag[g[a, i[1]], g[b, i[2]], g[i[1], d], g[i[2], c], v[i[1], i[2]]]

1.2 Define a plotting function

pic[diag[x__]] := Module[{i, j, k},
    Graph[List[x] /. {g[i_, j_] -> DirectedEdge[j, i],
                        v[j_, k_] -> UndirectedEdge[j, k]},
                    VertexLabels -> "Name",
                    PlotTheme -> "Business",
                    ImageSize -> 300, ImagePadding -> 10,
                    VertexLabelStyle -> Directive[Black, 11],
                    GraphHighlight -> 
    Cases[List[x], v[i_, j_] -> UndirectedEdge[i, j]]]]

1.3 Depict 2 two-particle Green's functions to the first order in the Coulomb interaction

pic /@ {f[0, 1][a, b, c, d], f[0, 2][a, b, c, d]}

enter image description here

Let us do a bit more complicated stuff. We re-sum two-particle diagrams in the $T$-matrix (particle-particle channel) fashion

2.1 Define functions for contracting diagrams

vlist[diag[x__]] := Union[Flatten[Apply[List, List[x], 1]]]
contract[x__, vC_] := Module[{dlist, vtab, vE, vI, dj, rules, ka},
  dlist = List[x];
  (* replace contracted indices *)
  
  rules = Table[vC[[j]] -> i[0, j], {j, Length[vC]}];
  dlist = dlist /. rules;
  (* rename internals *)
  dlist = Table[dj = dlist[[j]];
    rules = Flatten[Cases[vlist[dj], i[ka_] -> {i[ka] -> i[j, ka]}]];
    dj /. rules, {j, Length[dlist]}];
  (*Combine diagrams together*)
  
  dlist = Apply[diag, Flatten[List @@@ dlist]];
  (* Rename internals*)
  vI = Cases[vlist[dlist], i[__]];
  dlist /. Rule @@@ Transpose[{vI, i /@ Ordering[vI]}]
  ]

2.2 Define $T$-matrix diagrams

f[1, 2][a_, b_, c_, d_] = 
  contract[f[0, 1][p, q, c, d], V[p, q], G[a, p], G[b, q], {p, q}];
f[2, 2][a_, b_, c_, d_] = 
  contract[f[1, 2][p, q, c, d], V[p, q], G[a, p], G[b, q], {p, q}];
f[3, 2][a_, b_, c_, d_] = 
  contract[f[2, 2][p, q, c, d], V[p, q], G[a, p], G[b, q], {p, q}];

2.3 and plot the result

f[3, 2][a, b, c, d] // pic

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.