SQLite TAN function

The TAN function in SQLite is a mathematical function that returns the tangent of an input angle. The tangent of an angle is defined as the ratio of the length of the opposite side of a right-angled triangle to the length of the adjacent side.


The syntax for using the TAN function in SQLite is as follows:


Here, X represents the angle in radians for which the tangent is to be calculated. The value of X can be a numeric expression or a column name from a table.

The TAN function returns a floating-point value, which represents the tangent of the input angle. If the input angle is not valid, the TAN function returns NULL.


For example, if we want to calculate the tangent of an angle of 45 degrees (π/4 radians), we can use the following SQLite query:


The above query returns a value of 1, which is the tangent of 45 degrees.

It is important to note that the TAN function in SQLite operates on angles in radians, not degrees. Therefore, it is necessary to convert degrees to radians before passing them as input to the TAN function. This can be done using the built-in SQLite function RADIANS, which converts degrees to radians.

In conclusion, the TAN function in SQLite is a useful mathematical function that allows us to calculate the tangent of an input angle in radians. It is easy to use and returns accurate results when given valid input.