I am really hoping someone can help with this. I am getting two different results when using Integrate in Mathematica using the exact same integrand. When there is a new Kernel, the integral evaluates to one values, and after that, successive running of the Kernal yields a different result running the exact same integrand. Except, after the Kernel has been run more than once, the result doesnt change. The problem is that when you compare the two results, they are not equal.
Why would Mathematica evaluate the exact same integrand to two different results just because of successive running of the Kernel? And more concerning, why are the two results not equal.
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.
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.
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 *)
Henrik, Thank you for this analysis. This is a good test and a creative way to test their equivalence. It is an oddity though; even when I pass values for all of the parameters and test i1===i2, it still returns False.
It occurs to me, testing D[i1,v]===D[i2,v] is testing the equivalence of the integrand though; which we know to be correct because the integrand doesn’t change in either of the inputs i1,i2. I think this is relevant because it appears that the issue is with the function “Integrate[]”; something odd is going on where it returns two different values that are not equivalent. Is there some kind of simplification that is occurring in error?
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.
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.
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.