红宝石 | CMath asin() 方法
asin() 方法是 CMath 类,用于返回给定值的反正弦值。
Syntax: Math.asin(z)
Parameter: Here, z is the value whose arc sine is to be calculated.
Returns: This method returns the arc sine value of the z.
示例 1:
# Ruby code for asin() method
require 'cmath'
# Initialize value
a = 0.3584
b = 2
# Printing result
puts "asin value of a : #{CMath.asin(a)}\n\n"
puts "asin value of b : #{CMath.asin(b)}\n\n"
输出:
asin value of a : 0.3665534738291246
asin value of b : 1.5707963267948966-1.3169578969248166i
示例 2:
# Ruby code for asin() method
require 'cmath'
# Initialize value
a = 0
b = -0.247
# Printing result
puts "asin value of a : #{CMath.asin(a)}\n\n"
puts "asin value of b : #{CMath.asin(b)}\n\n"
输出:
asin value of a : 0.0
asin value of b : -0.24958310188075922