function [ N ] = Gerber( Sa, Sm, Se, Sut )
%
%  This routine computes the Gerber safety factor
%
%    Sa = the alternating stress
%    Sm = the mean stress
%    Se = the endurance strength
%    Sut = the ultimate tensile strength
%

if (Sm == 0.0)
    N = Se / Sa;
else
    A = sqrt(1 + (2*Sm*Se/(Sut*Sa))^2) - 1;
    N = 0.5 * ((Sut / Sm)^2)* (Sa / Se) * A;
end

end

