Menu

  • Home
  • Archives
  • Tags
  • RSS
January 30, 2014

mathematica 1 slash 9998

I saw this piece about how 1/1998 was approximated by series of powers of 2, which raised the question, "Can Mathematica help confirm this?" (of course it can!)

First, a gut check to see the decimal expansion


N[1/9998, 100]

which shows


0.00010002000400080016003200640128025605121024204840968193638727745549 \

10982196439287857571514302860572114

(if you don't specify the 100 in the argument to N[], it will show you just 0.00010002 by default)

This can be visualized as


0.0001 +

0.00000002 +

0.000000000004 +

0.0000000000000008 +

0.00000000000000000016 +

...

0.000000000000000000000000000000000256 +

...

All right, so we do see these powers of 2! They seem to be in "groups" – 0004, 0016, 1024 and so on.

So we want to check if something like 2^i/10000^i can add up to this number.


Parallelize[

 Table[1/9998 - Total[Table[2^i/10000^i, {i, 1, n}]], {n, 1, 10000}] ]

I initially tried this without Parallelize[], but that kept going for a while, so I had to abort it (Evaluation->Abort Evaluation) and try this version instead.

Anyway, so this whirs for a while. As this htop output shows, it really does use as many cores as possible.

{% img center http://farm6.staticflickr.com/5504/122279410344ce9d69db4z_d.jpg %}

Eventually when it's done, we can ListPlot it.


ListPlot[%118, Frame -> True, FrameStyle -> Black, 

 PlotRange -> { {1, 10000}, {-0.000105, -0.000095} }]

{% img center http://farm6.staticflickr.com/5535/12227532975ee70979b52z_d.jpg %}

As this graph shows, the result is remarkably close to a constant value of -0.0001 !!


Tags: old-post

« change that font mathematica a simple ant »

Copyright © 2020 Agam Brahma

Powered by Cryogen