sin
sin is most commonly used in observability to encode time-of-day or other periodic signals as cyclic coordinates. When combined with cos, it produces a two-dimensional representation of periodic phenomena that preserves circular distance. For example, you can encode hour-of-day cyclically so that hour 23 and hour 0 are treated as adjacent.
Usage#
Syntax#
sin(x)Parameters#
| Name | Type | Required | Description |
|---|---|---|---|
x |
real | Yes | The angle in radians. |
Returns#
The sine of x, a real number in the range [-1, 1].
Example#
Use sin to compute the sine of an angle in radians.
Query
print result = sin(pi() / 2)Output
| result |
|---|
| 1 |
List of related functions#
- cos: Returns the cosine. Use
sinandcostogether to produce a two-dimensional cyclic encoding of angles. - tan: Returns the tangent. Use it when you need the ratio of sine to cosine.
- asin: Returns the arc sine. Use it as the inverse of
sin. - pi: Returns the constant π. Use it to construct radian values before calling
sin. - radians: Converts degrees to radians. Use it to prepare degree inputs before calling
sin.
Other query languages#
Splunk SPL users
In Splunk SPL, sin() takes an angle in radians and returns the sine, just like APL.
Splunk example
| eval sin_val = sin(angle_rad)APL equivalent
['sample-http-logs']
| extend sin_val = sin(angle_rad)ANSI SQL users
In ANSI SQL, SIN() is a standard function with identical semantics.
SQL example
SELECT SIN(angle_rad) AS sin_val FROM logsAPL equivalent
['sample-http-logs']
| extend sin_val = sin(angle_rad)