Math.acos method

The Math.acos method returns the arccosine (or inverse cosine) of a number. The method parameter must be between -1 to 1, otherwise it will return NaN.

Syntax

javascriptMath.acos(number);

Example

Let's output the arccosine of the number 0.34:

javascriptconsole.log(Math.acos(0.37));

The code execution result:

javascript1.191787306098946

Example

Let's output the arccosine of the number 1:

javascriptconsole.log(Math.acos(1));

The code execution result:

javascript0

Example

The following example will output NaN because the parameter is greater than 1:

javascriptconsole.log(Math.acos(3));

The code execution result:

javascriptNaN

See also

  • the Math.cos method
    that returns the cosine of a number
  • the Math.sin method
    that returns the sine of a number
  • the Math.tan method
    that returns the tangent of a number
  • the Math.asin method
    that returns the arcsine of a number
  • the Math.atan method
    that returns the arctangent of a number