math.trig
sine, cosine and friends; angles as units
Example results generated on 2026-10-08. Ones using
now,todayor randomness will differ when you run them: press Run on any example to run it in your browser, after editing it if you like.
Functions
| function | description |
|---|---|
sin(x: num|quantity) | sine of radians or an angle unit |
cos(x: num|quantity) | cosine of radians or an angle unit |
tan(x: num|quantity) | tangent of radians or an angle unit |
asin(x: num) | arcsine, as an angle |
acos(x: num) | arccosine, as an angle |
atan(x: num) | arctangent, as an angle |
atan2(y: num|quantity, x: num|quantity) | angle of the point (x, y), as an angle |
sinh(x: num) | hyperbolic sine |
cosh(x: num) | hyperbolic cosine |
tanh(x: num) | hyperbolic tangent |
sin
sin(x: num|quantity): sine of radians or an angle unit
sin(30 deg)
# → 0.5
sin(pi / 2)
# → 1
cos
cos(x: num|quantity): cosine of radians or an angle unit
cos(60 deg)
# → 0.5
tan
tan(x: num|quantity): tangent of radians or an angle unit
tan(45 deg)
# → 1
asin
asin(x: num): arcsine, as an angle
asin(1) to deg
# → 90 deg
See also: sin
acos
acos(x: num): arccosine, as an angle
acos(0) to deg
# → 90 deg
See also: cos
atan
atan(x: num): arctangent, as an angle
atan(1) to deg
# → 45 deg
atan2
atan2(y: num|quantity, x: num|quantity): angle of the point (x, y), as an angle
atan2(1, -1) to deg
# → 135 deg
sinh
sinh(x: num): hyperbolic sine
sinh(1)
# → 1.1752
cosh
cosh(x: num): hyperbolic cosine
cosh(1)
# → 1.54308
tanh
tanh(x: num): hyperbolic tangent
tanh(1)
# → 0.761594
More examples
trig
# trig takes angle units
sin(30 deg)
# → 0.5
# radians back to degrees
atan2(1, 1) to deg
# → 45 deg