MongoDB $asinh Operator

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

What Is $asinh?

$asinh is a MongoDB aggregation expression that returns the inverse hyperbolic sine (arc hyperbolic sine) of a number—the value y such that sinh(y) equals that input. It accepts any real number (positive, negative, or zero).

Remember
$asinh = Math.asinh for aggregation

{ $asinh: <expression> }

input  → any real number
output → real number (asinh is odd: asinh(-x) = -asinh(x))
check  → asinh(0) = 0

null / missing → null
NaN → NaN
UsePrefer
Undo a hyperbolic sine$asinh
Forward hyperbolic sine$sinh
Inverse sine (trig, not hyperbolic)$asin

How to Use $asinh in MongoDB

Pass a number (or a field that holds one), then keep or round the result as needed.

  1. Choose an expression stage ($addFields or $project).
  2. Point $asinh at a field, literal, or nested numeric expression.
  3. Optionally wrap with $round for a shorter display value.
  4. Optionally check with $sinh that you get the original number back.
PieceRequired?Role
$asinhYesInverse hyperbolic sine
ExpressionYesAny real number, field, or nested math
$roundNoTrim floating-point noise for reports

Pseudocode

Pseudocode
for each document:
    x = evaluate(expression)
    if x is null or missing:
        result = null
    else if x is NaN:
        result = NaN
    else:
        result = asinh(x)   // any real x is fine
    emit { ..., field: result }

Cheat Sheet

Keep these facts handy while writing inverse-hyperbolic-sine expressions.

TopicDetail
TypeAggregation expression (not a find filter)
Syntax{ $asinh: <expression> }
DomainAll real numbers
Odd propertyasinh(-x) = -asinh(x)
Zero checkasinh(0) = 0
Round-trip$sinh({ $asinh: x }) ≈ x
Sample checkasinh(1) ≈ 0.8814

Live Preview

Watch $asinh turn a number into its inverse hyperbolic sine. Negatives and zero are valid.

Simulates $asinh (same idea as the mongosh examples below).

Result
x = 1
$asinh(x) → 0.881374

{ asinh_value: 0.881374 }

Worked Walkthrough — asinh(1)

Start with a single number 1. We want the value y where sinh(y) = 1.

Calculation
Document:
  { value: 1 }

Goal: find y such that sinh(y) = 1

$asinh(1) ≈ 0.881373587019543

Check with hyperbolic sine:
  sinh(0.881373587019543) ≈ 1 ✓

Also remember:
  asinh(0)  = 0
  asinh(-1) ≈ -0.8814   // odd function

MongoDB Examples

We use three small numbers: 0, 1, and -1. First we store them, then we compute $asinh, then we round for cleaner output. Run these in mongosh after inserting the sample data once.

Example 1 — Sample Data

Imagine three readings: zero, one positive, and one negative. We save each as its own document in a collection named hyperbolic.

mongosh
db.hyperbolic.insertMany([
  { _id: 1, value: 0 },
  { _id: 2, value: 1 },
  { _id: 3, value: -1 }
]);

How the Data Is Stored in MongoDB

After the insert, MongoDB keeps three documents in hyperbolic. Run find() to see them:

mongosh
db.hyperbolic.find().sort({ _id: 1 })

Read those documents like this:

Field in MongoDBValuePlain English
_id1, 2, 3Document id (row number for this lesson)
value0, 1, -1Number we will pass to $asinh
Picture
Three inputs (easy smoke tests):

  value:  0  → asinh should be  0
  value:  1  → asinh ≈  0.8814
  value: -1  → asinh ≈ -0.8814   (mirror of +1)

Why these three?
  • 0 checks the zero edge case
  • 1 is a common positive sample
  • -1 shows negatives are valid (unlike $acosh)

How It Works

  1. Insert once. insertMany adds three documents to hyperbolic.
  2. MongoDB stores fields as written. Each value is just a number: 0, 1, or -1.
  3. find() shows the same shape. What you inserted is what you get back—ready for $asinh in the next examples.

Example 2 — Basic $asinh

Goal: compute inverse hyperbolic sine for every stored value.

mongosh
db.hyperbolic.aggregate([
  {
    $addFields: {
      asinh_value: { $asinh: "$value" }
    }
  },
  { $sort: { _id: 1 } }
]);

How It Works

  1. Read each stored value. MongoDB already has 0, 1, and -1 from Example 1.
  2. Apply inverse hyperbolic sine. $asinh: "$value" runs on every document.
  3. Check the pattern. Zero stays zero; 1 and -1 are mirrors (odd function).
  4. Keep all fields. $addFields adds asinh_value next to the original value—nothing is deleted.

Example 3 — Rounded Results

Same inputs, but wrap $asinh with $round for shorter numbers in reports.

mongosh
db.hyperbolic.aggregate([
  {
    $addFields: {
      asinh_rounded: {
        $round: [ { $asinh: "$value" }, 4 ]
      }
    }
  },
  { $sort: { _id: 1 } }
]);

How It Works

  1. Same stored documents. Still using values 0, 1, and -1 from Example 1.
  2. Same $asinh first. Full precision is computed, then trimmed.
  3. Round to 4 decimals. $round keeps reports readable (0.8814 instead of a long float).
  4. Easy check. Zero stays 0; positive and negative results stay mirrors.

Edge Cases & Pitfalls

Check these before using $asinh in production pipelines.

name

Do not confuse with $asin

$asin is inverse sine with domain [-1, 1]. $asinh is hyperbolic and accepts any real number.

domain

Negatives are valid

Unlike $acosh, there is no “input must be ≥ 1” rule. Negative values simply return negative results.

null

Null and missing become null

Missing fields return null, not an error. Handle them before math if nulls are invalid in your data.

scale

Growth is slow for large |x|

For large magnitudes, asinh grows roughly like a log. That is useful for compressing outliers, but do not expect linear scaling.

Performance Notes

ApproachCostBest for
$asinh alonePer-document mathSimple inverse hyperbolic sine fields
$asinh + $roundStill O(docs)Readable report columns
$sinh round-trip checkTwo math opsValidating transforms in tests

Trig and hyperbolic expressions are cheap compared with large sorts or joins. Filter early with $match when only some documents need the transform.

Key Takeaways

  • Role: inverse hyperbolic sine of any real number.
  • Domain: no [-1, 1] clamp—negatives are fine.
  • Pair: reverse of $sinh; not the same as $asin.
  • Smoke test: asinh(0) = 0.

One line: $asinh answers “which value has this hyperbolic sine?”—for any real input, including negatives and zero.

Frequently Asked Questions

$asinh returns the inverse hyperbolic sine (arc hyperbolic sine) of a number—the value y such that sinh(y) equals that number. Use it inside aggregation expression stages such as $project and $addFields.
Any real number—positive, negative, or zero. Unlike $acosh (input ≥ 1) or $asin (input in [-1, 1]), $asinh has no domain clamp for normal numbers.
asinh(0) equals 0. That makes zero a handy smoke-test when checking pipeline output.
$asinh returns null when the input is null or the field is missing. If the argument is NaN, $asinh returns NaN.
$asin is inverse sine (trig, domain [-1, 1]). $asinh is inverse hyperbolic sine (any real input). Same naming style, different math.
Yes for the math. Think of $asinh as MongoDB’s aggregation version of Math.asinh—run it in the pipeline, not as a standalone find() filter.

Next: $atan

Compute the inverse tangent in an aggregation pipeline.

$atan tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful