import numpy as np
from scipy.integrate import solve_ivp
import matplotlib.pyplot as plt
def differential_equations(t, z):
x, y = z
dx_dt = -x ** 3 - y
dy_dt = x - y ** 3
return [dx_dt, dy_dt]
z0 = [1, 0.5]
t_span = (0, 30)
sol = solve_ivp(differential_equations, t_span, z0, t_eval=np.linspace(0, 30, 1000))
plt.figure(figsize=(10, 5))
plt.subplot(1, 2, 1)
plt.plot(sol.t, sol.y[0], label='x(t)')
plt.plot(sol.t, sol.y[1], label='y(t)')
plt.xlabel('t')
plt.ylabel('x, y')
plt.title('Solution Curves')
plt.legend()
plt.subplot(1, 2, 2)
plt.plot(sol.y[0], sol.y[1])
plt.xlabel('x')
plt.ylabel('y')
plt.title('Phase Plane Trajectory')
plt.tight_layout()
plt.show()
print('3022')