Why Matlab Mod is different from Wolfram Alpha

688 ^ 79 mod 3337 = 1570.

When I tried this on wolfram alpha, I got: enter image description here

but when I entered the same in Matlab, I get 364 as an answer. I have to do something wrong.

enter image description here

Any light on this will be appreciated.

+4
source share
2 answers

The reason is that Matlab uses doublefloating point arithmetic by default . A number equal to 688 ^ 79 cannot be represented exactly as double. (The largest integer that can be accurately represented as doubleis of the order of 2 ^ 53 ).

, , , :

>> x = sym('688^79');
>> y = sym('3337');
>> mod(x, y)
ans =
1570
+11

, , 688 ^ 79, , . , , , Matlab , .

+3

Source: https://habr.com/ru/post/1584803/


All Articles