CKTIS / Python
math.tan
Computes the tangent of a radian angle.
Version: Python 3.14; repository image, production runtime not attested
Syntax
math.tan(x, /)Computes the tangent of a radian angle.
Values near odd multiples of half pi are highly sensitive to small angle errors.
Tangent divides sine by cosine. At pi/4 radians those coordinates agree, giving approximately 1; at zero the sine is zero. At odd multiples of pi/2 the exact function has a pole. The floating-point approximation to that angle may give a huge finite value.
import math
assert math.isclose(math.tan(math.pi / 4), 1.0)
assert math.tan(0) == 0.0 and abs(math.tan(math.pi / 2)) > 1e12
Examples
import math
print(round(math.tan(math.pi / 4), 6))
print(math.tan(0))
Result
1.0 0.0
Tangent divides sine by cosine. At pi/4 radians those coordinates agree, giving approximately 1; at zero the sine is zero. At odd multiples of pi/2 the exact function has a pole. The floating-point approximation to that angle may give a huge finite value.