function F = lmaxfdf3(x,l,w,gbar,Etaext,Rext)
s_l = l/w*((Etaext(2:end-1)-Etaext(1:end-2))./(Rext(2:end-1)-Rext(1:end-2)));
s_u = l/w*((Etaext(3:end)-Etaext(2:end-1))./(Rext(3:end)-Rext(2:end-1)));
maxwR = 
fg = l*Etaext(2:end-1)./max(w*Rext(2:end-1)-x,0);
fg(isnan(fg)) = inf;
fvec = exppdf(fg,gbar).*(fg.^2)./(l*Etaext(2:end-1));
end