Skip to main content
Use the 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.
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].
| eval angle = acos(normalized_rate)
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.
SELECT ACOS(normalized_rate) AS angle FROM logs

Usage

Syntax

acos(x)

Parameters

NameTypeRequiredDescription
xrealYesA real number in the range [-1, 1].

Returns

  • The arc cosine of x in radians, in the range [0, π].
  • null if x < -1 or x > 1.

Example

Use acos to compute the arccosine of a value and return the angle in radians. Query
print result = acos(0.5)
Run in Playground Output
result
1.0472
  • 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 acos as the inverse.
  • radians: Converts degrees to radians. Use it to convert angle output from acos into degrees.
  • degrees: Converts radians to degrees. Use it if you need the acos result expressed in degrees.