Acos()

arisdelaCruz1413618857's avatar
Published Sep 1, 2023
Contribute to Docs

The Acos() function returns the arccosine, also known as the inverse cosine, value of the argument (in radians).

Syntax

result := math.Acos(x)

Notes on the parameter:

  • x is the value whose arccosine value is to be found.
  • The range must be between -1 and 1.
  • If the parameter is either less than -1 or greater than 1 it returns NaN.
  • The value returned will be of type float64.

Example

The following code calculates the arccosine and prints out the result:

package main
import (
"fmt"
"math"
)
func main() {
fmt.Println(math.Acos(-1))
fmt.Println(math.Acos(1.23))
}

The output will be:

3.141592653589793
NaN

All contributors

Contribute to Docs

Learn Go on Codecademy