AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

$cosh(式演算子)

$cosh

ラジアンで測定された値の双曲線コサインを返します。

$cosh の構文は次のとおりです。

{ $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.

デフォルトでは、 $coshdouble$cosh128は値を<expression>128 として返します。 では、 が ビットの 10 進数値に解決される場合は、 ビットの 10 進数として値を返すこともできます。

式の詳細については、「式 」を参照してください。

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.

結果

{ $cosh: NaN }

NaN

{ $cosh: null }

null

{ $cosh: -Infinity }

Infinity

{ $cosh: Infinity }

Infinity

次のtrigonometryコレクションには、度単位で測定されたangle値を保存するドキュメントが含まれています。

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

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

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

$degreesToRadians式は、 angleを度単位でラジアンに変換します。

出力例:

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

angle128ビットの$cosh 10 進数として保存されるため、 の出力も128 ビットの 10 進数になります。

次のtrigonometryコレクションには、ラジアンで測定されたangle値を保存するドキュメントが含まれています。

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

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

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

出力例:

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

Because angle is stored as a 128-bit decimal, the $cosh output is also a 128-bit decimal.

このページを評価

項目一覧