I am really confused what is exactly wrong. for first part of if the answer is always 0.0 , even separated part of formula are not 0. what is wrong here?
import numpy as np
def concpt(E,E0,theta):
rad= theta*(np.pi/180)
M=np.cos(rad)
print(M)
thrcondtion= 0.5*E*E0*(1-M)
if thrcondtion>= 1:
x=(1-(1/(E*E0*(1-M))))**0.5
print(x)
RESULT= (3/16)*(1-(x**2))* (((3-(x**4))*(np.log((1+x)/(1-x))))-(2*x*(2-(x**2))))
print(RESULT)
return RESULT
else:
print("invalid")
Try:
at a Python prompt.
It will print
Because the calculation is done using integers, since
3
and16
are both integers. You need e.g.3.0 / 16
there, to get0.1875
.