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
| 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
Use acos to compute the arccosine of a value and return the angle in radians.
Query
print result = acos(0.5)Output
| 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 isn't 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.