Group Abstract Group Abstract

Message Boards Message Boards

1
|
3.6K Views
|
8 Replies
|
9 Total Likes
View groups...
Share
Share this post:

Integrate function yielding two different answers

Posted 2 years ago
Attachments:
POSTED BY: Tim Kirkpatrick
8 Replies

Thank you, all, for your replies in input. This has all been extremely helpful. Seeing the comments about internal cahce states actually sounds familiar, and would explain why futher reduction might be possible after running the initial cache, but not subsequent runs.

Again, thank you, all.

POSTED BY: Tim Kirkpatrick

What Henrik Schachner and Gianluca Gorni wrote sums it up.

(1) An antiderivative is correct if its derivative recovers the integrand.

(2) Different antiderivatives can result from differences in the internal cache states or timing differences in various places that might use time-constrained attempts.

POSTED BY: Daniel Lichtblau

I think I heard that Integrate caches some intermediate results when it is run. Next time you run it, Integrate is in a different internal state, and this may be the reason it gives a different answer, but still valid. Someone from Wolfram may comment on this.

POSTED BY: Gianluca Gorni

Tim,

you made a good observation! But I guess that both results are correct: They do not need to be identical because you are just asking for an antiderivative:

(* -- start with a fresh kernel -- *)
li = List[(m0 v^3)/(c^2 (1 - v^2/c^2)^(3/2)) + (m0 v)/
     Sqrt[1 - v^2/c^2] + (m0 v^3)/(c0^2 Sqrt[
        1 - v^2/c^2] (-1 + v^2/c0^2)^(3/2)) - (m0 v^3)/(c^2 (1 - 
          v^2/c^2)^(3/2) Sqrt[-1 + v^2/c0^2]) - (m0 v)/(Sqrt[
        1 - v^2/c^2] Sqrt[-1 + v^2/c0^2]), v];
(* here you get different results: *)
i1 = Integrate @@ li
i2 = Integrate @@ li
(* but: *)
D[i1, v] - D[i2, v] // FullSimplify
(*  Out:   0 *)

Nevertheless this is a somewhat strange effect.

POSTED BY: Henrik Schachner
POSTED BY: Tim Kirkpatrick

I just copied and pasted the results directly from Mathematica. And yes, the arguments within ArcTan change after the same expression is run more than once in the same Kernel. That is what doesn't make any sense.

I ran your script and I still get False for comparison.

In[1]:= i1 = 
 Integrate[(m0 v^3)/(c^2 (1 - v^2/c^2)^(3/2)) + (m0 v)/
    Sqrt[1 - 
      v^2/c^2] + (m0 v^3)/(c0^2 Sqrt[
       1 - v^2/c^2] (-1 + v^2/c0^2)^(3/2)) - (m0 v^3)/(c^2 (1 - 
         v^2/c^2)^(3/2) Sqrt[-1 + v^2/c0^2]) - (m0 v)/(Sqrt[
       1 - v^2/c^2] Sqrt[-1 + v^2/c0^2]), v]

i2 = Integrate[(m0 v^3)/(c^2 (1 - v^2/c^2)^(3/2)) + (m0 v)/
    Sqrt[1 - 
      v^2/c^2] + (m0 v^3)/(c0^2 Sqrt[
       1 - v^2/c^2] (-1 + v^2/c0^2)^(3/2)) - (m0 v^3)/(c^2 (1 - 
         v^2/c^2)^(3/2) Sqrt[-1 + v^2/c0^2]) - (m0 v)/(Sqrt[
       1 - v^2/c^2] Sqrt[-1 + v^2/c0^2]), v]

i1 === i2

Out[1]= (m0 (-2 v^2 + 2 c^2 Sqrt[-1 + v^2/c0^2] - 
   Sqrt[c^2 - v^2] Sqrt[-c0^2 + v^2]
     ArcTan[(c^2 + c0^2 - 2 v^2)/(
     2 Sqrt[c^2 - v^2] Sqrt[-c0^2 + v^2])]))/(2 Sqrt[
 1 - v^2/c^2] Sqrt[-1 + v^2/c0^2])

Out[2]= (m0 (-v^2 + c^2 Sqrt[-1 + v^2/c0^2] + 
   Sqrt[c^2 - v^2] Sqrt[-c0^2 + v^2]
     ArcTan[Sqrt[-c0^2 + v^2]/Sqrt[c^2 - v^2]]))/(Sqrt[
 1 - v^2/c^2] Sqrt[-1 + v^2/c0^2])

Out[3]= False
POSTED BY: Tim Kirkpatrick

Actually, using Expand really highlights the problem even more. It is entirely associated with the ArcTan function. The answer changes after being run more than once in the same Kernel.

In[1]:= i1 = 
 Expand[  
  Integrate[(m0 v^3)/(c^2 (1 - v^2/c^2)^(3/2)) + (m0 v)/
     Sqrt[1 - 
       v^2/c^2] + (m0 v^3)/(c0^2 Sqrt[
        1 - v^2/c^2] (-1 + v^2/c0^2)^(3/2)) - (m0 v^3)/(c^2 (1 - 
          v^2/c^2)^(3/2) Sqrt[-1 + v^2/c0^2]) - (m0 v)/(Sqrt[
        1 - v^2/c^2] Sqrt[-1 + v^2/c0^2]), v]  ]

i2 = Expand[  
  Integrate[(m0 v^3)/(c^2 (1 - v^2/c^2)^(3/2)) + (m0 v)/
     Sqrt[1 - 
       v^2/c^2] + (m0 v^3)/(c0^2 Sqrt[
        1 - v^2/c^2] (-1 + v^2/c0^2)^(3/2)) - (m0 v^3)/(c^2 (1 - 
          v^2/c^2)^(3/2) Sqrt[-1 + v^2/c0^2]) - (m0 v)/(Sqrt[
        1 - v^2/c^2] Sqrt[-1 + v^2/c0^2]), v]  ]

i1 === i2

Out[1]= (c^2 m0)/Sqrt[1 - v^2/c^2] - (m0 v^2)/(
 Sqrt[1 - v^2/c^2] Sqrt[-1 + v^2/c0^2]) - (
 m0 Sqrt[c^2 - v^2] Sqrt[-c0^2 + v^2]
   ArcTan[(c^2 + c0^2 - 2 v^2)/(
   2 Sqrt[c^2 - v^2] Sqrt[-c0^2 + v^2])])/(
 2 Sqrt[1 - v^2/c^2] Sqrt[-1 + v^2/c0^2])

Out[2]= (c^2 m0)/Sqrt[1 - v^2/c^2] - (m0 v^2)/(
 Sqrt[1 - v^2/c^2] Sqrt[-1 + v^2/c0^2]) + (
 m0 Sqrt[c^2 - v^2] Sqrt[-c0^2 + v^2]
   ArcTan[Sqrt[-c0^2 + v^2]/Sqrt[c^2 - v^2]])/(
 Sqrt[1 - v^2/c^2] Sqrt[-1 + v^2/c0^2])

Out[3]= False
POSTED BY: Tim Kirkpatrick
Posted 2 years ago

Look at the ArcTan arguments in the comparison. Copy/paste error?

i1 = Integrate[(m0 v^3)/(c^2 (1 - v^2/c^2)^(3/2)) + (m0 v)/
    Sqrt[1 - 
      v^2/c^2] + (m0 v^3)/(c0^2 Sqrt[
       1 - v^2/c^2] (-1 + v^2/c0^2)^(3/2)) - (m0 v^3)/(c^2 (1 - 
         v^2/c^2)^(3/2) Sqrt[-1 + v^2/c0^2]) - (m0 v)/(Sqrt[
       1 - v^2/c^2] Sqrt[-1 + v^2/c0^2]), v]

i2 = Integrate[(m0 v^3)/(c^2 (1 - v^2/c^2)^(3/2)) + (m0 v)/
    Sqrt[1 - 
      v^2/c^2] + (m0 v^3)/(c0^2 Sqrt[
       1 - v^2/c^2] (-1 + v^2/c0^2)^(3/2)) - (m0 v^3)/(c^2 (1 - 
         v^2/c^2)^(3/2) Sqrt[-1 + v^2/c0^2]) - (m0 v)/(Sqrt[
       1 - v^2/c^2] Sqrt[-1 + v^2/c0^2]), v]

i1 === i2
(* True *)

$Version
(* 13.2.0 for Mac OS X ARM (64-bit) (November 18, 2022) *)
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard