0
$\begingroup$

Below is my code:

n = 15;
roots = Table[Sqrt[Prime[i]], {i, n}];
q = 10^125;
error = N[Abs[q*roots - Round[q* roots]], 12]

Here I have a large number q = 10^125. It is okay for other calculations (which I did not show). But because of it, I get

enter image description here

So, where did it go wrong? My OS is windows 7 and my version is 11. I am actually often confused by the operation N. When should I use it? Before any other operation or after all other operators?

$\endgroup$
4
  • $\begingroup$ Try this error = Block[{$MaxExtraPrecision = 400}, N[Abs[q*roots - Round[q*roots]], 12]] $\endgroup$ Mar 14, 2017 at 9:11
  • $\begingroup$ It works. But why is not an issue in other cases. The number q is used many times in other lines. $\endgroup$
    – S. Kohn
    Mar 14, 2017 at 9:15
  • $\begingroup$ Please don't use the bugs tag when posting questions. This is a special tag that is meant to be added by someone else than the original poster after the bug has been verified by the community. $\endgroup$
    – Szabolcs
    Mar 14, 2017 at 9:27
  • 2
    $\begingroup$ BTW this is not a bug. The red box is a warning that the results have no effective precision left in them. $\endgroup$
    – Szabolcs
    Mar 14, 2017 at 9:28

0

Your Answer

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

Browse other questions tagged or ask your own question.