Module: BigMathR::Const::EulerGamma
- Defined in:
- lib/bigdecimal/math_r/const/EulerGamma_engel.rb,
ext/bigdecimal/math_r/math_r.c
Class Method Summary collapse
-
.borwein_bailey(prec) ⇒ BigDecimal
Implement by Borwein-Bailey’s formula (Brent-McMillan type formula).
-
.brent_mcmillan(prec) ⇒ BigDecimal
Implement by Borwein-Bailey’s formula (Brent-McMillan type formula).
-
.engel(prec) ⇒ BigDecimal
Implement by Engel expansion.
Class Method Details
.borwein_bailey(prec) ⇒ BigDecimal
Implement by Borwein-Bailey’s formula (Brent-McMillan type formula)
177 178 179 180 181 |
# File 'ext/bigdecimal/math_r/const.c', line 177
static VALUE
__impl_const_euler_gamma_borwein_bailey(VALUE unused_obj, VALUE prec)
{
return EulerGamma_borwein_bailey(prec);
}
|
.brent_mcmillan(prec) ⇒ BigDecimal
Implement by Borwein-Bailey’s formula (Brent-McMillan type formula)
177 178 179 180 181 |
# File 'ext/bigdecimal/math_r/const.c', line 177
static VALUE
__impl_const_euler_gamma_borwein_bailey(VALUE unused_obj, VALUE prec)
{
return EulerGamma_borwein_bailey(prec);
}
|
.engel(prec) ⇒ BigDecimal
Implement by Engel expansion.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/bigdecimal/math_r/const/EulerGamma_engel.rb', line 19 def engel(prec) raise TypeError, "precision must be an Integer" unless prec.class == Integer raise RangeError, "Zero or negative precision" if prec <= 0 n = BigDecimal.double_fig + prec f = File.open(__dir__ + '/b053977/b053977.txt', 'r') g = 1 fread = -> do raise "there is no more list" if f.eof? _, coef = f.readline.chomp.split(' '); raise "expansion maximum reached" if coef.nil? g *= coef.to_i end d = BigDecimal(1) y = BigDecimal(0) while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0) m = BigDecimal.double_fig if m < BigDecimal.double_fig d = BigDecimal(Rational(1, fread.call), m) y += d end y.round(prec) end |