204k views
3 votes
Write code to simulate the following differential equation for x ranging from 0 to 5. Assume y = 0 when x = 0. Plot y vs. x using Matplotlib. Give the plot a title and x and y axis labels. Also plot grid lines. Use a stepsize for x of 0.01. (4 points) dy/dx=(〖50x〗^2-10y)/3

User Donkon
by
4.8k points

1 Answer

3 votes

Answer:

Check the explanation

Step-by-step explanation:

from scipy.integrate import solve_ivp

import numpy as np

import matplotlib.pyplot as plt

def ode(x,y):

return (50*x**2-10*y)/3

t=np.arange(0,5.01,.01)

sol = solve_ivp(ode, [0, 5], [0], t_eval = t)

plt.plot(sol.t,sol.y.T)

plt.show()

plt.title('ode')

plt.ylabel('y')

plt.xlabel('x')

plt.grid()

Write code to simulate the following differential equation for x ranging from 0 to-example-1
User Httpete
by
5.6k points