How does integrate handle %i?



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?

In particular, radcan seems to commute with multiplication, but not
with the usual meaning of multiplying two square roots (compare
radcan(h) and radcan(j) below):

(%i4) f:sqrt(25-x);
(%o4)                            sqrt(25 - x)
(%i5) radcan(f);
(%o5)                            sqrt(25 - x)
(%i6) g:sqrt(1/(4*(25-x))+1);
                                      1
(%o6)                        sqrt(---------- + 1)
                                  4 (25 - x)
(%i7) radcan(g);
                                sqrt(4 x - 101)
(%o7)                           ---------------
                                2 sqrt(x - 25)
(%i8) h:sqrt((1/(4*(25-x))+1)*(25-x));
                                  1
(%o8)                   sqrt((---------- + 1) (25 - x))
                              4 (25 - x)
(%i9) radcan(h);
                                sqrt(101 - 4 x)
(%o9)                           ---------------
                                       2
(%i11) j:f*g;
                                1
(%o11)                 sqrt(---------- + 1) sqrt(25 - x)
                            4 (25 - x)
(%i12) radcan(j);
                              %i sqrt(4 x - 101)
(%o12)                        ------------------
                                      2
(%i13) radcan(f)*radcan(g);
                         sqrt(25 - x) sqrt(4 x - 101)
(%o13)                   ----------------------------
                                2 sqrt(x - 25)
(%i14) radcan(radcan(f)*radcan(g));
                              %i sqrt(4 x - 101)
(%o14)                        ------------------
                                      2

Is this something unavoidable in the nature of a two-branched function
like sqrt, or is it possible to consider it a bug?  I honestly could
see either one being true, as I know nothing of how radcan does its
simplification, but radcan(g) seems kind of odd - why does it
"simplify" one square root into a ratio of square roots?

Thanks so much for any further explanation!