SIN

Compute the sine of an angle expressed in radians.

Category: mathReturns: DOUBLEDialect: Standard

Syntax

SIN(expr)

Description

## Overview Returns the sine of an angle provided in radians. The sine function is central to any workload that deals with periodic phenomena: oscillations, AC signals, rotational kinematics, and Fourier-style decomposition. It is also a building block for geospatial great-circle calculations and for coordinate rotations in 2D and 3D transforms. Because SQL exposes SIN as a scalar DOUBLE function, it composes cleanly with projections, WHERE predicates, and aggregates. Combine it with RADIANS() when your data is stored in degrees, or with COS() and ATAN2() when you need direction and magnitude from raw (x, y) components. ## Behavior - Accepts any finite DOUBLE value. There is no domain restriction, but very large magnitudes lose trigonometric precision because the input must be reduced modulo 2*pi before the series is evaluated. - Returns a DOUBLE strictly in the interval [-1, 1]. - Returns NULL if the argument is NULL. - Returns NaN for NaN input and 0 for input 0. - Implicitly casts integer inputs to DOUBLE before evaluation. - Is deterministic: identical inputs always produce identical outputs within the same engine version. ## Numeric precision - Computed using the IEEE 754 double-precision sine routine. Results are accurate to within one ULP near small inputs. - For inputs near integer multiples of pi, the result is a tiny non-zero value rather than mathematical zero, because pi itself is not exactly representable in binary floating-point. - Accuracy degrades for very large magnitudes because argument reduction amplifies the representation error in pi. ## Compatibility - Conforms to the SQL standard definition of SIN as a scalar DOUBLE function. - Matches the semantics of the IEEE 754 sin() intrinsic and is interchangeable with typical mathematical library implementations.

Parameters

NameTypeDescription
exprSpecifies the angle in radians whose sine is returned. Accepts any finite DOUBLE value. To pass an angle expressed in degrees, wrap the argument in RADIANS().

Examples

-- Basic literal: SIN of 0 radians
SELECT SIN(0);
-- Result: 0.0
-- SIN at pi/2 evaluates to 1
SELECT SIN(PI() / 2);
-- Result: 1.0
-- Convert degrees to radians before taking the sine
SELECT SIN(RADIANS(30));
-- Result: 0.49999999999999994
-- Edge case: SIN(PI()) is very close to 0 but not exactly 0 due to floating-point representation of pi
SELECT SIN(PI());
-- Result: 1.2246467991473532E-16
-- NULL propagation
SELECT SIN(NULL);
-- Result: NULL
-- Column use: project phase angle onto vertical component for oscillation signals
SELECT reading_id, SIN(phase_radians) AS vertical_component
FROM iot.telemetry.wave_samples;

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →