Menu Close

Go – Sincos() fucntion in math package in go

Here, We will learn about Sincos() fucntion in math package in go.  Sincos() is used to get Sin(x), Cos(x) at a time.

Function prototype:

func Sincos(x float64) (sin, cos float64)

Return value:

Sincos() function in math package returns
Sin(x), Cos(x) value of number.

Example with code:

package main

import (
  "fmt"
  "math"
)

func main() {

  sin, cos := math.Sincos(1.2)
  fmt.Println(sin, cos)

  sin, cos = math.Sincos(1)
  fmt.Println(sin, cos)

  sin, cos = math.Sincos(0)
  fmt.Println(sin, cos)

  sin, cos = math.Sincos(0.25)
  fmt.Println(sin, cos)

  sin, cos = math.Sincos(-1.25)
  fmt.Println(sin, cos)
}

Output:

0.9320390859672264 0.3623577544766736
0.8414709848078965 0.5403023058681398
0 1
0.24740395925452294 0.9689124217106447 -0.9489846193555862 0.3153223623952687

To learn more about golang, Please refer given below link:

https://www.techieindoor.com/go-lang-tutorial/

References:

https://golang.org/doc/
https://golang.org/pkg/
Posted in golang, math

Leave a Reply

Your email address will not be published.

Contact Us