# How to track accumulated error?

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

Accumulate@Tan[N@Range[10^8]]


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.

compare against a higher precision calculation

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


• 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. – Masacroso Nov 13 '17 at 18:56

This should give you what you need:

Accumulate@Tan[Range[10^8]]-SetPrecision[Accumulate@Tan[N@Range[10^8]],30]

• but SetPrecision is not just adding extra zeros to the already truncated numbers? – Masacroso Nov 13 '17 at 18:52
• 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. – mmeent Nov 13 '17 at 19:52