Cosh()
chip01889226953 total contributions
Published Sep 16, 2023
Contribute to Docs
The Cosh()
of the math
package is an inbuilt function that takes a given value and returns its hyperbolic cosine value.
Syntax
import "math"
CoshX = math.Cosh(x)
Where CoshX
is the hyperbolic cosine value of x
, it is of type float64
. It always returns the hyperbolic cosine value except for some special cases:
Cosh(±0)
is1
Cosh(±Inf)
is+Inf
Cosh(NaN)
isNaN
Example
The following Golang program calculates the hyperbolic cosine of x
and prints out the result:
package mainimport ("fmt""math")func main() {fmt.Println(math.Cosh(5))fmt.Println(math.Cosh(-5))}
The output will be:
74.2174.21
Codebyte Example
The following example shows how the Cosh()
function handles float64 arguments including special cases.
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.