Skip to content
Related Articles

Related Articles

Ruby | CMath acos() Method
  • Last Updated : 07 Jan, 2020

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:



filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby code for acos() method
require 'cmath'
  
# Initialize value 
a = 0.3584
b = 2
  
# Printing result  
puts "acos value of a : #{CMath.acos(a)}\n\n"
puts "acos value of b : #{CMath.acos(b)}\n\n"

chevron_right


Output:

acos value of a : 1.204242852965772

acos value of b : 0.0+1.3169578969248164i

Example #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby code for acos() method
require 'cmath'
  
# Initialize value 
a = 0
b = -0.247
  
# Printng result   
puts "acos value of a : #{CMath.acos(a)}\n\n"
puts "acos value of b : #{CMath.acos(b)}\n\n"

chevron_right


Output:

acos value of a : 1.5707963267948966

acos value of b : 1.8203794286756558
My Personal Notes arrow_drop_up
Recommended Articles
Page :