Exponentiation with negative base

泄露秘密 提交于 2019-11-29 11:05:20

The answer is a complex number, so you need to give it a complex argument:

> (4-7+0i)^1.3
[1] -2.451751-3.374545i

but remember this is only one root...

I quote from Wikipedia, especially the bold text (http://en.wikipedia.org/wiki/Exponentiation):

The IEEE 754-2008 floating point standard is used in the design of most > floating point libraries. It recommends a number of different functions for computing a power:[19]

  • pow treats 00 as 1. This is the oldest defined version. If the power is an exact integer the result is the same as for pown, otherwise the result is as for powr (except for some exceptional cases).
  • pown treats 00 as 1. The power must be an exact integer. The value is defined for negative bases, e.g. pown(−3,5) is −243.
  • powr treats 00 as NaN (Not-a-Number - undefined). The value is also NaN for cases like powr(−3,2) where the base is less than zero. The value is defined by epower×log(base).

So I think R is showing standard behavior according to international standards.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!