Ruby | CMath acos() Method
Last Updated :
20 Feb, 2023
acos() method is CMath class which is used to returns the arc cosine of the given value.
Syntax: Math.acos(z) Parameter: Here, z is the value whose arc cosine is to be calculated. Returns: This method returns the arc cosine value of the z.
Example #1:
Ruby
require 'cmath'
a = 0 . 3584
b = 2
puts "acos value of a :
puts "acos value of b :
|
Output:
acos value of a : 1.204242852965772
acos value of b : 0.0+1.3169578969248164i
Example #2:
Ruby
require 'cmath'
a = 0
b = - 0 . 247
puts "acos value of a :
puts "acos value of b :
|
Output:
acos value of a : 1.5707963267948966
acos value of b : 1.8203794286756558
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...