Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Bisection method
- emin = -2.3
- emax = -2.4
- while True:
- average = (emin + emax)/2
- #print("test")
- if (emin-emax) < 0.00000001:
- print(average)
- break
- guess = emin
- for i in range(len(episilon)):
- if i > 1:
- phi[i] = (2+h**2 * f(episilon[i-1]))*phi[i-1]-phi[i-2]
- #plt.plot(episilon,phi)
- eminphi = phi[950]
- #print(eminphi)
- guess = emax
- for i in range(len(episilon)):
- if i > 1:
- phi[i] = (2+h**2 * f(episilon[i-1]))*phi[i-1]-phi[i-2]
- #plt.plot(episilon,phi)
- emaxphi = phi[950]
- #print(emaxphi)
- guess = average
- for i in range(len(episilon)):
- if i > 1:
- phi[i] = (2+h**2 * f(episilon[i-1]))*phi[i-1]-phi[i-2]
- averagephi = phi[950]
- if np.sign(averagephi) == np.sign(eminphi):
- emin = average
- if np.sign(averagephi) == np.sign(emaxphi):
- emax = average
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement