Menu Close

Go – How to get the tangent of the radian of number in go

Here, We will learn how to get the tangent of the radian of number in go. We can get it by using Tan() function in math package in go golang.

Function prototype:

func Tan(x float64) float64

Return value:

Tan() function in math package returns 
the tangent of the radian argument x.

Example with code:

package main

import (
  "fmt"
  "math"
)

func main() {

  no := math.Tan(1.2)
  fmt.Println(no)

  no = math.Tan(-2.7)
  fmt.Println(no)

  no = math.Tan(0.0)
  fmt.Println(no)

  no = math.Tan(-2.9)
  fmt.Println(no)

  no = math.Tan(2)
  fmt.Println(no)
}

Output:

2.5721516221263188
0.4727276291030373
0
0.24640539397196634
-2.185039863261519

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