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.

tan
  • References/Ruby on Rails/Ruby/Classes/Math

Math.tan(x) â float Class Public methods Returns the tangent of x

2025-01-10 15:47:30
asinh
  • References/Ruby on Rails/Ruby/Classes/Math

Math.asinh(x) â float Class Public methods Computes the inverse hyperbolic

2025-01-10 15:47:30
log
  • References/Ruby on Rails/Ruby/Classes/Math

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

2025-01-10 15:47:30
sin
  • References/Ruby on Rails/Ruby/Classes/Math

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

2025-01-10 15:47:30
tanh
  • References/Ruby on Rails/Ruby/Classes/Math

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

2025-01-10 15:47:30
atan
  • References/Ruby on Rails/Ruby/Classes/Math

Math.atan(x) â float Class Public methods Computes the arc tangent of x

2025-01-10 15:47:30
ldexp
  • References/Ruby on Rails/Ruby/Classes/Math

Math.ldexp(flt, int) â float Class Public methods Returns the value of

2025-01-10 15:47:30
frexp
  • References/Ruby on Rails/Ruby/Classes/Math

Math.frexp(numeric) â [ fraction, exponent ] Class Public methods Returns

2025-01-10 15:47:30
acosh
  • References/Ruby on Rails/Ruby/Classes/Math

Math.acosh(x) â float Class Public methods Computes the inverse hyperbolic

2025-01-10 15:47:30
atanh
  • References/Ruby on Rails/Ruby/Classes/Math

Math.atanh(x) â float Class Public methods Computes the inverse hyperbolic

2025-01-10 15:47:30