On Sept. 22, Richard Hennessy wrote:
>I will start first with unit step, then I will have a better idea of how to
>handle if then
>else's. I do plan to support both in pwdefint, pwintegrate and pwdiff.
>If statements must be checked to see if the intervals defined are disjoint,
>I think. Unit_step does not have that
>problem since it can be assumed that the user intended to have some overlap
>and wants Maxima to add the pieces >together
>in the overlapping region. I see a big advantage to unit_step. I think it
>is the easiest way. With "If then else" you
>can't be sure what the user intended in some cases. Maybe they didn't
>notice the overlap, maybe they did but though >
>Maxima would take the first hit that evaluates to true.. Can you see the
>problem when there is overlap. Additionally
>with "if then else" plot2d or draw2d or qdraw will not plot it right when
>the intervals overlap if the user did not
>intend to match the first true expression.
---------------------------------------------
You may be right that coding if..then..elseif..else will be harder than
working with unit_step.
You can make it easier by not worrying about the user mistakenly entering a
confusing function.
Let the user bear the responsibility of taking care with the syntax required
to get it to work.
But you should allow the user to use either "if x > a and x < b" or "if x >=
a and x <=b"
or any permutation. Both would define a call to integrate(sub_expr,x,a,b)
and that doesn't
need worrying about since that type of overlap does not affect the value of
the integral.
----------------------------------
On Sept. 21, Richard Hennessy wrote:
> Edwin,
>
> I can do it that way too. I think it would be good to support both
> unit_step and if.
>
> Rich
>
-------------------------------------
This looks like a fun project. I am sure you will learn a lot about
programming in
Maxima whether or not the end result is useful.
------------------------------
>> It should not be that difficult to construct pwintegrate( expr,x, x1,x2)
>> which parses expr into pieces delimited by either (if .. then)
>> and (elseif ...then), and (else ...) and then creates a sum of
>> calls to integrate which have the correct subinterval
>> and function def for that subinterval.
>> Ted Woollett