Exp()
function is used to find the power of e
in the form of e**x
for the given input (x
– parameter) in Go language.
The standard math package of Go programming language has Exp()
function. The purpose of this function is to find the base-e
exponential of x
(e**x
). Where e
is called Euler’s number, named after the renowned mathematician Leonhard Euler.
Syntax of Exp()
Function in Go Language
The syntax of
Exp()
function in Go Language is:
func Exp(x float64) float64
Note: float64
is a data type in Go language which has IEEE-754 64-bit floating-point numbers.
Special cases are:
Exp(+Inf) = +Inf
Exp(NaN) = NaN
Note: Very large values overflow to 0
or +Inf
. Very small values underflow to 1
.
Parameters of Exp()
Function in Go Language
x
– Where x
is any Valid float64
Input value. This parameter is required.
Error Handling
If the
If there is no argument (
x
parameter is not a number (numeric value) Exp()
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 Exp()
Function in Go Language
Exp()
function will return the e**x
, the base-e exponential of x
of the given input(x
– parameters).
GoLang Exp()
Function Example 1
package main import "fmt" import "math" func main() { var x float64 x = math.Exp(0.369) fmt.Println(x) }
Output:
1.4462876036747396
Golang Exp()
Function Example 2
package main import "fmt" import "math" func main() { var x float64 x = math.Exp(-1) fmt.Println(x) }
Output:
0.36787944117144233
GoLang Exp()
Function Example 3
package main import "fmt" import "math" func main() { var x float64 x = math.Exp(18) fmt.Println(x) }
Output:
6.565996913733051e+07