Docs Menu

Docs HomeDevelop ApplicationsMongoDB Manual

$cosh (aggregation)

On this page

  • Behavior
  • Example
$cosh

New in version 4.2.

Returns the hyperbolic cosine of a value that is measured in radians.

$cosh has the following syntax:

{ $cosh: <expression> }

$cosh takes any valid expression that resolves to a number, measured in radians. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the value to radians.

By default $cosh returns values as a double. $cosh can also return values as a 128-bit decimal if the <expression> resolves to a 128-bit decimal value.

For more information on expressions, see Expressions.

If the input argument resolves to a value of null or refers to a field that is missing, $cosh returns null. If the argument resolves to NaN, $cosh returns NaN. If the argument resolves to negative or positive Infinity, $cosh returns positive Infinity.

Example
Results
{ $cosh: NaN }
NaN
{ $cosh: null }
null
{ $cosh: -Infinity }
Infinity
{ $cosh: Infinity }
Infinity
←  $cos (aggregation)$count (aggregation accumulator) →

On this page