Advertisement
mirosh111000

Атестація 2

Jan 4th, 2024
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. from scipy.integrate import odeint
  4.  
  5. def new_system(y, t):
  6.     x, y = y
  7.     dydt = [1 + x**2 * y - 2*x, x - y * x**2]
  8.     return dydt
  9.  
  10. def plot_phase_portrait(system, title, xlabel, ylabel, y0, t):
  11.     sol = odeint(system, y0, t)
  12.     plt.plot(sol[:, 0], sol[:, 1], label='Фазовий портрет')
  13.     plt.title(title)
  14.     plt.xlabel(xlabel)
  15.     plt.ylabel(ylabel)
  16.     plt.axis('equal')
  17.     plt.legend()
  18.     plt.grid(True)
  19.     plt.show()
  20.  
  21. y0_new_system = [0.0, 10.0]
  22.  
  23. plot_phase_portrait(new_system, 'Фазовий портрет нової системи', 'x', 'y', y0_new_system, t)
  24.  
  25. A_new_system = np.array([[1, 0],
  26.                          [-2*y0_new_system[1]*y0_new_system[0]**2 + y0_new_system[1]**2, -2*y0_new_system[0]*y0_new_system[1]*y0_new_system[0]]])
  27.  
  28. eigenvalues_new_system = np.linalg.eigvals(A_new_system)
  29.  
  30. print("Власні значення матриці A:", eigenvalues_new_system)
  31.  
  32. if all(eig_real < 0 for eig_real in eigenvalues_new_system.real):
  33.     print("Положення рівноваги для системи є стійким.")
  34. else:
  35.     print("Положення рівноваги для системи є нестійким.")
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement