Is numpy.power() less accurate then math.pow()?
Example:
Given A = numpy.array([6.66655333e+12,6.66658000e+12,6.66660667e+12,3.36664533e+12])
I define
result = numpy.power(A,2.5)
So
>> result = [ 1.14750185e+32 1.14751333e+32 1.14752480e+32 2.07966517e+31]
However:
math.pow(A[0],2.5) = 1.14750185103e+32
math.pow(A[1],2.5) = 1.14751332619e+32
math.pow(A[2],2.5) = 1.14752480144e+32
math.pow(A[3],2.5) = 2.079665167e+31
This is just a questions how the numbers are displayed:
>>> result[0]
1.1475018493845227e+32
and:
>>> math.pow(A[0],2.5)
1.1475018493845227e+32
Both ways lead to same value:
>>> result[0] == math.pow(A[0],2.5)
True
result
has its own method __repr__()
that shows numbers differently than the standard Python __repr__()
for float
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With