$sin (Sine)

Last updated: 2026-10-09

$sin (Sine)

$sin returns the sine of a value expressed in radians. It is used for periodic signal processing, coordinate transforms, and trigonometry, such as converting degrees to radians before taking the sine. A null or missing argument yields null, NaN input returns NaN, and ±Infinity throws an error. Convert degrees to radians with $degreesToRadians (and back with $radiansToDegrees) instead of hand-multiplying by pi.

CategoryMath
MongoDB Version1.0+
Example Languagemongosh (Shell)

📝 Syntax

{ $sin: <numeric-expression> }

⚙️ Parameters

radiansA numeric expression in radians.

Returns:The sine of the input radians; null when null or missing, error for ±Infinity

▶ Example

Run the commands below in your local mongosh (requires a running mongod):

// $sin: sine after converting degrees to radians
db.trig.aggregate([
  { $project: {
      y: { $sin: { $degreesToRadians: '$deg' } }
  } }
])

Output:

{ '_id': 1, 'y': 1 }
{ '_id': 2, 'y': 0.5 }

📌 Notes

More hands-on cases coming soon.

📚 Related Tutorials

❓ FAQ

QDoes $sin take degrees or radians?
ARadians; convert angle input with $degreesToRadians first.
QWhat does $sin return for Infinity?
AIt throws; the sine of infinity is undefined.
QHow do I compute $sin(30 degrees)?
AWrite $sin: { $degreesToRadians: 30 } and the result is 0.5.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏