Skip to main content

sin

Function sin 

Source
pub const fn sin(x: Real) -> Real
Expand description

Computes the sine of x (in radians).

This is a const fn implementation based on argument reduction followed by a polynomial approximation.

§Testing

The following tests have been performed:

  • Maximum observed error of ≤ 1 ULP, measured over 5,000,000 random samples across a wide dynamic range.
  • Edge cases, including ±0, ±π/2, ±π, subnormal numbers, infinity, and NaN.
  • Monotonicity testing in both increasing and decreasing regions.
  • High-density testing near π/2.
  • Testing near multiples of π.
  • Hard argument reduction cases.
  • Statistical random testing across multiple magnitude scales.
  • Compile-time evaluation via const fn.

This implementation is intended for use in no_std and embedded environments.