Python中的自然登录成为复数

时间:2019-03-10 03:46:47

标签: python math natural-logarithm

问题: 为什么我的float ^ float变成复数? 在Wolfram Alpha中,答案应该是-0.937

import numpy as np 
import math

implied_cost = -0.712589074
max_profit = 1.662707838
max_loss = -28.02850356

a = math.log(abs(implied_cost))
b = abs(max_profit/max_loss)
new_score = a**b

print(a)
print(type(a))
print(b)
print(type(b))
print(new_score)
print(type(new_score))

output:

-0.33885035851284695
<class 'float'>
0.05932203388742028
<class 'float'>
(0.9215800307441395+0.17376732129409583j)
<class 'complex'>

问题: 为什么我的float ^ float变成复数? 在Wolfram Alpha中,答案应该是-0.937

0 个答案:

没有答案