UNPKG

998 BMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function cos
4
5Calculate the cosine of a value.
6
7For matrices, the function is evaluated element wise.
8
9
10## Syntax
11
12```js
13math.cos(x)
14```
15
16### Parameters
17
18Parameter | Type | Description
19--------- | ---- | -----------
20`x` | number &#124; BigNumber &#124; Complex &#124; Unit &#124; Array &#124; Matrix | Function input
21
22### Returns
23
24Type | Description
25---- | -----------
26number &#124; BigNumber &#124; Complex &#124; Array &#124; Matrix | Cosine of x
27
28
29## Examples
30
31```js
32math.cos(2) // returns number -0.4161468365471422
33math.cos(math.pi / 4) // returns number 0.7071067811865475
34math.cos(math.unit(180, 'deg')) // returns number -1
35math.cos(math.unit(60, 'deg')) // returns number 0.5
36
37const angle = 0.2
38math.pow(math.sin(angle), 2) + math.pow(math.cos(angle), 2) // returns number ~1
39```
40
41
42## See also
43
44[cos](cos.md),
45[tan](tan.md)