VOOZH about

URL: https://www.geeksforgeeks.org/ruby/ruby-math-cos-function/

⇱ Ruby | Math cos() function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Ruby | Math cos() function

Last Updated : 12 Jul, 2025
The cos() is an inbuilt function in Ruby returns the cosine value of a given angle expressed in radians which is in range [-inf, +inf]. The returned value is in range [-1, +1].
Syntax: Math.cos(value) Parameters: The function accepts one mandatory parameter value whose corresponding cosine value is returned. Return Value: It returns the cosine value.
Example 1: Output:
 0.5403023058681398
0.8775825618903728
0.5403023058681398
0.6216099682706644
Example 2: Output:
-0.577002178942952
0.4948722204034305
-0.37447564566939956
-0.40075875500376773
Reference: https://devdocs.io/ruby~2.5/math#method-c-cos
Comment