--- title: "sinh" slug: "dev-database-reference-sql-functions-numeric-sinh" updated: 2026-10-30T18:18:51Z published: 2026-10-30T18:18:51Z canonical: "docs.vastdata.com/dev-database-reference-sql-functions-numeric-sinh" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.vastdata.com/llms.txt > Use this file to discover all available pages before exploring further. # sinh *Applies to VAST Cluster 5.5.* *[Functions](/develop/docs/dev-database-reference-sql-functions-index) › [Numeric and math functions](/develop/docs/dev-database-reference-sql-functions-numeric) › Hyperbolic functions.* Returns the hyperbolic sine of a number, `(exp(x) - exp(-x)) / 2`. It takes any number. A result too large for a `DOUBLE` is infinity, not an error. ## Syntax ``` sinh(x) ``` | Argument | Type | Description | | --- | --- | --- | | `x` | Any number (`DOUBLE`, `REAL`, an integer or a `DECIMAL`) | Any value, including `inf` and `-inf`. | **Returns:** `DOUBLE`. ## Set up the examples The examples connect with the ADBC driver, as in [VAST Query Engine (ADBC)](/develop/docs/dev-database-integrations-adbc), and work in a schema called `docs_sql_fn_numeric_sinh`. Set `QE_ENDPOINT`, `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` and `VASTDB_BUCKET` ([SQL reference](/develop/docs/dev-database-reference-sql-index#example-connect-and-use-a-transaction)), and run the blocks in order in one Python session. Below each block is the output you should see. This block connects, defines the `run()` and `plan()` helpers, and creates a table of six readings. Row 3 has no value, and row 6 is too large for its hyperbolic sine to fit in a `DOUBLE`: ``` import os import re import adbc_driver_manager import adbc_driver_manager.dbapi as dbapi import adbc_driver_vastdb BUCKET = os.environ["VASTDB_BUCKET"] SCHEMA = f'"{BUCKET}/docs_sql_fn_numeric_sinh"' conn = dbapi.connect( driver=adbc_driver_vastdb.get_driver_path(), db_kwargs={ "vast.db.endpoint": os.environ["QE_ENDPOINT"], "vast.db.access_key": os.environ["AWS_ACCESS_KEY_ID"], "vast.db.secret_key": os.environ["AWS_SECRET_ACCESS_KEY"], }, autocommit=True, ) def server_message(e): """The server's message in a driver error, without the request ID or the echoed statement.""" text = re.sub(r"\[req=0x[0-9a-f]+\]: ", "", str(e)) found = (re.search(r'message: "(.*?)", request_id', text, re.S) or re.search(r"description: (.*)\)", text, re.S)) message = found.group(1) if found else text.strip().splitlines()[-1] message = re.sub(r"^Plan query: '.*?' failed with: ", "", message, flags=re.S) message = re.split(r"\\n|\n", message)[0].replace('\\"', '"') return message.replace(BUCKET, "") def run(sql): """Run one statement. Print the rows it returns, or the error.""" try: with conn.cursor() as cur: cur.execute(sql) rows = cur.fetchall() if cur.description else [] except (adbc_driver_manager.Error, OSError) as e: print(f"{type(e).__name__}: {server_message(e)}") else: print(rows) def plan(sql): """Print the plan without its ~N Rows lines: the table's row count, which can still be 0 just after an insert.""" with conn.cursor() as cur: cur.execute("EXPLAIN " + sql) steps = cur.fetchall()[0][1] print("\n".join(line for line in steps.splitlines() if "Rows" not in line)) TABLE = f"{SCHEMA}.readings" run(f"CREATE SCHEMA IF NOT EXISTS {SCHEMA}") run(f"CREATE TABLE IF NOT EXISTS {TABLE} (id BIGINT, x DOUBLE)") run(f"INSERT INTO {TABLE} VALUES " "(1, 1.0), (2, -1.0), (3, NULL), (4, 0.0), (5, 2.5), (6, 800.0)") ``` ``` [] [] [(6,)] ``` ## What it does `sinh(x)` is the hyperbolic sine, `(exp(x) - exp(-x)) / 2`. It's an odd function (`sinh(-x)` is `-sinh(x)`), it's 0 at 0, and it grows like `exp(x) / 2` for large `x`. Its inverse is [asinh](/develop/docs/dev-database-reference-sql-functions-numeric-asinh). | Call | Result | | --- | --- | | `sinh(0)` | `0.0` | | `sinh(1)` | `1.1752011936438014` | | `sinh(-1)` | `-1.1752011936438014` | | `sinh(710)` | `1.1169973830808557e+308` | | `sinh(711)` | `inf`: too large for a `DOUBLE` | | `sinh(-711)` | `-inf` | The result is a `DOUBLE` for every numeric argument type: an integer, a `REAL`, a `DECIMAL` or a `DOUBLE`. ``` run("SELECT sinh(0), sinh(1), sinh(-1), sinh(710), sinh(711), sinh(-711)") run("SELECT typeof(sinh(1::INTEGER)), typeof(sinh(0.5::FLOAT)), typeof(sinh(0.5))") ``` ``` [(0.0, 1.1752011936438014, -1.1752011936438014, 1.1169973830808557e+308, inf, -inf)] [('DOUBLE', 'DOUBLE', 'DOUBLE')] ``` ## NULLs and edge cases | Input | Result | | --- | --- | | `NULL` | `NULL` | | `'inf'::DOUBLE` | `inf` | | `'-inf'::DOUBLE` | `-inf` | | `'nan'::DOUBLE` | `nan` | | `-0.0::DOUBLE` | `-0.0`: the sign of zero is kept | | The smallest positive `DOUBLE` (`5e-324`) | `5e-324` | | `'12'` (a string literal holding a number) | Converted to `DOUBLE`: `81377.39570642984` | | `'abc'` (a string that isn't a number) | Error: `Could not convert string 'abc' to DOUBLE` | | A `BLOB`, date, boolean, list or interval | Error: `No function matches the given name and argument types`, for example `'sinh(DATE)'` | The same cases, as the cluster returns them. They use the helpers from [Set up the examples](/develop/docs/dev-database-reference-sql-functions-numeric-sinh#set-up-the-examples): ``` run("SELECT sinh(NULL), sinh('inf'::DOUBLE), sinh('-inf'::DOUBLE), sinh('nan'::DOUBLE)") run("SELECT sinh(-0.0::DOUBLE), sinh(5e-324::DOUBLE), sinh('12')") run("SELECT sinh('abc')") run("SELECT sinh(DATE '2026-10-16')") ``` ``` [(None, inf, -inf, nan)] [(-0.0, 5e-324, 81377.39570642984)] OSError: Could not convert string 'abc' to DOUBLE InternalError: Binder Error: No function matches the given name and argument types 'sinh(DATE)'. You might need to add explicit type casts. ``` ## Examples The hyperbolic sine of each reading. Row 6 overflows to `inf`, and the query still returns every row: ``` run(f"SELECT id, x, sinh(x) FROM {TABLE} ORDER BY id LIMIT 10") ``` ``` [(1, 1.0, 1.1752011936438014), (2, -1.0, -1.1752011936438014), (3, None, None), (4, 0.0, 0.0), (5, 2.5, 6.0502044810397875), (6, 800.0, inf)] ``` Keep only the rows whose hyperbolic sine is above 10: ``` run(f"SELECT id, x FROM {TABLE} WHERE sinh(x) > 10 ORDER BY id LIMIT 10") ``` ``` [(6, 800.0)] ``` ## How it runs in VAST The Query Engine runs on the cluster's CNodes, and a query on a table starts with a scan in VAST DataBase (`VAST_SCAN`). VAST DataBase can evaluate a comparison of a column with a constant, but not a function of a column, so `sinh()` is always computed by the Query Engine: - **In the `SELECT` list,** the scan reads the column and the Query Engine computes `sinh()` for each row it returns. - **In `WHERE`,** the scan sends the column for every row, and a `FILTER` step in the Query Engine computes `sinh()` and keeps the rows that match. No rows are skipped in storage. The plan of the `WHERE` example shows the `FILTER` step above the scan: ``` plan(f"SELECT id FROM {TABLE} WHERE sinh(x) > 10") ``` ``` ┌───────────────────────────┐ │ PROJECTION │ │ ──────────────────── │ │ #1 │ │ │ └─────────────┬─────────────┘ ┌─────────────┴─────────────┐ │ FILTER │ │ ──────────────────── │ │ (sinh(x) > 10.0) │ │ │ └─────────────┬─────────────┘ ┌─────────────┴─────────────┐ │ VAST_SCAN │ │ ──────────────────── │ │ Function: VAST_SCAN │ │ │ │ Projections: │ │ x │ │ id │ │ │ └───────────────────────────┘ ``` ## Make it faster - **Compare the raw column with the inverse of the constant.** `sinh()` grows as its argument grows, so `sinh(x) > 10` is the same condition as `x > asinh(10)`. A function on constants is computed once, before the scan, so the second form is a comparison of the column with a constant, which is pushed down to VAST DataBase. Its plan has no `FILTER` step: ``` plan(f"SELECT id FROM {TABLE} WHERE x > asinh(10)") run(f"SELECT id, x FROM {TABLE} WHERE x > asinh(10) ORDER BY id LIMIT 10") ``` ``` ┌───────────────────────────┐ │ VAST_SCAN │ │ ──────────────────── │ │ Function: VAST_SCAN │ │ Projections: id │ │ │ └───────────────────────────┘ [(6, 800.0)] ``` - **Store the result if you filter on it often.** Compute it when you write the rows and keep it in its own column: a condition on that column is pushed down, a condition on `sinh()` isn't. ## Limitations and errors - **Overflow gives infinity, not an error.** Above about 710 the result is `inf` (`sinh(711)` is `inf`), and below about -710 it is `-inf`. To find those rows, test the result with [isinf](/develop/docs/dev-database-reference-sql-functions-numeric-isinf): ``` run(f"SELECT id, x, isinf(sinh(x)) FROM {TABLE} ORDER BY id LIMIT 10") ``` ``` [(1, 1.0, False), (2, -1.0, False), (3, None, None), (4, 0.0, False), (5, 2.5, False), (6, 800.0, True)] ``` - **Numbers only.** A `BLOB`, a date, a boolean, a list or an interval fails with `No function matches the given name and argument types`; the error lists the one form `sinh` has, `sinh(DOUBLE) -> DOUBLE`. A string literal is converted to `DOUBLE` if it holds a number, and otherwise fails with `Could not convert string 'abc' to DOUBLE`. - **Use `sinh()` rather than the `exp()` formula for large values.** `exp(710)` is already `inf`, so `(exp(x) - exp(-x)) / 2` overflows sooner than `sinh(710)`, which is `1.1169973830808557e+308`. - **One argument.** `sinh(1, 2)` fails with `No function matches the given name and argument types 'sinh(INTEGER_LITERAL, INTEGER_LITERAL)'`. ## Similar functions | Function | Returns | Result for `1` | | --- | --- | --- | | `sinh(x)` | the hyperbolic sine | `1.1752011936438014` | | [cosh](/develop/docs/dev-database-reference-sql-functions-numeric-cosh) | the hyperbolic cosine, `(exp(x) + exp(-x)) / 2` | `1.5430806348152437` | | [tanh](/develop/docs/dev-database-reference-sql-functions-numeric-tanh) | the hyperbolic tangent, `sinh(x) / cosh(x)` | `0.7615941559557649` | | [asinh](/develop/docs/dev-database-reference-sql-functions-numeric-asinh) | the inverse of `sinh` | `asinh(sinh(1))` is `1.0` | | [exp](/develop/docs/dev-database-reference-sql-functions-numeric-exp) | e to the power `x`; `(exp(x) - exp(-x)) / 2` is the same as `sinh(x)` | `(exp(1) - exp(-1)) / 2` is `1.1752011936438014` | | [sin](/develop/docs/dev-database-reference-sql-functions-numeric-sin) | the sine of an angle in radians | | ``` run("SELECT sinh(1), cosh(1), tanh(1), asinh(sinh(1)), (exp(1) - exp(-1)) / 2, sin(1)") ``` ``` [(1.1752011936438014, 1.5430806348152437, 0.7615941559557649, 1.0, 1.1752011936438014, 0.8414709848078965)] ``` Clean up: ``` run(f"DROP TABLE IF EXISTS {TABLE}") run(f"DROP SCHEMA IF EXISTS {SCHEMA}") conn.close() ``` ``` [] [] ``` ## See also - [Numeric and math functions](/develop/docs/dev-database-reference-sql-functions-numeric): all the numeric functions. - [Where filters run](/develop/docs/dev-database-reference-sql-select#where-filters-run) and [pushdowns](/develop/docs/dev-database-reference-pushdowns). - [EXPLAIN](/develop/docs/dev-database-reference-sql-explain): how to read a plan.