Sorry, but I am not able to understand what exactly math.Exp
is doing in following code block:
package main
import (
"fmt"
"math"
)
func main() {
for x := 0; x < 8; x++ {
fmt.Printf("x = %f ex = %8.3f\n", float64(x), math.Exp(float64(x)))
}
}
The output of the above program is:
x = 0.000000 ex = 1.000
x = 1.000000 ex = 2.718
x = 2.000000 ex = 7.389
x = 3.000000 ex = 20.086
x = 4.000000 ex = 54.598
x = 5.000000 ex = 148.413
x = 6.000000 ex = 403.429
x = 7.000000 ex = 1096.633
And, I am not able to understand what exactly is math.Exp
function is doing internally and converting float64(x)
to respective values as in the output. I have read the go
's official documentation , which says as below:
Exp returns e**x, the base-e exponential of x.
Reading which I am not very clear of the purpose and mechanism of math.Exp
function.
I am actually interested in what binary/mathematical operation is going under the hood.
It returns the value of e^x
(also expressed as e**x
or simply exp(x)
).
That function is based on the number e=2.71828...
[1] , which is defined (among other definitions) as:
Lim (1+1/n)^n when n tends to infinity
Particularly, the function e^x
has many properties that make it special, but the "most" important is the fact that the function itself is equal to its derivative , ie:
Let f(x)=e^x, then f'(x)=e^x
This translates to the fact that the value of the slope in one point is equal to the value of the function in that point.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.