LiDIA is available from

ftp://crypt1.cs.uni-sb.de/pub/systems/LiDIA/LiDIA-1.2.1.tgz

http://www-jb.cs.uni-sb.de/LiDIA/linkhtml/lidia/lidia.html

The implementation of the algorithm is:

inline void

const_catalan (bigfloat & y)

{

bigfloat p;

bigfloat t;

int i = 1, j = 3; // j = 2*i+1

// y = t = p = 1/2

divide (y, 1, 2);

t.assign (y);

p.assign (y);

// while t is greater than the desired accuracy

while (!t.is_approx_zero ())

{

// do

// p = p * (i/j);

// t = (t * i + p) / j;

// y = y + t;

// i++; j+=2;

multiply (p, p, i);

divide (p, p, j);

multiply (t, t, i);

add (t, t, p);

divide (t, t, j);

add (y, y, t);

i++;

j += 2;

}

}

Here is the output of the program:

Catalan's Constant [Ramanujan's Formula] · 第 3 / 9 题