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 differential_equation(y, x):
- dydx, d2ydx2, d3ydx3 = y[1], y[2], y[3]
- d4ydx4 = y[0]**2 + 3 * x
- return [dydx, d2ydx2, d3ydx3, d4ydx4]
- y0 = [4, 2, 1, 0]
- x_values = np.linspace(0, 1, 100)
- solution = odeint(differential_equation, y0, x_values)
- y_values = solution[:, 0]
- plt.plot(x_values, y_values, label='y(x)')
- plt.xlabel('x')
- plt.ylabel('y')
- plt.legend()
- plt.grid()
- plt.title('Розв\'язок диференціального рівняння')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement