Documentation moved.
This entry is documented with its primary interface. Open the documentation →
Function
src/index.ts:848nerdamer.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
core!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)"