bigdecimal-math_r 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/changelog.md +14 -0
  3. data/ext/bigdecimal/math_r/algofunc.h +11 -1
  4. data/ext/bigdecimal/math_r/api/bigmath/const_e.h +1 -1
  5. data/ext/bigdecimal/math_r/api/bigmath/const_euler_gamma.h +5 -0
  6. data/ext/bigdecimal/math_r/api/bigmath/csqrt.h +1 -1
  7. data/ext/bigdecimal/math_r/api/kernel/rb_BigDecimal_flo.h +8 -2
  8. data/ext/bigdecimal/math_r/api/numeric/nan_p.h +4 -1
  9. data/ext/bigdecimal/math_r/api.h +2 -0
  10. data/ext/bigdecimal/math_r/const.c +42 -5
  11. data/ext/bigdecimal/math_r/decl.h +11 -1
  12. data/ext/bigdecimal/math_r/exp.c +45 -3
  13. data/ext/bigdecimal/math_r/extconf.rb +5 -1
  14. data/ext/bigdecimal/math_r/{gamma_r.c → gamma_beta.c} +11 -78
  15. data/ext/bigdecimal/math_r/internal/algo/bigmath/E/{ser.h → napier.h} +1 -1
  16. data/ext/bigdecimal/math_r/internal/algo/bigmath/EulerGamma/borwein_bailey.h +37 -0
  17. data/ext/bigdecimal/math_r/internal/algo/bigmath/LOG10/ser.h +4 -2
  18. data/ext/bigdecimal/math_r/internal/algo/bigmath/LOG_PI/builtin.h +3 -1
  19. data/ext/bigdecimal/math_r/internal/algo/bigmath/SQRT2/builtin.h +4 -1
  20. data/ext/bigdecimal/math_r/internal/algo/bigmath/SQRT3/builtin.h +4 -1
  21. data/ext/bigdecimal/math_r/internal/algo/bigmath/acosh/edom.h +7 -5
  22. data/ext/bigdecimal/math_r/internal/algo/bigmath/acot/logrep.h +9 -6
  23. data/ext/bigdecimal/math_r/internal/algo/bigmath/acoth/edom.h +4 -3
  24. data/ext/bigdecimal/math_r/internal/algo/bigmath/acoth/logrep.h +5 -2
  25. data/ext/bigdecimal/math_r/internal/algo/bigmath/acsc/edom.h +7 -6
  26. data/ext/bigdecimal/math_r/internal/algo/bigmath/acsc/logrep.h +6 -5
  27. data/ext/bigdecimal/math_r/internal/algo/bigmath/acsch/logrep.h +7 -6
  28. data/ext/bigdecimal/math_r/internal/algo/bigmath/asec/edom.h +7 -6
  29. data/ext/bigdecimal/math_r/internal/algo/bigmath/asec/logrep.h +8 -7
  30. data/ext/bigdecimal/math_r/internal/algo/bigmath/asech/edom.h +10 -6
  31. data/ext/bigdecimal/math_r/internal/algo/bigmath/asech/logrep.h +3 -2
  32. data/ext/bigdecimal/math_r/internal/algo/bigmath/asin/edom.h +6 -5
  33. data/ext/bigdecimal/math_r/internal/algo/bigmath/asin/logrep.h +3 -2
  34. data/ext/bigdecimal/math_r/internal/algo/bigmath/asin/ser.h +1 -0
  35. data/ext/bigdecimal/math_r/internal/algo/bigmath/asinh/logrep.h +6 -5
  36. data/ext/bigdecimal/math_r/internal/algo/bigmath/asinh/ser.h +1 -0
  37. data/ext/bigdecimal/math_r/internal/algo/bigmath/atan/logrep.h +7 -6
  38. data/ext/bigdecimal/math_r/internal/algo/bigmath/atan/ser_euler.h +2 -0
  39. data/ext/bigdecimal/math_r/internal/algo/bigmath/atanh/edom.h +6 -3
  40. data/ext/bigdecimal/math_r/internal/algo/bigmath/atanh/logrep.h +2 -0
  41. data/ext/bigdecimal/math_r/internal/algo/bigmath/atanh/ser.h +1 -0
  42. data/ext/bigdecimal/math_r/internal/algo/bigmath/cabs/formula.h +6 -2
  43. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacos/logrep.h +7 -4
  44. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacosh/logrep.h +6 -5
  45. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacot/logrep.h +3 -2
  46. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacoth/logrep.h +8 -4
  47. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacsc/logrep.h +5 -4
  48. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacsch/logrep.h +7 -3
  49. data/ext/bigdecimal/math_r/internal/algo/bigmath/carg/formula.h +6 -2
  50. data/ext/bigdecimal/math_r/internal/algo/bigmath/casec/logrep.h +5 -4
  51. data/ext/bigdecimal/math_r/internal/algo/bigmath/casech/logrep.h +3 -1
  52. data/ext/bigdecimal/math_r/internal/algo/bigmath/casin/logrep.h +6 -4
  53. data/ext/bigdecimal/math_r/internal/algo/bigmath/casinh/logrep.h +1 -0
  54. data/ext/bigdecimal/math_r/internal/algo/bigmath/catan/logrep.h +3 -2
  55. data/ext/bigdecimal/math_r/internal/algo/bigmath/catanh/logrep.h +5 -2
  56. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccbrt/branch.h +40 -0
  57. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccbrt/formula.h +5 -2
  58. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccos/eulerf.h +4 -3
  59. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccosh/eulerf.h +4 -3
  60. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccot/eulerf.h +5 -3
  61. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccoth/eulerf.h +4 -2
  62. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccsc/eulerf.h +4 -2
  63. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccsch/eulerf.h +5 -3
  64. data/ext/bigdecimal/math_r/internal/algo/bigmath/cexp/eulerf.h +10 -7
  65. data/ext/bigdecimal/math_r/internal/algo/bigmath/cexp2/eulerf.h +5 -3
  66. data/ext/bigdecimal/math_r/internal/algo/bigmath/cexpm1/branch.h +13 -0
  67. data/ext/bigdecimal/math_r/internal/algo/bigmath/cexpm1/identity.h +17 -0
  68. data/ext/bigdecimal/math_r/internal/algo/bigmath/clog/branch.h +11 -12
  69. data/ext/bigdecimal/math_r/internal/algo/bigmath/clog10/branch.h +53 -0
  70. data/ext/bigdecimal/math_r/internal/algo/bigmath/clog10/formula.h +4 -3
  71. data/ext/bigdecimal/math_r/internal/algo/bigmath/clog2/branch.h +53 -0
  72. data/ext/bigdecimal/math_r/internal/algo/bigmath/clog2/formula.h +4 -3
  73. data/ext/bigdecimal/math_r/internal/algo/bigmath/cos/eulerf.h +6 -4
  74. data/ext/bigdecimal/math_r/internal/algo/bigmath/cos/ser.h +4 -4
  75. data/ext/bigdecimal/math_r/internal/algo/bigmath/cosh/eulerf.h +5 -3
  76. data/ext/bigdecimal/math_r/internal/algo/bigmath/cosh/formula.h +5 -5
  77. data/ext/bigdecimal/math_r/internal/algo/bigmath/cosh/ser.h +4 -3
  78. data/ext/bigdecimal/math_r/internal/algo/bigmath/cot/eulerf.h +5 -3
  79. data/ext/bigdecimal/math_r/internal/algo/bigmath/cot/ser.h +3 -2
  80. data/ext/bigdecimal/math_r/internal/algo/bigmath/coth/eulerf.h +4 -2
  81. data/ext/bigdecimal/math_r/internal/algo/bigmath/coth/formula.h +1 -0
  82. data/ext/bigdecimal/math_r/internal/algo/bigmath/coth/ser.h +3 -2
  83. data/ext/bigdecimal/math_r/internal/algo/bigmath/cpow/formula.h +7 -6
  84. data/ext/bigdecimal/math_r/internal/algo/bigmath/csc/eulerf.h +4 -2
  85. data/ext/bigdecimal/math_r/internal/algo/bigmath/csc/ser.h +5 -3
  86. data/ext/bigdecimal/math_r/internal/algo/bigmath/csch/eulerf.h +5 -3
  87. data/ext/bigdecimal/math_r/internal/algo/bigmath/csch/formula.h +2 -2
  88. data/ext/bigdecimal/math_r/internal/algo/bigmath/csch/ser.h +6 -3
  89. data/ext/bigdecimal/math_r/internal/algo/bigmath/csec/eulerf.h +5 -3
  90. data/ext/bigdecimal/math_r/internal/algo/bigmath/csech/eulerf.h +5 -3
  91. data/ext/bigdecimal/math_r/internal/algo/bigmath/csin/eulerf.h +4 -3
  92. data/ext/bigdecimal/math_r/internal/algo/bigmath/csinh/eulerf.h +4 -3
  93. data/ext/bigdecimal/math_r/internal/algo/bigmath/csqrt/branch.h +40 -0
  94. data/ext/bigdecimal/math_r/internal/algo/bigmath/csqrt/formula.h +13 -43
  95. data/ext/bigdecimal/math_r/internal/algo/bigmath/ctan/eulerf.h +4 -3
  96. data/ext/bigdecimal/math_r/internal/algo/bigmath/ctanh/eulerf.h +4 -3
  97. data/ext/bigdecimal/math_r/internal/algo/bigmath/cuberoot/branch.h +18 -0
  98. data/ext/bigdecimal/math_r/internal/algo/bigmath/cuberoot/newton.h +4 -12
  99. data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/algo911.h +7 -4
  100. data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/cf.h +1 -0
  101. data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/ser_inf.h +1 -0
  102. data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/ser_zero.h +1 -0
  103. data/ext/bigdecimal/math_r/internal/algo/bigmath/erfc/algo911.h +5 -2
  104. data/ext/bigdecimal/math_r/internal/algo/bigmath/erfc/cf.h +1 -0
  105. data/ext/bigdecimal/math_r/internal/algo/bigmath/escalb/edf.h +2 -0
  106. data/ext/bigdecimal/math_r/internal/algo/bigmath/exp/builtin.h +7 -1
  107. data/ext/bigdecimal/math_r/internal/algo/bigmath/exp/edf.h +6 -5
  108. data/ext/bigdecimal/math_r/internal/algo/bigmath/exp2/edf.h +9 -5
  109. data/ext/bigdecimal/math_r/internal/algo/bigmath/expm1/branch.h +13 -0
  110. data/ext/bigdecimal/math_r/internal/algo/bigmath/expm1/identity.h +18 -0
  111. data/ext/bigdecimal/math_r/internal/algo/bigmath/expxt/edf.h +1 -1
  112. data/ext/bigdecimal/math_r/internal/algo/bigmath/f_euler/formula.h +3 -2
  113. data/ext/bigdecimal/math_r/internal/algo/bigmath/hypot/l2norm.h +5 -4
  114. data/ext/bigdecimal/math_r/internal/algo/bigmath/hypot/mmm.h +1 -1
  115. data/ext/bigdecimal/math_r/internal/algo/bigmath/ipow/edf.h +6 -4
  116. data/ext/bigdecimal/math_r/internal/algo/bigmath/l2norm/formula.h +6 -1
  117. data/ext/bigdecimal/math_r/internal/algo/bigmath/log/branch.h +6 -2
  118. data/ext/bigdecimal/math_r/internal/algo/bigmath/log/builtin.h +3 -2
  119. data/ext/bigdecimal/math_r/internal/algo/bigmath/log/edf.h +8 -5
  120. data/ext/bigdecimal/math_r/internal/algo/bigmath/log/edom.h +10 -4
  121. data/ext/bigdecimal/math_r/internal/algo/bigmath/log/mercator.h +7 -9
  122. data/ext/bigdecimal/math_r/internal/algo/bigmath/log/ser_okumura.h +4 -1
  123. data/ext/bigdecimal/math_r/internal/algo/bigmath/log10/edf.h +3 -2
  124. data/ext/bigdecimal/math_r/internal/algo/bigmath/log10/mercator.h +9 -9
  125. data/ext/bigdecimal/math_r/internal/algo/bigmath/log1p/branch.h +8 -5
  126. data/ext/bigdecimal/math_r/internal/algo/bigmath/log1p/ser_mercator.h +16 -6
  127. data/ext/bigdecimal/math_r/internal/algo/bigmath/log2/branch.h +1 -1
  128. data/ext/bigdecimal/math_r/internal/algo/bigmath/log2/edf.h +3 -2
  129. data/ext/bigdecimal/math_r/internal/algo/bigmath/log2/mercator.h +9 -9
  130. data/ext/bigdecimal/math_r/internal/algo/bigmath/logxt/edf.h +6 -1
  131. data/ext/bigdecimal/math_r/internal/algo/bigmath/pow/formula.h +13 -8
  132. data/ext/bigdecimal/math_r/internal/algo/bigmath/rcm10/edf.h +10 -4
  133. data/ext/bigdecimal/math_r/internal/algo/bigmath/rcm2/edf.h +11 -3
  134. data/ext/bigdecimal/math_r/internal/algo/bigmath/sec/eulerf.h +5 -3
  135. data/ext/bigdecimal/math_r/internal/algo/bigmath/sec/ser.h +6 -4
  136. data/ext/bigdecimal/math_r/internal/algo/bigmath/sech/eulerf.h +5 -3
  137. data/ext/bigdecimal/math_r/internal/algo/bigmath/sech/formula.h +8 -4
  138. data/ext/bigdecimal/math_r/internal/algo/bigmath/sech/ser.h +5 -3
  139. data/ext/bigdecimal/math_r/internal/algo/bigmath/sin/eulerf.h +5 -2
  140. data/ext/bigdecimal/math_r/internal/algo/bigmath/sin/ser.h +4 -5
  141. data/ext/bigdecimal/math_r/internal/algo/bigmath/sincos/ser.h +9 -2
  142. data/ext/bigdecimal/math_r/internal/algo/bigmath/sinh/eulerf.h +5 -3
  143. data/ext/bigdecimal/math_r/internal/algo/bigmath/sinh/formula.h +8 -4
  144. data/ext/bigdecimal/math_r/internal/algo/bigmath/sinh/ser.h +4 -3
  145. data/ext/bigdecimal/math_r/internal/algo/bigmath/sinhcosh/ser.h +10 -3
  146. data/ext/bigdecimal/math_r/internal/algo/bigmath/sqrt/builtin.h +2 -2
  147. data/ext/bigdecimal/math_r/internal/algo/bigmath/sqrt/edom.h +1 -0
  148. data/ext/bigdecimal/math_r/internal/algo/bigmath/tan/eulerf.h +5 -3
  149. data/ext/bigdecimal/math_r/internal/algo/bigmath/tan/ser.h +3 -8
  150. data/ext/bigdecimal/math_r/internal/algo/bigmath/tanh/eulerf.h +5 -3
  151. data/ext/bigdecimal/math_r/internal/algo/bigmath/tanh/formula.h +7 -3
  152. data/ext/bigdecimal/math_r/internal/algo/bigmath/tanh/ser.h +3 -3
  153. data/ext/bigdecimal/math_r/internal/algo/bigmath/trig/f_euler.h +11 -5
  154. data/ext/bigdecimal/math_r/log.c +2 -2
  155. data/ext/bigdecimal/math_r/math_r/bigdecimal.h +5 -1
  156. data/ext/bigdecimal/math_r/math_r/bigmath.h +2 -0
  157. data/ext/bigdecimal/math_r/math_r/globals.h +1 -1
  158. data/ext/bigdecimal/math_r/math_r.c +5 -3
  159. data/lib/bigdecimal/math_r/const/E_euler.rb +46 -0
  160. data/lib/bigdecimal/math_r/version.rb +1 -1
  161. data/lib/bigdecimal/math_r.rb +1 -0
  162. metadata +20 -10
  163. data/.ruby-version +0 -1
  164. data/lib/bigdecimal/math_r.so +0 -0
@@ -1,13 +1,16 @@
1
1
  VALUE
2
2
  acot_logrep(VALUE x, VALUE prec)
3
3
  {
4
- VALUE n, m, y;
4
+ VALUE n1, m1, y, n;
5
+
6
+ rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
5
8
 
6
9
  x = rb_num_canonicalize(x, prec, ARG_REAL, ARG_RECIPROCAL);
7
- n = rb_Complex(BIG_ONE, x);
8
- m = rb_bigmath_sqrt(rb_funcall1(BIG_ONE, '+', rb_funcall1(x, '*', x)), prec);
9
- y = rb_funcall1(n, '/', m);
10
- y = rb_bigmath_carg(y, prec);
10
+ n1 = rb_Complex(BIG_ONE, x);
11
+ m1 = rb_bigmath_sqrt(rb_funcall1(BIG_ONE, '+', rb_funcall1(x, '*', x)), n);
12
+ y = rb_funcall1(n1, '/', m1);
13
+ y = rb_bigmath_carg(y, n);
11
14
 
12
- return y;
15
+ return rb_num_round(y, prec);
13
16
  }
@@ -1,16 +1,17 @@
1
1
  VALUE
2
2
  acoth_edom(VALUE x, VALUE prec)
3
3
  {
4
- VALUE t, pi;
4
+ VALUE t, pi, n;
5
5
 
6
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
7
8
 
8
9
  t = rb_funcall1(
9
10
  rb_funcall1(x, '+', BIG_ONE), '/',
10
11
  rb_funcall1(x, '-', BIG_ONE));
11
- pi = rb_bigmath_const_pi(prec);
12
+ pi = rb_bigmath_const_pi(n);
12
13
  t = rb_Complex(
13
- rb_bigmath_log(rb_num_abs(t), prec),
14
+ rb_bigmath_log(rb_num_abs(t), n),
14
15
  rb_num_negative_p(x) ? pi : rb_num_uminus(pi));
15
16
  t = rb_funcall1(rb_Rational(INT2FIX(1), INT2FIX(2)), '*', t);
16
17
 
@@ -1,12 +1,15 @@
1
1
  VALUE
2
2
  acoth_logrep(VALUE x, VALUE prec)
3
3
  {
4
- VALUE y;
4
+ VALUE y, n;
5
+
6
+ rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
5
8
 
6
9
  y = rb_funcall1(
7
10
  rb_funcall1(x, '+', BIG_ONE), '/',
8
11
  rb_funcall1(x, '-', BIG_ONE));
9
- y = rb_bigmath_log(y, prec);
12
+ y = rb_bigmath_log(y, n);
10
13
  y = rb_funcall1(rb_Rational(INT2FIX(1), INT2FIX(2)), '*', y);
11
14
  y = rb_num_round(y, prec);
12
15
 
@@ -2,19 +2,20 @@ VALUE
2
2
  acsc_edom(VALUE x, VALUE prec)
3
3
  {
4
4
  const ID div = rb_intern("div");
5
- VALUE imag, y, arg, t;
5
+ VALUE imag, y, arg, t, n;
6
6
 
7
7
  rb_check_precise(prec);
8
+ n = rb_numdiff_make_n(prec);
8
9
 
9
- x = rb_num_canonicalize(x, prec, ARG_REAL, ARG_RECIPROCAL);
10
+ x = rb_num_canonicalize(x, n, ARG_REAL, ARG_RECIPROCAL);
10
11
  t = rb_funcall1(BIG_ONE, '-', rb_funcall1(x, '*', x));
11
- t = rb_funcall1(rb_bigmath_sqrt(rb_num_uminus(t), prec), '+', x);
12
- arg = rb_funcall(rb_bigmath_const_pi(prec), div, 2, INT2FIX(2), prec);
12
+ t = rb_funcall1(rb_bigmath_sqrt(rb_num_uminus(t), n), '+', x);
13
+ arg = rb_funcall(rb_bigmath_const_pi(n), div, 2, INT2FIX(2), n);
13
14
  if (!rb_num_negative_p(x))
14
15
  arg = rb_num_uminus(arg);
15
- imag = rb_bigmath_log(rb_num_abs(t), prec);
16
+ imag = rb_bigmath_log(rb_num_abs(t), n);
16
17
  y = rb_Complex(arg, imag);
17
18
  y = rb_num_uminus(y);
18
19
 
19
- return y;
20
+ return rb_num_round(y, prec);
20
21
  }
@@ -1,16 +1,17 @@
1
1
  VALUE
2
2
  acsc_logrep(VALUE x, VALUE prec)
3
3
  {
4
- VALUE t;
4
+ VALUE t, n;
5
5
 
6
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
7
8
 
8
- x = rb_num_canonicalize(x, prec, ARG_REAL, ARG_RECIPROCAL);
9
+ x = rb_num_canonicalize(x, n, ARG_REAL, ARG_RECIPROCAL);
9
10
  t = rb_funcall1(x, '*', x);
10
11
  t = rb_funcall1(INT2FIX(1), '-', t);
11
- t = rb_bigmath_sqrt(t, prec);
12
+ t = rb_bigmath_sqrt(t, n);
12
13
  t = rb_funcall1(x, '/', t);
13
- t = rb_bigmath_atan(t, prec);
14
+ t = rb_bigmath_atan(t, n);
14
15
 
15
- return t;
16
+ return rb_num_round(t, prec);
16
17
  }
@@ -1,22 +1,23 @@
1
1
  VALUE
2
2
  acsch_logrep(VALUE x, VALUE prec)
3
3
  {
4
- VALUE t, y;
4
+ VALUE t, y, n;
5
5
 
6
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
7
8
 
8
- x = rb_num_canonicalize(x, prec, ARG_REAL, ARG_RECIPROCAL);
9
+ x = rb_num_canonicalize(x, n, ARG_REAL, ARG_RECIPROCAL);
9
10
  if (rb_num_positive_p(x))
10
11
  {
11
12
  t = rb_funcall1(rb_funcall1(x, '*', x), '+', BIG_ONE);
12
- t = rb_bigmath_sqrt(t, prec);
13
- y = rb_bigmath_log(rb_funcall1(x, '+', t), prec);
13
+ t = rb_bigmath_sqrt(t, n);
14
+ y = rb_bigmath_log(rb_funcall1(x, '+', t), n);
14
15
  }
15
16
  else if (rb_num_negative_p(x))
16
17
  {
17
18
  t = rb_funcall1(rb_funcall1(x, '*', x), '+', BIG_ONE);
18
- t = rb_bigmath_sqrt(t, prec);
19
- t = rb_bigmath_log(rb_funcall1(t, '-', x), prec);
19
+ t = rb_bigmath_sqrt(t, n);
20
+ t = rb_bigmath_log(rb_funcall1(t, '-', x), n);
20
21
  y = rb_num_uminus(t);
21
22
  }
22
23
  else
@@ -1,16 +1,17 @@
1
1
  VALUE
2
2
  asec_edom(VALUE x, VALUE prec)
3
3
  {
4
- VALUE imag, y, arg, t;
4
+ VALUE imag, y, arg, t, n;
5
5
 
6
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
7
8
 
8
- x = rb_num_canonicalize(x, prec, ARG_REAL, ARG_RECIPROCAL);
9
+ x = rb_num_canonicalize(x, n, ARG_REAL, ARG_RECIPROCAL);
9
10
  t = rb_funcall1(BIG_ONE, '-', rb_funcall1(x, '*', x));
10
- t = rb_funcall1(rb_bigmath_sqrt(rb_num_uminus(t), prec), '+', x);
11
- arg = rb_num_negative_p(x) ? rb_bigmath_const_pi(prec) : BIG_ZERO;
12
- imag = rb_bigmath_log(rb_num_abs(t), prec);
11
+ t = rb_funcall1(rb_bigmath_sqrt(rb_num_uminus(t), n), '+', x);
12
+ arg = rb_num_negative_p(x) ? rb_bigmath_const_pi(n) : BIG_ZERO;
13
+ imag = rb_bigmath_log(rb_num_abs(t), n);
13
14
  y = rb_Complex(arg, imag);
14
15
 
15
- return y;
16
+ return rb_num_round(y, prec);
16
17
  }
@@ -3,19 +3,20 @@ asec_logrep(VALUE x, VALUE prec)
3
3
  {
4
4
  const ID div = rb_intern("div");
5
5
  const ID sub = rb_intern("sub");
6
- VALUE t, pi_2;
6
+ VALUE t, pi_2, n;
7
7
 
8
8
  rb_check_precise(prec);
9
+ n = rb_numdiff_make_n(prec);
9
10
 
10
- x = rb_num_canonicalize(x, prec, ARG_REAL, ARG_RECIPROCAL);
11
+ x = rb_num_canonicalize(x, n, ARG_REAL, ARG_RECIPROCAL);
11
12
  t = rb_funcall1(x, '*', x);
12
13
  t = rb_funcall1(INT2FIX(1), '-', t);
13
- t = rb_bigmath_sqrt(t, prec);
14
+ t = rb_bigmath_sqrt(t, n);
14
15
  t = rb_funcall1(x, '/', t);
15
- t = rb_bigmath_atan(t, prec);
16
+ t = rb_bigmath_atan(t, n);
16
17
  pi_2 = rb_funcall(
17
- rb_bigmath_const_pi(prec), div, 2, INT2FIX(2), prec);
18
- t = rb_funcall(pi_2, sub, 2, t, prec);
18
+ rb_bigmath_const_pi(n), div, 2, INT2FIX(2), n);
19
+ t = rb_funcall(pi_2, sub, 2, t, n);
19
20
 
20
- return t;
21
+ return rb_num_round(t, prec);
21
22
  }
@@ -1,19 +1,23 @@
1
1
  VALUE
2
2
  asech_edom(VALUE x, VALUE prec)
3
3
  {
4
- VALUE absx, recip_x, sqr, w, y;
4
+ VALUE absx, recip_x, sqr, w, y, n;
5
+
6
+ rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
5
8
 
6
9
  absx = rb_num_abs(x);
7
- recip_x = rb_num_canonicalize(absx, prec, ARG_REAL, ARG_RECIPROCAL);
10
+ recip_x = rb_num_canonicalize(absx, n, ARG_REAL, ARG_RECIPROCAL);
8
11
  sqr = rb_funcall1(
9
12
  rb_funcall1(BIG_ONE, '-', absx), '/',
10
13
  rb_funcall1(absx, '+', BIG_ONE));
11
- w = rb_Complex(BIG_ZERO, rb_bigmath_sqrt(sqr, prec));
14
+ w = rb_Complex(BIG_ZERO, rb_bigmath_sqrt(sqr, n));
12
15
  w = rb_funcall1(w, '*', rb_funcall1(recip_x, '+', BIG_ONE));
13
16
  w = rb_funcall1(w, '+', recip_x);
14
- y = rb_bigmath_carg(w, prec);
17
+ y = rb_bigmath_carg(w, n);
15
18
  if (rb_num_negative_p(x))
16
- y =rb_funcall1(rb_bigmath_const_pi(prec), '-', y);
19
+ y =rb_funcall1(rb_bigmath_const_pi(n), '-', y);
20
+ y = rb_Complex(BIG_ZERO, y);
17
21
 
18
- return rb_Complex(BIG_ZERO, y);
22
+ return rb_num_round(y, prec);
19
23
  }
@@ -1,13 +1,14 @@
1
1
  VALUE
2
2
  asech_logrep(VALUE x, VALUE prec)
3
3
  {
4
- VALUE y;
4
+ VALUE y, n;
5
5
 
6
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
7
8
 
8
9
  y = rb_funcall1(x, '*', x);
9
10
  y = rb_funcall1(BIG_ONE, '-', y);
10
- y = rb_bigmath_sqrt(y, prec);
11
+ y = rb_bigmath_sqrt(y, n);
11
12
  y = rb_funcall1(y, '+', BIG_ONE);
12
13
  y = rb_funcall1(y, '/', x);
13
14
  y = rb_bigmath_log(y, prec);
@@ -2,19 +2,20 @@ VALUE
2
2
  asin_edom(VALUE x, VALUE prec)
3
3
  {
4
4
  const ID div = rb_intern("div");
5
- VALUE imag, y, arg, t;
5
+ VALUE imag, y, arg, t, n;
6
6
 
7
7
  rb_check_precise(prec);
8
+ n = rb_numdiff_make_n(prec);
8
9
 
9
10
  t = rb_funcall1(BIG_ONE, '-', rb_funcall1(x, '*', x));
10
- t = rb_funcall1(rb_bigmath_sqrt(rb_num_uminus(t), prec), '+', x);
11
+ t = rb_funcall1(rb_bigmath_sqrt(rb_num_uminus(t), n), '+', x);
11
12
  arg = rb_funcall(
12
- rb_bigmath_const_pi(prec), div, 2, INT2FIX(2), prec);
13
+ rb_bigmath_const_pi(n), div, 2, INT2FIX(2), n);
13
14
  if (!rb_num_negative_p(x))
14
15
  arg = rb_num_uminus(arg);
15
- imag = rb_bigmath_log(rb_num_abs(t), prec);
16
+ imag = rb_bigmath_log(rb_num_abs(t), n);
16
17
  y = rb_Complex(arg, imag);
17
18
  y = rb_num_uminus(y);
18
19
 
19
- return y;
20
+ return rb_num_round(y, prec);
20
21
  }
@@ -1,13 +1,14 @@
1
1
  VALUE
2
2
  asin_logrep(VALUE x, VALUE prec)
3
3
  {
4
- VALUE t;
4
+ VALUE t, n;
5
5
 
6
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
7
8
 
8
9
  t = rb_funcall1(x, '*', x);
9
10
  t = rb_funcall1(INT2FIX(1), '-', t);
10
- t = rb_bigmath_sqrt(t, prec);
11
+ t = rb_bigmath_sqrt(t, n);
11
12
  t = rb_funcall1(x, '/', t);
12
13
  t = rb_bigmath_atan(t, prec);
13
14
 
@@ -4,6 +4,7 @@ asin_ser(VALUE x, VALUE prec)
4
4
  const ID mult = rb_intern("mult");
5
5
  VALUE one, i, d, x2, y, n, m;
6
6
 
7
+ rb_check_precise(prec);
7
8
  n = rb_numdiff_make_n(prec);
8
9
 
9
10
  one = BIG_ONE;
@@ -1,21 +1,22 @@
1
1
  VALUE
2
2
  asinh_logrep(VALUE x, VALUE prec)
3
3
  {
4
- VALUE t, y;
4
+ VALUE t, y, n;
5
5
 
6
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
7
8
 
8
9
  if (rb_num_positive_p(x))
9
10
  {
10
11
  t = rb_funcall1(rb_funcall1(x, '*', x), '+', BIG_ONE);
11
- t = rb_bigmath_sqrt(t, prec);
12
- y = rb_bigmath_log(rb_funcall1(x, '+', t), prec);
12
+ t = rb_bigmath_sqrt(t, n);
13
+ y = rb_bigmath_log(rb_funcall1(x, '+', t), n);
13
14
  }
14
15
  else if (rb_num_negative_p(x))
15
16
  {
16
17
  t = rb_funcall1(rb_funcall1(x, '*', x), '+', BIG_ONE);
17
- t = rb_bigmath_sqrt(t, prec);
18
- t = rb_bigmath_log(rb_funcall1(t, '-', x), prec);
18
+ t = rb_bigmath_sqrt(t, n);
19
+ t = rb_bigmath_log(rb_funcall1(t, '-', x), n);
19
20
  y = rb_num_uminus(t);
20
21
  }
21
22
  else
@@ -5,6 +5,7 @@ asinh_ser(VALUE x, VALUE prec)
5
5
  VALUE n, m;
6
6
  VALUE one, two, x2, c, t, f_n, f_m, d, y, i;
7
7
 
8
+ rb_check_precise(prec);
8
9
  n = rb_numdiff_make_n(prec);
9
10
 
10
11
  one = BIG_ONE;
@@ -1,14 +1,15 @@
1
1
  VALUE
2
2
  atan_logrep(VALUE x, VALUE prec)
3
3
  {
4
- VALUE n, m, y;
4
+ VALUE n1, m1, y, n;
5
5
 
6
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
7
8
 
8
- n = rb_Complex(BIG_ONE, x);
9
- m = rb_bigmath_sqrt(rb_funcall1(BIG_ONE, '+', rb_funcall1(x, '*', x)), prec);
10
- y = rb_funcall1(n, '/', m);
11
- y = rb_bigmath_carg(y, prec);
9
+ n1 = rb_Complex(BIG_ONE, x);
10
+ m1 = rb_bigmath_sqrt(rb_funcall1(BIG_ONE, '+', rb_funcall1(x, '*', x)), n);
11
+ y = rb_funcall1(n1, '/', m1);
12
+ y = rb_bigmath_carg(y, n);
12
13
 
13
- return y;
14
+ return rb_num_round(y, prec);
14
15
  }
@@ -9,6 +9,8 @@ atan_ser_euler(VALUE x, VALUE prec)
9
9
  VALUE m, y, w, t, s;
10
10
  long n = 1;
11
11
 
12
+ rb_check_precise(prec);
13
+
12
14
  if (rb_num_zero_p(x))
13
15
  return BIG_ZERO;
14
16
 
@@ -1,14 +1,17 @@
1
1
  VALUE
2
2
  atanh_edom(VALUE x, VALUE prec)
3
3
  {
4
- VALUE t, pi;
4
+ VALUE t, pi, n;
5
+
6
+ rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
5
8
 
6
9
  t = rb_funcall1(
7
10
  rb_funcall1(BIG_ONE, '+', x), '/',
8
11
  rb_funcall1(BIG_ONE, '-', x));
9
- pi = rb_bigmath_const_pi(prec);
12
+ pi = rb_bigmath_const_pi(n);
10
13
  t = rb_Complex(
11
- rb_bigmath_log(rb_num_abs(t), prec),
14
+ rb_bigmath_log(rb_num_abs(t), n),
12
15
  rb_num_negative_p(x) ? pi : rb_num_uminus(pi));
13
16
  t = rb_funcall1(rb_Rational(INT2FIX(1), INT2FIX(2)), '*', t);
14
17
 
@@ -5,6 +5,8 @@ atanh_logrep(VALUE x, VALUE prec)
5
5
  const ID mult = rb_intern("mult");
6
6
  VALUE n, half;
7
7
 
8
+ rb_check_precise(prec);
9
+
8
10
  n = rb_numdiff_make_n(prec);
9
11
  half = rb_BigDecimal1(rb_str_new_cstr("0.5"));
10
12
 
@@ -5,6 +5,7 @@ atanh_ser(VALUE x, VALUE prec)
5
5
  const ID mult = rb_intern("mult");
6
6
  VALUE one, two, i, d, y, x2, n, m;
7
7
 
8
+ rb_check_precise(prec);
8
9
  n = rb_numdiff_make_n(prec);
9
10
 
10
11
  one = BIG_ONE;
@@ -1,8 +1,12 @@
1
1
  VALUE
2
2
  cabs_formula(VALUE z, VALUE prec)
3
3
  {
4
+ VALUE w, n;
5
+
4
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
5
8
 
6
- return rb_bigmath_l2norm(
7
- rb_assoc_new(rb_num_real(z), rb_num_imag(z)), prec);
9
+ w = rb_bigmath_l2norm(
10
+ rb_assoc_new(rb_num_real(z), rb_num_imag(z)), n);
11
+ return rb_num_round(w, prec);
8
12
  }
@@ -2,14 +2,17 @@ VALUE
2
2
  cacos_logrep(VALUE z, VALUE prec)
3
3
  {
4
4
  const ID div = rb_intern("div");
5
- VALUE c1, c2, c3, c4, c5, c6;
5
+ VALUE c1, c2, c3, c4, c5, c6, n;
6
+
7
+ rb_check_precise(prec);
8
+ n = rb_numdiff_make_n(prec);
6
9
 
7
10
  c1 = rb_ImaginaryZ(z, SIGN_PLUS);
8
11
  c2 = rb_bigmath_csqrt(rb_funcall1(BIG_ONE, '-',
9
- rb_funcall1(z, '*', z)), prec);
10
- c3 = rb_bigmath_clog(rb_funcall1(c1, '+', c2), prec);
12
+ rb_funcall1(z, '*', z)), n);
13
+ c3 = rb_bigmath_clog(rb_funcall1(c1, '+', c2), n);
11
14
  c4 = rb_ImaginaryZ(c3, SIGN_PLUS);
12
- c5 = rb_funcall(rb_bigmath_const_pi(prec), div, 2, INT2FIX(2), prec);
15
+ c5 = rb_funcall(rb_bigmath_const_pi(n), div, 2, INT2FIX(2), n);
13
16
  c6 = rb_funcall1(c5, '+', c4);
14
17
 
15
18
  return rb_num_round(c6, prec);
@@ -1,17 +1,18 @@
1
1
  VALUE
2
2
  cacosh_logrep(VALUE z, VALUE prec)
3
3
  {
4
- VALUE c1, c2, c3;
4
+ VALUE c1, c2, c3, n;
5
5
 
6
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
7
8
 
8
9
  c2 = rb_funcall1(z, '+', BIG_ONE);
9
- c2 = rb_bigmath_csqrt(c2, prec);
10
+ c2 = rb_bigmath_csqrt(c2, n);
10
11
  c3 = rb_funcall1(z, '-', BIG_ONE);
11
- c3 = rb_bigmath_csqrt(c3, prec);
12
+ c3 = rb_bigmath_csqrt(c3, n);
12
13
  c1 = rb_funcall1(c2, '*', c3);
13
14
  c1 = rb_funcall1(z, '+', c1);
14
- c1 = rb_bigmath_clog(c1, prec);
15
+ c1 = rb_bigmath_clog(c1, n);
15
16
 
16
- return c1;
17
+ return rb_num_round(c1, prec);
17
18
  }
@@ -1,14 +1,15 @@
1
1
  VALUE
2
2
  cacot_logrep(VALUE z, VALUE prec)
3
3
  {
4
- VALUE c1, c2, c3;
4
+ VALUE c1, c2, c3, n;
5
5
 
6
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
7
8
 
8
9
  c1 = rb_ImaginaryZ(z, SIGN_PLUS);
9
10
  c2 = rb_funcall1(rb_funcall1(c1, '-', BIG_ONE), '/',
10
11
  rb_funcall1(c1, '+', BIG_ONE));
11
- c3 = rb_bigmath_clog(c2, prec);
12
+ c3 = rb_bigmath_clog(c2, n);
12
13
 
13
14
  c1 = rb_funcall1(rb_Complex(INT2FIX(0), INT2FIX(1)), '/', INT2FIX(2));
14
15
  c2 = rb_funcall1(rb_num_uminus(c1), '*', c3);
@@ -1,11 +1,15 @@
1
1
  VALUE
2
2
  cacoth_logrep(VALUE z, VALUE prec)
3
3
  {
4
+ VALUE n;
5
+
4
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
5
8
 
6
- z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RAWVALUE);
9
+ z = rb_num_canonicalize(z, n, ARG_COMPLEX, ARG_RAWVALUE);
7
10
  z = rb_ImaginaryZ(z, SIGN_MINUS);
8
- z = cacot_logrep(z, prec);
9
-
10
- return rb_ImaginaryZ(z, SIGN_MINUS);
11
+ z = cacot_logrep(z, n);
12
+ z = rb_ImaginaryZ(z, SIGN_MINUS);
13
+
14
+ return rb_num_round(z, prec);
11
15
  }
@@ -1,18 +1,19 @@
1
1
  VALUE
2
2
  cacsc_logrep(VALUE z, VALUE prec)
3
3
  {
4
- VALUE y;
4
+ VALUE y, n;
5
5
 
6
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
7
8
 
8
9
  y = rb_funcall1(z, '*', z);
9
10
  y = rb_funcall1(BIG_ONE, '/', y);
10
11
  y = rb_funcall1(BIG_ONE, '-', y);
11
- y = rb_bigmath_csqrt(y, prec);
12
+ y = rb_bigmath_csqrt(y, n);
12
13
  y = rb_Complex(y,
13
14
  rb_num_canonicalize(
14
- rb_num_uminus(z), prec, ARG_COMPLEX, ARG_RECIPROCAL));
15
- y = rb_bigmath_clog(y, prec);
15
+ rb_num_uminus(z), n, ARG_COMPLEX, ARG_RECIPROCAL));
16
+ y = rb_bigmath_clog(y, n);
16
17
  y = rb_ImaginaryZ(y, SIGN_PLUS);
17
18
 
18
19
  return rb_num_round(y, prec);
@@ -1,11 +1,15 @@
1
1
  VALUE
2
2
  cacsch_logrep(VALUE z, VALUE prec)
3
3
  {
4
+ VALUE n;
5
+
4
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
5
8
 
6
- z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RAWVALUE);
9
+ z = rb_num_canonicalize(z, n, ARG_COMPLEX, ARG_RAWVALUE);
10
+ z = rb_ImaginaryZ(z, SIGN_PLUS);
11
+ z = cacsc_logrep(z, n);
7
12
  z = rb_ImaginaryZ(z, SIGN_PLUS);
8
- z = cacsc_logrep(z, prec);
9
13
 
10
- return rb_ImaginaryZ(z, SIGN_PLUS);
14
+ return rb_num_round(z, prec);
11
15
  }
@@ -1,8 +1,12 @@
1
1
  VALUE
2
2
  carg_formula(VALUE z, VALUE prec)
3
3
  {
4
+ VALUE n;
5
+
4
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
5
8
 
6
- return rb_bigmath_quadrant(
7
- rb_num_real(z), rb_num_imag(z), prec);
9
+ z = rb_bigmath_quadrant(rb_num_real(z), rb_num_imag(z), n);
10
+
11
+ return rb_num_round(z, prec);
8
12
  }
@@ -1,17 +1,18 @@
1
1
  VALUE
2
2
  casec_logrep(VALUE z, VALUE prec)
3
3
  {
4
- VALUE w;
4
+ VALUE w, n;
5
5
 
6
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
7
8
 
8
9
  w = rb_funcall1(z, '*', z);
9
10
  w = rb_funcall1(BIG_ONE, '/', w);
10
11
  w = rb_funcall1(BIG_ONE, '-', w);
11
- w = rb_bigmath_csqrt(w, prec);
12
+ w = rb_bigmath_csqrt(w, n);
12
13
  w = rb_funcall1(rb_ImaginaryZ(w, SIGN_PLUS), '+',
13
- rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RECIPROCAL));
14
- w = rb_bigmath_clog(w, prec);
14
+ rb_num_canonicalize(z, n, ARG_COMPLEX, ARG_RECIPROCAL));
15
+ w = rb_bigmath_clog(w, n);
15
16
  w = rb_ImaginaryZ(w, SIGN_MINUS);
16
17
 
17
18
  return rb_num_round(w, prec);
@@ -1,9 +1,11 @@
1
1
  VALUE
2
2
  casech_logrep(VALUE z, VALUE prec)
3
3
  {
4
+ VALUE n;
4
5
  rb_check_precise(prec);
6
+ n = rb_numdiff_make_n(prec);
5
7
 
6
- z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RECIPROCAL);
8
+ z = rb_num_canonicalize(z, n, ARG_COMPLEX, ARG_RECIPROCAL);
7
9
 
8
10
  return cacosh_logrep(z, prec);
9
11
  }
@@ -1,14 +1,16 @@
1
1
  VALUE
2
2
  casin_logrep(VALUE z, VALUE prec)
3
3
  {
4
- VALUE c1, c2, c3;
4
+ VALUE c1, c2, c3, n;
5
5
 
6
6
  rb_check_precise(prec);
7
+ n = rb_numdiff_make_n(prec);
7
8
 
8
9
  c1 = rb_ImaginaryZ(z, SIGN_PLUS);
9
10
  c2 = rb_bigmath_csqrt(
10
- rb_funcall1(BIG_ONE, '-', rb_funcall1(z, '*', z)), prec);
11
- c3 = rb_bigmath_clog(rb_funcall1(c1, '+', c2), prec);
11
+ rb_funcall1(BIG_ONE, '-', rb_funcall1(z, '*', z)), n);
12
+ c3 = rb_bigmath_clog(rb_funcall1(c1, '+', c2), n);
13
+ z = rb_ImaginaryZ(c3, SIGN_MINUS);
12
14
 
13
- return rb_ImaginaryZ(c3, SIGN_MINUS);
15
+ return rb_num_round(z, prec);
14
16
  }
@@ -3,6 +3,7 @@ casinh_logrep(VALUE z, VALUE prec)
3
3
  {
4
4
  VALUE n, t, y;
5
5
 
6
+ rb_check_precise(prec);
6
7
  n = rb_numdiff_make_n(prec);
7
8
 
8
9
  t = rb_funcall1(rb_funcall1(z, '*', z), '+', BIG_ONE);