0
$\begingroup$

I am working on computing the following integration:

aa = N[2, 20]
H = 4/160;
X = Range[-aa, aa, H];   
Integrate[400/(1 + 40*x^2), {x, X[[k]], X[[k + 1]]

and using the same X[[k]] and X[[k + 1]], I get different results in different versions of Mathematica. For example if k=2, I get the following results:

Solution with v.9.0

0.06449530173506807

Solution with v.11.0

0.06449530173253662

This difference exists for all of k=1,..,160.

Why do not the results agree on each version? This tiny difference hurts the rest of my calculations.

I want to compute the integral in v.11.0; however, I need to get the results in v.9.0. Is there any way (using v.11.0 and getting the results the same as v.9.0)?

Unfortunately, it is impossible to install v.9.0 anymore, and I have to use v.11.0.

$\endgroup$
3
  • $\begingroup$ Without the definition for X we cannot produce any results for comparison. $\endgroup$
    – Bob Hanlon
    Commented Jun 20, 2021 at 5:09
  • $\begingroup$ H = 4/160; and X = Range[-2, 2, H]; $\endgroup$
    – FA mn
    Commented Jun 20, 2021 at 5:10
  • $\begingroup$ If results correct to 10-11 decimal places are insufficient for your needs, then it is unlikely that you will be able to use machine arithmetic for these computations. $\endgroup$ Commented Jun 20, 2021 at 14:36

1 Answer 1

2
$\begingroup$
$Version

(* "12.3.0 for Mac OS X x86 (64-bit) (May 10, 2021)" *)

Clear["Global`*"];

aa = N[2, 20];
H = 4/160;
X = Range[-aa, aa, H];

You appear to be using a value of 2 for k

k = 2;
Integrate[400/(1 + 40*x^2),
 {x, X[[k]], X[[k + 1]]}]

(* 0.06449530173253662 *)

This agrees with the result you show for version 11.0

To compare your two versions you should use exact input and first compare the exact results.

aa = 2;
H = 4/160;
X = Range[-aa, aa, H];
k = 2;
int = Integrate[400/(1 + 40*x^2),
  {x, X[[k]], X[[k + 1]]}]

(* 20 Sqrt[10] ArcCot[3101/Sqrt[10]] *)

N[int, 20]

(* 0.064495301732536633622 *)
$\endgroup$
5
  • $\begingroup$ Thanks for your reply. For all of k=1,.., 160, there is the difference. My question is that "Is there any way (using v.11.0 and getting the results the same as v.9.0)?" Even with different digits N[int, digits] , this difference exists. $\endgroup$
    – FA mn
    Commented Jun 20, 2021 at 5:43
  • 1
    $\begingroup$ Rather than trying to get the same result as v9, you should be trying to get the correct result. I believe that the result with v11 is correct. To find out why there is a difference I recommend that you look at the exact results in both cases. $\endgroup$
    – Bob Hanlon
    Commented Jun 20, 2021 at 5:49
  • $\begingroup$ Yes, I checked the exact results, but the problem is the same. Although v11 is correct, the rest of my computation will be wrong with the results of v11. I should compare my computation with the results of the available paper using v9. However, I have only v11. $\endgroup$
    – FA mn
    Commented Jun 20, 2021 at 5:55
  • $\begingroup$ Considering your most recent comment, perhaps you can just correct the computations such that they are correct in v11? It seems that, if v9 is indeed mathematically incorrect, then it would be better for your overall usage if you correct the method, rather than try to continue with the incorrect path? $\endgroup$ Commented Jun 21, 2021 at 3:47
  • $\begingroup$ Yes, that's right. I am trying to find any way to correct it. Thanks all for helping me to solve the problem. $\endgroup$
    – FA mn
    Commented Jun 21, 2021 at 4:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.