function result = PWLCM(P, Xt)
if (0 <= Xt) && (Xt<P)
    result = Xt/P;
elseif (P <= Xt) && (Xt<0.5)
    result = (Xt-P)/(0.5-P);
elseif (0.5 <= Xt) && (Xt<(1-P))
    result = (1-Xt-P)/(0.5-P);
elseif (1-P <= Xt) && (Xt<1)
    result = (1-Xt)/P;
end
    
    