Skip to content

MooseValley/Math---Pi-calculator---Chudnovsky-algorithm

Repository files navigation

Math - Pi calculator - Chudnovsky Algorithm

My code / solution to calculate Pi using the Chudnovsky Algorithm in Java using the BigNumber and BigDecimal classes.

The Chudnovsky Algorithm is the algorithm programmers and computers use to calculate Pi to trillions of decimal places.

Chudnovsky Algorithm

        (6q!) x (q * 545140134 + 13591409)
F(q) = -------------------------------------------
        (3q!)  x (q!^3) x (-262537412640768000^q)

Pi = 426880 x SQRT (10005) / SUM (F(q))

i.e. Calculate F(0), F(1), F(2), etc and sum them up, and divide into 426880 x SQRT (10005).

Calculation using only F(0):
0. 3.141592653589734020		Pi is correct to 13 digits
                  ^^^^^

Calculation using SUM F(0), F(1), F(2), F(3) and F(4):
4.	3.141592653589793051		Pi is correct to 15 digits
                    ^^^

William Shanks method:

Pi = 16 arctan (1/5) - 4 arctan (1/239)

arctan (1/x) = 1/x - 1/3x^3 + 1/5x^5 - 1/7x^7 + 1/9x^9 - .....

Useful Links:

Moose
Moose's Software Valley - Established July, 1996.
https://moosevalley.github.io/

About

Math - Pi calculator - Chudnovsky algorithm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages