What is the Sin function in Golang?

The Sin function in the Go programming language is used to find the sine value of a number.

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

Function definition

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

Parameters

The Sin function takes a single argument of type float64. This argument represents the angle whose sine value you want to find.

Return value

The Sin function returns a single value of type float64. This value represents the sine value of the argument. The possible range of all return values is between -1 and 1 (both inclusive).

An exception to the above statements is when you pass something as an argument that is infinity or NAN. In these cases, the Sin function returns a NAN.

Example

The following is a simple example in which we find out the sine value of 25:

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

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved