Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. from scipy import interpolate
  4. a, b = -1, 1
  5. c, d = -10, 10
  6. maxiter = 1000
  7. p = 4
  8. x = np.linspace(a, b, 1000)
  9.  
  10. for i in range(maxiter):
  11. xi = np.random.rand(p+1)
  12. yi = np.random.rand(p+1)
  13. f = interpolate.lagrange(xi, yi)
  14. y = f(x)
  15. if y.max()<d and y.min()>c:
  16. break
  17. print i
  18. plt.plot(x, y, '-', lw=3, clip_on=False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement