Why is Math.pow(0, 0) === 1?

后端 未结 9 729
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 01:47

We all know that 00 is indeterminate.

But, javascript says that:

Math.pow(0, 0) === 1 // true

9条回答
  •  攒了一身酷
    2020-11-30 02:11

    For this to understand you need to solve calculus:

    Expanding x^x around zero using Taylor series, we get:

    So to understand what's going on with limit when x goes to zero, we need to find out what's going on with second term x log(x), because other terms are proportional to x log(x) raised to some power.

    We need to use transformation:

    Now after this transformation we can use L'Hôpital's rule, which states that:

    So differentiating that transformation we get:

    So we've calculated that term log(x)*x approaches 0 when x approaches 0. It's easy to see that other consecutive terms also approaches zero and even faster than second term.

    So at point x=0, series becomes 1 + 0 + 0 + 0 + ... and thus equals to 1.

提交回复
热议问题