OKPEDIA PYTHON TRIGONOMETRIA EN

How to calculate the tangent in python

To calculate the tangent trigonometric function in python language, you can use the tan () function of the math module.

import math
math.tan(x)

The parameter x is the measure of the angle expressed in radians.

The tan (x) function returns the tangent of x.

What's the tangent? In trigonometry, the tangent is the ratio of the sine to the cosine of the angle. The tangent equals zero if the angle is 0 degrees. It equals infinity if the angle is 90 °.
the tangent function

Examples

Example 1

An angle of 45 ° measures π / 4 radians.

The pi (π) in the math module is the constant math.pi

This procedure calculates the tangent of the angle

import math
x=math.pi/4
math.tan(x)

The tan() function returns the value

0.9999999999999999

The tangent of π / 4 is 1.

Note. Python functions often do not round infinitesimal values. Hence, it is preferable to round off the tan function.

Example 2

This script calculates the tangent of an angle of 10 °

import math
x=math.radians(10)
math.tan(x)

The math.radians() function transforms the angle from sexagesimal to radians.

In the next line, the tan() function calculates the tangent of the angle

0.17632698070846498

The tangent of an angle of 10 degrees is approximately 0.17632..

https://how.okpedia.org/en/python/how-to-calculate-the-tangent-in-python


Report us an error or send a suggestion to improve this page


How to find in Python


FacebookTwitterLinkedinLinkedin