2

Getting different answers when the same input is entered on the mentioned consoles known as $W$ and $R$ respectively. Any ideas on the root cause?

The first example shows a difference of $128$.

> 17*13^2*11^3*7^4*5^5*3^6*2^7
W -> 2677277333530800000    
R -> 2677277333530800128

The difference is wayyy off for higher level computations.

> 43*41^2*37^3*31^4*29^5*23^6*19^7*17^8*13^9*11^10*7^11*5^12*3^13*2^14
W -> 222046261244808869776040900239313953120666458401987626347805929809038681543479663134628000000000000
R -> 222046261244808840700006648066224468060080800828422604066066440880808286822248662002686864284808040
ab123
  • 2,521
Rohit
  • 123

1 Answers1

5

R is using double precision numbers, which can only represent numbers that can be expressed as $\pm k2^e$ for $k \in \mathbb N < 2^{53}$. The number you have calculated in the first instance requires a numerator of over $2^{54}$, so it gave up and rounded off to the nearest number it could use. Wolfram Alpha is using arbitrary sized integers in this case and can represent very large numbers exactly.

To be precise:

Your first number is $1.293ccc6672777c_{16}\times2^{61}$. However, to meet the restrictions of double-precision numbers, in this form, with the exponent chosen so the hexadecimal digit before the radix point is always 1, you are only allowed 13 digits after the radix point, and you have 14. The rounded value, used by R, is $1.293ccc6672778_{16}\times2^{61}$, which is the closest it can get.

Your second number has base 1.9fd1 ca40 73ce 9f52 ea8f ad0e f70b ffe1 2570 ef7f a683 a504 059e 3c7c 79ed d897 2645 f3cb cc74 b9 which is way way way too much detail to include in a double, and rounds to $1.9fd1\ ca40\ 73ce\ a\times2^{246}$.

Dan Uznanski
  • 11,025