Type:
Module
Constants:
PI : DBL2NUM(M_PI)
E : DBL2NUM(M_E)

When mathn is required, the Math module changes as follows:

Standard Math module behaviour:

Math.sqrt(4/9)     # => 0.0
Math.sqrt(4.0/9.0) # => 0.666666666666667
Math.sqrt(- 4/9)   # => Errno::EDOM: Numerical argument out of domain - sqrt

After require 'mathn', this is changed to:

require 'mathn'
Math.sqrt(4/9)      # => 2/3
Math.sqrt(4.0/9.0)  # => 0.666666666666667
Math.sqrt(- 4/9)    # => Complex(0, 2/3)

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.

asin

Math.asin(x) â float Class Public methods Computes the arc sine of x

2015-04-18 01:15:56
rsqrt

rsqrt(a) Class Public methods Compute square root of a non negative number.

2015-04-18 02:28:33
exp

Math.exp(x) â float Class Public methods Returns e**x.

2015-04-18 01:53:30
cbrt

Math.cbrt(numeric) â float Class Public methods Returns the cube root of

2015-04-18 01:32:26
erfc

Math.erfc(x) â float Class Public methods Calculates the complementary error

2015-04-18 01:48:11
lgamma

Math.lgamma(x) â [float, -1 or 1] Class Public methods Calculates the logarithmic

2015-04-18 02:15:07
sqrt

sqrt(a) Class Public methods Computes the square root of a. It

2015-04-18 02:36:33
log2

Math.log2(numeric) â float Class Public methods Returns the base 2 logarithm

2015-04-18 02:25:55
log

Math.log(numeric) â floatMath.log(num,base) â float Class Public methods Returns

2015-04-18 02:21:04
tanh

Math.tanh() â float Class Public methods Computes the hyperbolic tangent

2015-04-18 02:40:01