MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: [Mathematica 6] Integrate strange result

  • To: mathgroup at smc.vnet.net
  • Subject: [mg78355] Re: [mg78325] [Mathematica 6] Integrate strange result
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Fri, 29 Jun 2007 05:40:32 -0400 (EDT)
  • References: <200706280829.EAA20660@smc.vnet.net>

On 28 Jun 2007, at 17:29, Nasser Abbasi wrote:

> In[13]:= $Version
> Out[13]= 6.0 for Microsoft Windows (32-bit) (April 27, 2007)
>
> The problem is this: When I ask Mathematica to integrate something
> involving some constant parameter, it gives an answer for some range
> of the constant involved, say range A, and it says there is no answer
> for the other range, say range B
>
> But next, when I specify, using assumptions, that the constant is now
> in range B, then Mathematica does given an answer to the integral !
>
> Why does it in one case say there is no answer if the constant is in
> range B, and in the second case it gives an answer when the constant
> is in range B?
>
> case 1
> ========
>
> In[2]:= f = (1 + k*Sin[a]^2)^(1/2);
> In[12]:= Assuming[Element[k, Reals], Integrate[f, {a, 0, 2*Pi}]]
>
> Out[12]= If[k >= -1, 4*EllipticE[-k],   Integrate[Sqrt[1 +
> k*Sin[a]^2],    {a, 0, 2*Pi}, Assumptions ->     k < -1]]
>
> notice in the above, it says for k<-1 there is NO answer
>
> case 2
> =======
> In[2]:= f = (1 + k*Sin[a]^2)^(1/2);
> In[10]:= Assuming[Element[k, Reals] && k < -1,   Integrate[f, {a, 0,
> 2*Pi}]]
>
> Out[10]= 0
>
> Notice in the above, for k<-1  it gives an answer, which is zero.
>
> What is it I am missing here?
>
> thanks
> Nasser
>
>


The first thing you are missing here is that the second answer is wrong:

Integrate[(1 - 2*Sin[a]^2)^(1/2), {a, 0, 2*Pi}]

4*EllipticE[2]

This is, as one would expect, a non-real number:

N[%, 5]
2.3962804693361682454`5.000000000000002 +
   2.3962804693361682454`5.000000000000002*I

When Mathematica returns an answer in this conditional form it is not  
actually saying that when the condition is not satisfied "there is no  
answer". It is only saying that it could not establish an answer. It  
attempts to (not always successfully) return an answer that is valid  
under the given conditions, but this does not mean that the answer  
(or some other answer) is not valid when this condition is not  
satisfied. All it means that Integrate has returned a set f   
conditions under which it "believes" it has been able to establish  
that the answer it gave is valid.

In this particular case we can try to see what happens when we use a  
variable limit in place of 2 Pi

f = (1 + k*Sin[t]^2)^(1/2);
q = Integrate[f, {t, 0, b}]
If[k*Cos[2*b] != k + 2 && (Im[k*Sin[b]^2] != 0 ||
     Re[k*Sin[b]^2] + 1 >= 0) &&
    (Re[((Cos[2*b]*k - k - 2)*Csc[b]^2)/k] >= 0 ||
     Im[((Cos[2*b]*k - k - 2)*Csc[b]^2)/k] != 0 ||
     (Re[((Cos[2*b]*k - k - 2)*Csc[b]^2)/k] + 2 <= 0 &&
      (Re[(((-Cos[2*b])*k + k + 2)*Csc[b]^2)/k] >= 2 ||
       Im[(((-Cos[2*b])*k + k + 2)*Csc[b]^2)/k] != 0))),
   EllipticE[b, -k], Integrate[Sqrt[k*Sin[t]^2 + 1], {t, 0, b},
    Assumptions -> k*Cos[2*b] == k + 2 || (Im[k*Sin[b]^2] == 0 &&
       Re[k*Sin[b]^2] + 1 < 0) ||
      (Im[((Cos[2*b]*k - k - 2)*Csc[b]^2)/k] == 0 &&
       Re[((Cos[2*b]*k - k - 2)*Csc[b]^2)/k] < 0 &&
       (Re[((Cos[2*b]*k - k - 2)*Csc[b]^2)/k] + 2 > 0 ||
        (Im[(((-Cos[2*b])*k + k + 2)*Csc[b]^2)/k] == 0 &&
         Re[(((-Cos[2*b])*k + k + 2)*Csc[b]^2)/k] < 2)))]]

This looks complicated, but

Simplify[q /. b -> 2*Pi]
4*EllipticE[-k]

which suggests that the result that you got under the restriction  k  
 >= -1 is actually valid without any restrictions on k. Empirical  
tests, with various values of k (real and complex) seem to confirm this.

On the other hand, however:

  Integrate[f, {t, 0, 2*Pi}]

If[Re[k] > -1, 2*(EllipticE[-k] + Sqrt[k + 1]*EllipticE[k/(k + 1)]),
   Integrate[Sqrt[k*Sin[t]^2 + 1], {t, 0, 2*Pi},
    Assumptions -> Re[k] <= -1]]

The problem is not only the we now have again a condition on Re[k]  
but also that this answer does not agree with the answer 4*EllipticE[- 
k] that we got earlier and, in particular,  with:

Assuming[Element[k, Reals], Integrate[f, {t, 0, 2*Pi}]]

If[k >= -1, 4*EllipticE[-k], Integrate[Sqrt[k*Sin[t]^2 + 1], {t, 0,  
2*Pi}, Assumptions -> k < -1]]

For example, taking k==5 (so that k>=-1) we get:

  N[2*(EllipticE[-k] + Sqrt[k + 1]*EllipticE[k/(k + 1)]) /. k -> 5, 10]
  11.32079299

N[4 EllipticK[-k] /. k -> 5, 10]
3.822015708

Andrzej Kozlowski







  • Prev by Date: RV: System of differential-algebraic equations
  • Next by Date: Iterpolation and Dates
  • Previous by thread: Re: [Mathematica 6] Integrate strange result
  • Next by thread: Re: [Mathematica 6] Integrate strange result