Module Math
In: math.c
lib/complex.rb
lib/mathn.rb

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   acos   acosh   acosh   asin   asin   asinh   asinh   atan   atan   atan2   atan2   atanh   atanh   cos   cos   cosh   cosh   erf   erfc   exp   exp   frexp   hypot   ldexp   log   log   log10   log10   rsqrt   sin   sin   sinh   sinh   sqrt   sqrt   sqrt   tan   tan   tanh   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))

External Aliases

sqrt -> sqrt!
exp -> exp!
log -> log!
log10 -> log10!
cos -> cos!
sin -> sin!
tan -> tan!
cosh -> cosh!
sinh -> sinh!
tanh -> tanh!
acos -> acos!
asin -> asin!
atan -> atan!
atan2 -> atan2!
acosh -> acosh!
asinh -> asinh!
atanh -> atanh!

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 0..PI.

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).

Public Instance methods

Redefined to handle a Complex argument.

Redefined to handle a Complex argument.

Redefined to handle a Complex argument.

Redefined to handle a Complex argument.

Redefined to handle a Complex argument.

Redefined to handle a Complex argument.

Redefined to handle a Complex argument.

[Validate]

ruby-doc.org is a service of James Britt and Neurogami, a Ruby application development company in Phoenix, AZ.

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.