acos

This page explains how to use the acos function in APL.

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.

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