自然對數e

實際應用例如同一時間段複利計算的極限

https://zh.wikipedia.org/wiki/E_(数学常数\

往下拉到定義部分

1.

定義 e 爲下列極限值:

可用程式計算

n趨近極大值

function a (n){return (1+1/n) ** n }

// a(9000000000)
// 2.718282053219686

以及

n趨近極小值

function b (n){return (1+n) ** (1/n) }

// b(0.000000000001)
// 2.7185234960372378

但javascript有最大限制

http://stackoverflow.com/questions/43729790/natural-logarithm-e-1

2.

定義 e 爲下列無窮級數之和:

可用程式計算

//fact用來計算階層的倒數
function fact(x) {
   if(x==0) {
      return 1;
   }
   return 1 / x * fact(x-1) ;
}


function c(n) {
  var total = fact(n);
  for(i = 1; i <= n; i++ ){
    total += fact(n - i)
  }
 return total;
}

//c(345)

>以上兩者給n到一數以上時都會為2.7.......

Math.newsqrt = function(a, b) {
  if(b > 0) {
    a = Math.sqrt(a);
    return Math.newsqrt(a, b - 1);
  } else {
    return a
  }
}

Math.newsqrt(Math.exp(1), Math.exp(1))

http://blog.udn.com/cchahacaptain/4565752

Last updated