I am new to Python, so please be careful.
I seriously donβt know what is wrong with my code.
Here he is:
import numpy as np def epsilon(t): epsilon = (1 - np.exp(-pow(t, 4))) return epsilon def r(t): r = pow( (epsilon(t) - 16) / 4, 1/4) return r print(r(0))
Since epsilon(0) = 0 , I would expect (analytically) to get r = (-16/4) ^ (1/4) = (-1) ^ (1/4) * sqrt (2) = exp (i pi / 4) * sqrt (2) = 1 + 1 i
But instead, I get:
RuntimeWarning: invalid value encountered in double_scalars r = pow((4 * epsilon(t) - 16) / 4, 1/4) nan
I tried to find the error. If I print epsilon(0) , I get 0 as expected, and if I install epsilon(0) manually, like:
def r(t): r = pow( 0 - 16) / 4, 1/4) return r print(r(0))
I get 1 + 1 j . And if I remove to the power of 1/4 , it works, and I get -4
import numpy as np def epsilon(t): epsilon = (1 - np.exp(-pow(t, 4))) return epsilon def r(t): r = (epsilon(t) - 16) / 4 return r print(r(0))
So why
import numpy as np def epsilon(t): epsilon = (1 - np.exp(-pow(t, 4))) return epsilon def r(t): r = pow( (epsilon(t) - 16) / 4, 1/4) return r print(r(0))
Am I getting this error?
source share