static ScalarValue DiLog1(ScalarValue e) { ScalarValue f = new ScalarValue(Math.PI * Math.PI / 6.0); if (e == 0.0) { return(f); } var L = e.Ln(); var ek = ScalarValue.One; for (int k = 1; k < 250; k++) { var f_old = f.Clone(); ek *= e; var df = ek * (L - 1.0 / k) / k; f += df; if (f == f_old) { return(f); } } throw new YAMPNotConvergedException("spence"); }
static ScalarValue LogGamma_Stirling(ScalarValue z) { if (z.Im < 0.0) { return(LogGamma_Stirling(z.Conjugate()).Conjugate()); } var f = (z - 0.5) * z.Ln() - z + Math.Log(2.0 * Math.PI) / 2.0; var reduce = f.Im / (2.0 * Math.PI); reduce = f.Im - (int)(reduce) * 2.0 * Math.PI; f = new ScalarValue(f.Re, reduce); var zsqu = z * z; var zp = z.Clone(); for (var i = 1; i < 10; i++) { var f_old = f.Clone(); f += Helpers.BernoulliNumbers[i] / (2 * i) / (2 * i - 1) / zp; if (f == f_old) { return(f); } zp = zp * zsqu; } throw new YAMPNotConvergedException("gamma"); }
static ScalarValue DiLog0(ScalarValue z) { var zz = z.Clone(); var f = zz.Clone(); for (int k = 2; k < 250; k++) { var f_old = f.Clone(); zz *= z; f += zz / (k * k); if (f == f_old) { return(f); } } throw new YAMPNotConvergedException("spence"); }
static ScalarValue DiLog0(ScalarValue z) { var zz = z.Clone(); var f = zz.Clone(); for (var k = 2; k < 250; k++) { var f_old = f.Clone(); zz *= z; f += zz / (k * k); if (f == f_old) { return f; } } throw new YAMPNotConvergedException("spence"); }
static ScalarValue LogGamma_Stirling(ScalarValue z) { if (z.Im < 0.0) { return LogGamma_Stirling(z.Conjugate()).Conjugate(); } var f = (z - 0.5) * z.Ln() - z + Math.Log(2.0 * Math.PI) / 2.0; var reduce = f.Im / (2.0 * Math.PI); reduce = f.Im - (int)(reduce) * 2.0 * Math.PI; f = new ScalarValue(f.Re, reduce); var zsqu = z * z; var zp = z.Clone(); for (var i = 1; i < 10; i++) { var f_old = f.Clone(); f += Helpers.BernoulliNumbers[i] / (2 * i) / (2 * i - 1) / zp; if (f == f_old) { return (f); } zp = zp * zsqu; } throw new YAMPNotConvergedException("gamma"); }
static ScalarValue DiLog1(ScalarValue e) { var f = new ScalarValue(Math.PI * Math.PI / 6.0); if (e == 0.0) { return f; } var L = e.Ln(); var ek = ScalarValue.One; for (var k = 1; k < 250; k++) { var f_old = f.Clone(); ek *= e; var df = ek * (L - 1.0 / k) / k; f += df; if (f == f_old) { return f; } } throw new YAMPNotConvergedException("spence"); }