How to define a New Maxima Function



hello robert,

in fact, that was our first try to use unit_step.
unfortunately, we have next to integrate the function. and 
integrate(f(x)) does not really work nice if f(x) contains unit_step.
 
we try to to calculate a price of a generic plain-vanilla financial 
option, that is nothing else but integrate(f(x,a,b,c,...),x,minf,inf). 
where f(x) typically is piecewise-continuous/differentiable but may 
depend on parameters a,b,c,... in quite a tricky unpredictable manner 
(you have to solve an implicit equation first in order to define the 
integral). 
 
do you plan to invest more resources in your integration algorithm? if 
this is the case we would be happy to provide you with nice examples.
 
regards
alex
>> Is it possible/easy to define in MAXIMA a generic SYMBOLIC function of
>> the following form?
>>
>> F( x, (x11,x12,f1(x)), (x21,x22,f2(x), ... )
>>
>> ==
>>
>> f1(x), if x in [x11,x12]
>> f2(x), if x in [x21,x22]
>> ...
>> 0, if x elsewhere
>>     
>
> The good news is that it is possible, the bad news is that it is not simple,
> and the moderately good news is that given the existing machinery in
> Maxima, we could probably figure out a way to equip Maxima with
> that capability. Given that functions defined piecewise are a recurring
> source of questions, I'm inclined to think we should go ahead & do it.
>
> Here is an initial attempt to solve your problem in terms of the
> unit_step function.
> A solution could probably also be formulated in terms of conditional
> expressions. I hope I haven't made some kind of fundamental error here.
>
> load (orthopoly);
> matchdeclare (aa, all, xx, mapatom);
> tellsimpafter ('diff (unit_step(aa), xx, 1), if freeof (xx,aa) then 0
> else delta (aa));
>
> More stuff has to be thrown in to handle the delta(x) stuff.
> I'll let it go for now. Here's what we can get with just that rule.
>
> foo : f(x) * (1 - unit_step (x - 3)) + g(x) * unit_step (x - 3);
> diff (foo, x);
>  => unit_step(x - 3) * 'diff(g(x),x,1) + (1 - unit_step(x - 3)) *
> 'diff(f(x),x,1) + delta(x - 3) * g(x) - delta(x - 3) * f(x)
>
> In case it isn't clear, "f1(x), if x in [x11, x12]"  is represented as
> f1(x) * (unit_step (x - x11) - unit_step (x - x12)).
>
> Hope this helps. Sorry that Maxima cannot do a better job on this stuff.
>
> Robert Dodier
>
>