function S = sawtooth(x)
    if x < 0.5
        S = 2*x;
    else
        S = 2*x-1;
    end   
end