1 import numpy as np
2 import matplotlib.pyplot as plt
3 def f(x):
4 return x**3+5.1*x**2-2.25*x-15.151
5 #вывод таблицы
6 for x in np.arange(-5,5,0.5):
7 print(f'(x:0.3f} {f(x):0.3f}')
8 #построение графика
9 xs = np.linspace (-5, 5, 100)
10 plt.plot(xs,f(xs))
11 plt.grid(1)
12 xn=np.roots([1,5.1,-2.25,-15.151])
13 print('корни многочлена\n",xn)
14 plt.show()