$acosh is a MongoDB aggregation expression that returns the inverse hyperbolic cosine of a number—the value whose hyperbolic cosine equals that input. Results are in radians. Input must be 1 or greater.
Remember
$acosh = Math.acosh for aggregation
{ $acosh: <expression> }
input → must be ≥ 1
output → radians (≥ 0)
degrees → wrap with $radiansToDegrees
acosh(1) → 0
null / missing → null
x < 1 → pipeline error
Ensure the argument is ≥ 1 (filter or validate first if data can be smaller).
Pass that expression to $acosh to get radians.
Optionally wrap with $radiansToDegrees for a degree result.
Piece
Required?
Role
$acosh
Yes
Inverse hyperbolic cosine → radians
Expression
Yes
Number ≥ 1, field, or nested math
$radiansToDegrees
No
Convert output when you want degrees
Pseudocode
Pseudocode
for each document:
x = evaluate(expression)
if x is null or missing:
result = null
else if x is NaN:
result = NaN
else if x is +Infinity:
result = Infinity
else if x < 1:
error // aggregation fails
else:
result = acosh(x) // radians
emit { ..., field: result }
Reference
Cheat Sheet
Keep these facts handy while writing inverse hyperbolic cosine expressions.
Topic
Detail
Type
Aggregation expression (not a find filter)
Syntax
{ $acosh: <expression> }
Domain
x ≥ 1 (up to +Infinity)
Range
0 to +Infinity radians
Degrees pattern
{ $radiansToDegrees: { $acosh: "$x" } }
Sample check
acosh(1) = 0; acosh(3) ≈ 100.998°
Try it
Live Preview
Watch $acosh turn an x value into radians (and degrees). Try values ≥ 1.
Simulates $acosh then $radiansToDegrees (same idea as the mongosh examples below).
Result
x = 3
$acosh(x) → 1.762747 rad
$radiansToDegrees → 100.997973 °
{ y_rad: 1.762747, y_deg: 100.997973 }
Trace
Worked Walkthrough — acosh(3)
One number on the x-axis: 3. Inverse hyperbolic cosine gives a y-value in radians; convert if you want degrees.
Number line (only x ≥ 1 is allowed):
... 0 ... 1 -------- 3 -------------- 10 ...
↑ ↑ ↑
acosh=0 ~1.76 rad ~2.99 rad
Invalid for $acosh: 0, 0.5, -1 → pipeline error
How It Works
Insert once.insertMany adds three documents to hyperbolic.
MongoDB stores fields as written. Each document has _id and x—plain numbers.
find() shows the same shape. What you inserted is what you get back—ready for $acosh in the next examples.
Example 2 — Result in Radians
Goal: for each stored x, compute $acosh in radians.
Convert units.$radiansToDegrees turns those into degrees (about 101° for x = 3).
Easy check.x = 1 still maps to 0°.
Edge Cases & Pitfalls
Check these before using $acosh in production pipelines.
domain
Stay at x ≥ 1
Values below 1 make the pipeline fail. Filter with $match or clamp before calling $acosh.
units
Output is radians
Do not treat the raw result as degrees. Convert with $radiansToDegrees when your report expects °.
null
Null and missing become null
Missing fields return null, not an error. Handle them before hyperbolic math if nulls are invalid in your data.
vs acos
Not the same as $acos
$acos is regular inverse cosine (domain [-1, 1]). $acosh is hyperbolic (domain ≥ 1).
Analysis
Performance Notes
Approach
Cost
Best for
$acosh alone
Per-document math
Values already ≥ 1
$match then $acosh
Filter + math
Dirty data that may be < 1
+ $radiansToDegrees
One extra conversion
Human-readable degree reports
Hyperbolic expressions are cheap compared with large sorts or joins. Filter early with $match when only some documents need the transform.
Remember
Key Takeaways
Role: inverse hyperbolic cosine → result in radians.
Domain: argument must be ≥ 1.
Degrees: wrap with $radiansToDegrees.
Check:acosh(1) = 0.
One line:$acosh answers “which value has this hyperbolic cosine?”—in radians, for inputs ≥ 1.
Frequently Asked Questions
$acosh returns the inverse hyperbolic cosine (hyperbolic arc cosine) of a number—the value whose hyperbolic cosine is that number. Results are in radians. Use it inside aggregation expression stages such as $project and $addFields.
The argument must resolve to a number greater than or equal to 1 (up to +Infinity). Values less than 1 cause the aggregation to fail with an error.
$acosh returns radians. Convert with $radiansToDegrees when you want degrees.
acosh(1) equals 0. That is a useful check when testing a pipeline.
$acosh returns null when the input is null or the field is missing. If the argument is NaN, $acosh returns NaN. Infinity returns Infinity.
Yes for the math. Think of $acosh as MongoDB’s aggregation version of Math.acosh—run it in the pipeline, not as a standalone find() filter.