Overview

acos

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.

Usage#

Syntax#

acos(x)

Parameters#

Name Type Required Description
x real Yes A 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 isn't 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.

Other query languages#

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].

Splunk example

| eval angle = acos(normalized_rate)

APL equivalent

['sample-http-logs']
| extend angle = acos(normalized_rate)
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.

SQL example

SELECT ACOS(normalized_rate) AS angle FROM logs

APL equivalent

['sample-http-logs']
| extend angle = acos(normalized_rate)

Updated

Was this page helpful?