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

究竟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.

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

报告相同问题?

悬赏问题

  • ¥100 需要跳转番茄畅听app的adb命令
  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证