D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Math
/
Filename :
cdesc-Math.ri
back
Copy
U:RDoc::NormalModule[iI" Math:ET@0o:RDoc::Markup::Document:@parts[o;;[=o:RDoc::Markup::Paragraph;[I"=\Module \Math provides methods for basic trigonometric, ;TI"Ilogarithmic, and transcendental functions, and for extracting roots.;To:RDoc::Markup::BlankLine o; ;[I"7You can write its constants and method calls thus:;T@o:RDoc::Markup::Verbatim;[ I"*Math::PI # => 3.141592653589793 ;TI"*Math::E # => 2.718281828459045 ;TI"Math.sin(0.0) # => 0.0 ;TI"Math.cos(0.0) # => 1.0 ;T:@format0o; ;[I">If you include module \Math, you can write simpler forms:;T@o;;[ I"include Math ;TI"%PI # => 3.141592653589793 ;TI"%E # => 2.718281828459045 ;TI"sin(0.0) # => 0.0 ;TI"cos(0.0) # => 1.0 ;T;0o; ;[I".For simplicity, the examples here assume:;T@o;;[I"include Math ;TI" INFINITY = Float::INFINITY ;T;0o; ;[I",The domains and ranges for the methods ;TI".are denoted by open or closed intervals, ;TI"9using, respectively, parentheses or square brackets:;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o; ;[I"5An open interval does not include the endpoints:;T@o;;[I"(-INFINITY, INFINITY) ;T;0o;;0;[o; ;[I".A closed interval includes the endpoints:;T@o;;[I"[-1.0, 1.0] ;T;0o;;0;[o; ;[I"CA half-open interval includes one endpoint, but not the other:;T@o;;[I"[1.0, INFINITY) ;T;0o; ;[ I"IMany values returned by \Math methods are numerical approximations. ;TI";This is because many such values are, in mathematics, ;TI";of infinite precision, while in numerical computation ;TI"the precision is finite.;T@o; ;[I"=Thus, in mathematics, <i>cos(π/2)</i> is exactly zero, ;TI"Nbut in our computation <tt>cos(PI/2)</tt> is a number very close to zero:;T@o;;[I"*cos(PI/2) # => 6.123031769111886e-17 ;T;0o; ;[I"4For very large and very small returned values, ;TI"1we have added formatted numbers for clarity:;T@o;;[I"Ctan(PI/2) # => 1.633123935319537e+16 # 16331239353195370.0 ;TI"Ctan(PI) # => -1.2246467991473532e-16 # -0.0000000000000001 ;T;0o; ;[I"'See class Float for the constants ;TI"2that affect Ruby's floating-point arithmetic.;T@S:RDoc::Markup::Heading: leveli: textI"What's Here;T@S;;i ;I"Trigonometric Functions;T@o; ;;;[o;;0;[o; ;[I"5::cos: Returns the cosine of the given argument.;To;;0;[o; ;[I"3::sin: Returns the sine of the given argument.;To;;0;[o; ;[I"6::tan: Returns the tangent of the given argument.;T@S;;i ;I"$Inverse Trigonometric Functions;T@o; ;;;[ o;;0;[o; ;[I":::acos: Returns the arc cosine of the given argument.;To;;0;[o; ;[I"8::asin: Returns the arc sine of the given argument.;To;;0;[o; ;[I";::atan: Returns the arc tangent of the given argument.;To;;0;[o; ;[I"=::atan2: Returns the arg tangent of two given arguments.;T@S;;i ;I"'Hyperbolic Trigonometric Functions;T@o; ;;;[o;;0;[o; ;[I"A::cosh: Returns the hyperbolic cosine of the given argument.;To;;0;[o; ;[I"?::sinh: Returns the hyperbolic sine of the given argument.;To;;0;[o; ;[I"B::tanh: Returns the hyperbolic tangent of the given argument.;T@S;;i ;I"/Inverse Hyperbolic Trigonometric Functions;T@o; ;;;[o;;0;[o; ;[I"J::acosh: Returns the inverse hyperbolic cosine of the given argument.;To;;0;[o; ;[I"H::asinh: Returns the inverse hyperbolic sine of the given argument.;To;;0;[o; ;[I"K::atanh: Returns the inverse hyperbolic tangent of the given argument.;T@S;;i ;I"-Exponentiation and Logarithmic Functions;T@o; ;;;[ o;;0;[o; ;[I"G::exp: Returns the value of a given value raised to a given power.;To;;0;[o; ;[I"C::log: Returns the logarithm of a given value in a given base.;To;;0;[o; ;[I"B::log10: Returns the base 10 logarithm of the given argument.;To;;0;[o; ;[I"@::log2: Returns the base 2 logarithm of the given argument.;T@S;;i ;I"$Fraction and Exponent Functions;T@o; ;;;[o;;0;[o; ;[I"F::frexp: Returns the fraction and exponent of the given argument.;To;;0;[o; ;[I"B::ldexp: Returns the value for a given fraction and exponent.;T@S;;i ;I"Root Functions;T@o; ;;;[o;;0;[o; ;[I"9::cbrt: Returns the cube root of the given argument.;To;;0;[o; ;[I";::sqrt: Returns the square root of the given argument.;T@S;;i ;I"Error Functions;T@o; ;;;[o;;0;[o; ;[I"Q::erf: Returns the value of the Gauss error function for the given argument.;To;;0;[o; ;[I"C::erfc: Returns the value of the complementary error function ;TI"for the given argument.;T@S;;i ;I"Gamma Functions;T@o; ;;;[o;;0;[o; ;[I"M::gamma: Returns the value of the gamma function for the given argument.;To;;0;[o; ;[I"C::lgamma: Returns the value of the logarithmic gamma function ;TI"for the given argument.;T@S;;i ;I"Hypotenuse Function;T@o; ;;;[o;;0;[o; ;[I"K::hypot: Returns <tt>sqrt(a**2 + b**2)</tt> for the given +a+ and +b+.;T: @fileI"math.c;T:0@omit_headings_from_table_of_contents_below0;0;0[ [U:RDoc::Constant[i I"PI;TI" Math::PI;T:public0o;;[o; ;[I"BDefinition of the mathematical constant PI as a Float number.;T@;@;0@@cRDoc::NormalModule0U;[i I"E;TI"Math::E;T;0o;;[o; ;[I"XDefinition of the mathematical constant E for Euler's number (e) as a Float number.;T@;@;0@@@0[ [[I" class;T[[;[[I" acos;TI"math.c;T[I" acosh;T@+[I" asin;T@+[I" asinh;T@+[I" atan;T@+[I" atan2;T@+[I" atanh;T@+[I" cbrt;T@+[I"cos;T@+[I" cosh;T@+[I"erf;T@+[I" erfc;T@+[I"exp;T@+[I" frexp;T@+[I" gamma;T@+[I" hypot;T@+[I" ldexp;T@+[I"lgamma;T@+[I"log;T@+[I" log10;T@+[I" log2;T@+[I"sin;T@+[I" sinh;T@+[I" sqrt;T@+[I"tan;T@+[I" tanh;T@+[:protected[ [:private[ [I" instance;T[[;[ [;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;0;0[@@cRDoc::TopLevel