The TAN() function in MySQL is used to calculate the tangent of a number. The number is expected to be in radians.
Definition and Usage
- The
TAN()function returns the tangent of a given number (in radians).
Syntax
TAN(number)
Parameter Values
| Parameter | Description |
|---|---|
number |
A numeric value representing the angle in radians. |
Technical Details
- Works in: From MySQL 4.0
- Return Value: A numeric value representing the tangent of the input number.
Examples
Example 1: Tangent of a number
SELECT TAN(1.75);
Output (example):
TAN(1.75)
-----------
1.7016
In this example, the tangent of 1.75 radians is calculated.
Example 2: Tangent of a negative number
SELECT TAN(-3);
Output (example):
TAN(-3)
----------
0.1425
In this example, the tangent of -3 radians is calculated.
Example 3: Using PI() function for an angle
SELECT TAN(PI()/4);
Output (example):
TAN(PI()/4)
------------
1
Here, PI()/4 radians equals 45 degrees, and the tangent of 45 degrees is 1.
Use Cases
- Trigonometric Calculations: The
TAN()function is useful for various trigonometric computations, such as in geometry, physics, and engineering. - Angle-based Calculations: When working with angles in radians and needing to find their tangent.
Related Functions
SIN(): Returns the sine of a number.COS(): Returns the cosine of a number.ATAN(): Returns the arc tangent of a number.ATAN2(): Returns the arc tangent of two values.