What Stavros says is right, but perhaps I can add some insight.
The operation "integration" is not always defined the same
way in human discussions.
You can use it to mean "area under a curve" in your calculus
class. You can use it to mean some subtler concepts in
higher math classes (e.g. Lebesque integration).
By contrast, what
integration means in Macsym/Maxima and other computer algebra
systems, is mostly what is done
by their integration programs, but the indefinite integration
procedures mostly aim at ANTIDIFFERENTIATION. That is what
the Risch "algorithm" does. This works on certain classes
of algebraic expressions. It does not work (except by making
special hacks) on arbitrary functions, including those that are
piecewise defined. The builder of a CAS may add such hacks
on the grounds that "the custosmer is always right" and put
it in to the integration program. But don't expect it to work
on every input you can create.
As Stavros points out, one COULD try to do stuff like this...
diff ( (if p then f(x) else g(x)) ,x ) ==>
if p then diff(f(x),x) else diff(g(x),x)
and I would add -- it can probably be done in a modular way
so as to not affect anything that already exists in the system.
RJF
In brief, the reason Stavros Macrakis wrote:
> Maxima currently cannot handle piecewise definitions in any reasonable way.
>
> Although there does exist a mechanism for *expressing* piecewise
> definitions, you can do almost nothing useful with them:
>
> To define an expression (not a function, we'll get to that) that is 0
> for x<0 and 1 otherwise:
>
> expr: 'if x<0 then 0 else 1
>
> (This is *not* the same as '(if ...) .)
>
> Note the quotation mark before the "if". That means that the
> condition should not be evaluated immediately, but left in suspense.
> That expression prints out (obscurely) as:
>
> expr =>
> cond(x<0,0,true,1)
>
> Now, you'd think that if you substituted some particular value of x,
> this would simplify, but it doesn't:
>
> expr, x=3 =>
> cond(3>0,3,true,0) --No simplification
> subst(3,x,expr) =>
> cond(3>0,3,true,0) -- No simplification
>
> not even if you force an extra evaluation:
>
> expr,x=3,eval => same thing
>
> As it happens, "cond" is a so-called noun-form, so let's try
>
> expr,x=3,cond =>
> cond(3>0,3,true,0) -- Nope
>
> *but*
>
> expr,x=3,nouns => 3
> expr,x=3,"if" => 3
>
> Success, sort of. But Maxima doesn't know how to do anything
> intelligent with these expressions:
>
> diff(expr,x) => useless
> integrate(expr,x) => useless
> limit(expr,x,inf) => useless
> is(expr>=0) => doesn't know
>
> This has been discussed several times, and the basic part of the
> solution is certainly doable... but someone has to do it.
>
> ---------------------
>
> Now back to the issue of "functions" vs. "expressions".
>
> Maxima provides a way of defining a procedure with a return value,
> often called a "function" in programming contexts. That is the ":="
> syntax:
>
> f(x) := if x<0 then 0 else 1$
>
> This is *not* a mathematical function definition. In fact, Maxima has
> no way of defining a mathematical function (named or not). As in the
> "if" case above, Maxima does have a "lambda" operator, but it knows
> nothing about it mathematically. For example,
>
> diff( lambda([a],a*x), x)
>
> should presumably return
>
> lambda([a],a)
>
> but it does not. In fact, lambda, like if, really only works as a
> programming construct, not a mathematical construct.
>
> Maxima, instead, operates on mathematical **expressions**, so you'd say
>
> diff( a*x , x) => a
>
> Hope this explanation helps.
>
> -s
>
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima