As an example, if I calculate the gradient of an If statement in the following way:
grad = Grad[If[x^2 + y^2 >= 1, x^2 + y^2, x + y + .5], {x, y}]
I get
{If[x^2 + y^2 >= 1, 2 x, 1], If[x^2 + y^2 >= 1, 2 y, 1]}
I'd like to have a general method to convert the gradient to the equivalent, but simpler
If[x^2 + y^2 >= 1, {2 x, 2 y}, {1, 1}]
Is there a general way to do that?