(* Program to Calculate the traces of Moller scattering without neglecting
   the electron mass. Problem 5.14 of QFT

 Last Version: 06/12/2024
 Compatible with FeynCalc 10.1.0
 Author: Jorge C. Romao
 email: jorge.romao@tecnico.ulisboa.pt
*)


Remove["Global`*"]

(* Definitions *)

prop[p_,m_]:=GS[p]+m
PR=(1 + GA[5])/2
PL=(1 - GA[5])/2


Line1:= prop[p3,m] . GA[mu] .  prop[p1,m] . GA[nu]  

Line2:= prop[p4,m] . GA[mu] .  prop[p2,m] . GA[nu]

Line3:= prop[p4,m] . GA[mu] .  prop[p1,m] . GA[nu]  

Line4:= prop[p3,m] . GA[mu] .  prop[p2,m] . GA[nu]

Line5:= prop[p3,m] . GA[mu] .  prop[p1,m] . GA[nu] . prop[p4,m] . GA[mu] . prop[p2,m] . GA[nu] 



ans1= Simplify[Contract[TR[Line1] TR[Line2]]]

ans2= Simplify[Contract[TR[Line3] TR[Line4]]]

ans3= Simplify[Contract[TR[Line5]]]


ans=ans1/Dt^2+ans2/Du^2-2*ans3/Du/Dt

ans= ans/4 //FCE


dot={SP[p1,p2]->(s-2m^2)/2,SP[p3,p4]->(s-2 m^2)/2,SP[p1,p3]->(2 m^2-t)/2,SP[p2,p4]->(2 m^2-t)/2,SP[p1,p4]->(2 m^2-u)/2,SP[p2,p3]->(2 m^2 -u)/2}

mandel={s->4 m^2 -t -u}

res= ans /. dot

res= res /. mandel 

fA=Coefficient[res,Dt,-2]//Simplify
fB=Coefficient[res,Du,-2]//Simplify
fC=Coefficient[Coefficient[res,Du,-1], Dt, -1]//Simplify

f=Function[{x,y}, 2 (x-4 m^2)^2 + 2 (y -4 m^2)^2 -16 m^4]

TestA:=fA-f[s,u] /. mandel //Simplify
TestB:=fB-f[s,t] /. mandel //Simplify
TestC:=fC-f[s,s] /. mandel //Simplify

Msqavrgd = fA/t^2 + fB/u^2 + fC/t/u ;

Print["\!\(\*FractionBox[\(1\), \(4\)]\) \!\(\*UnderscriptBox[\(\[Sum]\), \(spins\)]\)|M\!\(\*SuperscriptBox[\(|\), \(2\)]\) = ",Msqavrgd]


Print["f(s,u) = ",f[s,u] /. mandel //Simplify]
Print["f(s,t) = ",f[s,t] /. mandel //Simplify]
Print["f(s,s) = ",f[s,s] /. mandel //Simplify]
