acos function in APL to compute the arc cosine (inverse cosine) of a numeric expression. The function returns the angle, in radians, whose cosine equals the input value. The input must be in the range [-1, 1]; values outside this range return null.
acos is useful when you work with normalized ratios or rates that fall in the [-1, 1] range and you need to encode them as angular values. For example, you can use acos to convert a normalized success rate into a phase angle for cyclic analysis or signal processing.
For users of other query languages
If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.Splunk SPL users
Splunk SPL users
In Splunk SPL,
acos() is available in the eval command and works identically: it returns the arc cosine in radians for inputs in [-1, 1].ANSI SQL users
ANSI SQL users
In ANSI SQL,
ACOS() is a standard mathematical function with the same semantics. Pass a value in [-1, 1] to receive the arc cosine in radians.Usage
Syntax
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
x | real | Yes | A real number in the range [-1, 1]. |
Returns
- The arc cosine of
xin radians, in the range [0, π]. nullifx< -1 orx> 1.
Example
Useacos to compute the arccosine of a value and return the angle in radians.
Query
| result |
|---|
| 1.0472 |
List of related functions
- asin: Returns the arc sine. Use it when the input value maps to a sine rather than a cosine.
- atan: Returns the arc tangent. Use it when the input is not constrained to [-1, 1].
- cos: Returns the cosine. Use it to apply the forward transformation before using
acosas the inverse. - radians: Converts degrees to radians. Use it to convert angle output from
acosinto degrees. - degrees: Converts radians to degrees. Use it if you need the
acosresult expressed in degrees.