Module Math
In: math.c

The Math module contains module functions for basic trigonometric and transcendental functions. See class Float for a list of constants that define Ruby‘s floating point accuracy.

Methods

acos   acosh   asin   asinh   atan   atan2   atanh   cos   cosh   erf   erfc   exp   frexp   hypot   ldexp   log   log10   sin   sinh   sqrt   tan   tanh  

Constants

PI = rb_float_new(M_PI)
PI = rb_float_new(atan(1.0)*4.0)
E = rb_float_new(M_E)
E = rb_float_new(exp(1.0))

Public Class methods

Computes the arc cosine of x. Returns 0..PI.

Computes the inverse hyperbolic cosine of x.

Computes the arc sine of x. Returns -{PI/2} .. {PI/2}.

Computes the inverse hyperbolic sine of x.

Computes the arc tangent of x. Returns -{PI/2} .. {PI/2}.

Computes the arc tangent given y and x. Returns -PI..PI.

Computes the inverse hyperbolic tangent of x.

Computes the cosine of x (expressed in radians). Returns -1..1.

Computes the hyperbolic cosine of x (expressed in radians).

Calculates the error function of x.

Calculates the complementary error function of x.

Returns a two-element array containing the normalized fraction (a Float) and exponent (a Fixnum) of numeric.

   fraction, exponent = Math.frexp(1234)   #=> [0.6025390625, 11]
   fraction * 2**exponent                  #=> 1234.0

Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled triangle with sides x and y.

   Math.hypot(3, 4)   #=> 5.0

Returns the value of flt*(2**int).

   fraction, exponent = Math.frexp(1234)
   Math.ldexp(fraction, exponent)   #=> 1234.0

Returns the natural logarithm of numeric.

Returns the base 10 logarithm of numeric.

Computes the sine of x (expressed in radians). Returns -1..1.

Computes the hyperbolic sine of x (expressed in radians).

Returns the non-negative square root of numeric.

Returns the tangent of x (expressed in radians).

Computes the hyperbolic tangent of x (expressed in radians).

[Validate]

ruby-doc.org is a community service provided by Happy Camper Studios, a Phoenix, Arizona, Ruby application development company.

Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.

For more information on the Ruby programming language, visit ruby-lang.org.

Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.