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.

Aliases

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

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

Attributes

Show files where this module is defined (3 files)
Register or log in to add new notes.
March 31, 2009
0 thanks

Input for trigonometric functions must be radians

You must use radians to have the right result. For example to compute the sin of 125 degrees use:

Math.sin(125*Math::PI/180)