Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

class method

Math.sin

(::Math::double x) -> ::Float
Math.sin(x) → float

Returns the sine of x in radians.

  • Domain: (-INFINITY, INFINITY).

  • Range: [-1.0, 1.0].

Examples:

Example
sin(-PI)   # => -1.2246063538223773e-16 # -0.0000000000000001
sin(-PI/2) # => -1.0
sin(0.0)   # => 0.0
sin(PI/2)  # => 1.0
sin(PI)    # => 1.2246063538223773e-16  # 0.0000000000000001
See also .log2 .sinh .log10 .sqrt also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0