function f = piecewisefunction(x)
if x <= -2
  f = -2;
elseif x < 2
  f = x^2 - 2;
else
  f = 2;
end