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.misc import derivative as der
- def F(x):
- return x**4 + x**2 + x + 1
- def Par(a, b, eps, x):
- #метод средней точки
- for i in np.arange(a, b, eps/10):
- x.append(i)
- y = [F(i) for i in x]
- x_temp = (a+b)/2
- while abs(der(F(x_temp))) < eps:
- x_temp = (a+b)/2
- if der(F(x_temp)) < 0:
- b = x_temp
- else:
- a = x_temp
- y = [F(i) for i in x]
- plt.plot (x, y)
- plt.grid(True)
- plt.show()
- print("Метод срединной точки: \nx* = ", x_temp, "\ny_min = ", F(x_temp))
- def main():
- a = -1
- b = 0
- eps = 0.01
- x = []
- for i in np.arange(a, b, eps/10):
- x.append(i)
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement