$acosh (aggregation)
$acosh
Returns the inverse hyperbolic cosine (hyperbolic arc cosine) of a value.
$acosh
の構文は次のとおりです。{ $acosh: <expression> } $acosh
は、1
と+Infinity
の間の数値に変換される有効な式であればどれでもかまいません。例を以下に示します。
1 <= value <= +Infinity
。$acosh
はラジアン単位で値を返します。$radiansToDegrees
演算子を使用して出力値をラジアンから度に変換します。デフォルトでは、
$acosh
は値をdouble
として返します。$acosh
は、<expression>
が128ビットの 10 進数値に解決される限り、 128ビットの 10 進数として値を返すこともできます。
式の詳細については、「式 」を参照してください。
動作
null
、NaN
、+/- Infinity
If the argument resolves to a value of null
or refers to a field
that is missing, $acosh
returns null
. If the argument
resolves to NaN
, $acosh
returns NaN
. If the
argument resolves to negative infinity, $acosh
throws an
error. If the argument resolves to Infinity
, $acosh
returns Infinity
. If the argument resolves to a value outside the
bounds of [-1, Infinity]
inclusive, $acosh
throws an error.
例 | 結果 | |||
---|---|---|---|---|
|
| |||
|
| |||
|
| |||
| 次の形式の出力のようなエラーメッセージをスローします。
|
例
trigonometry
コレクションには、 2 -D グラフのx
軸に沿って値を保存するドキュメントが含まれています。
{ "_id" : ObjectId("5c50782193f833234ba90d85"), "x-coordinate" : NumberDecimal("3") }
The following aggregation operation uses the
$acosh
expression to calculate inverse hyperbolic
cosine of x-coordinate
and add it to the input document using
the $addFields
pipeline stage.
db.trigonometry.aggregate([ { $addFields : { "y-coordinate" : { $radiansToDegrees : { $acosh : "$x-coordinate" } } } } ])
$radiansToDegrees
式は、 $acosh
によって返されたラジアン値を度単位の同等の値に変換します。
このコマンドは、次の出力を返します。
{ "_id" : ObjectId("5c50782193f833234ba90d85"), "x-coordinate" : NumberDecimal("3"), "y-coordinate" : NumberDecimal("100.9979734210524228844295260083432") }
x-coordinate
は128ビットの 10 進数として保存されているため、 $acosh
の出力は128ビットの 10 進数になります。
trigonometry
コレクションには、 2 -D グラフのx
軸に沿って値を保存するドキュメントが含まれています。
{ "_id" : ObjectId("5c50782193f833234ba90d85"), "x-coordinate" : NumberDecimal("3") }
The following aggregation operation uses the
$acosh
expression to calculate inverse hyperbolic
cosine of x-coordinate
and add it to the input document using
the $addFields
pipeline stage.
db.trigonometry.aggregate([ { $addFields : { "y-coordinate" : { $acosh : "$x-coordinate" } } } ])
このコマンドは、次の出力を返します。
{ "_id" : ObjectId("5c50782193f833234ba90d85"), "x-coordinate" : NumberDecimal("3"), "y-coordinate" : NumberDecimal("1.762747174039086050465218649959585") }
x-coordinate
は128ビットの 10 進数として保存されているため、 $acosh
の出力は128ビットの 10 進数になります。