Skip to content

Commit f47e1d8

Browse files
jason-price-mongodbandf-mongodb
authored andcommitted
DOCS-14051 Documentation for sinh cosh tanh
1 parent 24ab696 commit f47e1d8

File tree

8 files changed

+551
-2
lines changed

8 files changed

+551
-2
lines changed

config/redirects

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,6 +1454,9 @@ raw: /master/release-notes/3.0-general-improvements -> ${base}/release-notes/3.0
14541454
[*-v4.0]: /${version}/reference/operator/aggregation/asinh -> ${base}/${version}/reference/operator/aggregation
14551455
[*-v4.0]: /${version}/reference/operator/aggregation/acosh -> ${base}/${version}/reference/operator/aggregation
14561456
[*-v4.0]: /${version}/reference/operator/aggregation/atanh -> ${base}/${version}/reference/operator/aggregation
1457+
[*-v4.0]: /${version}/reference/operator/aggregation/sinh -> ${base}/${version}/reference/operator/aggregation
1458+
[*-v4.0]: /${version}/reference/operator/aggregation/cosh -> ${base}/${version}/reference/operator/aggregation
1459+
[*-v4.0]: /${version}/reference/operator/aggregation/tanh -> ${base}/${version}/reference/operator/aggregation
14571460
[*-v4.0]: /${version}/reference/operator/aggregation/degreesToRadians -> ${base}/${version}/reference/operator/aggregation
14581461
[*-v4.0]: /${version}/reference/operator/aggregation/radiansToDegrees -> ${base}/${version}/reference/operator/aggregation
14591462

@@ -1664,6 +1667,9 @@ raw: /v2.8/release-notes/2.8-changes -> ${base}/v3.0/release-notes/3.0
16641667
[v3.0-v4.0]: /${version}/reference/operator/aggregation/asinh -> ${base}/${version}/reference/operator/aggregation
16651668
[v3.0-v4.0]: /${version}/reference/operator/aggregation/acosh -> ${base}/${version}/reference/operator/aggregation
16661669
[v3.0-v4.0]: /${version}/reference/operator/aggregation/atanh -> ${base}/${version}/reference/operator/aggregation
1670+
[v3.0-v4.0]: /${version}/reference/operator/aggregation/sinh -> ${base}/${version}/reference/operator/aggregation
1671+
[v3.0-v4.0]: /${version}/reference/operator/aggregation/cosh -> ${base}/${version}/reference/operator/aggregation
1672+
[v3.0-v4.0]: /${version}/reference/operator/aggregation/tanh -> ${base}/${version}/reference/operator/aggregation
16671673
[v3.0-v4.0]: /${version}/reference/operator/aggregation/degreesToRadians -> ${base}/${version}/reference/operator/aggregation
16681674
[v3.0-v4.0]: /${version}/reference/operator/aggregation/radiansToDegrees -> ${base}/${version}/reference/operator/aggregation
16691675

source/includes/extracts-agg-operators.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ content: |
4646
- Returns the inverse hyperbolic tangent (hyperbolic arc
4747
tangent) of a value in radians.
4848
49+
* - :expression:`$sinh`
50+
- Returns the hyperbolic sine of a value that is measured in
51+
radians.
52+
53+
* - :expression:`$cosh`
54+
- Returns the hyperbolic cosine of a value that is measured in
55+
radians.
56+
57+
* - :expression:`$tanh`
58+
- Returns the hyperbolic tangent of a value that is measured in
59+
radians.
60+
4961
* - :expression:`$degreesToRadians`
5062
- Converts a value from degrees to radians.
5163

source/meta/aggregation-quick-reference.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ Index of Expression Operators
361361
- :expression:`$cond`
362362
- :expression:`$convert`
363363
- :expression:`$cos`
364+
- :expression:`$cosh`
364365
- :expression:`$dateFromParts`
365366
- :expression:`$dateFromString`
366367
- :expression:`$dateToParts`
@@ -434,6 +435,7 @@ Index of Expression Operators
434435
- :expression:`$setIsSubset`
435436
- :expression:`$setUnion`
436437
- :expression:`$sin`
438+
- :expression:`$sinh`
437439
- :expression:`$size`
438440
- :expression:`$slice`
439441
- :expression:`$split`
@@ -450,6 +452,7 @@ Index of Expression Operators
450452
- :group:`$sum`
451453
- :expression:`$switch`
452454
- :expression:`$tan`
455+
- :expression:`$tanh`
453456
- :expression:`$toBool`
454457
- :expression:`$toDate`
455458
- :expression:`$toDecimal`

source/reference/operator/aggregation.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@ Alphabetical Listing of Expression Operators
307307

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

310+
* - :expression:`$cosh`
311+
312+
- Returns the hyperbolic cosine of a value that is measured in
313+
radians.
310314

311315
* - :expression:`$dateFromParts`
312316

@@ -776,6 +780,10 @@ Alphabetical Listing of Expression Operators
776780

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

783+
* - :expression:`$sinh`
784+
785+
- Returns the hyperbolic sine of a value that is measured in
786+
radians.
779787

780788
* - :expression:`$slice`
781789

@@ -880,7 +888,12 @@ Alphabetical Listing of Expression Operators
880888
* - :expression:`$tan`
881889

882890
- Returns the tangent of a value that is measured in radians.
883-
891+
892+
893+
* - :expression:`$tanh`
894+
895+
- Returns the hyperbolic tangent of a value that is measured in
896+
radians.
884897

885898
* - :expression:`$toBool`
886899

@@ -995,6 +1008,7 @@ Alphabetical Listing of Expression Operators
9951008
/reference/operator/aggregation/cond
9961009
/reference/operator/aggregation/convert
9971010
/reference/operator/aggregation/cos
1011+
/reference/operator/aggregation/cosh
9981012
/reference/operator/aggregation/dateFromParts
9991013
/reference/operator/aggregation/dateToParts
10001014
/reference/operator/aggregation/dateFromString
@@ -1070,6 +1084,7 @@ Alphabetical Listing of Expression Operators
10701084
/reference/operator/aggregation/setUnion
10711085
/reference/operator/aggregation/size
10721086
/reference/operator/aggregation/sin
1087+
/reference/operator/aggregation/sinh
10731088
/reference/operator/aggregation/slice
10741089
/reference/operator/aggregation/split
10751090
/reference/operator/aggregation/sqrt
@@ -1085,6 +1100,7 @@ Alphabetical Listing of Expression Operators
10851100
/reference/operator/aggregation/sum
10861101
/reference/operator/aggregation/switch
10871102
/reference/operator/aggregation/tan
1103+
/reference/operator/aggregation/tanh
10881104
/reference/operator/aggregation/toBool
10891105
/reference/operator/aggregation/toDate
10901106
/reference/operator/aggregation/toDecimal

source/reference/operator/aggregation/cos.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Example
142142
:expression:`$cos` is a 128-bit decimal.
143143

144144
- id: radians
145-
name: Sine of Value in Radians
145+
name: Cosine of Value in Radians
146146
content: |
147147

148148
The ``trigonometry`` collection contains a document that
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
===================
2+
$cosh (aggregation)
3+
===================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
.. expression:: $cosh
14+
15+
.. versionadded:: 4.2
16+
17+
Returns the hyperbolic cosine of a value that is measured in radians.
18+
19+
:expression:`$cosh` has the following syntax:
20+
21+
.. code-block:: javascript
22+
23+
{ $cosh: <expression> }
24+
25+
:expression:`$cosh` takes any valid :ref:`expression
26+
<aggregation-expressions>` that resolves to a number, measured in
27+
radians. If the expression returns a value in degrees, use the
28+
:expression:`$degreesToRadians` operator to convert the value to
29+
radians.
30+
31+
By default :expression:`$cosh` returns values as a ``double``.
32+
:expression:`$cosh` can also return values as a :ref:`128-bit decimal
33+
<shell-type-decimal>` if the ``<expression>`` resolves to a 128-bit
34+
decimal value.
35+
36+
For more information on expressions, see
37+
:ref:`aggregation-expressions`.
38+
39+
Behavior
40+
--------
41+
42+
``null``, ``NaN``, and ``+/- Infinity``
43+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44+
45+
If the input argument resolves to a value of ``null`` or refers to a
46+
field that is missing, :expression:`$cosh` returns ``null``. If the
47+
argument resolves to ``NaN``, :expression:`$cosh` returns ``NaN``. If
48+
the argument resolves to negative or positive ``Infinity``,
49+
:expression:`$cosh` returns positive ``Infinity``.
50+
51+
.. list-table::
52+
:header-rows: 1
53+
:widths: 50 50
54+
55+
* - Example
56+
- Results
57+
58+
* - ``{ $cosh: NaN }``
59+
- ``NaN``
60+
61+
* - ``{ $cosh: null }``
62+
- ``null``
63+
64+
* - ``{ $cosh: -Infinity }``
65+
- ``Infinity``
66+
67+
* - ``{ $cosh: Infinity }``
68+
- ``Infinity``
69+
70+
Example
71+
-------
72+
73+
.. tabs::
74+
75+
tabs:
76+
77+
- id: degrees
78+
name: Hyperbolic Cosine of Value in Degrees
79+
content: |
80+
81+
The following ``trigonometry`` collection contains a document
82+
that stores an ``angle`` value measured in degrees:
83+
84+
.. code-block:: javascript
85+
86+
db.trigonometry.insertOne(
87+
{
88+
"_id" : ObjectId( "5c50782193f833234ba90d85" ),
89+
"angle" : NumberDecimal( "53.1301023541559787031443874490659" )
90+
}
91+
)
92+
93+
The following aggregation operation uses the
94+
:expression:`$cosh` expression to calculate the hyperbolic
95+
cosine of ``angle`` and adds it to the input document using the
96+
:pipeline:`$addFields` pipeline stage:
97+
98+
.. code-block:: javascript
99+
100+
db.trigonometry.aggregate( [
101+
{
102+
$addFields : {
103+
"cosh_output" : { $cosh : { $degreesToRadians : "$angle" } }
104+
}
105+
}
106+
] )
107+
108+
The :expression:`$degreesToRadians` expression converts the
109+
``angle`` in degrees to radians.
110+
111+
Example output:
112+
113+
.. code-block:: javascript
114+
:copyable: false
115+
116+
{
117+
"_id" : ObjectId("5c50782193f833234ba90d85"),
118+
"angle" : NumberDecimal("53.1301023541559787031443874490659"),
119+
"cosh_output" : NumberDecimal("1.461642741099671277595921778079396")
120+
}
121+
122+
Because ``angle`` is stored as a :ref:`128-bit decimal
123+
<shell-type-decimal>`, the :expression:`$cosh` output is also a
124+
128-bit decimal.
125+
126+
- id: radians
127+
name: Hyperbolic Cosine of Value in Radians
128+
content: |
129+
130+
The following ``trigonometry`` collection contains a document
131+
that stores an ``angle`` value measured in radians:
132+
133+
.. code-block:: javascript
134+
135+
db.trigonometry.insertOne(
136+
{
137+
"_id" : ObjectId( "5c50782193f833234ba90d15" ),
138+
"angle" : NumberDecimal( "1.6301023541559787031443874490659" )
139+
}
140+
)
141+
142+
The following aggregation operation uses the
143+
:expression:`$cosh` expression to calculate the hyperbolic
144+
cosine of ``angle`` and adds it to the input document using
145+
the :pipeline:`$addFields` pipeline stage:
146+
147+
.. code-block:: javascript
148+
149+
db.trigonometry.aggregate( [
150+
{
151+
$addFields : {
152+
"cosh_output" : { $cosh : "$angle" }
153+
}
154+
}
155+
] )
156+
157+
Example output:
158+
159+
.. code-block:: javascript
160+
:copyable: false
161+
162+
{
163+
"_id" : ObjectId("5c50782193f833234ba90d15"),
164+
"angle" : NumberDecimal("1.6301023541559787031443874490659"),
165+
"cosh_output" : NumberDecimal("2.650153334504361016712328539738000")
166+
}
167+
168+
Because ``angle`` is stored as a :ref:`128-bit decimal
169+
<shell-type-decimal>`, the :expression:`$cosh` output is also
170+
a 128-bit decimal.

0 commit comments

Comments
 (0)