$asin (Arcsine)
Last updated: 2026-10-09
$asin (Arcsine)
$asin returns the arcsine of a number, with the result expressed in radians. The input must be between -1 and 1. It is used to recover an angle from a sine value or in coordinate transforms. A null or missing argument yields null; input outside [-1, 1] throws an error because no real angle exists for it. Convert the radian result to degrees with $radiansToDegrees. $asin is the inverse of $sin: $sin($asin(x)) equals x.
| Category | Math |
|---|---|
| MongoDB Version | 1.0+ |
| Example Language | mongosh (Shell) |
📝 Syntax
{ $asin: <numeric-expression> }
⚙️ Parameters
| numeric value | A numeric expression between -1 and 1. |
|---|
Returns:The arcsine in radians; null when null or missing, error outside [-1, 1]
▶ Example
Run the commands below in your local mongosh (requires a running mongod):
// $asin: recover an angle (radians) from a sine value
db.trig.aggregate([
{ $project: {
angleRad: { $asin: '$sinValue' }
} }
])
Output:
{ '_id': 1, 'angleRad': 1.5707963267948966 }
{ '_id': 2, 'angleRad': 0.5235987755982989 }
📌 Notes
- The input must be between -1 and 1; outside that range it throws
- The result is in radians; convert with $radiansToDegrees
- It is the inverse of $sin
🏷️ Related Tags
💡 Related Cases
More hands-on cases coming soon.
📚 Related Tutorials
❓ FAQ
QWhat is the input range of $asin?
AIt must be between -1 and 1; values outside throw.
QDoes $asin return radians or degrees?
ARadians; use $radiansToDegrees for degrees.
QWhat is $asin(1)?
AIt is π/2, the radian measure of 90 degrees, about 1.5708.