Documentation moved.
This entry is now part of the unified function reference. Open the unified page →
Function
src/index.ts:740nerdamer.cos
nerdamer.cos(x: ExpressionInput): ExpressionComputes the cosine of an expression. Returns exact symbolic values for well-known multiples of π (π/6, π/4, π/3, π/2, π, etc.). Cosine is an even function:
`cos(-x)`automatically simplifies to
`cos(x)`. Inverse trig compositions are resolved: -
`cos(acos(x))`returns
`x`-
`cos(asin(x))`returns
`sqrt(1 − x²)`-
`cos(atan(x))`returns
`1/sqrt(1 + x²)`throws
UndefinedError If
`x`is
`±∞`.
Parameters
| Name | Type | Description |
|---|---|---|
x | ExpressionInput | The angle in radians. |
Returns
Expression — The cosine of `x`.
Examples
cos(0).text() // "1"
cos('pi').text() // "-1"
cos('pi/2').text() // "0"
cos('pi/3').text() // "1/2"
cos('pi/4').text() // "1/2*sqrt(2)"
cos('pi/6').text() // "1/2*sqrt(3)"
// Symbolic
cos('x').text() // "cos(x)"