Skip to main content

tan

1. TAN Function

The TAN function in H2 database is used to calculate the tangent of a given angle in radians.

2. Syntax

The syntax for the TAN function in H2 database is as follows:

TAN(angle)

Arguments

  • angle: The angle for which the tangent needs to be calculated. It should be a numeric value representing the angle in radians.

Return

  • The TAN function returns the tangent of the given angle.

3. Notes

  • The TAN function in H2 database expects the angle to be in radians. If the angle is in degrees, you can convert it to radians using the RADIANS function.
  • If the input angle is not a number or exceeds the numeric range, the TAN function will return NULL.
  • Remember to use the correct syntax and data type while using the TAN function to avoid errors.

4. Examples

Here are a few examples demonstrating the usage of the TAN function in H2 database:

Example 1 - Calculating the tangent of 1 radian:

SELECT TAN(1) AS tangent;

Output:

TANGENT
-------
1.5574077246549023

Example 2 - Calculating the tangent of an angle stored in a column:

CREATE TABLE angles (
id INT PRIMARY KEY,
angle DOUBLE
);

INSERT INTO angles VALUES (1, 0.5), (2, 1), (3, 1.5);

SELECT id, angle, TAN(angle) AS tangent
FROM angles;

Output:

ID | ANGLE |      TANGENT
---+-------+------------------
1 | 0.5 | 0.5463024898437905
2 | 1 | 1.5574077246549023
3 | 1.5 | 14.101419947171719
  • sin - Calculate sine
  • cos - Calculate cosine