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