Wednesday, March 14, 2012

Calculator Pi

There is a very fast converging algorithm for computing pi that you can do on a desktop calculator.
  • Set x = 3
  • Now set x = x + sin(x)
  • Repeat
This converges ridiculously fast, after 1 step you get 4 digits right, after 2 steps you get 11 correct, in general we find:



# steps Digits right
1 4
2 11
3 33
4 100
5 301
6 903
7 2708
8 8124


of course on a pocket calculator, you only need to do 2 steps to have an accuracy greater than the calculator can display.  To make this chart I had to trick a computer into doing high precision arithmetic, the code is here.

Granted, this approximation is really cheating, since sin is a hard function to compute, and basically being able to compute sin means you know what pi is already.  Really, this is just Newton's method for computing the root of sin(x) in disguise

2 comments:

  1. I always like to read a quality content having accurate information regarding the subject and the same thing I found in this post. Nice work
    Donovan Mtichell HBCU Pride Jacket

    ReplyDelete
  2. This is a fantastic and quite useful article for me. Thank you so much for all of your hard work in giving such excellent information! search engine optimization services in usa

    ReplyDelete