Ruby CMath sin() Method with example
sin() method is CMath class which is used to returns the sine of the given value.
Syntax: Math.sin(z)
Parameter: Here, z is the value whose sine is to be calculated.
Returns: This method returns the sine value of the z.
Example 1:
require 'cmath'
a = 0 . 3584
b = 2
puts "sin value of a : #{CMath.sin(a)}\n\n"
puts "sin value of b : #{CMath.sin(b)}\n\n"
|
Output:
sin value of a : 0.35077634808518837
sin value of b : 0.9092974268256817
Example 2:
require 'cmath'
a = 0
b = - 0 . 247
puts "sin value of a : #{CMath.sin(a)}\n\n"
puts "sin value of b : #{CMath.sin(b)}\n\n"
|
Output:
sin value of a : 0.0
sin value of b : -0.24449611303251328
Last Updated :
07 Jan, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...