Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from scipy.integrate import odeint
- import matplotlib.pyplot as plt
- def system_of_equations(variables, t):
- x, y, dxdt, dydt = variables
- d2xdt2 = x**2 + y**2
- d2ydt2 = x - np.cos(y)**2 + t
- return [dxdt, dydt, d2xdt2, d2ydt2]
- initial_conditions = [2, 10, 1, 3]
- t_span = np.linspace(0, 1, 1000)
- solution = odeint(system_of_equations, initial_conditions, t_span)
- x_values = solution[:, 0]
- y_values = solution[:, 1]
- plt.plot(t_span, x_values, label='x(t)')
- plt.plot(t_span, y_values, label='y(t)')
- plt.legend()
- plt.grid()
- plt.title('Розв\'язок системи диференціальних рівнянь')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement