JS Built-ins
← Math97 / 215
Mathcosintermediate

Math.cos(Math.PI) β‰ˆ -1

πŸ“– Usage Example
// Cosine of an angle in radians
Math.cos(0)          // β†’ 1
Math.cos(Math.PI)    // β†’ -1

Use Math.cos() to compute the cosine of an angle (in radians) for trigonometry and graphics.

Math.cos(x)

Math.cos(Math.PI) returns a value very close to -1 due to floating-point precision.

Challenge: Verify that Math.cos(Math.PI) is approximately -1.

πŸ’‘ Hints (2)
  • β€’ cos(180Β°) = -1
  • β€’ Floating-point imprecision is common with irrational inputs like Ο€