0
$\begingroup$

I have this code

list = Accumulate@Tan[N[Range[10^8]]]; // AbsoluteTiming

and the timing is slightly more than two seconds. Now if I try to compute this

list = Accumulate@Tan[N[Range[10^8],30]]; // AbsoluteTiming

my computer its completely blocked. I have a laptop with an i7 chipset and 4gb of RAM, and Im not running any other thing in the background. It is really as big this calculation to block my computer or there is something wrong in the code or in my computer?

More over: this code

ListPlot[Abs[Accumulate[Tan[N[Range[10^6]]]] -Accumulate@Tan[N[Range[10^6],1000]]]]

(with an arbitrary precision of 1000 inside!!!) runs fine, that is, it make the plot in some minutes. However I cant use a range bigger than $10^6$. What is going on? Its $10^8$ too big for my computer?

There is an alternative code, with the same dimension of $10^8$ and precision at least $30$ that can be handled easier for a computer?

$\endgroup$
  • 3
    $\begingroup$ Something to ponder on: a single arbitrary-precision number like N[10, 30] needs 96 or so bytes of space (ByteCount[N[10, 30]]). Now, look at UnitConvert[Quantity[10^8 96., "Bytes"], "Gigabytes"]. (I'm ignoring the extra bytes needed for collecting these numbers into a list for the purposes of this little experiment.) $\endgroup$ – J. M. is away Nov 14 '17 at 14:06
  • $\begingroup$ @J.M. I see... the difference when I put in your code $10^6$ instead of $10^8$ is BIG. From $\approx 10$ GB to $\approx 0.1$ GB... $\endgroup$ – Masacroso Nov 14 '17 at 14:08
  • $\begingroup$ ListLinePlot[AbsoluteTiming[Tan[N[Range[#], 30]]][[1]] & /@ (10^# & /@ Range[6])] shows how the time growth. $\endgroup$ – mrz Nov 14 '17 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.