Question: How do I solve a IF..THEN..problem with DIFF

Is there any way to use DIFF for the function formula in IF..THEN..?

g := proc(x) if x <= 0 then x^2 + x; else if x < 3*Pi then sin(x); else x^2 - 6*x*Pi + 9*Pi^2 - x + 3*Pi; end if; end if; end proc;

diff(g, x);
                              

Like the above example, but the diff result is 0.....

Please Wait...