# How to expaind the Pi number with n decimal digits?

14 views

### nib...@yahoo.com

Sep 5, 2019, 9:25:14 AM9/5/19
to
How to expaind the Pi number with n decimal digits?

I would like to know how to calculate, how to compute
the pi number with n decimal digits, say 1000 places.

I intent to follow Machin formula (or another).

pi = 16 arctan (1/5) - 4 arctan (1/239)
where arctan (x) = x - x^3/3 + x^5/5 - x^7/7 + ...

The common known algorithm is:

a = 16 / 5
b = 4 / 239
pi = a - b
sign = -1
FOR n = 3 TO ... STEP 2
a = a / 25
b = b / 57121
pi = pi + sign * (a - b) / n
sign = -sign
NEXT n

We know the computer does not support this amount of
numbers, and this is exactly the question: how to make
the expansion of the decimal digits. I would like
to know an easy method, step-by-step, for beginner
user (not for advanced user). Preferentially with a
simple text.

Can anyone here help me?

Thanks.
Nilton

### jdall...@yahoo.com

Sep 6, 2019, 9:45:17 AM9/6/19
to
On Thursday, September 5, 2019 at 8:25:14 PM UTC+7, nib...@yahoo.com wrote:
> How to expaind the Pi number with n decimal digits?

"unlimited precision" (or very high-precision) numbers.
For example, using 'bc' I type
scale = 1001
4*a(1)
and see Pi expanded correctly for 1000 digits. The a() function
is 'built-in'; you can write your own functions to calculate pi yourself.
('bc' is a C-like language with functions, loops, arrays, etc.)

To do this WITHOUT using a language that supports unlimited precision,
you'll need to implement the high precision arithmetic yourself.

James D. Allen

### rosab

Sep 6, 2019, 6:01:27 PM9/6/19
to
nib...@yahoo.com a écrit :
> How to expaind the Pi number with n decimal digits?
>
> [...]

> Can anyone here help me?
>
> Thanks.
> Nilton

You need to program the "spigot algorithm for pi" :
https://en.wikipedia.org/wiki/Spigot_algorithm

The principle is explained here :
http://www.pi314.net/eng/goutte.php

An example of java program with references :
http://www.luschny.de/math/PiSpigot.java.txt

--
rosab