If Im not wrong when we use the command N we are using float point numbers in machine precision, right? And the machine precision depends on the bits of the CPU where Mathematica is installed. Then, by example, irrational numbers are truncated at some place and there is some error associated to the magnitude of the truncated number.

Then I'm using the following list of values


where I cant quit the N to speed up other calculations over this list. But I need to know what is the accumulated error of the last element in this list. And, if it would be possible, I would like to graph this list inside the increasing area of accumulated error relative to each value of the list.

But searching (almost randomly) in the documentation of Wolfram Mathematica I dont found something that make me think how I can do this. Can someone help me? Thank you in advance.


2 Answers 2


compare against a higher precision calculation

n = 100000;
  Abs[Accumulate@Tan[N[Range[n]]] - 
    Accumulate@Tan[N[Range[n], 1000]]]]]

enter image description here

  • $\begingroup$ thank you very much, indeed this is more "powerful" than what I was searching for... This is insanely useful: I can make some statistic of the error. $\endgroup$
    – Masacroso
    Commented Nov 13, 2017 at 18:56

This should give you what you need:

  • $\begingroup$ but SetPrecision is not just adding extra zeros to the already truncated numbers? $\endgroup$
    – Masacroso
    Commented Nov 13, 2017 at 18:52
  • 3
    $\begingroup$ It is doing just that. But by setting it higher than $MachinePrecision ensures that no further arithmetical error is made in the comparison. In this case this is not that relevant since the accumulated error is much bigger than the MachinePrecision threshold. $\endgroup$
    – TimRias
    Commented Nov 13, 2017 at 19:52

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.