Strange behavior of R

我们两清 提交于 2019-12-02 02:54:22

-0.9090909 ^ a is the same as -(0.9090909 ^ a). Notice the parentheses.

However, your test contains negative values, and you cannot take the root of a negative number. Try (-0.9090909) ^ a to verify this:

> (-0.9090909) ^ -0.1
[1] NaN

You are trying to take a root of a negative number. If you wish to do complex arithmetic you need to convert to complex

as.complex(test) ^ a
# [1] 0.9601644-0.3119763i 0.7249946-0.2355650i 0.9601644-0.3119763i
# [4] 0.6115633-0.1987090i 0.9601644-0.3119763i 0.9601644-0.3119763i
# [7] 0.6435367-0.2090978i 0.9601644-0.3119763i 0.7357171-0.2390490i
#[10] 0.9601644-0.3119763i 0.7022627-0.2281790i 0.6243418-0.2028609i
#[13] 0.9601644-0.3119763i 0.9601644-0.3119763i 0.9601644-0.3119763i
#[16] 0.9601644-0.3119763i 0.5389643-0.1751201i 0.9601644-0.3119763i
#[19] 0.9601644-0.3119763i 0.9601644-0.3119763i 0.7623605-0.2477059i
#[22] 0.9601644-0.3119763i 0.6912151-0.2245894i 0.9601644-0.3119763i
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!