Reference · Math

math.atan

signature
math.atan(num) -> float

What it does

The arc tangent: the angle in radians, between -pi/2 and pi/2, whose tangent is the number, as Python's math.atan. It takes any number. For the angle of a point (x, y), which needs the signs of both, use math.atan2.

Examples

print(math.atan(0), math.atan(1), math.atan(-1))print(math.degrees(math.atan(1)), math.atan(math.tan(1)))
output
0.0 0.7853981633974483 -0.785398163397448345.0 1.0

Edge cases

print(math.atan(math.inf), math.atan(-math.inf), math.atan(1e300))print(math.atan(-1 / -1), math.atan2(-1, -1))print(math.atan(1) * 4 == math.pi)print(math.atan(math.nan))
output
1.5707963267948966 -1.5707963267948966 1.57079632679489660.7853981633974483 -2.356194490192345trueNaN

Errors

There is no domain error. A value that is not a number is a runtime error, not an error value: it stops the request; a decimal is converted first with float.

this one fails
print(math.atan("1"))
output
line 1: `math.atan` expects a number as argument 1, got str

Chaining

print(0.5 | math.atan | math.degrees)print([0, 1, 2] | map(math.atan) | map(math.degrees))
output
26.56505117707799[0.0, 45.0, 63.43494882292201]

See also

math.atan2, math.tan, math.asin, math.acos, math.degrees

Thread
7Useful? Like it, or add to its thread below.

Thread 0 posts

On math.atan(): questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.

    Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo