The $acosh operator returns the inverse hyperbolic cosine of a number in MongoDB aggregation pipelines. It is the reverse of $cosh and is useful when analyzing exponential growth, decay, or other hyperbolic relationships in your data.
01
Inverse acosh
Reverse of hyperbolic cosine.
02
Syntax
One expression inside $acosh.
03
Input Range
Values must be ≥ 1.
04
$project Stage
Add computed fields easily.
05
Use Cases
Growth, finance, statistics.
06
Edge Case
acosh(1) = 0
Fundamentals
Definition and Usage
In MongoDB’s aggregation framework, the $acosh operator computes the inverse hyperbolic cosine of a numeric expression. If cosh(y) = x, then acosh(x) = y. For example, $acosh(1) returns 0, and $acosh(2) returns approximately 1.317.
💡
Beginner Tip
Think of $acosh as MongoDB’s version of JavaScript’s Math.acosh(). Use it inside aggregation expression stages, not as a standalone query filter operator.
Foundation
📝 Syntax
The $acosh operator takes one numeric expression:
mongosh
{ $acosh: <expression> }
Syntax Rules
$acosh — returns the inverse hyperbolic cosine of the expression.
<expression> — must evaluate to a number greater than or equal to 1.
Use it inside stages like $project, $addFields, or $set.
If the input is null, the result is null.
Values less than 1 return NaN.
⚠️ Valid Input Range: ≥ 1
$acosh is only defined for values greater than or equal to 1. Values below 1 return NaN.
$acosh: 1 → 0(valid edge case)
$acosh: 2 → 1.317(valid)
$acosh: 0.5 → NaN(out of range!)
Cheat Sheet
⚡ Quick Reference
Question
Answer
Operator type
Aggregation expression operator (hyperbolic)
Syntax
{ $acosh: <expression> }
Input range
≥ 1
Inverse of
$cosh
Common stages
$project, $addFields, $set
Edge case
{
$acosh: 1
}
Returns 0
Field
{
$acosh: "$x"
}
From document field
Example
{
$acosh: 2
}
≈ 1.317
Null input
{
$acosh: null
}
Returns null
Hands-On
Examples Gallery
Walk through sample data, run an aggregation pipeline, and inspect the inverse hyperbolic cosine results.
📚 Basic Computation
Use a values collection and compute $acosh for each numeric field with $project.
Sample Input Documents
Suppose you have a values collection with a numeric field x:
$acosh(1) = 0 is the most important edge case. Larger inputs produce progressively larger results, growing slowly compared to exponential functions.
Applications
🚀 Use Cases
Growth analysis — model exponential growth rates or processes with logarithmic-style scaling.
Financial modeling — transform hyperbolic values in interest-rate or asset-value calculations.
Statistical analysis — normalize skewed distributions or transform extreme values in analytics pipelines.
Signal processing — recover parameters from hyperbolic cosine outputs in scientific datasets.
🧠 How $acosh Works
1
MongoDB reads the value
The pipeline evaluates the input — a field like "$x" or a numeric expression.
Input
2
Domain check (≥ 1)
If the value is below 1, MongoDB returns NaN. Valid inputs proceed to the calculation.
Validate
3
$acosh computes the inverse
MongoDB applies the inverse hyperbolic cosine and stores the result in your projected field.
Transform
=
📈
Hyperbolic value recovered
You get a numeric result ready for further math, grouping, or reporting.
Wrap Up
Conclusion
The $acosh operator is a specialized but powerful math tool in MongoDB aggregation pipelines. It reverses hyperbolic cosine values and supports growth modeling, financial analysis, and statistical transformations.
For beginners, remember three things: input must be ≥ 1, acosh(1) = 0, and values below 1 return NaN. Use $cond to guard against invalid inputs in real-world data.
Validate that input values are ≥ 1 before applying $acosh
Remember acosh(1) = 0 when checking results
Use $round for readable output values
Pair with $cosh to verify round-trip calculations
Handle null inputs with $ifNull when needed
❌ Don’t
Pass values less than 1 without guarding against NaN
Confuse $acosh with $acos (different functions)
Use $acosh as a query filter operator outside expressions
Assume it works on negative numbers (returns NaN)
Forget to test the edge case where input equals exactly 1
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about $acosh
Use these points when working with hyperbolic math in MongoDB.
5
Core concepts
📈01
Inverse acosh
Reverse of $cosh.
Purpose
📝02
Simple Syntax
{ $acosh: expr }
Syntax
📏03
Input Range
Must be ≥ 1.
Domain
🔢04
Edge Case
acosh(1) = 0
Special
⚠05
Below 1
Returns NaN.
Edge case
❓ Frequently Asked Questions
$acosh returns the inverse hyperbolic cosine (arc hyperbolic cosine) of a number. It is the reverse of $cosh and is used in aggregation expression stages like $project and $addFields.
The syntax is { $acosh: <expression> }. The expression can be a field reference like "$x", a literal number, or another numeric expression.
$acosh is defined for values greater than or equal to 1. Values less than 1 return NaN.
acosh(1) equals 0. This is an important edge case when validating pipeline results.
$acosh returns null when the input is null. It does not throw an error.