Message Boards Message Boards

0
|
5436 Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Integrate gives wrong result

Posted 9 years ago

When I try to analytically solve the Integral

F = Integrate[Sqrt[(x + Cos[?])^2 + (y + Sin[?])^2], {?, 0,2 ?}]

Mathematica gives the solution

F = 0

(so does Maple and other programs).

Since Sin and Cos only give values between -1 and +1 one can clearly see that this can not be true if x or y are high or low numbers. I tried to find a fitting curve and found that

F = Power[(2 ?)^E + (2 ? Sqrt[x^2 + y^2])^E, (E)^-1]

I have no mathematical proof for that, but it seems elegant enough to be true. Of course I know that Integrate has some "possible issues" and I always recommend to test the result with NIntegrate. But anyway, since I seem to have found a better analytical solution than zero I thought it might help if I share it. Maybe this can be fixed in future versions of Mathematica.

POSTED BY: tyran simon
6 Replies

As pointed out above the phase in the integral is of no importance because a and b in the integrand Sqrt [ a + b Cos [ w ] ] are constant and the Integration is around the whole circle from 0 to 2 Pi. Therefore we can write

In[1]:= j1a =  Sqrt[1 + x^2 + y^2 + 2 Sqrt[x^2 + y^2] Cos[phi - t]] /. t -> 0

Out[1]= Sqrt[1 + x^2 + y^2 + 2 Sqrt[x^2 + y^2] Cos[phi]]

Avoiding lots of Messages by

In[2]:= SetOptions[Integrate, GenerateConditions -> False]

Out[2]= {Assumptions :> $Assumptions, GenerateConditions -> False, 
 PrincipalValue -> False}

we get

In[3]:= res = Integrate[j1a, {phi, 0, 2 Pi}]

Out[3]= 4 Sqrt[1 + x^2 + y^2 + 2 Sqrt[x^2 + y^2]]
  EllipticE[(4 Sqrt[x^2 + y^2])/(1 + x^2 + y^2 + 2 Sqrt[x^2 + y^2])]

and as above

In[4]:= res /. x -> 0 /. y -> 0

Out[4]= 2 \[Pi]

In[5]:= res /. x -> 5. /. y -> 3.8

Out[5]= 39.7097
POSTED BY: Hans Dolhaine
POSTED BY: Hans Dolhaine

If you first expand and simplify the argument of the square root, the integration works:

In[1]:= 
Simplify[Expand[(x + Cos[\[CurlyPhi]])^2 + (y + Sin[\[CurlyPhi]])^2]]

Out[1]= 1 + x^2 + y^2 + 2 x Cos[\[CurlyPhi]] + 2 y Sin[\[CurlyPhi]]

In[2]:= Integrate[
 Sqrt[1 + x^2 + y^2 + 2 x Cos[\[CurlyPhi]] + 
   2 y Sin[\[CurlyPhi]]], {\[CurlyPhi], 0, 2 \[Pi]}]

Out[2]= ConditionalExpression[
 4 Sqrt[1 + x^2 + y^2 - 2 Sqrt[x^2 + y^2]]
   EllipticE[-((4 Sqrt[x^2 + y^2])/(
    1 + x^2 + y^2 - 2 Sqrt[x^2 + y^2]))], 
 2 Sqrt[x^2 + y^2] < 1 + x^2 + y^2 && (1 + x^2 + y^2)/Sqrt[
   x^2 + y^2] >= 2]
POSTED BY: S M Blinder

The difference between F and G is of the order of .2 or less. It is too small to perceive it in the two plots you have made. Try plotting the difference:

With[{n = E, y = 0}, 
 Plot[NIntegrate[
    Sqrt[(x + Cos[\[CurlyPhi]])^2 + (y + 
         Sin[\[CurlyPhi]])^2], {\[CurlyPhi], 0, 2 \[Pi]}] - 
   Power[(2 \[Pi])^E + (2 \[Pi] Sqrt[x^2 + y^2])^E, (E)^-1], {x, 0, 
   2 Pi}]]
POSTED BY: Gianluca Gorni
Posted 9 years ago

On the Plot it fits:

x,y

r

POSTED BY: tyran simon

I tested your formula for F numerically, and it doesn't seem true:

With[{x = 1, 
   y = 2}, {Integrate[
    Sqrt[(x + Cos[\[CurlyPhi]])^2 + (y + 
         Sin[\[CurlyPhi]])^2], {\[CurlyPhi], 0, 2 \[Pi]}],
   Power[(2 \[Pi])^E + (2 \[Pi] Sqrt[x^2 + y^2])^E, (E)^-1]}] // N
With[{y = 2}, 
 Plot[NIntegrate[
    Sqrt[(x + Cos[\[CurlyPhi]])^2 + (y + 
         Sin[\[CurlyPhi]])^2], {\[CurlyPhi], 0, 2 \[Pi]}] -
   Power[(2 \[Pi])^E + (2 \[Pi] Sqrt[x^2 + y^2])^E, (E)^-1], {x, -20, 
   20}]]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract