SQL COSH function
Returns the hyperbolic cosine: COSH(0) is 1 and COSH grows exponentially, always 1 or greater.
- Kategorie
- Math
- Returns
float / double- In this category
- 42 of 82
Syntax
COSH(number)
Engine-Unterstützung
| Engine | Support | Notizen |
|---|---|---|
| SQL Server | Not built in | No hyperbolic functions; compute (EXP(x) + EXP(-x)) / 2.0 |
| PostgreSQL | Ja | Built in since PostgreSQL 12 |
| MySQL | Not built in | No hyperbolic functions in MySQL 8.4; use the EXP identity |
| SQLite | Ja | Built in on 3.35+ |
| Oracle | Ja | Built in |
Beispiele
PostgreSQL
SELECT COSH(0) AS one; -- 1
SQL Server
SELECT (EXP(1.0) + EXP(-1.0)) / 2.0 AS cosh_one; -- 1.5430
Oracle
SELECT COSH(x) AS catenary FROM cable_points;
MySQL
SELECT (EXP(x) + EXP(-x)) / 2 AS cosh_x FROM cable_points; -- no COSH in MySQL
Gut zu wissen
- COSH(x) >= 1 for every input: the e^x and e^-x terms cannot cancel below 1.
- COSH and SINH pair up in the identity COSH(x)^2 - SINH(x)^2 = 1, the hyperbolic analogue of the Pythagorean one.
- The exponential fallback for SQL Server is (EXP(x) + EXP(-x)) / 2.0, subject to the same EXP overflow near x = 710.
Questions about COSH
What is the smallest value COSH can return?
1, at x = 0. The function is symmetric and grows exponentially away from zero in both directions.
How do I compute COSH on SQL Server or MySQL?
(EXP(x) + EXP(-x)) / 2.0. Neither engine ships hyperbolic functions.
Is COSH related to regular COS?
Only by name. COS oscillates between -1 and 1; COSH is a smooth exponential curve that never drops below 1.
Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.
Related on SQLly
Cheat sheets for the engines that have it: PostgreSQL, SQLite, Oracle.
Functions your engine actually has
SQLly's completion lists the built-in functions of the engine you're connected to, whether that's SQL Server, PostgreSQL, MySQL, SQLite or Oracle. Hover a function for help, and signature hints show each argument as you type.