Tan()
The Tan()
function returns the tangent of an angle given in radians. The math
library must be imported in order to use this function.
Syntax
result := math.Tan(angle)
Where result
is the tangent value of angle
, returned as a float, except under the following circumstances:
- The result of
Tan(-Inf)
isNaN
- The result of
Tan(+Inf)
isNaN
- The result of
Tan(NaN)
isNaN
Example
The following calculates the tangent of angle
and prints out the result:
package mainimport ("fmt""math")func main() {angle := math.Pi / 6tangent := math.Tan(angle)fmt.Printf("%.1f\n", tangent)}
The output will be:
0.6
Codebyte Example
The following example is runnable and shows how the Tan()
function handles infinite values.
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.