This site is supported by donations to The OEIS Foundation.

# Template:Cos

The following documentation is located at Template:Cos/doc. [Edit Template:Cos/doc]
[<Purge> Template:Cos]

The {{cos}} circular function template returns the cosine of $\scriptstyle x \,$, where $\scriptstyle x \,$ is a real number expressing a circular angle in radians.

Note that you may also use the cos operator (used within the {{#expr: }} parser function extension, e.g. {{#expr: cos (pi/6) }}) which also takes a circular angle in radians as argument.

## Usage

{{cos|a real number}}

## Valid input

A real number (expressing a circular angle in radians) as argument.

## Examples

Examples with valid input

Code Result
{{cos|-5*pi/2}} 3.0616169978684E-16
{{cos|-pi/2}} 6.1232339957368E-17
{{cos|-pi/3}} 0.5
{{cos|-pi/4}} 0.70710678118655
{{cos|-pi/6}} 0.86602540378444
{{cos|0}} 1
{{cos|pi/6}} 0.86602540378444
{{cos|pi/4}} 0.70710678118655
{{cos|pi/3}} 0.5
{{cos|pi/2}} 6.1232339957368E-17
{{cos|5*pi/2}} 3.0616169978684E-16

Examples with invalid input (returns an error message)

Code Result
{{cos|i}} Expression error: Unrecognised word "i"

## Code

Currently (using built-in error message)

```
{{#expr: cos ({{{1}}}) }}

```

instead of (using custom error message)

```
{{ifnum| {{{1|NAN}}}
| {{#expr: cos ({{{1}}}) }}
| {{error| Cos error: Argument must be a real number (circular angle in radians) }}
}}

```