(********************* Program SelfEnergy.m ***********************)
(*
 Version campatible with FeynCalc 10.1.0- Big changes with respect
 to previous versions

 Date: 09/12/2024
 Author: Jorge C. Romao
 email: jorge.romao@tecnico.ulisboa.pt
*)
 
(* First input FeynCalc *)
(* Uncomment below if you want to call from this program. If open a new
   mathematica notebook and load FeynCalc from there you should not load
   it again
*)
(*
<< FeynCalc`
*)

(* Tell FeynCalc to reduce the result to scalar functions *)

(*
SetOptions[{B0,B1,B00,B11},BReduce->True]
SetOptions[OneLoop,Dimension->D]
*)
SetOptions[PaVeReduce,A0ToB0->True]
$LimitTo4 = True;


(* Now write the numerator of the Feynman diagram. We define the 
   constant

       C= - alpha/(4 pi) 
  
  The minus sign comes from the photon propagator. The factor 
  i/(16 pi^2) is already included in this definition.

   I also use the FCE notation available since FeynCalc 6. See manual
   for explanations.

 
*)

(* Everything has to be in dimension D *)

num:= C GAD[mu] .  (GSD[p]+GSD[k]+m) . GAD[mu] 


(* Define the amplitude *)

amp:= num * FAD[{p+k,m},{k}]


(* Calculate the result *)

res:=(-I / Pi^2) OneLoop[k,amp] 

ans=-res;

(* OneLoop gives the result in dimension 4 with the correct finite
 parts. For some cases it gives problems and one uses TID. There
 one has to be careful with the finite parts. See program
 SelfEnergy-TID.nb *)

(* 
The minus sign in ans comes from the fact that -i \Sigma = diagram 
*)

(* Calculate the functions A(p^2) and B(p^2) *)

A=Coefficient[ans,DiracSlash[p],0];
B=Coefficient[ans,DiracSlash[p],1];

(* Calculate delm *)

delm=A + m B /. ScalarProduct[p,p]->m^2//Simplify

(* Calculate delZ2 *)

Ap2 = A /. ScalarProduct[p,p]->p2
Bp2 = B /. ScalarProduct[p,p]->p2

aux=2 m D[Ap2,p2] + Bp2 \
    + 2 m^2 D[Bp2,p2] /. D[B0[p2,0,m^2],p2]->DB0[p2,0,m^2]

aux2= aux /. p2->m^2

aux3= aux2 /. A0[m^2]->m^2 (B0[m^2,0,m^2] -1)

delZ2=Simplify[aux3]

(* Print Results *)

Print["A=",A]
Print["B=",B]
Print["delm=",delm]
Print["delZ2=",delZ2]
  
(***************** End of Program SelfEnergy.m ********************)
