Sign is not a mathematical function in Maxima, it is a utility function, like is(). So Sign(x) is not a mathematical expression the
way x^2 is; it simply evaluates to a symbol summarizing what Maxima thinks the sign of the expression "x" is; in this case PNZ
(positive, negative, or zero) because Maxima doesn't know anything about x. Try Sign(x-1) and it will give the same answer.
Similarly, in Maxima, when you say f(x):=..., you are not defining the mathematical function f, but rather a computing function f,
that will return a result if you call it. Try typing in your expression 'naked':
1/2+sign(x)*(1/2-1/4*exp(-abs(x))*(2+abs(x)));
You will see that it comes back as 1/2 + PNZ*(....). That is, it is not the differentiation that is generating the PNZ, but the
simple evaluation of sign(x).
What I think you want is the function Signum(x), which *is* the mathematical function.
Unfortunately, Maxima doesn't deal with Signum, Abs, etc. very cleverly:
Things it can do
diff(abs(x),x) => x/abs(x) Nicely handles non-definedness at 0
limit(abs(x),x,0,plus) => 0
limit(abs(x),x,0,minus) => 0
abs(x)^2 => x^2
Things it can't do
limit(abs(x),x,0) => can't evaluate (noun form)
diff(signum(x),x) => can't evaluate (noun form)
diff(abs(x),x,2) => 0 Ignores non-definedness at 0
cos(abs(x)) does not simplify to cos(x)
x * signum(x) does not simplify to abs(x)
abs(x)*signum(x) does not simplify to x
integrate(abs(x),x) => can't evaluate (should be abs(x)*x/2)
integrate(signum(x),x) => can't evaluate (should be signum(x)*x)
Of course, most of these things can be done using the pattern-matching capabilities of Maxima -- for all I know, there may well be a
Share package that does them.
-s