dousu8767 2018-11-03 09:06
浏览 129
已采纳

究竟math.Exp有什么作用?

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
", 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.

  • 写回答

1条回答 默认 最新

  • dpnfxk251524 2018-11-03 09:27
    关注

    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, i.e.:

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持