PostgreSQL TANH() Function
The PostgreSQL TANH() function returns hyperbolic tangent of a value. The hyperbolic tangent of x is defined as:
where e is an Euler's number.
Syntax
TANH(x)
Parameters
x |
Required. Specify the value. |
Return Value
Returns the hyperbolic tangent of a value.
Example 1:
The example below shows the usage of TANH() function.
SELECT TANH(0); Result: 0 SELECT TANH(1); Result: 0.7615941559557649 SELECT TANH(-1); Result: -0.7615941559557649 SELECT TANH(2); Result: 0.9640275800758169 SELECT TANH(-2); Result: -0.9640275800758169
Example 2:
Consider a database table called Sample with the following records:
Data | x |
---|---|
Data 1 | 0 |
Data 2 | 0.5 |
Data 3 | 1 |
Data 4 | 1.5 |
Data 5 | 2 |
The statement given below can be used to calculate the hyperbolic tangent of values of column x.
SELECT *, TANH(x) AS TANH_Value FROM Sample;
This will produce the result as shown below:
Data | x | TANH_Value |
---|---|---|
Data 1 | 0 | 0 |
Data 2 | 0.5 | 0.46211715726000974 |
Data 3 | 1 | 0.7615941559557649 |
Data 4 | 1.5 | 0.9051482536448664 |
Data 5 | 2 | 0.9640275800758169 |
❮ PostgreSQL Functions