Differentiate conditional expressions?



Maxima doesn't know the derivative of an 'if then' conditional.
I don't think there is an easy fix to this. A workaround is to
define a split-rule function using charfun  (defined in nummod.lisp;
get it from  http://www.unk.edu/facstaff/profiles/willisb/)

If you are not bothered by incorrect values for the
derivative at the the split point(s), you can try:

(%i1) load("c:/maxima/nummod/nummod.lisp")$
(%i2) gradef(charfun(p),0)$                   <--- nummod doesn't define
the derivative of charfun

(%i3) f(x) := sin(x) * (x * charfun(x > 1) - x^2 * charfun(x <= 1));
(%o3) f(x):=sin(x)*(x*CHARFUN(x>1)-x^2*CHARFUN(x<=1))

(%i4) diff(f(x),x);
(%o4) cos(x)*(x*CHARFUN(x>1)-x^2*CHARFUN(x<=1))+sin(x)*(CHARFUN(x>1)-2
*x*CHARFUN(x<=1)) <-- wrong at 1.

Barton

-----maxima-admin@math.utexas.edu wrote: -----

>Michael Krasnyk wrote:
>
>> Hi,
>>
>> I'm trying to use Maxima for differentiation, but
>> don't know how to differentiate conditional expressions.