Advertisement
mirosh111000

9

Sep 17th, 2023
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. import numpy as np
  2. from scipy.integrate import odeint
  3. import matplotlib.pyplot as plt
  4.  
  5. def system_of_equations(yz, x):
  6.     y, z = yz
  7.     dydx = y**2 + z - 3
  8.     dzdx = np.cos(y) + x
  9.     return [dydx, dzdx]
  10.  
  11.  
  12. initial_conditions = [4, 2]
  13.  
  14. x_values = np.linspace(0, 0.255, 100)
  15.  
  16. solution = odeint(system_of_equations, initial_conditions, x_values)
  17.  
  18. y_values, z_values = solution[:, 0], solution[:, 1]
  19.  
  20. plt.plot(x_values, y_values, label='y(x)')
  21. plt.xlabel('x')
  22. plt.ylabel('y')
  23. plt.legend()
  24. plt.grid()
  25. plt.title('Графік функції y(x)')
  26. plt.show()
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement