$cosh
New from version 8.0.1.
The $cosh operator in Amazon DocumentDB returns the hyperbolic cosine of a value. Use it in the aggregation pipeline to perform hyperbolic trigonometric calculations on numeric fields.
Parameters
-
expression: An expression that resolves to a number.
The return type is double by default. If the input is a 128-bit decimal, the output is also a 128-bit decimal.
Example (MongoDB Shell)
The following example shows how to use the $cosh operator to calculate the hyperbolic cosine of numeric values.
Create sample documents
db.values.insertMany([ { "_id": 1, "value": 0 }, { "_id": 2, "value": 1 }, { "_id": 3, "value": -1 } ]);
Query example
db.values.aggregate([ { $project: { "result": { $cosh: "$value" } }} ]);
Output
[
{ "_id": 1, "result": 1 },
{ "_id": 2, "result": 1.5430806348152437 },
{ "_id": 3, "result": 1.5430806348152437 }
]
Code examples
To view a code example for using the $cosh operator, choose the tab for the language that you want to use: