bigdecimal-math_r 0.2.1 → 0.2.3

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 +16 -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. data/lib/bigdecimal/math_r.so +0 -0
  163. metadata +20 -9
  164. data/.ruby-version +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 719ac1d5b1b20031ea157c824a660307e45adf15bf00edd6f906eaef31e8ef47
4
- data.tar.gz: 4340bfae2018a9c332991f5c5e0ab4833f0ad914a15a05729ae68e07833a25fd
3
+ metadata.gz: 518812b6a73ac402e7e68bbab7063ccda4cf1f65dc52bd7267894252e56308b7
4
+ data.tar.gz: a16aa529cbf7f3da0f9aec0699ee447cfff6925c7a6d2b30cfff2693dc346310
5
5
  SHA512:
6
- metadata.gz: 7eb916c9ab6c4f2288c7b8a5c9d36dfe5879bf547082fba2be2e4ea01925e97fd5de4f7445d0d28dee03faa457502d8a86107ac71d5c417d1508cf8a2e4a44dd
7
- data.tar.gz: 2fcc65443645680121c138272d4825d9707fa9296936b114ab2e630f49213f0710ada866c3c080bc9c38a332a7e9f5cdefb24bac2e0c528efec910cbc35cb6ef
6
+ metadata.gz: 473370ffad4f28e5679d52ff5b164270fba4cc39bb83befbcc108a168449d52b6383952dddd1c00edf885bc4ffab0eff95ede1e356a09f59ec16389fc2bfc08e
7
+ data.tar.gz: 9976dcd853ca1209736a19d65f4b184d7d01a6d8d05c744c0415d0da15d4c423b94ec6c82a6d770928b317d4f72dd289a0c04f32836cd088ba07cc6fe3760bb9
data/changelog.md CHANGED
@@ -7,6 +7,22 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.2] - 2025-10-XX
11
+
12
+ ### Changed
13
+ - The names of mathematical constants were unified by the discoverer
14
+ - Renamed `BigMathR::Const::E.ser` to `BigMathR::Const::E.napier`
15
+ - Renamed `BigMathR::GammaR` to `BigMathR::GammaBeta`
16
+
17
+ ### Added
18
+ - `BigMathR::Const::E#euler`. Continued fraction type constant $e$ .
19
+ - `BigMathR::Const::E#euler_number`. It is an alias of `napier`.
20
+ - `BigMathR::Const::EulerGamma#borwein_bailey`. Brent-McMillan type constant $\gamma$ .
21
+ - `BigMathR::Const::EulerGamma#brent_mcmillan`. It is an alias of `borwein_bailey`.
22
+ - `BigMathR#EulerGamma`.
23
+ - Branches for the logarithmic functions.
24
+ - `expm1` Function.
25
+
10
26
  ## [0.2.1] - 2025-05-XX
11
27
 
12
28
  ### Changed
@@ -1,7 +1,8 @@
1
1
  #ifndef BIGMATH_ALGOFUNC_H
2
2
  #define BIGMATH_ALGOFUNC_H
3
3
 
4
- #include "internal/algo/bigmath/E/ser.h"
4
+ #include "internal/algo/bigmath/E/napier.h"
5
+ #include "internal/algo/bigmath/EulerGamma/borwein_bailey.h"
5
6
  #include "internal/algo/bigmath/LOG10/ser.h"
6
7
  #include "internal/algo/bigmath/LOG2/BBP2002.h"
7
8
  #include "internal/algo/bigmath/LOG_PI/builtin.h"
@@ -72,6 +73,7 @@
72
73
  #include "internal/algo/bigmath/catan/logrep.h"
73
74
  #include "internal/algo/bigmath/catanh/branch.h"
74
75
  #include "internal/algo/bigmath/catanh/logrep.h"
76
+ #include "internal/algo/bigmath/ccbrt/branch.h"
75
77
  #include "internal/algo/bigmath/ccbrt/formula.h"
76
78
  #include "internal/algo/bigmath/ccos/branch.h"
77
79
  #include "internal/algo/bigmath/ccos/eulerf.h"
@@ -89,10 +91,14 @@
89
91
  #include "internal/algo/bigmath/cexp/eulerf.h"
90
92
  #include "internal/algo/bigmath/cexp2/branch.h"
91
93
  #include "internal/algo/bigmath/cexp2/eulerf.h"
94
+ #include "internal/algo/bigmath/cexpm1/branch.h"
95
+ #include "internal/algo/bigmath/cexpm1/identity.h"
92
96
  #include "internal/algo/bigmath/clog/branch.h"
93
97
  #include "internal/algo/bigmath/clog/formula.h"
98
+ #include "internal/algo/bigmath/clog10/branch.h"
94
99
  #include "internal/algo/bigmath/clog10/formula.h"
95
100
  #include "internal/algo/bigmath/clog1p/branch.h"
101
+ #include "internal/algo/bigmath/clog2/branch.h"
96
102
  #include "internal/algo/bigmath/clog2/formula.h"
97
103
  #include "internal/algo/bigmath/cos/branch.h"
98
104
  #include "internal/algo/bigmath/cos/eulerf.h"
@@ -124,11 +130,13 @@
124
130
  #include "internal/algo/bigmath/csin/eulerf.h"
125
131
  #include "internal/algo/bigmath/csinh/branch.h"
126
132
  #include "internal/algo/bigmath/csinh/eulerf.h"
133
+ #include "internal/algo/bigmath/csqrt/branch.h"
127
134
  #include "internal/algo/bigmath/csqrt/formula.h"
128
135
  #include "internal/algo/bigmath/ctan/branch.h"
129
136
  #include "internal/algo/bigmath/ctan/eulerf.h"
130
137
  #include "internal/algo/bigmath/ctanh/branch.h"
131
138
  #include "internal/algo/bigmath/ctanh/eulerf.h"
139
+ #include "internal/algo/bigmath/cuberoot/branch.h"
132
140
  #include "internal/algo/bigmath/cuberoot/newton.h"
133
141
  #include "internal/algo/bigmath/erf/algo911.h"
134
142
  #include "internal/algo/bigmath/erf/branch.h"
@@ -144,6 +152,8 @@
144
152
  #include "internal/algo/bigmath/exp/edf.h"
145
153
  #include "internal/algo/bigmath/exp2/branch.h"
146
154
  #include "internal/algo/bigmath/exp2/edf.h"
155
+ #include "internal/algo/bigmath/expm1/branch.h"
156
+ #include "internal/algo/bigmath/expm1/identity.h"
147
157
  #include "internal/algo/bigmath/expxt/edf.h"
148
158
  #include "internal/algo/bigmath/f_euler/formula.h"
149
159
  #include "internal/algo/bigmath/hypot/branch.h"
@@ -1,5 +1,5 @@
1
1
  VALUE
2
2
  rb_bigmath_const_e(VALUE prec)
3
3
  {
4
- return rb_bigmath_const(BIGMATH_E, E_ser, prec);
4
+ return rb_bigmath_const(BIGMATH_E, E_napier, prec);
5
5
  }
@@ -0,0 +1,5 @@
1
+ VALUE
2
+ rb_bigmath_const_euler_gamma(VALUE prec)
3
+ {
4
+ return rb_bigmath_const(BIGMATH_EulerGamma, EulerGamma_borwein_bailey, prec);
5
+ }
@@ -1,5 +1,5 @@
1
1
  VALUE
2
2
  rb_bigmath_csqrt(VALUE z, VALUE prec)
3
3
  {
4
- return csqrt_formula(z, prec);
4
+ return csqrt_branch(z, prec, csqrt_formula);
5
5
  }
@@ -3,7 +3,13 @@ rb_BigDecimal_flo(VALUE x)
3
3
  {
4
4
  const ID BigDecimal = rb_intern("BigDecimal");
5
5
  const ID DIG = rb_intern("DIG");
6
- VALUE FLOAT_DIG = rb_const_get_at(rb_cFloat, DIG);
7
- VALUE y = rb_funcall(rb_cObject, BigDecimal, 2, x, FLOAT_DIG);
6
+ VALUE FLOAT_DIG, y;
7
+ if (rb_num_nan_p(x))
8
+ y = BIG_NAN;
9
+ else
10
+ {
11
+ FLOAT_DIG = rb_const_get_at(rb_cFloat, DIG);
12
+ y = rb_funcall(rb_cObject, BigDecimal, 2, x, FLOAT_DIG);
13
+ }
8
14
  return y;
9
15
  }
@@ -1,5 +1,8 @@
1
1
  bool
2
2
  rb_num_nan_p(VALUE z)
3
3
  {
4
- return rb_num_notequal_p(z, z);
4
+ if (rb_num_real_p(z))
5
+ return rb_num_notequal_p(z, z);
6
+ else
7
+ return !rb_num_finite_p(z) && !rb_num_infinite_p(z);
5
8
  }
@@ -20,6 +20,7 @@
20
20
  #include "api/bigmath/clog.h"
21
21
  #include "api/bigmath/const.h"
22
22
  #include "api/bigmath/const_e.h"
23
+ #include "api/bigmath/const_euler_gamma.h"
23
24
  #include "api/bigmath/const_log10.h"
24
25
  #include "api/bigmath/const_log2.h"
25
26
  #include "api/bigmath/const_log_pi.h"
@@ -50,6 +51,7 @@
50
51
  #include "api/numeric/abs.h"
51
52
  #include "api/numeric/canonicalize.h"
52
53
  #include "api/numeric/cmpeql.h"
54
+ #include "api/numeric/domain_p.h"
53
55
  #include "api/numeric/equal_p.h"
54
56
  #include "api/numeric/finite_p.h"
55
57
  #include "api/numeric/imag.h"
@@ -54,6 +54,21 @@ __impl_const_e(VALUE unused_obj, VALUE prec)
54
54
  return rb_bigmath_const_e(prec);
55
55
  }
56
56
 
57
+ /**
58
+ * The Euler-Mascheroni constant gamma.
59
+ * @example
60
+ * BigMathR.EulerGamma(20) #=>
61
+ * @param prec [Integer] Arbitrary precision
62
+ * @return [BigDecimal] Real solution
63
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
64
+ * @since 0.1.0
65
+ */
66
+ static VALUE
67
+ __impl_const_euler_gamma(VALUE unused_obj, VALUE prec)
68
+ {
69
+ return rb_bigmath_const_euler_gamma(prec);
70
+ }
71
+
57
72
  /**
58
73
  * The natural logarithm of 2.
59
74
  * @example
@@ -135,7 +150,7 @@ __impl_const_pi_machin(VALUE unused_obj, VALUE prec)
135
150
  * Implement by series expansion: sum_(n=0)^infty 1/n!
136
151
  *
137
152
  * @example
138
- * BigMathR::Const::E.ser(20)
153
+ * BigMathR::Const::E.napier(20)
139
154
  * #=> 0.27182818284590452354e1
140
155
  * @param prec [Integer] Arbitrary precision
141
156
  * @return [BigDecimal] Natural logarithm of 2
@@ -143,9 +158,26 @@ __impl_const_pi_machin(VALUE unused_obj, VALUE prec)
143
158
  * @raise [RangeError] Zero or negative precision
144
159
  */
145
160
  static VALUE
146
- __impl_const_e_ser(VALUE unused_obj, VALUE prec)
161
+ __impl_const_e_napier(VALUE unused_obj, VALUE prec)
162
+ {
163
+ return E_napier(prec);
164
+ }
165
+
166
+ /**
167
+ * Implement by Borwein-Bailey's formula (Brent-McMillan type formula)
168
+ *
169
+ * @example
170
+ * BigMathR::Const::EulerGamma.borwein_bailey(20)
171
+ * #=>
172
+ * @param prec [Integer] Arbitrary precision
173
+ * @return [BigDecimal] Natural logarithm of 2
174
+ * @raise [TypeError] not an Integer
175
+ * @raise [RangeError] Zero or negative precision
176
+ */
177
+ static VALUE
178
+ __impl_const_euler_gamma_borwein_bailey(VALUE unused_obj, VALUE prec)
147
179
  {
148
- return E_ser(prec);
180
+ return EulerGamma_borwein_bailey(prec);
149
181
  }
150
182
 
151
183
  /**
@@ -172,6 +204,7 @@ InitVM_Const(void)
172
204
  {
173
205
  rb_define_module_function(rb_mBigMathR, "PI", __impl_const_pi, 1);
174
206
  rb_define_module_function(rb_mBigMathR, "E", __impl_const_e, 1);
207
+ rb_define_module_function(rb_mBigMathR, "EulerGamma", __impl_const_euler_gamma, 1);
175
208
  rb_define_module_function(rb_mBigMathR, "LOG2", __impl_const_log2, 1);
176
209
  rb_define_module_function(rb_mBigMathR, "LOG_PI", __impl_const_log_pi, 1);
177
210
  rb_define_module_function(rb_mBigMathR, "LOG10", __impl_const_log10, 1);
@@ -179,8 +212,12 @@ InitVM_Const(void)
179
212
  rb_define_module_function(rb_mBigMathR, "SQRT3", __impl_const_sqrt3, 1);
180
213
 
181
214
  rb_define_module_function(rb_mConstPI, "machin", __impl_const_pi_machin, 1);
182
- rb_define_module_function(rb_mConstE, "ser", __impl_const_e_ser, 1);
215
+ rb_define_module_function(rb_mConstE, "napier", __impl_const_e_napier, 1);
216
+ rb_define_module_function(rb_mConstE, "euler_number", __impl_const_e_napier, 1);
217
+ rb_define_module_function(rb_mConstEulerGamma, "borwein_bailey",
218
+ __impl_const_euler_gamma_borwein_bailey, 1);
219
+ rb_define_module_function(rb_mConstEulerGamma, "brent_mcmillan",
220
+ __impl_const_euler_gamma_borwein_bailey, 1);
183
221
  rb_define_module_function(rb_mConstLOG2, "bbp2002", __impl_const_log2_bbp2002, 1);
184
-
185
222
  }
186
223
 
@@ -1,7 +1,8 @@
1
1
  #ifndef BIGMATH_MATHFUNC_H
2
2
  #define BIGMATH_MATHFUNC_H
3
3
 
4
- VALUE E_ser(VALUE prec);
4
+ VALUE E_napier(VALUE prec);
5
+ VALUE EulerGamma_borwein_bailey(VALUE prec);
5
6
  VALUE LOG10_ser(VALUE prec);
6
7
  VALUE LOG2_BBP2002(VALUE prec);
7
8
  VALUE LOG_PI_builtin(VALUE prec);
@@ -72,6 +73,7 @@ VALUE catan_branch(VALUE x, VALUE prec, bigmath_func1 cb);
72
73
  VALUE catan_logrep(VALUE x, VALUE prec);
73
74
  VALUE catanh_branch(VALUE x, VALUE prec, bigmath_func1 cb);
74
75
  VALUE catanh_logrep(VALUE x, VALUE prec);
76
+ VALUE ccbrt_branch(VALUE x, VALUE prec, bigmath_func1 cb);
75
77
  VALUE ccbrt_formula(VALUE x, VALUE prec);
76
78
  VALUE ccos_branch(VALUE x, VALUE prec, bigmath_func1 cb);
77
79
  VALUE ccos_eulerf(VALUE x, VALUE prec);
@@ -89,10 +91,14 @@ VALUE cexp_branch(VALUE x, VALUE prec, bigmath_func1 cb);
89
91
  VALUE cexp_eulerf(VALUE x, VALUE prec);
90
92
  VALUE cexp2_branch(VALUE x, VALUE prec, bigmath_func1 cb);
91
93
  VALUE cexp2_eulerf(VALUE x, VALUE prec);
94
+ VALUE cexpm1_branch(VALUE x, VALUE prec, bigmath_func1 cb);
95
+ VALUE cexpm1_identity(VALUE x, VALUE prec);
92
96
  VALUE clog_branch(VALUE x, VALUE prec, bigmath_func1 cb);
93
97
  VALUE clog_formula(VALUE x, VALUE prec);
98
+ VALUE clog10_branch(VALUE x, VALUE prec, bigmath_func1 cb);
94
99
  VALUE clog10_formula(VALUE x, VALUE prec);
95
100
  VALUE clog1p_branch(VALUE x, VALUE prec, bigmath_func1 cb);
101
+ VALUE clog2_branch(VALUE x, VALUE prec, bigmath_func1 cb);
96
102
  VALUE clog2_formula(VALUE x, VALUE prec);
97
103
  VALUE cos_branch(VALUE x, VALUE prec, bigmath_func1 cb);
98
104
  VALUE cos_eulerf(VALUE x, VALUE prec);
@@ -124,11 +130,13 @@ VALUE csin_branch(VALUE x, VALUE prec, bigmath_func1 cb);
124
130
  VALUE csin_eulerf(VALUE x, VALUE prec);
125
131
  VALUE csinh_branch(VALUE x, VALUE prec, bigmath_func1 cb);
126
132
  VALUE csinh_eulerf(VALUE x, VALUE prec);
133
+ VALUE csqrt_branch(VALUE x, VALUE prec, bigmath_func1 cb);
127
134
  VALUE csqrt_formula(VALUE x, VALUE prec);
128
135
  VALUE ctan_branch(VALUE x, VALUE prec, bigmath_func1 cb);
129
136
  VALUE ctan_eulerf(VALUE x, VALUE prec);
130
137
  VALUE ctanh_branch(VALUE x, VALUE prec, bigmath_func1 cb);
131
138
  VALUE ctanh_eulerf(VALUE x, VALUE prec);
139
+ VALUE cuberoot_branch(VALUE x, VALUE prec, bigmath_func1 cb);
132
140
  VALUE cuberoot_newton(VALUE x, VALUE prec);
133
141
  VALUE erf_algo911(VALUE x, VALUE prec);
134
142
  VALUE erf_branch(VALUE x, VALUE prec, bigmath_func1 cb);
@@ -144,6 +152,8 @@ VALUE exp_builtin(VALUE x, VALUE prec);
144
152
  VALUE exp_edf(VALUE x, VALUE prec);
145
153
  VALUE exp2_branch(VALUE x, VALUE prec, bigmath_func1 cb);
146
154
  VALUE exp2_edf(VALUE x, VALUE prec);
155
+ VALUE expm1_branch(VALUE x, VALUE prec, bigmath_func1 cb);
156
+ VALUE expm1_identity(VALUE x, VALUE prec);
147
157
  VALUE expxt_edf(VALUE x, VALUE y, VALUE prec);
148
158
  VALUE f_euler_formula(VALUE x, VALUE prec);
149
159
  VALUE hypot_branch(VALUE x, VALUE y, VALUE prec, bigmath_func2 cb);
@@ -18,7 +18,7 @@
18
18
  * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
19
19
  * @raise [TypeError] Occurs when +x+ is not a numeric class.
20
20
  * @example
21
- * BigMathR::EDF.exp(1, 20)
21
+ * BigMathR::Exp.exp_edf(1, 20)
22
22
  * #=> 0.27182818284590452354e1
23
23
  * @since 0.1.0
24
24
  */
@@ -38,7 +38,7 @@ __impl_exp_edf(VALUE unused_obj, VALUE x, VALUE prec)
38
38
  * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
39
39
  * @raise [TypeError] Occurs when +x+ is not a numeric class.
40
40
  * @example
41
- * BigMathR::EDF.exp2(1/2r, 20)
41
+ * BigMathR::Exp.exp2_edf(1/2r, 20)
42
42
  * #=> 0.14142135623730950488e1
43
43
  * @since 0.1.0
44
44
  */
@@ -48,6 +48,46 @@ __impl_exp2_edf(VALUE unused_obj, VALUE x, VALUE prec)
48
48
  return exp2_branch(x, prec, exp2_edf);
49
49
  }
50
50
 
51
+ /**
52
+ * Computes the subtracted 1 from x of the exponential function.
53
+ * <br>
54
+ * The calculation is more accurate than +exp(x)-1+ when the argument is near zero.
55
+ * @param x [Numeric] Numerical argument
56
+ * @param prec [Integer] Arbitrary precision
57
+ * @return [BigDecimal] Real solution
58
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
59
+ * @raise [TypeError] Occurs when +x+ is not a numeric class.
60
+ * @example
61
+ * BigMathR::Exp.expm1_identity(BigDecimal(1), 20)
62
+ * #=> 0.17182818284590452354e1
63
+ * @since 0.2.2
64
+ */
65
+ static VALUE
66
+ __impl_expm1_identity(VALUE unused_obj, VALUE x, VALUE prec)
67
+ {
68
+ return expm1_branch(x, prec, expm1_identity);
69
+ }
70
+
71
+ /**
72
+ * Computes the subtracted 1 from +z+ of the exponential function.
73
+ *
74
+ * @param z [Numeric] Numerical argument
75
+ * @param prec [Integer] Arbitrary precision
76
+ * @return [Complex] Complex solution
77
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
78
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
79
+ * @example
80
+ * BigMathR::Exp.cexpm1_identity(1+1i, 20)
81
+ * # => (0.46869393991588515714e0+0.22873552871788423912e1i)
82
+ * @since 0.2.2
83
+ */
84
+ static VALUE
85
+ __impl_cexpm1_identity(VALUE unused_obj, VALUE z, VALUE prec)
86
+ {
87
+ return cexpm1_branch(z, prec, cexpm1_identity);
88
+ }
89
+
90
+
51
91
 
52
92
  /**
53
93
  * Document-module: BigMathR::Exp
@@ -62,11 +102,13 @@ __impl_exp2_edf(VALUE unused_obj, VALUE x, VALUE prec)
62
102
  * <br>
63
103
  * Exponential function: +exp()+ <br>
64
104
  * Base-2 (binary) exponent: +exp2()+ <br>
65
- *
105
+ * expm1 function: +expm1()+ <br>
66
106
  */
67
107
  void
68
108
  InitVM_Exp(void)
69
109
  {
70
110
  rb_define_module_function(rb_mExp, "exp_edf", __impl_exp_edf, 2);
71
111
  rb_define_module_function(rb_mExp, "exp2_edf", __impl_exp2_edf, 2);
112
+ rb_define_module_function(rb_mExp, "expm1_identity", __impl_expm1_identity, 2);
113
+ rb_define_module_function(rb_mExp, "cexpm1_identity", __impl_cexpm1_identity, 2);
72
114
  }
@@ -16,6 +16,7 @@ VOID = "void"
16
16
  MATHFUNCS = {
17
17
  "exp" => [VALUE, ARG1], "cexp" => [VALUE, ARG1],
18
18
  "exp2" => [VALUE, ARG1], "cexp2" => [VALUE, ARG1],
19
+ "expm1" => [VALUE, ARG1], "cexpm1" => [VALUE, ARG1],
19
20
  "expxt" => [VALUE, ARG2],
20
21
  "log" => [VALUE, ARG1], "clog" => [VALUE, ARG1],
21
22
  "log1p" => [VALUE, ARG1], "clog1p" => [VALUE, ARG1],
@@ -64,6 +65,7 @@ MATHFUNCS = {
64
65
  "f_euler" => [VALUE, ARG1],
65
66
  "PI"=>[VALUE, ARG_PREC],
66
67
  "E"=>[VALUE, ARG_PREC],
68
+ "EulerGamma"=>[VALUE, ARG_PREC],
67
69
  "LOG2"=>[VALUE, ARG_PREC],
68
70
  "LOG10"=>[VALUE, ARG_PREC],
69
71
  "LOG_PI"=>[VALUE, ARG_PREC],
@@ -74,11 +76,13 @@ MATHFUNCS = {
74
76
  CB_TYPE = {
75
77
  "exp" => "bigmath_func1", "cexp" => "bigmath_func1",
76
78
  "exp2" => "bigmath_func1", "cexp2" => "bigmath_func1",
79
+ "expm1" => "bigmath_func1", "cexpm1" => "bigmath_func1",
77
80
  "log" => "bigmath_func1", "clog" => "bigmath_func1",
78
81
  "log2" => "bigmath_func1", "clog2" => "bigmath_func1",
79
82
  "log10" => "bigmath_func1", "clog10" => "bigmath_func1",
80
83
  "log1p" => "bigmath_func1", "clog1p" => "bigmath_func1",
81
- "sqrt" => "bigmath_func1",
84
+ "sqrt" => "bigmath_func1", "csqrt" => "bigmath_func1",
85
+ "cuberoot" => "bigmath_func1", "ccbrt" => "bigmath_func1",
82
86
  "sin" => "bigmath_func1", "csin" => "bigmath_func1",
83
87
  "cos" => "bigmath_func1", "ccos" => "bigmath_func1",
84
88
  "tan" => "bigmath_func1", "ctan" => "bigmath_func1",
@@ -1,5 +1,5 @@
1
1
  /*******************************************************************************
2
- gamma_r.c -- Regularized Incomplete Gamma Function
2
+ gamma_beta.c -- Gamma and Beta Functions
3
3
 
4
4
  Author: tribusonz
5
5
  Lisence: MIT
@@ -82,20 +82,20 @@ gammar_q(VALUE a, VALUE x, VALUE loggamma_a, VALUE prec)
82
82
  n = rb_numdiff_make_n(prec);
83
83
  la = one; lb = rb_funcall1(one, '+', rb_funcall1(x, '-', a)); // Laguerreの多項式
84
84
  // w = exp(a * log(x, prec) - x - loggamma_a, n);
85
- w = rb_funcall1(a, '*', rb_bigmath_log(x, prec));
85
+ w = rb_funcall1(a, '*', rb_bigmath_log(x, n));
86
86
  w = rb_funcall1(w, '-', x);
87
87
  w = rb_funcall1(w, '-', loggamma_a);
88
- w = rb_bigmath_exp(w, prec);
88
+ w = rb_bigmath_exp(w, n);
89
89
  result = rb_funcall1(w, '/', lb);
90
90
  big_k = two;
91
+
91
92
  for (int k = 2; k <= 1000; k++)
92
93
  {
93
94
  // temp = ((k - one - a) * (lb - la) + (k + x) * lb).div(k, n);
94
- temp = rb_funcall1(k, '-', rb_funcall1(one, '-', a));
95
+ temp = rb_funcall1(big_k, '-', rb_funcall1(one, '-', a));
95
96
  temp = rb_funcall1(temp, '*', rb_funcall1(lb, '-', la));
96
- temp = rb_funcall1(temp, '+', rb_funcall1(rb_funcall1(k, '+', x), '*', lb));
97
+ temp = rb_funcall1(temp, '+', rb_funcall1(rb_funcall1(big_k, '+', x), '*', lb));
97
98
  temp = rb_funcall(temp, div, 2, big_k, n);
98
-
99
99
  la = lb; lb = temp;
100
100
  // w *= (k - one - a) / k;
101
101
  temp = rb_funcall1(rb_funcall1(big_k, '-', one), '-', a);
@@ -126,7 +126,6 @@ retval:
126
126
  return result;
127
127
  }
128
128
 
129
- // TODO: -1 <= x <= 1 以外はエラーが出る: `erf': undefined method `-' for nil (NoMethodError)
130
129
  VALUE
131
130
  erf_gammar(VALUE x, VALUE prec)
132
131
  {
@@ -140,35 +139,6 @@ erf_gammar(VALUE x, VALUE prec)
140
139
  return rb_num_round(y, prec);
141
140
  }
142
141
 
143
- VALUE
144
- erf_branch(VALUE x, VALUE prec, bigmath_func1 erf_cb)
145
- {
146
- VALUE y = Qundef;
147
- x = rb_num_canonicalize(x, prec, ARG_REAL, ARG_RAWVALUE);
148
- if (erf_cb == NULL)
149
- return BIG_NAN;
150
- if (!rb_num_finite_p(x))
151
- {
152
- if (rb_num_nan_p(x))
153
- y = BIG_NAN;
154
- else
155
- {
156
- switch (rb_num_infinite_p(x)) {
157
- case -1:
158
- y = BIG_MINUS_ONE;
159
- break;
160
- case 1:
161
- y = BIG_ONE;
162
- break;
163
- }
164
- }
165
- }
166
- if (y == Qundef)
167
- y = erf_cb(x, prec);
168
- return y;
169
- }
170
-
171
- // TODO: -1 <= x <= 1 以外はエラーが出る: `erf': undefined method `-' for nil (NoMethodError)
172
142
  VALUE
173
143
  erfc_gammar(VALUE x, VALUE prec)
174
144
  {
@@ -188,64 +158,27 @@ erfc_gammar(VALUE x, VALUE prec)
188
158
  return rb_num_round(y, prec);
189
159
  }
190
160
 
191
- VALUE
192
- erfc_branch(VALUE x, VALUE prec, bigmath_func1 erfc_cb)
193
- {
194
- VALUE y = Qundef;
195
- x = rb_num_canonicalize(x, prec, ARG_REAL, ARG_RAWVALUE);
196
- if (erfc_cb == NULL)
197
- return BIG_NAN;
198
- if (!rb_num_finite_p(x))
199
- {
200
- if (rb_num_nan_p(x))
201
- y = BIG_NAN;
202
- else
203
- {
204
- switch (rb_num_infinite_p(x)) {
205
- case -1:
206
- y = rb_BigDecimal1(INT2FIX(2));
207
- break;
208
- case 1:
209
- y = BIG_ZERO;
210
- break;
211
- }
212
- }
213
- }
214
- if (y == Qundef)
215
- y = erfc_cb(x, prec);
216
- return y;
217
- }
218
-
219
-
220
161
 
221
162
 
222
163
  static VALUE
223
- __impl_gammar_erf(VALUE unused_obj, VALUE x, VALUE prec)
164
+ __impl_gammabeta_erf(VALUE unused_obj, VALUE x, VALUE prec)
224
165
  {
225
166
  return erf_branch(x, prec, erf_gammar);
226
167
  }
227
168
 
228
169
 
229
170
  static VALUE
230
- __impl_gammar_erfc(VALUE unused_obj, VALUE x, VALUE prec)
171
+ __impl_gammabeta_erfc(VALUE unused_obj, VALUE x, VALUE prec)
231
172
  {
232
173
  return erfc_branch(x, prec, erfc_gammar);
233
174
  }
234
-
235
-
236
- // TODO: eps-16の誤差がある。
237
- // |erf(1) - 0.84270079294971474562456763838456194738845892814039e0|
238
- // 結果: 1.237166529966980473119076080698259... × 10^-16
239
- // |erfc(1) - 0.15729920705028525437543236161543805261154107185961e0|
240
- // 結果: 1.2371665299669804731190760806982591... × 10^-16
241
-
242
175
  #endif
243
176
 
244
177
  void
245
- InitVM_GammaR(void)
178
+ InitVM_GammaBeta(void)
246
179
  {
247
180
  #if 0
248
- rb_define_module_function(rb_mGammaR, "erf", __impl_gammar_erf, 2);
249
- rb_define_module_function(rb_mGammaR, "erfc", __impl_gammar_erfc, 2);
181
+ rb_define_module_function(rb_mGammaBeta, "erf", __impl_gammabeta_erf, 2);
182
+ rb_define_module_function(rb_mGammaBeta, "erfc", __impl_gammabeta_erfc, 2);
250
183
  #endif
251
184
  }
@@ -1,5 +1,5 @@
1
1
  VALUE
2
- E_ser(VALUE prec)
2
+ E_napier(VALUE prec)
3
3
  {
4
4
  const ID div = rb_intern("div");
5
5
  VALUE n, m, a, e;
@@ -0,0 +1,37 @@
1
+ VALUE
2
+ EulerGamma_borwein_bailey(VALUE prec)
3
+ {
4
+ const ID add = rb_intern("add");
5
+ const ID div = rb_intern("div");
6
+ VALUE zero, one, m, n, nn, a, b, u, v, k;
7
+ rb_check_precise(prec);
8
+ zero = BIG_ZERO;
9
+ one = BIG_ONE;
10
+ n = rb_numdiff_make_n(prec);
11
+ nn = rb_BigDecimal1(n);
12
+ a = u = rb_num_uminus(rb_bigmath_log(n, n));
13
+ b = v = one;
14
+ k = zero;
15
+ while (rb_numdiff_condition_p(u, a, n, &m))
16
+ {
17
+ k = rb_funcall1(k, '+', one);
18
+ b = rb_funcall(rb_funcall1(b, '*', rb_funcall1(nn, '*', nn)),
19
+ div, 2, rb_funcall1(k, '*', k), m);
20
+ a = rb_funcall1(
21
+ rb_funcall(one, div, 2, k, m), '*',
22
+ rb_funcall(rb_funcall(rb_funcall1(a, '*', rb_funcall1(nn, '*', nn)),
23
+ div, 2, k, m),
24
+ add, 2, b, m));
25
+ u = rb_funcall1(u, '+', a);
26
+ v = rb_funcall1(v, '+', b);
27
+ }
28
+ RB_GC_GUARD(zero);
29
+ RB_GC_GUARD(one);
30
+ RB_GC_GUARD(nn);
31
+ RB_GC_GUARD(a);
32
+ RB_GC_GUARD(b);
33
+ RB_GC_GUARD(u);
34
+ RB_GC_GUARD(v);
35
+ RB_GC_GUARD(k);
36
+ return rb_funcall(u, div, 2, v, prec);
37
+ }
@@ -1,6 +1,8 @@
1
1
  VALUE
2
2
  LOG10_ser(VALUE prec)
3
3
  {
4
+ rb_check_precise(prec);
5
+ VALUE n = rb_numdiff_make_n(prec);
4
6
  #if 0
5
7
  VALUE x = rb_Rational(INT2FIX(-9), INT2FIX(10));
6
8
  x = log_ser_mercator(x, prec);
@@ -8,8 +10,8 @@ LOG10_ser(VALUE prec)
8
10
  #else
9
11
  const ID add = rb_intern("add");
10
12
  VALUE x = rb_Rational(INT2FIX(1), INT2FIX(4)), log2;
11
- x = log1p_p_adic(x, prec);
12
- log2 = LOG2_BBP2002(prec);
13
+ x = log1p_p_adic(x, n);
14
+ log2 = LOG2_BBP2002(n);
13
15
  return rb_funcall(rb_funcall1(log2, '*', INT2FIX(3)), add, 2, x, prec);
14
16
  #endif
15
17
  }
@@ -1,7 +1,9 @@
1
1
  VALUE
2
2
  LOG_PI_builtin(VALUE prec)
3
3
  {
4
- VALUE log_pi = rb_bigmath_const_pi(prec);
4
+ rb_check_precise(prec);
5
+ VALUE n = rb_numdiff_make_n(prec);
6
+ VALUE log_pi = rb_bigmath_const_pi(n);
5
7
  return log_builtin(log_pi, prec);
6
8
  }
7
9
 
@@ -1,5 +1,8 @@
1
1
  VALUE
2
2
  SQRT2_builtin(VALUE prec)
3
3
  {
4
- return rb_bigmath_sqrt(INT2FIX(2), prec);
4
+ rb_check_precise(prec);
5
+ VALUE n = rb_numdiff_make_n(prec);
6
+ VALUE x = rb_bigmath_sqrt(INT2FIX(2), n);
7
+ return rb_num_round(x, prec);
5
8
  }
@@ -1,5 +1,8 @@
1
1
  VALUE
2
2
  SQRT3_builtin(VALUE prec)
3
3
  {
4
- return rb_bigmath_sqrt(INT2FIX(3), prec);
4
+ rb_check_precise(prec);
5
+ VALUE n = rb_numdiff_make_n(prec);
6
+ VALUE x = rb_bigmath_sqrt(INT2FIX(3), n);
7
+ return rb_num_round(x, prec);
5
8
  }