Docs Menu

Docs HomeMongoDB Manual

$tanh (aggregation)

On this page

  • Behavior
  • Example

New in version 4.2.

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

$tanh has the following syntax:

{ $tanh: <expression> }

$tanh 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 $tanh returns values as a double. $tanh 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, $tanh returns null. If the argument resolves to NaN, $tanh returns NaN. If the argument resolves to negative or positive Infinity, $tanh returns -1 or 1 respectively.

{ $tanh: NaN }
{ $tanh: null }
{ $tanh: -Infinity }
{ $tanh: Infinity }
←  $tan (aggregation)$toBool (aggregation) →

On this page

Share Feedback
© 2023 MongoDB, Inc.


  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2023 MongoDB, Inc.