PostgreSQL COSH() Function
The PostgreSQL COSH() function returns hyperbolic cosine of a value. The hyperbolic cosine of x is defined as:
where e is an Euler's number.
Syntax
COSH(x)
Parameters
x |
Required. Specify the value. |
Return Value
Returns the hyperbolic cosine of a value.
Example 1:
The example below shows the usage of COSH() function.
SELECT COSH(0); Result: 1 SELECT COSH(1); Result: 1.5430806348152437 SELECT COSH(-1); Result: 1.5430806348152437 SELECT COSH(2); Result: 3.7621956910836314 SELECT COSH(-2); Result: 3.7621956910836314
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 cosine of values of column x.
SELECT *, COSH(x) AS COSH_Value FROM Sample;
This will produce the result as shown below:
Data | x | COSH_Value |
---|---|---|
Data 1 | 0 | 1 |
Data 2 | 0.5 | 1.1276259652063807 |
Data 3 | 1 | 1.5430806348152437 |
Data 4 | 1.5 | 2.352409615243247 |
Data 5 | 2 | 3.7621956910836314 |
❮ PostgreSQL Functions