Ruby – Find Inverse Arc Sine – asin() Method – Examples & Explanation

asin() method can be used to find the inverse arc sine of the any given complex number in Ruby programming language. CMath.asin() method exists in CMath library of Ruby language.

asin() Method in Ruby

asin() method exists in Standard CMath Library of Ruby. The purpose of this method is to provide perfect arc sine of the given complex number.

Syntax of the asin() Method in Ruby

Syntax of asin() Method is:

cmath.asin(x)

 

Parameters of asin() Method in Ruby

Parameter  Description
x Any valid complex number. This parameter is required.

Note: If the x parameter is not a complex number, asin() method will return an error.

 

Return Value of asin()

asin() method will return the arc sine of the given numeric complex number.

Ruby – Get the asin() of any Given Numbers

 # import CMath library 
 require 'cmath' 
 x = CMath.asin(5 + 5i) 
 puts x 

Output

0.7803985799853912+2.649196177806475i

 

Ruby asin() Function Example 2

 # import CMath library 
 require 'cmath' 
 x = CMath.asin(-5 + 5i) 
 puts x  

Ouput

-0.7803985799853912+2.649196177806475i

 

Ruby Non-Complex numbers in asin()Function Example 3

 # import CMath library 
 require 'cmath' 
 x = CMath.asin(a5 - b5i) 
 puts x 

Output

Error

 

Ruby – Use of Negative Value in asin() Function Example 4

 # import CMath library 
 require 'cmath' 
 x = CMath.asin(-5 - 5i) 
 puts x 

Output

-0.7803985799853841-2.649196177806471i

 

Ruby – Get the asin() of Particular Number Example 5

 # import CMath library 
 require 'cmath' 
 x = CMath.asin(8) 
 puts x 

Output

1.5707963267948966-2.7686593833135738i