1 /**********************************************************************
6 created at: Tue Jan 25 14:12:56 JST 1994
8 Copyright (C) 1993-2007 Yukihiro Matsumoto
10 **********************************************************************/
12 #include "ruby/internal/config.h"
15 # define _USE_MATH_DEFINES 1
23 #include "internal/bignum.h"
24 #include "internal/complex.h"
25 #include "internal/math.h"
26 #include "internal/object.h"
27 #include "internal/vm.h"
30 VALUE rb_eMathDomainError
;
32 #define Get_Double(x) rb_num_to_dbl(x)
34 #define domain_error(msg) \
35 rb_raise(rb_eMathDomainError, "Numerical argument is out of domain - " msg)
36 #define domain_check_min(val, min, msg) \
37 ((val) < (min) ? domain_error(msg) : (void)0)
38 #define domain_check_range(val, min, max, msg) \
39 ((val) < (min) || (max) < (val) ? domain_error(msg) : (void)0)
43 * Math.atan2(y, x) -> Float
45 * Computes the arc tangent given +y+ and +x+.
46 * Returns a Float in the range -PI..PI. Return value is a angle
47 * in radians between the positive x-axis of cartesian plane
48 * and the point given by the coordinates (+x+, +y+) on it.
50 * Domain: (-INFINITY, INFINITY)
54 * Math.atan2(-0.0, -1.0) #=> -3.141592653589793
55 * Math.atan2(-1.0, -1.0) #=> -2.356194490192345
56 * Math.atan2(-1.0, 0.0) #=> -1.5707963267948966
57 * Math.atan2(-1.0, 1.0) #=> -0.7853981633974483
58 * Math.atan2(-0.0, 1.0) #=> -0.0
59 * Math.atan2(0.0, 1.0) #=> 0.0
60 * Math.atan2(1.0, 1.0) #=> 0.7853981633974483
61 * Math.atan2(1.0, 0.0) #=> 1.5707963267948966
62 * Math.atan2(1.0, -1.0) #=> 2.356194490192345
63 * Math.atan2(0.0, -1.0) #=> 3.141592653589793
64 * Math.atan2(INFINITY, INFINITY) #=> 0.7853981633974483
65 * Math.atan2(INFINITY, -INFINITY) #=> 2.356194490192345
66 * Math.atan2(-INFINITY, INFINITY) #=> -0.7853981633974483
67 * Math.atan2(-INFINITY, -INFINITY) #=> -2.356194490192345
72 math_atan2(VALUE unused_obj
, VALUE y
, VALUE x
)
77 if (dx
== 0.0 && dy
== 0.0) {
82 return DBL2NUM(-M_PI
);
85 if (isinf(dx
) && isinf(dy
)) {
86 /* optimization for FLONUM */
88 const double dz
= (3.0 * M_PI
/ 4.0);
89 return (dy
< 0.0) ? DBL2NUM(-dz
) : DBL2NUM(dz
);
92 const double dz
= (M_PI
/ 4.0);
93 return (dy
< 0.0) ? DBL2NUM(-dz
) : DBL2NUM(dz
);
97 return DBL2NUM(atan2(dy
, dx
));
103 * Math.cos(x) -> Float
105 * Computes the cosine of +x+ (expressed in radians).
106 * Returns a Float in the range -1.0..1.0.
108 * Domain: (-INFINITY, INFINITY)
112 * Math.cos(Math::PI) #=> -1.0
117 math_cos(VALUE unused_obj
, VALUE x
)
119 return DBL2NUM(cos(Get_Double(x
)));
124 * Math.sin(x) -> Float
126 * Computes the sine of +x+ (expressed in radians).
127 * Returns a Float in the range -1.0..1.0.
129 * Domain: (-INFINITY, INFINITY)
133 * Math.sin(Math::PI/2) #=> 1.0
138 math_sin(VALUE unused_obj
, VALUE x
)
140 return DBL2NUM(sin(Get_Double(x
)));
146 * Math.tan(x) -> Float
148 * Computes the tangent of +x+ (expressed in radians).
150 * Domain: (-INFINITY, INFINITY)
152 * Codomain: (-INFINITY, INFINITY)
154 * Math.tan(0) #=> 0.0
159 math_tan(VALUE unused_obj
, VALUE x
)
161 return DBL2NUM(tan(Get_Double(x
)));
166 * Math.acos(x) -> Float
168 * Computes the arc cosine of +x+. Returns 0..PI.
174 * Math.acos(0) == Math::PI/2 #=> true
179 math_acos(VALUE unused_obj
, VALUE x
)
184 domain_check_range(d
, -1.0, 1.0, "acos");
185 return DBL2NUM(acos(d
));
190 * Math.asin(x) -> Float
192 * Computes the arc sine of +x+. Returns -PI/2..PI/2.
196 * Codomain: [-PI/2, PI/2]
198 * Math.asin(1) == Math::PI/2 #=> true
202 math_asin(VALUE unused_obj
, VALUE x
)
207 domain_check_range(d
, -1.0, 1.0, "asin");
208 return DBL2NUM(asin(d
));
213 * Math.atan(x) -> Float
215 * Computes the arc tangent of +x+. Returns -PI/2..PI/2.
217 * Domain: (-INFINITY, INFINITY)
219 * Codomain: (-PI/2, PI/2)
221 * Math.atan(0) #=> 0.0
225 math_atan(VALUE unused_obj
, VALUE x
)
227 return DBL2NUM(atan(Get_Double(x
)));
234 return (exp(x
) + exp(-x
)) / 2;
240 * Math.cosh(x) -> Float
242 * Computes the hyperbolic cosine of +x+ (expressed in radians).
244 * Domain: (-INFINITY, INFINITY)
246 * Codomain: [1, INFINITY)
248 * Math.cosh(0) #=> 1.0
253 math_cosh(VALUE unused_obj
, VALUE x
)
255 return DBL2NUM(cosh(Get_Double(x
)));
262 return (exp(x
) - exp(-x
)) / 2;
268 * Math.sinh(x) -> Float
270 * Computes the hyperbolic sine of +x+ (expressed in radians).
272 * Domain: (-INFINITY, INFINITY)
274 * Codomain: (-INFINITY, INFINITY)
276 * Math.sinh(0) #=> 0.0
281 math_sinh(VALUE unused_obj
, VALUE x
)
283 return DBL2NUM(sinh(Get_Double(x
)));
290 # if defined(HAVE_SINH) && defined(HAVE_COSH)
291 const double c
= cosh(x
);
292 if (!isinf(c
)) return sinh(x
) / c
;
294 const double e
= exp(x
+x
);
295 if (!isinf(e
)) return (e
- 1) / (e
+ 1);
297 return x
> 0 ? 1.0 : -1.0;
303 * Math.tanh(x) -> Float
305 * Computes the hyperbolic tangent of +x+ (expressed in radians).
307 * Domain: (-INFINITY, INFINITY)
311 * Math.tanh(0) #=> 0.0
316 math_tanh(VALUE unused_obj
, VALUE x
)
318 return DBL2NUM(tanh(Get_Double(x
)));
323 * Math.acosh(x) -> Float
325 * Computes the inverse hyperbolic cosine of +x+.
327 * Domain: [1, INFINITY)
329 * Codomain: [0, INFINITY)
331 * Math.acosh(1) #=> 0.0
336 math_acosh(VALUE unused_obj
, VALUE x
)
341 domain_check_min(d
, 1.0, "acosh");
342 return DBL2NUM(acosh(d
));
347 * Math.asinh(x) -> Float
349 * Computes the inverse hyperbolic sine of +x+.
351 * Domain: (-INFINITY, INFINITY)
353 * Codomain: (-INFINITY, INFINITY)
355 * Math.asinh(1) #=> 0.881373587019543
360 math_asinh(VALUE unused_obj
, VALUE x
)
362 return DBL2NUM(asinh(Get_Double(x
)));
367 * Math.atanh(x) -> Float
369 * Computes the inverse hyperbolic tangent of +x+.
373 * Codomain: (-INFINITY, INFINITY)
375 * Math.atanh(1) #=> Infinity
380 math_atanh(VALUE unused_obj
, VALUE x
)
385 domain_check_range(d
, -1.0, +1.0, "atanh");
386 /* check for pole error */
387 if (d
== -1.0) return DBL2NUM(-HUGE_VAL
);
388 if (d
== +1.0) return DBL2NUM(+HUGE_VAL
);
389 return DBL2NUM(atanh(d
));
394 * Math.exp(x) -> Float
398 * Domain: (-INFINITY, INFINITY)
400 * Codomain: (0, INFINITY)
402 * Math.exp(0) #=> 1.0
403 * Math.exp(1) #=> 2.718281828459045
404 * Math.exp(1.5) #=> 4.4816890703380645
409 math_exp(VALUE unused_obj
, VALUE x
)
411 return DBL2NUM(exp(Get_Double(x
)));
414 #if defined __CYGWIN__
415 # include <cygwin/version.h>
416 # if CYGWIN_VERSION_DLL_MAJOR < 1005
417 # define nan(x) nan()
419 # define log(x) ((x) < 0.0 ? nan("") : log(x))
420 # define log10(x) ((x) < 0.0 ? nan("") : log10(x))
424 # define M_LN2 0.693147180559945309417232121458176568
427 # define M_LN10 2.30258509299404568401799145468436421
430 static double math_log1(VALUE x
);
431 FUNC_MINIMIZED(static VALUE
math_log(int, const VALUE
*, VALUE
));
435 * Math.log(x) -> Float
436 * Math.log(x, base) -> Float
438 * Returns the logarithm of +x+.
439 * If additional second argument is given, it will be the base
440 * of logarithm. Otherwise it is +e+ (for the natural logarithm).
442 * Domain: (0, INFINITY)
444 * Codomain: (-INFINITY, INFINITY)
446 * Math.log(0) #=> -Infinity
447 * Math.log(1) #=> 0.0
448 * Math.log(Math::E) #=> 1.0
449 * Math.log(Math::E**3) #=> 3.0
450 * Math.log(12, 3) #=> 2.2618595071429146
455 math_log(int argc
, const VALUE
*argv
, VALUE unused_obj
)
457 return rb_math_log(argc
, argv
);
461 rb_math_log(int argc
, const VALUE
*argv
)
466 rb_scan_args(argc
, argv
, "11", &x
, &base
);
469 d
/= math_log1(base
);
475 get_double_rshift(VALUE x
, size_t *pnumbits
)
479 if (RB_BIGNUM_TYPE_P(x
) && BIGNUM_POSITIVE_P(x
) &&
480 DBL_MAX_EXP
<= (numbits
= rb_absint_numwords(x
, 1, NULL
))) {
481 numbits
-= DBL_MANT_DIG
;
482 x
= rb_big_rshift(x
, SIZET2NUM(numbits
));
488 return Get_Double(x
);
495 double d
= get_double_rshift(x
, &numbits
);
497 domain_check_min(d
, 0.0, "log");
498 /* check for pole error */
499 if (d
== 0.0) return -HUGE_VAL
;
501 return log(d
) + numbits
* M_LN2
; /* log(d * 2 ** numbits) */
509 return log10(x
)/log10(2.0);
512 extern double log2(double);
518 * Math.log2(x) -> Float
520 * Returns the base 2 logarithm of +x+.
522 * Domain: (0, INFINITY)
524 * Codomain: (-INFINITY, INFINITY)
526 * Math.log2(1) #=> 0.0
527 * Math.log2(2) #=> 1.0
528 * Math.log2(32768) #=> 15.0
529 * Math.log2(65536) #=> 16.0
534 math_log2(VALUE unused_obj
, VALUE x
)
537 double d
= get_double_rshift(x
, &numbits
);
539 domain_check_min(d
, 0.0, "log2");
540 /* check for pole error */
541 if (d
== 0.0) return DBL2NUM(-HUGE_VAL
);
543 return DBL2NUM(log2(d
) + numbits
); /* log2(d * 2 ** numbits) */
548 * Math.log10(x) -> Float
550 * Returns the base 10 logarithm of +x+.
552 * Domain: (0, INFINITY)
554 * Codomain: (-INFINITY, INFINITY)
556 * Math.log10(1) #=> 0.0
557 * Math.log10(10) #=> 1.0
558 * Math.log10(10**100) #=> 100.0
563 math_log10(VALUE unused_obj
, VALUE x
)
566 double d
= get_double_rshift(x
, &numbits
);
568 domain_check_min(d
, 0.0, "log10");
569 /* check for pole error */
570 if (d
== 0.0) return DBL2NUM(-HUGE_VAL
);
572 return DBL2NUM(log10(d
) + numbits
* log10(2)); /* log10(d * 2 ** numbits) */
575 static VALUE
rb_math_sqrt(VALUE x
);
579 * Math.sqrt(x) -> Float
581 * Returns the non-negative square root of +x+.
583 * Domain: [0, INFINITY)
585 * Codomain:[0, INFINITY)
588 * p [x, Math.sqrt(x), Math.sqrt(x)**2]
592 * # [2, 1.4142135623731, 2.0]
593 * # [3, 1.73205080756888, 3.0]
595 * # [5, 2.23606797749979, 5.0]
596 * # [6, 2.44948974278318, 6.0]
597 * # [7, 2.64575131106459, 7.0]
598 * # [8, 2.82842712474619, 8.0]
600 * # [10, 3.16227766016838, 10.0]
602 * Note that the limited precision of floating point arithmetic
603 * might lead to surprising results:
605 * Math.sqrt(10**46).to_i #=> 99999999999999991611392 (!)
607 * See also BigDecimal#sqrt and Integer.sqrt.
611 math_sqrt(VALUE unused_obj
, VALUE x
)
613 return rb_math_sqrt(x
);
617 f_negative_p(VALUE x
)
620 return RBOOL(FIX2LONG(x
) < 0);
621 return rb_funcall(x
, '<', 1, INT2FIX(0));
626 if (RB_FLOAT_TYPE_P(x
)) {
627 double f
= RFLOAT_VALUE(x
);
628 return RBOOL(!isnan(f
) && signbit(f
));
630 return f_negative_p(x
);
634 rb_math_sqrt(VALUE x
)
638 if (RB_TYPE_P(x
, T_COMPLEX
)) {
639 VALUE neg
= f_signbit(RCOMPLEX(x
)->imag
);
640 double re
= Get_Double(RCOMPLEX(x
)->real
), im
;
641 d
= Get_Double(rb_complex_abs(x
));
642 im
= sqrt((d
- re
) / 2.0);
643 re
= sqrt((d
+ re
) / 2.0);
645 return rb_complex_new(DBL2NUM(re
), DBL2NUM(im
));
648 domain_check_min(d
, 0.0, "sqrt");
649 if (d
== 0.0) return DBL2NUM(0.0);
650 return DBL2NUM(sqrt(d
));
655 * Math.cbrt(x) -> Float
657 * Returns the cube root of +x+.
659 * Domain: (-INFINITY, INFINITY)
661 * Codomain: (-INFINITY, INFINITY)
664 * p [x, Math.cbrt(x), Math.cbrt(x)**3]
666 * #=> [-9, -2.0800838230519, -9.0]
668 * # [-7, -1.91293118277239, -7.0]
669 * # [-6, -1.81712059283214, -6.0]
670 * # [-5, -1.7099759466767, -5.0]
671 * # [-4, -1.5874010519682, -4.0]
672 * # [-3, -1.44224957030741, -3.0]
673 * # [-2, -1.25992104989487, -2.0]
677 * # [2, 1.25992104989487, 2.0]
678 * # [3, 1.44224957030741, 3.0]
679 * # [4, 1.5874010519682, 4.0]
680 * # [5, 1.7099759466767, 5.0]
681 * # [6, 1.81712059283214, 6.0]
682 * # [7, 1.91293118277239, 7.0]
684 * # [9, 2.0800838230519, 9.0]
689 math_cbrt(VALUE unused_obj
, VALUE x
)
691 double f
= Get_Double(x
);
693 #if defined __GLIBC__
694 if (isfinite(r
) && !(f
== 0.0 && r
== 0.0)) {
695 r
= (2.0 * r
+ (f
/ r
/ r
)) / 3.0;
703 * Math.frexp(x) -> [fraction, exponent]
705 * Returns a two-element array containing the normalized fraction (a Float)
706 * and exponent (an Integer) of +x+.
708 * fraction, exponent = Math.frexp(1234) #=> [0.6025390625, 11]
709 * fraction * 2**exponent #=> 1234.0
713 math_frexp(VALUE unused_obj
, VALUE x
)
718 d
= frexp(Get_Double(x
), &exp
);
719 return rb_assoc_new(DBL2NUM(d
), INT2NUM(exp
));
724 * Math.ldexp(fraction, exponent) -> float
726 * Returns the value of +fraction+*(2**+exponent+).
728 * fraction, exponent = Math.frexp(1234)
729 * Math.ldexp(fraction, exponent) #=> 1234.0
733 math_ldexp(VALUE unused_obj
, VALUE x
, VALUE n
)
735 return DBL2NUM(ldexp(Get_Double(x
), NUM2INT(n
)));
740 * Math.hypot(x, y) -> Float
742 * Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled triangle with
745 * Math.hypot(3, 4) #=> 5.0
749 math_hypot(VALUE unused_obj
, VALUE x
, VALUE y
)
751 return DBL2NUM(hypot(Get_Double(x
), Get_Double(y
)));
756 * Math.erf(x) -> Float
758 * Calculates the error function of +x+.
760 * Domain: (-INFINITY, INFINITY)
764 * Math.erf(0) #=> 0.0
769 math_erf(VALUE unused_obj
, VALUE x
)
771 return DBL2NUM(erf(Get_Double(x
)));
776 * Math.erfc(x) -> Float
778 * Calculates the complementary error function of x.
780 * Domain: (-INFINITY, INFINITY)
784 * Math.erfc(0) #=> 1.0
789 math_erfc(VALUE unused_obj
, VALUE x
)
791 return DBL2NUM(erfc(Get_Double(x
)));
796 * Math.gamma(x) -> Float
798 * Calculates the gamma function of x.
800 * Note that gamma(n) is the same as fact(n-1) for integer n > 0.
801 * However gamma(n) returns float and can be an approximation.
803 * def fact(n) (1..n).inject(1) {|r,i| r*i } end
804 * 1.upto(26) {|i| p [i, Math.gamma(i), fact(i-1)] }
812 * # [8, 5040.0, 5040]
813 * # [9, 40320.0, 40320]
814 * # [10, 362880.0, 362880]
815 * # [11, 3628800.0, 3628800]
816 * # [12, 39916800.0, 39916800]
817 * # [13, 479001600.0, 479001600]
818 * # [14, 6227020800.0, 6227020800]
819 * # [15, 87178291200.0, 87178291200]
820 * # [16, 1307674368000.0, 1307674368000]
821 * # [17, 20922789888000.0, 20922789888000]
822 * # [18, 355687428096000.0, 355687428096000]
823 * # [19, 6.402373705728e+15, 6402373705728000]
824 * # [20, 1.21645100408832e+17, 121645100408832000]
825 * # [21, 2.43290200817664e+18, 2432902008176640000]
826 * # [22, 5.109094217170944e+19, 51090942171709440000]
827 * # [23, 1.1240007277776077e+21, 1124000727777607680000]
828 * # [24, 2.5852016738885062e+22, 25852016738884976640000]
829 * # [25, 6.204484017332391e+23, 620448401733239439360000]
830 * # [26, 1.5511210043330954e+25, 15511210043330985984000000]
835 math_gamma(VALUE unused_obj
, VALUE x
)
837 static const double fact_table
[] = {
845 /* fact(7) */ 5040.0,
846 /* fact(8) */ 40320.0,
847 /* fact(9) */ 362880.0,
848 /* fact(10) */ 3628800.0,
849 /* fact(11) */ 39916800.0,
850 /* fact(12) */ 479001600.0,
851 /* fact(13) */ 6227020800.0,
852 /* fact(14) */ 87178291200.0,
853 /* fact(15) */ 1307674368000.0,
854 /* fact(16) */ 20922789888000.0,
855 /* fact(17) */ 355687428096000.0,
856 /* fact(18) */ 6402373705728000.0,
857 /* fact(19) */ 121645100408832000.0,
858 /* fact(20) */ 2432902008176640000.0,
859 /* fact(21) */ 51090942171709440000.0,
860 /* fact(22) */ 1124000727777607680000.0,
861 /* fact(23)=25852016738884976640000 needs 56bit mantissa which is
862 * impossible to represent exactly in IEEE 754 double which have
865 enum {NFACT_TABLE
= numberof(fact_table
)};
868 /* check for domain error */
870 if (signbit(d
)) domain_error("gamma");
871 return DBL2NUM(HUGE_VAL
);
874 return signbit(d
) ? DBL2NUM(-HUGE_VAL
) : DBL2NUM(HUGE_VAL
);
877 domain_check_min(d
, 0.0, "gamma");
878 if (1.0 <= d
&& d
<= (double)NFACT_TABLE
) {
879 return DBL2NUM(fact_table
[(int)d
- 1]);
882 return DBL2NUM(tgamma(d
));
887 * Math.lgamma(x) -> [float, -1 or 1]
889 * Calculates the logarithmic gamma of +x+ and the sign of gamma of +x+.
891 * Math.lgamma(x) is the same as
892 * [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1]
893 * but avoids overflow by Math.gamma(x) for large x.
895 * Math.lgamma(0) #=> [Infinity, 1]
900 math_lgamma(VALUE unused_obj
, VALUE x
)
906 /* check for domain error */
908 if (signbit(d
)) domain_error("lgamma");
909 return rb_assoc_new(DBL2NUM(HUGE_VAL
), INT2FIX(1));
912 VALUE vsign
= signbit(d
) ? INT2FIX(-1) : INT2FIX(+1);
913 return rb_assoc_new(DBL2NUM(HUGE_VAL
), vsign
);
915 v
= DBL2NUM(lgamma_r(d
, &sign
));
916 return rb_assoc_new(v
, INT2FIX(sign
));
922 rb_math_##n(VALUE x)\
924 return math_##n(0, x);\
929 rb_math_##n(VALUE x, VALUE y)\
931 return math_##n(0, x, y);\
947 * Document-class: Math::DomainError
949 * Raised when a mathematical function is evaluated outside of its
950 * domain of definition.
952 * For example, since +cos+ returns values in the range -1..1,
953 * its inverse function +acos+ is only defined on that interval:
959 * Math::DomainError: Numerical argument is out of domain - "acos"
963 * Document-class: Math
965 * The Math module contains module functions for basic
966 * trigonometric and transcendental functions. See class
967 * Float for a list of constants that
968 * define Ruby's floating point accuracy.
970 * Domains and codomains are given only for real (not complex) numbers.
977 rb_mMath
= rb_define_module("Math");
978 rb_eMathDomainError
= rb_define_class_under(rb_mMath
, "DomainError", rb_eStandardError
);
980 /* Definition of the mathematical constant PI as a Float number. */
981 rb_define_const(rb_mMath
, "PI", DBL2NUM(M_PI
));
984 /* Definition of the mathematical constant E for Euler's number (e) as a Float number. */
985 rb_define_const(rb_mMath
, "E", DBL2NUM(M_E
));
987 rb_define_const(rb_mMath
, "E", DBL2NUM(exp(1.0)));
990 rb_define_module_function(rb_mMath
, "atan2", math_atan2
, 2);
991 rb_define_module_function(rb_mMath
, "cos", math_cos
, 1);
992 rb_define_module_function(rb_mMath
, "sin", math_sin
, 1);
993 rb_define_module_function(rb_mMath
, "tan", math_tan
, 1);
995 rb_define_module_function(rb_mMath
, "acos", math_acos
, 1);
996 rb_define_module_function(rb_mMath
, "asin", math_asin
, 1);
997 rb_define_module_function(rb_mMath
, "atan", math_atan
, 1);
999 rb_define_module_function(rb_mMath
, "cosh", math_cosh
, 1);
1000 rb_define_module_function(rb_mMath
, "sinh", math_sinh
, 1);
1001 rb_define_module_function(rb_mMath
, "tanh", math_tanh
, 1);
1003 rb_define_module_function(rb_mMath
, "acosh", math_acosh
, 1);
1004 rb_define_module_function(rb_mMath
, "asinh", math_asinh
, 1);
1005 rb_define_module_function(rb_mMath
, "atanh", math_atanh
, 1);
1007 rb_define_module_function(rb_mMath
, "exp", math_exp
, 1);
1008 rb_define_module_function(rb_mMath
, "log", math_log
, -1);
1009 rb_define_module_function(rb_mMath
, "log2", math_log2
, 1);
1010 rb_define_module_function(rb_mMath
, "log10", math_log10
, 1);
1011 rb_define_module_function(rb_mMath
, "sqrt", math_sqrt
, 1);
1012 rb_define_module_function(rb_mMath
, "cbrt", math_cbrt
, 1);
1014 rb_define_module_function(rb_mMath
, "frexp", math_frexp
, 1);
1015 rb_define_module_function(rb_mMath
, "ldexp", math_ldexp
, 2);
1017 rb_define_module_function(rb_mMath
, "hypot", math_hypot
, 2);
1019 rb_define_module_function(rb_mMath
, "erf", math_erf
, 1);
1020 rb_define_module_function(rb_mMath
, "erfc", math_erfc
, 1);
1022 rb_define_module_function(rb_mMath
, "gamma", math_gamma
, 1);
1023 rb_define_module_function(rb_mMath
, "lgamma", math_lgamma
, 1);