MongoDB $asinh Operator

Beginner
⏱️ 9 min read
📚 Updated: Jul 2026
🎯 4 Examples
Hyperbolic Math

What You’ll Learn

The $asinh operator returns the inverse hyperbolic sine of a number in MongoDB aggregation pipelines. It is the reverse of $sinh and accepts any real number — positive, negative, or zero.

01

Inverse asinh

Reverse of hyperbolic sine.

02

Syntax

One expression inside $asinh.

03

All Reals

Any number is valid input.

04

$project Stage

Add computed fields easily.

05

Use Cases

Stats, signals, transforms.

06

Edge Case

asinh(0) = 0

Definition and Usage

In MongoDB’s aggregation framework, the $asinh operator computes the inverse hyperbolic sine of a numeric expression. If sinh(y) = x, then asinh(x) = y. For example, $asinh(1) returns approximately 0.881, and $asinh(0) returns 0.

💡
Beginner Tip

Unlike $acosh, $asinh works on any real number including negatives. Think of it as MongoDB’s version of JavaScript’s Math.asinh().

📝 Syntax

The $asinh operator takes one numeric expression:

mongosh
{ $asinh: <expression> }

Syntax Rules

  • $asinh — returns the inverse hyperbolic sine of the expression.
  • <expression> — can be any real number (positive, negative, or zero).
  • Use it inside stages like $project, $addFields, or $set.
  • If the input is null, the result is null.
  • No domain restriction like $acosh (which requires input ≥ 1).

💡 $asinh vs $acosh

Both are inverse hyperbolic operators, but their input domains differ:

$asinh — accepts any real number (including negatives)
$acosh — requires input ≥ 1
$asinh: -2-1.444 (valid)
$acosh: -2NaN (invalid)

⚡ Quick Reference

QuestionAnswer
Operator typeAggregation expression operator (hyperbolic)
Syntax{ $asinh: <expression> }
Input rangeAll real numbers
Inverse of$sinh
Common stages$project, $addFields, $set
Example
{
  $asinh: 1
}

≈ 0.881

Negative
{
  $asinh: -2
}

≈ -1.444

Zero
{
  $asinh: 0
}

Returns 0

Null input
{
  $asinh: null
}

Returns null

Examples Gallery

Compute inverse hyperbolic sine on sample values, including positive, negative, and zero inputs.

📚 Basic Computation

Use a data collection and compute $asinh for each numeric field with $project.

Sample Input Documents

Suppose you have a data collection with a numeric value field:

mongosh
[
  { "_id": ObjectId("609c26812e9274a86871bc6a"), "value": 1 },
  { "_id": ObjectId("609c26812e9274a86871bc6b"), "value": 2 },
  { "_id": ObjectId("609c26812e9274a86871bc6c"), "value": 3 }
]

Example 1 — Basic $asinh on a Field

Compute the inverse hyperbolic sine for each value:

mongosh
db.data.aggregate([
  {
    $project: {
      value: 1,
      asinhValue: { $asinh: "$value" }
    }
  }
])

How It Works

  • Document 1: asinh(1)0.881.
  • Document 2: asinh(2)1.444.
  • Document 3: asinh(3)1.818.

📈 Practical Patterns

Handle negative values, round results, and apply statistical transformations.

Example 2 — Negative Values Work Too

Unlike $acosh, $asinh handles negative inputs:

mongosh
db.data.aggregate([
  {
    $project: {
      value: 1,
      asinhValue: { $asinh: "$value" },
      asinhRounded: {
        $round: [ { $asinh: "$value" }, 3 ]
      }
    }
  }
])

// Sample values: -2, 0, 1.5
// asinh(-2)  ≈ -1.444
// asinh(0)   =  0
// asinh(1.5) ≈  1.195

How It Works

$asinh is an odd function: asinh(-x) = -asinh(x). Negative inputs produce negative outputs.

Example 3 — Transform Skewed Data

Apply an inverse hyperbolic sine transform to stabilize skewed numeric distributions:

mongosh
db.sales.aggregate([
  {
    $project: {
      region: 1,
      revenue: 1,
      logRevenue: { $asinh: "$revenue" }
    }
  },
  {
    $group: {
      _id: "$region",
      avgLogRevenue: { $avg: "$logRevenue" }
    }
  }
])

How It Works

The asinh transform compresses large values while preserving sign. It is commonly used in statistics and econometrics to handle skewed revenue or count data before averaging.

Example 4 — $asinh with Literal Values

Common values for quick validation:

mongosh
db.samples.aggregate([
  {
    $project: {
      asinhZero:  { $asinh: 0 },     // 0
      asinhOne:   { $asinh: 1 },     // ≈ 0.881
      asinhNeg:   { $asinh: -1 },    // ≈ -0.881
      asinhLarge: { $asinh: 100 }    // ≈ 5.298
    }
  }
])

How It Works

asinh(0) = 0 is the key edge case. For large inputs, asinh grows slowly (like a log), which makes it useful for compressing extreme values.

🚀 Use Cases

  • Data transformation — preprocess numerical values with an inverse hyperbolic sine function before analysis.
  • Signal processing — transform sensor readings or signals in aggregation pipelines.
  • Statistical analysis — normalize or stabilize skewed data distributions (asinh transform).
  • Outlier compression — reduce the impact of extreme values while keeping sign information.

🧠 How $asinh Works

1

MongoDB reads the value

The pipeline evaluates the input — a field like "$value" or a numeric expression.

Input
2

$asinh computes the inverse

MongoDB applies the inverse hyperbolic sine function. Any real number is valid input.

Transform
3

The result is stored in the pipeline

The computed value is written to the field you define in $project or $addFields.

Output
=

Transformed numeric data

Use the result for grouping, averaging, or further pipeline stages.

Conclusion

The $asinh operator is a versatile hyperbolic math tool in MongoDB aggregation pipelines. It accepts any real number, handles negatives naturally, and is especially useful for statistical transforms and compressing skewed data.

For beginners, remember: asinh(0) = 0, negatives are valid, and pair with $round when you need clean display values.

💡 Best Practices

✅ Do

  • Use $asinh for skewed data transforms before averaging
  • Remember asinh(0) = 0 when checking results
  • Use $round for readable output values
  • Pair with $sinh to verify round-trip calculations
  • Handle null inputs with $ifNull when needed

❌ Don’t

  • Confuse $asinh with $asin (different functions)
  • Apply the same domain rules as $acosh (asinh has no minimum)
  • Use $asinh as a query filter outside expressions
  • Expect linear growth for large inputs (asinh grows logarithmically)
  • Forget to test with zero and negative values

Key Takeaways

Knowledge Unlocked

Five things to remember about $asinh

Use these points when working with hyperbolic math in MongoDB.

5
Core concepts
📝 02

Simple Syntax

{ $asinh: expr }

Syntax
📏 03

All Reals

Any number is valid.

Domain
🔢 04

Odd Function

asinh(-x) = -asinh(x).

Property
05

Zero Edge Case

asinh(0) = 0.

Special

❓ Frequently Asked Questions

$asinh returns the inverse hyperbolic sine (arc hyperbolic sine) of a number. It is the reverse of $sinh and is used in aggregation expression stages like $project and $addFields.
The syntax is { $asinh: <expression> }. The expression can be a field reference like "$value", a literal number, or another numeric expression.
$asinh accepts any real number — positive, negative, or zero. Unlike $acosh, there is no minimum domain restriction.
asinh(0) equals 0. This is a useful edge case when validating pipeline results.
$asinh returns null when the input is null. It does not throw an error.

Continue the Math Operator Series

Move on to $atan or review $asin for arc sine calculations.

Next: $atan →

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.

5 people found this page helpful