pastebin

Paste Search Dynamic
Recent pastes
gf mid
  1. def gf(x):
  2.         d = -25*x**4 + 16*x**3 - 36*x**2 + 22*x - 2
  3.         return d
  4.  
  5. a,b,mid = -0.5,0.5,0
  6. epsilon = 10**-5
  7. while abs(b-a) > epsilon:
  8.         mid = (a+b)/2.0
  9.         if gf(mid)>0.0:
  10.                 b = mid
  11.         elif gf(mid)<0.0:
  12.                 a = mid
  13.         elif gf(mid)==0.0:
  14.                 break
  15.  
  16. print("min point",mid)
  17. print("gradient :",gf(mid))
Parsed in 0.003 seconds