# # = Mathematical Functions # Contents: # 1. {Mathematical Constants}[link:rdoc/math_rdoc.html#1] # 1. {Infinities and Not-a-number}[link:rdoc/math_rdoc.html#2] # 1. {Constants}[link:rdoc/math_rdoc.html#2.1] # 1. {Module functions}[link:rdoc/math_rdoc.html#2.2] # 1. {Elementary Functions}[link:rdoc/math_rdoc.html#3] # 1. {Small Integer Powers}[link:rdoc/math_rdoc.html#4] # 1. {Testing the Sign of Numbers}[link:rdoc/math_rdoc.html#5] # 1. {Testing for Odd and Even Numbers}[link:rdoc/math_rdoc.html#6] # 1. {Maximum and Minimum functions}[link:rdoc/math_rdoc.html#7] # 1. {Approximate Comparison of Floating Point Numbers}[link:rdoc/math_rdoc.html#8] # # == {}[link:index.html"name="1] Mathematical Constants # --- # * GSL::M_E # # The base of exponentials, e # --- # * GSL::M_LOG2E # # The base-2 logarithm of e, log_2(e) # --- # * GSL::M_LOG10E # # The base-10 logarithm of e, log_10(e) # --- # * GSL::M_SQRT2 # # The square root of two, sqrt(2) # --- # * GSL::M_SQRT1_2 # # The square root of one-half, sqrt(1/2) # --- # * GSL::M_SQRT3 # # The square root of three, sqrt(3) # --- # * GSL::M_PI # # The constant pi # --- # * GSL::M_PI_2 # # Pi divided by two # --- # * GSL::M_PI_4 # # Pi divided by four # --- # * GSL::M_SQRTPI # # The square root of pi # --- # * GSL::M_2_SQRTPI # # Two divided by the square root of pi # --- # * GSL::M_1_PI # # The reciprocal of pi, 1/pi # --- # * GSL::M_2_PI # # Twice the reciprocal of pi, 2/pi # --- # * GSL::M_LN10 # # The natural logarithm of ten, ln(10) # --- # * GSL::M_LN2 # # The natural logarithm of ten, ln(2) # --- # * GSL::M_LNPI # # The natural logarithm of ten, ln(pi) # --- # * GSL::M_EULER # # Euler's constant # # == {}[link:index.html"name="2] Infinities and Not-a-number # # === {}[link:index.html"name="2.1] Constants # --- # * GSL::POSINF # # The IEEE representation of positive infinity, # computed from the expression +1.0/0.0. # --- # * GSL::NEGINF # # The IEEE representation of negative infinity, # computed from the expression -1.0/0.0. # --- # * GSL::NAN # # The IEEE representation of the Not-a-Number symbol, # computed from the ratio 0.0/0.0. # # === {}[link:index.html"name="2.2] Module functions # --- # * GSL::isnan(x) # # This returns 1 if <tt>x</tt> is not-a-number. # --- # * GSL::isnan?(x) # # This returns <tt>true</tt> if <tt>x</tt> is not-a-number, and <tt>false</tt> otherwise. # --- # * GSL::isinf(x) # # This returns +1 if <tt>x</tt> is positive infinity, # -1 if <tt>x</tt> is negative infinity and 0 otherwise. # NOTE: In Darwin9.5.0-gcc4.0.1, this method returns 1 for -inf. # --- # * GSL::isinf?(x) # # This returns <tt>true</tt> if <tt>x</tt> is positive or negative infinity, # and <tt>false</tt> otherwise. # --- # * GSL::finite(x) # # This returns 1 if <tt>x</tt> is a real number, # and 0 if it is infinite or not-a-number. # --- # * GSL::finite?(x) # # This returns <tt>true</tt> if <tt>x</tt> is a real number, # and <tt>false</tt> if it is infinite or not-a-number. # # == {}[link:index.html"name="3] Elementary Functions # --- # * GSL::log1p(x) # # This method computes the value of log(1+x) # in a way that is accurate for small <tt>x</tt>. It provides an alternative # to the BSD math function log1p(x). # --- # * GSL::expm1(x) # # This method computes the value of exp(x)-1 # in a way that is accurate for small <tt>x</tt>. It provides an alternative # to the BSD math function expm1(x). # --- # * GSL::hypot(x, y) # # This method computes the value of sqrt{x^2 + y^2} in a way that # avoids overflow. # --- # * GSL::hypot3(x, y, z) # # Computes the value of sqrt{x^2 + y^2 + z^2} in a way that avoids overflow. # --- # * GSL::acosh(x) # # This method computes the value of arccosh(x). # --- # * GSL::asinh(x) # # This method computes the value of arcsinh(x). # --- # * GSL::atanh(x) # # This method computes the value of arctanh(x). # # These methods above can take argument <tt>x</tt> of # Integer, Float, Array, Vector or Matrix. # # --- # * GSL::ldexp(x) # # This method computes the value of x * 2^e. # --- # * GSL::frexp(x) # # This method splits the number <tt>x</tt> into its normalized fraction # f and exponent e, such that x = f * 2^e and 0.5 <= f < 1. # The method returns f and the exponent e as an array, [f, e]. # If <tt>x</tt> is zero, both f and e are set to zero. # # == {}[link:index.html"name="4] Small Integer Powers # --- # * GSL::pow_int(x, n) # # This routine computes the power <tt>x^n</tt> for integer <tt>n</tt>. # The power is computed efficiently -- for example, x^8 is computed as # ((x^2)^2)^2, requiring only 3 multiplications. # # --- # * GSL::pow_2(x) # * GSL::pow_3(x) # * GSL::pow_4(x) # * GSL::pow_5(x) # * GSL::pow_6(x) # * GSL::pow_7(x) # * GSL::pow_8(x) # * GSL::pow_9(x) # # These methods can be used to compute small integer powers x^2, x^3, etc. # efficiently. # # == {}[link:index.html"name="5] Testing the Sign of Numbers # --- # * GSL::SIGN(x) # * GSL::sign(x) # # Return the sign of <tt>x</tt>. # It is defined as ((x) >= 0 ? 1 : -1). # Note that with this definition the sign of zero is positive # (regardless of its IEEE sign bit). # # == {}[link:index.html"name="6] Testing for Odd and Even Numbers # --- # * GSL::is_odd(n) # * GSL::IS_ODD(n) # # Evaluate to 1 if <tt>n</tt> is odd and 0 if <tt>n</tt> is even. # The argument <tt>n</tt> must be of Fixnum type. # --- # * GSL::is_odd?(n) # * GSL::IS_ODD?(n) # # Return <tt>true</tt> if <tt>n</tt> is odd and <tt>false</tt> if even. # --- # * GSL::is_even(n) # * GSL::IS_EVEN(n) # # Evaluate to 1 if <tt>n</tt> is even and 0 if <tt>n</tt> is odd. # The argument <tt>n</tt> must be of Fixnum type. # --- # * GSL::is_even?(n) # * GSL::IS_even?(n) # # Return <tt>true</tt> if <tt>n</tt> is even and <tt>false</tt> if odd. # # == {}[link:index.html"name="7] Maximum and Minimum functions # --- # * GSL::max(a, b) # * GSL::MAX(a, b) # * GSL::min(a, b) # * GSL::MIN(a, b) # # # == {}[link:index.html"name="8] Approximate Comparison of Floating Point Numbers # --- # * GSL::fcmp(a, b, epsilon = 1e-10) # # This method determines whether <tt>x</tt> and <tt>y</tt> are approximately equal to a # relative accuracy <tt>epsilon</tt>. # --- # * GSL::equal?(a, b, epsilon = 1e-10) # # # == {}[link:index.html"name="9] Module Constants # --- # * GSL::VERSION # # GSL version # # --- # * GSL::RB_GSL_VERSION # * GSL::RUBY_GSL_VERSION # # Ruby/GSL version # # {prev}[link:rdoc/ehandling_rdoc.html] # {next}[link:rdoc/complex_rdoc.html] # # {Reference index}[link:rdoc/ref_rdoc.html] # {top}[link:index.html] # #