Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- import numpy as np
- from scipy import interpolate
- a, b = -1, 1
- c, d = -10, 10
- maxiter = 1000
- p = 4
- x = np.linspace(a, b, 1000)
- for i in range(maxiter):
- xi = np.random.rand(p+1)
- yi = np.random.rand(p+1)
- f = interpolate.lagrange(xi, yi)
- y = f(x)
- if y.max()<d and y.min()>c:
- break
- print i
- plt.plot(x, y, '-', lw=3, clip_on=False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement