MongoDB $sinh Operator

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

What You’ll Learn

The $sinh operator computes the hyperbolic sine of a number in MongoDB aggregation pipelines. Use it for exponential growth models, physics simulations, and advanced math transformations on numeric data.

01

Hyperbolic Sine

Exponential-style math.

02

Syntax

One expression inside $sinh.

03

sinh(0) = 0

Zero at origin.

04

Odd Function

sinh(-x) = -sinh(x).

05

Use Cases

Growth, physics, stats.

06

vs $sin

Hyperbolic vs circular.

Definition and Usage

In MongoDB’s aggregation framework, the $sinh operator returns the hyperbolic sine of a numeric expression. The formula is sinh(x) = (ex - e-x) / 2. For example, sinh(0) = 0, sinh(1) ≈ 1.175, and sinh(2) ≈ 3.627. Values grow exponentially as the input moves away from zero.

💡
Beginner Tip

Think of $sinh as MongoDB’s version of JavaScript’s Math.sinh(). Use it inside aggregation expression stages like $project or $addFields, not as a query filter.

📝 Syntax

The $sinh operator takes one numeric expression:

mongosh
{ $sinh: <expression> }

Syntax Rules

  • $sinh — returns the hyperbolic sine of the expression.
  • <expression> — a field reference, literal, or nested numeric expression.
  • sinh(0) = 0 — the function passes through the origin.
  • $sinh is an odd function: sinh(-x) = -sinh(x).
  • Output can be positive or negative; magnitude grows rapidly for large |x|.
  • Use inside stages like $project, $addFields, or $set.
  • If the input is null, the result is null.

⚠️ Exponential Growth Away from Zero

$sinh(0)0
$sinh(1)≈ 1.175
$sinh(2)≈ 3.627
$sinh(3)≈ 10.018 (grows quickly)
$sinh(-2)≈ -3.627 (odd function)

💡 $sinh vs $sin vs $asinh

$sinh — hyperbolic sine; grows exponentially; odd function
$sin — circular sine; output -1 to 1; periodic waves; input in radians
$asinh — inverse of $sinh; recovers x from a sinh value

⚡ Quick Reference

QuestionAnswer
Operator typeAggregation expression operator (hyperbolic)
Syntax{ $sinh: <expression> }
InputAny real number
Output at zero0
Common stages$project, $addFields, $set
Zero
{
  $sinh: 0
}

Returns 0

Field
{
  $sinh: "$x"
}

From document field

Example
{
  $sinh: 1
}

≈ 1.175

Null input
{
  $sinh: null
}

Returns null

Examples Gallery

Compute hyperbolic sines from stored values, verify the odd-function property, and explore exponential growth with $sinh.

📚 Exponential Data

Use an exponentialData collection and compute $sinh for each numeric field with $project.

Sample Input Documents

Suppose you have an exponentialData collection with a numeric field x:

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

Example 1 — Basic $sinh on a Field

Compute the hyperbolic sine of each stored value:

mongosh
db.exponentialData.aggregate([
  {
    $project: {
      x: 1,
      sinhValue: { $sinh: "$x" }
    }
  }
])

How It Works

  • x: 1sinh(1) ≈ 1.175.
  • x: 2sinh(2) ≈ 3.627.
  • x: 3sinh(3) ≈ 10.018 (grows faster than linear).

📈 Practical Patterns

Verify the odd-function property, model growth, and test boundary values.

Example 2 — Odd Function: sinh(-x) = -sinh(x)

Hyperbolic sine negates its result for negative inputs:

mongosh
db.exponentialData.aggregate([
  {
    $project: {
      x: 1,
      sinhPositive: { $sinh: "$x" },
      sinhNegative: { $sinh: { $multiply: [ "$x", -1 ] } }
    }
  }
])

// x: 2  → sinhPositive ≈ 3.627, sinhNegative ≈ -3.627
// x: -1 → sinhPositive ≈ -1.175

How It Works

Unlike $cosh (even function), $sinh flips sign for negative inputs. This symmetry is important in physics and signal-processing formulas.

Example 3 — Exponential Growth Modeling

Hyperbolic sine models rapid growth and decay in scientific datasets:

mongosh
db.metrics.aggregate([
  {
    $project: {
      time: 1,
      growthFactor: { $sinh: "$time" },
      scaledGrowth: {
        $multiply: [
          { $sinh: "$time" },
          "$baseRate"
        ]
      }
    }
  }
])

How It Works

As time increases, $sinh(time) grows exponentially. Pair with other operators to build physics, finance, or statistics models inside the pipeline.

Example 4 — $sinh with Literal Values

Common values every beginner should know:

mongosh
db.samples.aggregate([
  {
    $project: {
      sinhZero:  { $sinh: 0 },    // 0
      sinhOne:   { $sinh: 1 },    // ≈ 1.175
      sinhTwo:   { $sinh: 2 },    // ≈ 3.627
      sinhNegOne:{ $sinh: -1 }   // ≈ -1.175 (opposite of sinh(1))
    }
  }
])

How It Works

$sinh(0) = 0. $sinh(-1) equals the negative of $sinh(1), confirming the odd-function property.

🚀 Use Cases

  • Exponential growth modeling — analyze processes with rapid increase, such as population or reaction rates.
  • Financial forecasting — model non-linear changes in metrics when hyperbolic transforms apply.
  • Physics and engineering — heat transfer, fluid dynamics, and wave equations involving hyperbolic functions.
  • Data transformation — preprocess numeric fields for statistical or machine-learning pipelines.

🧠 How $sinh Works

1

MongoDB reads the input

The pipeline evaluates the expression — a field like "$x" or a numeric literal.

Input
2

$sinh applies the hyperbolic formula

MongoDB computes (ex - e-x) / 2 and returns the result.

Transform
3

The result is stored in the pipeline

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

Output
=

Hyperbolic value ready to use

Use in further math, pair with $cosh, or feed into $asinh for the inverse.

Conclusion

The $sinh operator brings hyperbolic sine math directly into MongoDB aggregation pipelines. Remember that sinh(0) = 0, the function is odd (sinh(-x) = -sinh(x)), and values grow exponentially for large inputs.

Do not confuse $sinh with circular $sin — they behave very differently. Next in the series: $size.

💡 Best Practices

✅ Do

  • Use $sinh for exponential-style growth and hyperbolic transforms
  • Remember sinh(0) = 0 when validating pipeline output
  • Pair with $cosh when both hyperbolic components are needed
  • Use $asinh for the inverse when recovering original values
  • Test with small literals (0, 1, -1) before running on large datasets

❌ Don’t

  • Confuse $sinh (hyperbolic) with $sin (circular trig)
  • Expect bounded output like $sin$sinh grows without limit
  • Forget that null input returns null
  • Assume $sinh is even like $cosh — it is odd
  • Pass very large values without considering overflow in downstream math

Key Takeaways

Knowledge Unlocked

Five things to remember about $sinh

Use these points when computing hyperbolic sines in MongoDB.

5
Core concepts
📝 02

{ $sinh: x }

One expression.

Syntax
📏 03

sinh(0) = 0

Passes origin.

Rule
🛠 04

Odd function

Flips sign.

Property
05

Not $sin

Hyperbolic vs circular.

Important

❓ Frequently Asked Questions

$sinh returns the hyperbolic sine of a numeric value. The formula is sinh(x) = (e^x - e^(-x)) / 2. It is an aggregation expression operator used inside stages like $project and $addFields.
The syntax is { $sinh: <expression> }. The expression can be a field reference like "$x", a literal number, or another numeric expression.
$sin is circular trigonometry (input in radians, output -1 to 1, periodic). $sinh is hyperbolic (any real input, grows exponentially, not periodic). They solve different math problems.
Yes. sinh(-x) equals -sinh(x). In a pipeline, $sinh applied to a negative field returns the negated result of the positive value.
$sinh returns null when the input is null. It does not throw an error.

Continue the Operator Series

Move on to $size to count array elements, or review $sin for circular trigonometry.

Next: $size →

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