How to use the math.Cosh() function to get the hyperbolic cosine of a number in Go

1 Answer

0 votes
package main

import (
	"fmt"
	"math"
)

func main() {
	fmt.Println("math.Cosh(-1) =", math.Cosh(-1))
	fmt.Println("math.Cosh(1) =", math.Cosh(1))
	fmt.Println("math.Cosh(0) =", math.Cosh(0))
	fmt.Println("math.Cosh(-0) =", math.Cosh(-0))
	fmt.Println("math.Cosh(0.9) =", math.Cosh(0.9))
	fmt.Println("math.Cosh(math.Pi) =", math.Cosh(math.Pi))
	fmt.Println("math.Cosh(math.Pi * 2) =", math.Cosh(math.Pi*2))
	fmt.Println("math.Cosh(math.Pi / 2) =", math.Cosh(math.Pi/2))
	fmt.Println("math.Cosh(math.Pi / 3) =", math.Cosh(math.Pi/3))
}


/*
run:

math.Cosh(-1) = 1.5430806348152437
math.Cosh(1) = 1.5430806348152437
math.Cosh(0) = 1
math.Cosh(-0) = 1
math.Cosh(0.9) = 1.4330863854487745
math.Cosh(math.Pi) = 11.591953275521519
math.Cosh(math.Pi * 2) = 267.7467614837482
math.Cosh(math.Pi / 2) = 2.5091784786580567
math.Cosh(math.Pi / 3) = 1.6002868577023865

*/

 



answered Aug 11, 2024 by avibootz
...