what is wrong about this script?

81 views Asked by At

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")
1

There are 1 answers

0
unwind On

Try:

>>> print(3/16)

at a Python prompt.

It will print

0

Because the calculation is done using integers, since 3 and 16 are both integers. You need e.g. 3.0 / 16 there, to get 0.1875.