This site is supported by donations to The OEIS Foundation.

# Template:Acos

The {{acos}} circular function template returns the arc cosine (a circular angle in ${\displaystyle \scriptstyle [0,\,\pi ]\,}$ radians) of ${\displaystyle \scriptstyle x\,}$, where ${\displaystyle \scriptstyle x\,}$ is a real number in closed interval [-1, +1].

Note that you may also use the acos operator (used within the {{#expr: }} parser function extension, e.g. {{#expr: acos 0.5 }}) which also returns a circular angle in ${\displaystyle \scriptstyle [0,\,\pi ]\,}$radians.

## Usage

{{acos|a real number in closed interval [-1, +1]}}

## Valid input

A real number in closed interval [-1, +1].

## Examples

Examples with valid input

Code Result
{{acos|- (2^(1/2) / 2)}} 2.3561944901923
{{acos|-0.5}} 2.0943951023932
{{acos|0}} 1.5707963267949
{{acos|0.5}} 1.0471975511966
{{acos|2^(1/2) / 2}} 0.78539816339745

Examples with invalid input (returns an error message)

Code Result
{{acos|i}} Expression error: Unrecognized word "i".
{{acos|- (2^(1/2))}} Invalid argument for acos: < -1 or > 1.
{{acos|+ 2^(1/2)}} Invalid argument for acos: < -1 or > 1.

## Code

Currently (using built-in error message)


{{#expr: acos ({{{1}}}) }}



instead of (using custom error message)


{{ifnum| {{{1|NAN}}}
| {{#ifexpr: abs ({{{1}}}) <= 1
| {{#expr: acos ({{{1}}}) }}
| {{error| Acos error: Argument must be a real number in closed interval [-1, +1] }}
}}
| {{error| Acos error: Argument must be a real number in closed interval [-1, +1] }}
}}