On 1/13/08, Johan Beke <johanbeke at hotmail.com> wrote:
> When I try to integrate som functions (part of a double integral) and I
> fill in some bounds, maxima always keeps asking: is ...... positive,
> negative or zero.
>
> Can this question turned off?
Here are some results after loading a package I wrote which
captures most queries from Maxima and turns them into
conditional expressions.
asksign (x);
=> if x < 0 then neg elseif equal(x,0) then zero else pos
asksign (abs (x));
=> if equal(x,0) then zero else pos
realpart (sqrt (25 - x^2 - y^2));
=> if y^2+x^2-25 < 0 then sqrt(-y^2-x^2+25)
elseif equal(y^2+x^2-25,0) then 0 else 0
integrate (exp(a*x), x, 0, inf);
=> if a < 0 then -1/a elseif equal(a,0) then 0
else ?merror("Integral is divergent")
integrate (x^k, x);
=> if equal(k+1,0) then log(x) else x^(k+1)/(k+1)
integrate (x^k, x, 1, b);
=> if k < 0 then integrate(x^k,x,1,b) elseif equal(k,0)
then b^(k+1)/(k+1)-1/(k+1) else b^(k+1)/(k+1)-1/(k+1)
limit (a * x, x, inf);
=> if a < 0 then minf elseif equal(a,0) then 0 else inf
limit (x^a, x, inf);
=> if a < 0 then 0 elseif equal(a,0) then 1 else inf
tlimit (s/(1 + s^2) / sinh (s*T), s, inf);
=> if T < 0 then tlimit(s/((s^2+1)*sinh(s*T)),s,inf)
elseif equal(T,0) then 0 else 0
ode2 ('diff(y, x, 2) + a*y = c* x, y, x);
=> if a < 0
then y = %k1*%e^(%i*sqrt(a)*x)
+%k2*%e^-(%i*sqrt(a)*x)+c*x/a
elseif equal(a,0) then y = c*x^3/6+%k2*x+%k1
else y = %k1*sin(sqrt(a)*x)+%k2*cos(sqrt(a)*x)+c*x/a
As it stands the code more or less works from the user's point
of view although it could be slicker (e.g. merging equivalent
branches, expansion of branches into sub-branches).
The major drawback is that the code works by throwing the
asked-about expression (instead of waiting for user input).
Throwing something can mess up the state of Maxima --
e.g. assumptions made via assume(...) are not cleaned up.
I don't know for sure what to do; one way to finesse the
problem is to introduce constructs such as
(limit (...), integrate (....), solve (...)) assuming (a > 0, b < 0);
which would put assume(...) and the beginning and forget(...)
at the end, and ensure that forget is always called, even if
something is thrown.
it has been claimed, on this august mailing list, that ordinary
Maxima conditional expressions if ... then ... else are not
appropriate for expressing stuff like the result of limit(x^n, x, inf)
and that instead a different notation, with different evaluation
and simplification policies, is needed. Not sure about that.
FWIW
Robert Dodier