Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. #Bisection method
  2. emin = -2.3
  3. emax = -2.4
  4. while True:
  5.     average = (emin + emax)/2
  6.     #print("test")
  7.     if (emin-emax) < 0.00000001:
  8.         print(average)
  9.         break
  10.     guess = emin
  11.     for i in range(len(episilon)):
  12.         if i > 1:
  13.             phi[i] = (2+h**2 * f(episilon[i-1]))*phi[i-1]-phi[i-2]
  14.         #plt.plot(episilon,phi)
  15.     eminphi = phi[950]
  16.     #print(eminphi)
  17.     guess = emax
  18.     for i in range(len(episilon)):
  19.         if i > 1:
  20.             phi[i] = (2+h**2 * f(episilon[i-1]))*phi[i-1]-phi[i-2]
  21.         #plt.plot(episilon,phi)
  22.     emaxphi = phi[950]
  23.     #print(emaxphi)
  24.     guess = average
  25.     for i in range(len(episilon)):
  26.         if i > 1:
  27.             phi[i] = (2+h**2 * f(episilon[i-1]))*phi[i-1]-phi[i-2]
  28.     averagephi = phi[950]
  29.     if np.sign(averagephi) == np.sign(eminphi):
  30.         emin = average
  31.     if np.sign(averagephi) == np.sign(emaxphi):
  32.         emax = average
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement