Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

GoLang – Find Hyperbolic Tangent – Tanh() Function – Examples & Explanation

Tanh() function is used to find the hyperbolic tangent of the given input (x – parameter) in Go language. The standard math package of Go programming language has Tanh() function.

Syntax of Tanh() Function in Go Language

The syntax of Tanh() function in Go Language is:

Note: float64 is a data type in Go language which has IEEE-754 64-bit floating-point numbers.
Special cases are:
Tanh(±0) = ±0
Tanh(±Inf) = ±1
Tanh(NaN) = NaN

 

Parameters of Tanh() Function in Go Language

x – Where x is any Valid float64 Input value. This parameter is required.

 

Error Handling

If the x parameter is not a number (numeric value) Tanh() function returns an error .
If there is no argument (x – input value) passes to the function, then the compiler will produce an error.

 

Return Value of Tanh() Function in Go Language

Tanh() function will returns the hyperbolic tangent of the given input(x – parameter).

 

GoLang Tanh() Function Example 1


Output:
-0.9999999863134581

 

GoLang Tanh() Function Example 2


Output:
0.9999999750614947

 

GoLang Tanh() Function Example 3


Output:
1

 

Loading...
LearnAndLearn.com © 2018 - All rights reserved