What is the Acos function in Golang?

The Acos function in the Go programming language is used to find the inverse of the cosine value of a number:

Acos stands for arccosine, the actual name for the inverse of the cos value for any number.

To use this function, you must import the math package in your file and access the Acos function within it using the . notation (math.Acos). Here, Acos is the actual function, while math is the Go package that stores the definition of this function.

Function definition

The definition of the Acos function inside the math package is:

Parameters

The Acos function takes a single argument of type float64. This argument represents the angle whose cos inverse value you want to find. This value can range from -1 to 1 (both inclusive).

Return value

The Acos function returns a single value of type float64. This value represents the cos inverse value of the argument and is in radians.

Examples

The following is a simple example in which we find out the cos inverse value (in radians) of 0.25:

package main
import ("fmt"
"math")
func main() {
x := 0.25
y := math.Acos(x)
fmt.Print(y)
}

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved