(* Program to Calculate the Traces of Bhabha scattering without neglecting
   the electron mass, as in Problem 5.17 of ITC

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

(* Definitions *)

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


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

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

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

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

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



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

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

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

ans=ans1/Ds^2+ans2/Dt^2-2*ans3/Ds/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={u->4 m^2 -t -s}

res= ans /. dot

res= res /. mandel 

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

Msqavrgd = fA/s^2 + fB/t^2 + fC/s/t ;
Print["\!\(\*FractionBox[\(1\), \(4\)]\) \!\(\*UnderscriptBox[\(\[Sum]\), \(spins\)]\)|M\!\(\*SuperscriptBox[\(|\), \(2\)]\) = ",Msqavrgd]

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

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

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