Learn and Learn

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

GoLang – Find e Raised to Power x – Expm1() Function – Examples & Explanation

Expm1() function is used to find e raised to the power x - 1 for the given input (x – parameter) in Go language.
The standard math package of Go programming language has Expm1() function. The purpose of this function is to find the base-e exponential of x minus 1 (e**x - 1) and It is more accurate than Exp(x) - 1 when x is near zero.

Syntax of Expm1() Function in Go Language

The syntax of Expm1() 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:
Expm1(+Inf) = +Inf
Expm1(-Inf) = -1
Expm1(NaN) = NaN

Note: Very large values overflow to -1 or +Inf.

 

Parameters of Expm1() 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) Expm1() 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 Expm1() Function in Go Language

Expm1() function will return e**x - 1, the base-e exponential of x minus 1 of the given input(x – parameters).

 

GoLang Expm1() Function Example 1


Output:
-0.6321205588285577

 

GoLang Expm1() Function Example 2


Output:
8102.083927575384

 

GoLang Expm1() Function Example 3


Output:
17.17414536944306

 

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