multivalued square roots: was Re: another bug in integrate (5.27.0)
Subject: multivalued square roots: was Re: another bug in integrate (5.27.0)
From: Richard Fateman
Date: Tue, 26 Jun 2012 14:42:56 -0700
On 6/26/2012 2:27 PM, J?rome Laurens wrote:
> Hi list,
>
> consider the following code
>
> assume(t>0);
> assume(x>0);
> integrate(f(sqrt(t^2-1)),t,1,2);
> changevar(%,t-sqrt(x^2+1),x,t);
>
> the result is
>
> -integrate((x*f(x))/sqrt(x^2+1),x,-sqrt(3),0)
>
> whereas it should be
>
> -integrate((x*f(x))/sqrt(x^2+1),x,sqrt(3),0)
>
> +?3 instead of -?3 in the lower bound.
>
> One can imagine that to find the new integral bounds changevar is using
>
> solve(subst(t,2,t-sqrt(x^2+1)=0),x)
>
> which gives exactly the two solutions -?3 and +?3
> unfortunately, changevar picks up the wrong one.
>
> One would expect changevar to choose the solution that fulfills the requirements in facts(),
> or at least inform the user that some solution may be lost.
Computer algebra systems do "algebra" mostly. Trying to get them to do
"analysis" is tricky and
sometimes unsuccessful. The "assume" data base is often unused by
programs, especially
those that were written before assume was written. When the assume data
base is used, it
is sometimes used inadequately because "doing the right thing" is not
necessarily computable,
and (more likely) even if it is computable, it is sometimes not computed
by the algorithms in the system.
The idea that the sqrt has TWO values has been fought more or less
continuously by some programmers
of computer algebra systems, who, for example, think that sqrt(x^2) is a
definition of |x|.
This may, in part, explain the discrepancy regarding changevar.
On the other hand, you can be accused of mis-using the system yourself,
in that you did not
specify adequately which sqrt you meant when you typed sqrt(t^2-1).
Assume(t>0) has actually
no bearing on this whatsoever, since sqrt(3) has two values, one
positive and one negative.
If you had specified in your integration problem both roots, e.g. by
f (Root(y^2 - (t^2-1), y))
which would be an encoding of BOTH square roots, then maybe the computer
would have had a chance.
> More friendly: in case of an untractable choice, maxima should give both answers and let the client make its own decision.
The system in some sense thought you had already made a choice, and it
was just following along.
A proper solution to this whole issue can be envisioned in terms of
multi-valued expressions, and
that presents implementation difficulties.
RJF