function xCND=xCND( x )
%UNTITLED3 Summary of this function goes here
%   Detailed explanation goes here

if(x<0)
    x=-x;
    sgn1=-1;
elseif(x>0)
    sgn1=1;
else
    xCND=0.5;
end

if(x>20)
    if(sgn1<0)
        xCND=0;
    else
        xCND=1;
    end
end

x = 0.707106781186547 * x;
x2 = x * x;

if (x < 0.46875)
q1 = 3209.37758913847 + x2 * (377.485237685302 + x2 * (113.86415415105 + x2 * (3.16112374387057 + x2 * 0.185777706184603)));
q2 = 2844.23683343917 + x2 * (1282.61652607737 + x2 * (244.024637934444 + x2 * (23.6012909523441 + x2)));
xCND = 0.5 * (1 + sgn1 * x * q1 / q2);
elseif (x < 4)
q1 = 1230.339354798 + x * (2051.07837782607 + x * (1712.04761263407 + x * (881.952221241769 + x * (298.6351381974 + x * (66.1191906371416 + x * (8.88314979438838 + x * (0.56418849698867 + x * 2.15311535474404E-08)))))));
q2 = 1230.33935480375 + x * (3439.36767414372 + x * (4362.61909014325 + x * (3290.79923573346 + x * (1621.38957456669 + x * (537.18110186201 + x * (117.693950891312 + x * (15.7449261107098 + x)))))));
xCND = 0.5 * (1+ sgn1 * (1 - exp(-x2) * q1 / q2));
else
q0 = 1 / x2;
q1 = 6.58749161529838E-04 + q0 * (1.60837851487423E-02 + q0 * (0.125781726111229 + q0 * (0.360344899949804 + q0 * (0.305326634961232 + q0 * 1.63153871373021E-02))));
q2 = 2.33520497626869E-03 + q0 * (6.05183413124413E-02 + q0 * (0.527905102951428 + q0 * (1.87295284992346 + q0 * (2.56852019228982 + q0))));
xCND = 0.5 * (1 + sgn1 * (1 - exp(-x2) / x * (0.564189583547756 - q0 * q1 / q2)));
end
end

