
% Laguerre Gauss PL
% wriutten by Aidan Brooks, 27-Jan-2019
% outputs a field
%
% p = p-th order
% l = l-th order
% X = x-coords
% Y = y-coords
% w = beam size

function out = LGpl(p,l,X,Y,w)

%norm = sqrt(sqrt(2/pi)/(2^m*fact(m)*w))*sqrt(sqrt(2/pi)/(2^n*fact(n)*w));
r = sqrt(X.^2 + Y.^2);
phi = atan2(X,Y);

CLGlp = sqrt(2*fact(p)/(pi*fact(p+abs(l))));
norm = CLGlp/w*(r*sqrt(2)/w).^abs(l);

out = norm.*exp(-(r/w).^2).*exp(-1i*l*phi).*laguerreL(p,l, 2*(r/w).^2);
