code: def main():
      a = Symbol("a", real=True)
      b = Symbol("b", real=True)
      c = Symbol("c", real=True)
  
      p = (a, b, c)
  
      assert u(p, 1).D * u(p, 2) == Matrix(1, 1, [0])
      assert u(p, 2).D * u(p, 1) == Matrix(1, 1, [0])
  
      p1, p2, p3 = [Symbol(x, real=True) for x in ["p1", "p2", "p3"]]
      pp1, pp2, pp3 = [
          Symbol(x, real=True) for x in ["pp1", "pp2", "pp3"]
      ]
      k1, k2, k3 = [Symbol(x, real=True) for x in ["k1", "k2", "k3"]]
      kp1, kp2, kp3 = [
          Symbol(x, real=True) for x in ["kp1", "kp2", "kp3"]
      ]
  
      p = (p1, p2, p3)
      pp = (pp1, pp2, pp3)
  
      k = (k1, k2, k3)
      kp = (kp1, kp2, kp3)
  
      mu = Symbol("mu")
  
      e = (pslash(p) + m * ones(4)) * (pslash(k) - m * ones(4))
      f = pslash(p) + m * ones(4)
      g = pslash(p) - m * ones(4)
  
      xprint("Tr(f*g)", Tr(f * g))
  
      M0 = [
          (v(pp, 1).D * mgamma(mu) * u(p, 1))
          * (u(k, 1).D * mgamma(mu, True) * v(kp, 1))
          for mu in range(4)
      ]
      M = M0[0] + M0[1] + M0[2] + M0[3]
      M = M[0]
      if not isinstance(M, Basic):
          raise TypeError("Invalid type of variable")
  
      d = Symbol("d", real=True)  # d=E+m
  
      xprint("M", M)
      print("-" * 40)
      M = ((M.subs(E, d - m)).expand() * d**2).expand()
      xprint("M2", 1 / (E + m) ** 2 * M)
      print("-" * 40)
      x, y = M.as_real_imag()
      xprint("Re(M)", x)
      xprint("Im(M)", y)
      e = x**2 + y**2
      xprint("abs(M)**2", e)
      print("-" * 40)
      xprint("Expand(abs(M)**2)", e.expand())
  
file_path: sympy/examples/advanced/qft.py
imports: from sympy import Basic, Symbol, Matrix, ones, sqrt, pprint, Eq, sympify
  from sympy.physics import msigma, mgamma
label_desc: Use image node_id 6 for calling a global function with example usage: main() without return types