Type:
Module

CMath

CMath is a library that provides trigonometric and transcendental functions for complex numbers.

Usage

To start using this library, simply:

1
require "cmath"

Square root of a negative number is a complex number.

1
CMath.sqrt(-9#=> 0+3.0i
sqrt
  • References/Ruby on Rails/Ruby/Classes/CMath

sqrt(z) Class Public methods Returns the non-negative square root of

2025-01-10 15:47:30
cbrt
  • References/Ruby on Rails/Ruby/Classes/CMath

cbrt(z) Class Public methods returns the principal value of the cube root of

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

sin(z) Class Public methods returns the sine of z, where z

2025-01-10 15:47:30
asin
  • References/Ruby on Rails/Ruby/Classes/CMath

asin(z) Class Public methods returns the arc sine of z

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

log(*args) Class Public methods Returns the natural logarithm of

2025-01-10 15:47:30
exp
  • References/Ruby on Rails/Ruby/Classes/CMath

exp(z) Class Public methods Math::E raised to the z power

2025-01-10 15:47:30
acos
  • References/Ruby on Rails/Ruby/Classes/CMath

acos(z) Class Public methods returns the arc cosine of z

2025-01-10 15:47:30
cosh
  • References/Ruby on Rails/Ruby/Classes/CMath

cosh(z) Class Public methods returns the hyperbolic cosine of z

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

tanh(z) Class Public methods returns the hyperbolic tangent of z

2025-01-10 15:47:30
log10
  • References/Ruby on Rails/Ruby/Classes/CMath

log10(z) Class Public methods returns the base 10 logarithm of z

2025-01-10 15:47:30