To take derivatives of piecewise functions you take the derivative of each piece and keep the bounds on x the same.
if f(x) = 2x for x<0 and f(x)=x^2 for x>=0 then
the first derivative will be
f'(x)=2 for x<0 and f'(x)=2x for x>=0.
Hope this helps with your problem!