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: [mg78455] Re: [Mathematica 6] Integrate strange result
  • From: dimitris <dimmechan at yahoo.com>
  • Date: Mon, 2 Jul 2007 06:49:54 -0400 (EDT)
  • References: <f684kc$euk$1@smc.vnet.net>

            Bhuvanesh       :
> > notice in the above, it says for k<-1 there is NO answer
>
> That's not what the If structure is saying. It's giving a result for k>=-1 and the third argument of the If statement is held (unevaluated). For a given result If[cond, res, int], if you want the result when the condition cond is satisfied, you can extract that from the If (by using a replacement rule or by using Refine); if you want the other part, you have to explicitly evaluate the held integral.
>
> In[1]:= f = (1 + k*Sin[a]^2)^(1/2);
>
> In[2]:= Assuming[Element[k, Reals], Integrate[f, {a, 0, 2*Pi}]] //InputForm
>
> Out[2]//InputForm=
> If[k >= -1, 4*EllipticE[-k], Integrate[Sqrt[1 + k*Sin[a]^2], {a, 0, 2*Pi},
>   Assumptions -> k < -1]]
>
> In[3]:= PiecewiseExpand[%] //InputForm
>
> Out[3]//InputForm= Piecewise[{{4*EllipticE[-k], k >= -1}}, 0]
>
> Bhuvanesh,
> Wolfram Research

I think the zero result of Mathematica 6 (for k<-1) is not correct.

In[1]:=
f = (1 + k*Sin[a]^2)^(1/2);

In[9]:=
(Integrate[f /. k -> #1, {a, 0, 2*Pi}] & ) /@ Range[-2, 2, 1/2]
Out[9]=
{4*EllipticE[2], 4*EllipticE[3/2], 4, 4*EllipticE[1/2], 2*Pi,
4*EllipticE[-(1/2)], 4*EllipticE[-1], 4*EllipticE[-(3/2)],
  4*EllipticE[-2]}

In[10]:=
N[%, 6]
Out[10]=
{2.3962804694711844149`6. + 2.3962804694711844149`6.*I,
2.8652477548003570588`6.107322497811495 +
   1.3441362690754466525`5.778603616820505*I, 4.`5.999999999999999,
5.4025755241907020101`6., 6.2831853071795864769`6.,
  7.0070851027792714481`5.999999999999999, 7.6403955780554240358`6.,
8.2119799371303580141`6.000000000000002,
  8.7377525709848047416`6.}

In[14]:=
(NIntegrate[f /. k -> #1, {a, 0, 2*Pi}, PrecisionGoal -> 6,
WorkingPrecision -> 30, MaxRecursion -> 16,
    MinRecursion -> 12] & ) /@ Range[-2, 2, 1/2]
Out[14]=
{2.3962804824931275141`6.867324832781741 +
2.3962804824931275141`6.867324832781741*I,
  2.8652481708644431405`6.140427816954616 +
1.3441367923543156877`5.811709041972459*I,
 
3.999999999999999999999999999999999999999999997881`29.698969071855394,
 
5.402575524190702010080698941354903365398089467201`29.69896907185536,
 
6.283185307179586476925286766559005768394338798049`29.69896907185541,
  7.00708510277927144810600735593804816551`29.698969071855373,
7.64039557805542403580952416434288658353`29.698969071855373,
  8.21197993713035801408795561311839155877`29.69896907185541,
8.73775257098480474161935195770797451132`29.698969071855352}

Note that in version 5.2

In[15]:=
Integrate[f, {a, 0, 2*Pi}]
Out[15]=
If[Re[k] > -1, 2*(EllipticE[-k] + Sqrt[1 + k]*EllipticE[k/(1 + k)]),
Integrate[Sqrt[1 + k*Sin[a]^2], {a, 0, 2*Pi},
   Assumptions -> Re[k] <= -1]]

In[16]:=
PiecewiseExpand[%]
Out[16]=
Piecewise[{{4*EllipticE[-k], Re[k] <= -1}}, 2*(EllipticE[-k] + Sqrt[1
+ k]*EllipticE[k/(1 + k)])]

If we assume k is Real,

In[17]:=
Integrate[f, {a, 0, 2*Pi}, Assumptions -> Element[k,Reals]]
Out[17]=
If[k >= -1, 4*EllipticE[-k], Integrate[Sqrt[1 + k*Sin[a]^2], {a, 0,
2*Pi}, Assumptions -> k < -1]]

In[18]:=
PiecewiseExpand[%]
Out[18]=
4*EllipticE[-k]

Unfortunately for Mathematica 6, 5.2 is correct here!

Dimitris



  • Prev by Date: Re: Graphics package in v6
  • Next by Date: Re: Rotable Graphics and ViewPoint
  • Previous by thread: Re: Re: [Mathematica 6] Integrate strange result
  • Next by thread: Re: [Mathematica 6] Integrate strange result