//double eps = prec2err(0.577, mc.getPrecision()); // removed by l.bruninx, 2012-03-26
/*
* Euler-Stieltjes as shown in Dilcher, Aequat Math 48 (1) (1994) 55-85
*/
MathContext mcloc = new MathContext(2 + mc.getPrecision());
BigDecimal resul = BigDecimal.ONE;
resul = resul.add(log(new BigDecimal(2), mcloc));
resul = resul.subtract(log(new BigDecimal(3), mcloc));
/* how many terms: zeta-1 falls as 1/2^(2n+1), so the
* terms drop faster than 1/2^(4n+2). Set 1/2^(4kmax+2) < eps.
* Leading term zeta(3)/(4^1*3) is 0.017. Leading zeta(3) is 1.2. Log(2) is 0.7
*/
//int kmax = (int) ((Math.log(eps / 0.7) - 2.) / 4.); // removed by l.bruninx, 2012-03-26
//mcloc = new MathContext(1 + err2prec(1.2, eps / kmax)); // removed by l.bruninx, 2012-03-26
int n = Const.GAMMA.precision();//1; // modified by l.bruninx, 2012-03-26
/**
* n : precision ???
*/
BigDecimal old_resul=Const.GAMMA;
Bernoulli bern_cache=new Bernoulli();
Factorial fact_cache=new Factorial();
//bern_cache.at(mc.getPrecision()*2);
//fact_cache.at(mc.getPrecision()*2);
Interpreter.Log("Start gamma:");
do{ // modified by l.bruninx, 2012-03-26
old_resul=resul.round(mc);
/*
* zeta is close to 1. Division of zeta-1 through
* 4^n*(2n+1) means divion through roughly 2^(2n+1)
*/
//System.out.print("A("+(2 * n + 1)+"):");
BigDecimal c = zeta(2 * n + 1, mcloc,bern_cache,fact_cache).subtract(BigDecimal.ONE,mcloc);
//System.out.print("B");
BigInteger fourn = new BigInteger("" + (2 * n + 1));
fourn = fourn.shiftLeft(2 * n);
c = c.divide(new BigDecimal(fourn),mcloc);
resul = resul.subtract(c,mcloc);
//if (c.doubleValue() < 0.1 * eps) // removed by l.bruninx, 2012-03-26
// break; // removed by l.bruninx, 2012-03-26
if(Interpreter.isDebugMode()){
Interpreter.Log("gamma Step:"+resul.round(new MathContext(_common_precision_of_(old_resul,resul))).toPlainString());
}
n++;
}while(resul.round(mc).compareTo(old_resul)!=0); // modified by l.bruninx, 2012-03-26
return resul.round(mc);