y = piecewise[{{500, x < 10}, {800 - 30x, x < 20}, {200, x > 20}}] + x^2