Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. import matplotlib as mlp
  2. import matplotlib.pyplot as plt
  3. import numpy as np
  4. import math
  5. #
  6. #def f(x):
  7. # return 0.5*x**3 - 0.2*x**2 - 2.9*x + 3
  8.  
  9.  
  10.  
  11. b = 1
  12. a = 5
  13. m = ((a + b)/2)
  14.  
  15. def f(x):
  16. return ((x**2/4) - 3*x + 5)
  17.  
  18.  
  19. for i in range(10):
  20. m = ((a + b)/2)
  21. if f(a) * f(m) < 0.21:
  22. b = m
  23. else:
  24. a = m
  25. print(f(m))
  26.  
  27.  
  28.  
  29. #if f(a) < 0 < f(b)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement