How does integrate handle %i?



Karl-Dieter Crisman wrote:
> On Tue, Oct 20, 2009 at 11:39 AM, Raymond Toy
> <raymond.toy at stericsson.com> wrote:
>   
>> Karl-Dieter Crisman wrote:
>>     
>>> Dear list,
>>>
>>> The following session seems to indicate that integrate "chooses"
>>> different square roots of negative one depending on the context (note
>>> that the last output is precisely minus the penultimate output).  Is
>>> there any flag to set which would ensure that I get the same answer
>>> from integrating both f and g from 9 to 16?  Thank you!
>>>
>>> Maxima 5.19post http://maxima.sourceforge.net
>>> using Lisp SBCL 1.0.24
>>> Distributed under the GNU Public License. See the file COPYING.
>>> Dedicated to the memory of William Schelter.
>>> The function bug_report() provides bug reporting information.
>>> (%i1) f:sqrt(25-x)*sqrt(1+1/(4*(25-x)));
>>>                                 1
>>> (%o1)                  sqrt(---------- + 1) sqrt(25 - x)
>>>                             4 (25 - x)
>>>
>>>
>>>       
>> [snip]
>>     
>>> (%i4) radcan(f);
>>>                               %i sqrt(4 x - 101)
>>> (%o4)                         ------------------
>>>                                       2
>>>
>>>       
>> The issue is not integrate but radcan.  f and radcan(f) are different.
>> In fact g = -f over the range from 9 to 16 and if you evaluate the
>> integrals, you'll see that they are, in fact, negatives of each other.
>>
>>     
>
> Yes, thank you.  In fact, I remember realizing this the last time I
> looked at this, but I forgot by the time I remembered to ask about the
> question!
>
> Okay, so why does radcan use the "wrong" square root of negative 1?
> I know I can keep radcan from taking out the %i with radexpand, but
> presumably it is nice not to do so.  Shouldn't radcan(f)=f for inputs
> x for which it is nicely defined?
>   
The real answer can be found somewhere on the mailing list. 

But some of the transformations that radcan does won't preserve what you
want.  In particular sqrt(x^2) -> x, which is not right if x is
negative.  Also, I vaguely remember that radcan will produce the correct
result if you think about what happens if x is large enough.  In this
case, you're interested in small values of x.

I generally avoid radcan and use ratsimp instead, unless I know that x
is large enough for the radcan to produce the desired results.

Ray