Skip to content

DOCS-14051 Documentation for sinh cosh tanh #4802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/redirects
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,9 @@ raw: /master/release-notes/3.0-general-improvements -> ${base}/release-notes/3.0
[*-v4.0]: /${version}/reference/operator/aggregation/asinh -> ${base}/${version}/reference/operator/aggregation
[*-v4.0]: /${version}/reference/operator/aggregation/acosh -> ${base}/${version}/reference/operator/aggregation
[*-v4.0]: /${version}/reference/operator/aggregation/atanh -> ${base}/${version}/reference/operator/aggregation
[*-v4.0]: /${version}/reference/operator/aggregation/sinh -> ${base}/${version}/reference/operator/aggregation
[*-v4.0]: /${version}/reference/operator/aggregation/cosh -> ${base}/${version}/reference/operator/aggregation
[*-v4.0]: /${version}/reference/operator/aggregation/tanh -> ${base}/${version}/reference/operator/aggregation
[*-v4.0]: /${version}/reference/operator/aggregation/degreesToRadians -> ${base}/${version}/reference/operator/aggregation
[*-v4.0]: /${version}/reference/operator/aggregation/radiansToDegrees -> ${base}/${version}/reference/operator/aggregation

Expand Down Expand Up @@ -1664,6 +1667,9 @@ raw: /v2.8/release-notes/2.8-changes -> ${base}/v3.0/release-notes/3.0
[v3.0-v4.0]: /${version}/reference/operator/aggregation/asinh -> ${base}/${version}/reference/operator/aggregation
[v3.0-v4.0]: /${version}/reference/operator/aggregation/acosh -> ${base}/${version}/reference/operator/aggregation
[v3.0-v4.0]: /${version}/reference/operator/aggregation/atanh -> ${base}/${version}/reference/operator/aggregation
[v3.0-v4.0]: /${version}/reference/operator/aggregation/sinh -> ${base}/${version}/reference/operator/aggregation
[v3.0-v4.0]: /${version}/reference/operator/aggregation/cosh -> ${base}/${version}/reference/operator/aggregation
[v3.0-v4.0]: /${version}/reference/operator/aggregation/tanh -> ${base}/${version}/reference/operator/aggregation
[v3.0-v4.0]: /${version}/reference/operator/aggregation/degreesToRadians -> ${base}/${version}/reference/operator/aggregation
[v3.0-v4.0]: /${version}/reference/operator/aggregation/radiansToDegrees -> ${base}/${version}/reference/operator/aggregation

Expand Down
12 changes: 12 additions & 0 deletions source/includes/extracts-agg-operators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ content: |
- Returns the inverse hyperbolic tangent (hyperbolic arc
tangent) of a value in radians.

* - :expression:`$sinh`
- Returns the hyperbolic sine of a value that is measured in
radians.

* - :expression:`$cosh`
- Returns the hyperbolic cosine of a value that is measured in
radians.

* - :expression:`$tanh`
- Returns the hyperbolic tangent of a value that is measured in
radians.

* - :expression:`$degreesToRadians`
- Converts a value from degrees to radians.

Expand Down
3 changes: 3 additions & 0 deletions source/meta/aggregation-quick-reference.txt
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ Index of Expression Operators
- :expression:`$cond`
- :expression:`$convert`
- :expression:`$cos`
- :expression:`$cosh`
- :expression:`$dateFromParts`
- :expression:`$dateFromString`
- :expression:`$dateToParts`
Expand Down Expand Up @@ -434,6 +435,7 @@ Index of Expression Operators
- :expression:`$setIsSubset`
- :expression:`$setUnion`
- :expression:`$sin`
- :expression:`$sinh`
- :expression:`$size`
- :expression:`$slice`
- :expression:`$split`
Expand All @@ -450,6 +452,7 @@ Index of Expression Operators
- :group:`$sum`
- :expression:`$switch`
- :expression:`$tan`
- :expression:`$tanh`
- :expression:`$toBool`
- :expression:`$toDate`
- :expression:`$toDecimal`
Expand Down
18 changes: 17 additions & 1 deletion source/reference/operator/aggregation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ Alphabetical Listing of Expression Operators

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

* - :expression:`$cosh`

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

* - :expression:`$dateFromParts`

Expand Down Expand Up @@ -776,6 +780,10 @@ Alphabetical Listing of Expression Operators

- Returns the sine of a value that is measured in radians.

* - :expression:`$sinh`

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

* - :expression:`$slice`

Expand Down Expand Up @@ -880,7 +888,12 @@ Alphabetical Listing of Expression Operators
* - :expression:`$tan`

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



* - :expression:`$tanh`

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

* - :expression:`$toBool`

Expand Down Expand Up @@ -995,6 +1008,7 @@ Alphabetical Listing of Expression Operators
/reference/operator/aggregation/cond
/reference/operator/aggregation/convert
/reference/operator/aggregation/cos
/reference/operator/aggregation/cosh
/reference/operator/aggregation/dateFromParts
/reference/operator/aggregation/dateToParts
/reference/operator/aggregation/dateFromString
Expand Down Expand Up @@ -1070,6 +1084,7 @@ Alphabetical Listing of Expression Operators
/reference/operator/aggregation/setUnion
/reference/operator/aggregation/size
/reference/operator/aggregation/sin
/reference/operator/aggregation/sinh
/reference/operator/aggregation/slice
/reference/operator/aggregation/split
/reference/operator/aggregation/sqrt
Expand All @@ -1085,6 +1100,7 @@ Alphabetical Listing of Expression Operators
/reference/operator/aggregation/sum
/reference/operator/aggregation/switch
/reference/operator/aggregation/tan
/reference/operator/aggregation/tanh
/reference/operator/aggregation/toBool
/reference/operator/aggregation/toDate
/reference/operator/aggregation/toDecimal
Expand Down
2 changes: 1 addition & 1 deletion source/reference/operator/aggregation/cos.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Example
:expression:`$cos` is a 128-bit decimal.

- id: radians
name: Sine of Value in Radians
name: Cosine of Value in Radians
content: |

The ``trigonometry`` collection contains a document that
Expand Down
170 changes: 170 additions & 0 deletions source/reference/operator/aggregation/cosh.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
===================
$cosh (aggregation)
===================

.. default-domain:: mongodb

.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol

.. expression:: $cosh

.. versionadded:: 4.2

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

:expression:`$cosh` has the following syntax:

.. code-block:: javascript

{ $cosh: <expression> }

:expression:`$cosh` takes any valid :ref:`expression
<aggregation-expressions>` that resolves to a number, measured in
radians. If the expression returns a value in degrees, use the
:expression:`$degreesToRadians` operator to convert the value to
radians.

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

For more information on expressions, see
:ref:`aggregation-expressions`.

Behavior
--------

``null``, ``NaN``, and ``+/- Infinity``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

.. list-table::
:header-rows: 1
:widths: 50 50

* - Example
- Results

* - ``{ $cosh: NaN }``
- ``NaN``

* - ``{ $cosh: null }``
- ``null``

* - ``{ $cosh: -Infinity }``
- ``Infinity``

* - ``{ $cosh: Infinity }``
- ``Infinity``

Example
-------

.. tabs::

tabs:

- id: degrees
name: Hyperbolic Cosine of Value in Degrees
content: |

The following ``trigonometry`` collection contains a document
that stores an ``angle`` value measured in degrees:

.. code-block:: javascript

db.trigonometry.insertOne(
{
"_id" : ObjectId( "5c50782193f833234ba90d85" ),
"angle" : NumberDecimal( "53.1301023541559787031443874490659" )
}
)

The following aggregation operation uses the
:expression:`$cosh` expression to calculate the hyperbolic
cosine of ``angle`` and adds it to the input document using the
:pipeline:`$addFields` pipeline stage:

.. code-block:: javascript

db.trigonometry.aggregate( [
{
$addFields : {
"cosh_output" : { $cosh : { $degreesToRadians : "$angle" } }
}
}
] )

The :expression:`$degreesToRadians` expression converts the
``angle`` in degrees to radians.

Example output:

.. code-block:: javascript
:copyable: false

{
"_id" : ObjectId("5c50782193f833234ba90d85"),
"angle" : NumberDecimal("53.1301023541559787031443874490659"),
"cosh_output" : NumberDecimal("1.461642741099671277595921778079396")
}

Because ``angle`` is stored as a :ref:`128-bit decimal
<shell-type-decimal>`, the :expression:`$cosh` output is also a
128-bit decimal.

- id: radians
name: Hyperbolic Cosine of Value in Radians
content: |

The following ``trigonometry`` collection contains a document
that stores an ``angle`` value measured in radians:

.. code-block:: javascript

db.trigonometry.insertOne(
{
"_id" : ObjectId( "5c50782193f833234ba90d15" ),
"angle" : NumberDecimal( "1.6301023541559787031443874490659" )
}
)

The following aggregation operation uses the
:expression:`$cosh` expression to calculate the hyperbolic
cosine of ``angle`` and adds it to the input document using
the :pipeline:`$addFields` pipeline stage:

.. code-block:: javascript

db.trigonometry.aggregate( [
{
$addFields : {
"cosh_output" : { $cosh : "$angle" }
}
}
] )

Example output:

.. code-block:: javascript
:copyable: false

{
"_id" : ObjectId("5c50782193f833234ba90d15"),
"angle" : NumberDecimal("1.6301023541559787031443874490659"),
"cosh_output" : NumberDecimal("2.650153334504361016712328539738000")
}

Because ``angle`` is stored as a :ref:`128-bit decimal
<shell-type-decimal>`, the :expression:`$cosh` output is also
a 128-bit decimal.
Loading