Professional Documents
Culture Documents
Import Numpy As NP
Import Numpy As NP
global zo
if((z==0)or((z%(np.pi/2))==0)):
return 0
else:
return -1/np.tan(z)-np.sqrt((zo/z)**2-1)
global zo
if((z==0)or(z%(np.pi))==0):# to avoid devide by zero at tan(0,270,...)
return 0
else:
return np.tan(z)- np.sqrt((zo/z)**2-1)
z=np.linspace(0.0001,6*np.pi,1000)
f_yo = np.zeros(len(z))
f_ye = np.zeros(len(z))
for i in range(len(z)):
resulto = fo(z[i])
f_yo[i]=resulto
resulte=fe(z[i])
f_ye[i]=resulte
#obtaining the sign of the function
se=np.sign(f_ye)
print('the values of energies for odd value of n:')
for i in range(len(se)-1):
if se[i]+se[i+1]==0:
#if the sum of the two consecutive element is zero.change the sign of the function
zero=brentq(fe,z[i],z[i+1])
print (zero)