In MySQL, the TAN()
function returns the tangent of a value.
You provide the value as an argument when calling the function.
Syntax
This function can be used in either of the following two ways:
TAN(X)
Where X
is the value for which you’d like the arc tangent returned.
Example 1 – Basic Usage
Here’s a basic example to demonstrate.
SELECT TAN(1);
Result:
+-------------------+ | TAN(1) | +-------------------+ | 1.557407724654902 | +-------------------+
And with another value.
SELECT TAN(2.7);
Result:
+---------------------+ | TAN(2.7) | +---------------------+ | -0.4727276291030373 | +---------------------+
And with a negative value.
SELECT TAN(-2.7);
Result:
+--------------------+ | TAN(-2.7) | +--------------------+ | 0.4727276291030373 | +--------------------+
Example 2 – Expressions
You can also pass in expressions like this:
SELECT TAN(2.1 + 0.3);
Result:
+---------------------+ | TAN(2.1 + 0.3) | +---------------------+ | -0.9160142896734106 | +---------------------+
Example 3 – Passing in a Function
In this example I pass in the MySQL PI()
function as the argument.
SELECT TAN(PI());
Result:
+-------------------------+ | TAN(PI()) | +-------------------------+ | -1.2246467991473532e-16 | +-------------------------+