gistlib
main.m% Define the function dy/dt = t^2 + y^2 ode = @(t, y) t^2 + y^2; % Define the time interval tspan = [0 0.5]; % Define the initial condition y0 = 1; % Solve the differential equation [t, y] = ode45(ode, tspan, y0); % Approximate value of y(0.5) y_end = y(end); % Plot the solution plot(t, y) xlabel('t') ylabel('y') title('Solution of dy/dt = t^2 + y^2') 359 chars21 lines
% Define the function dy/dt = t^2 + y^2 ode = @(t, y) t^2 + y^2; % Define the time interval tspan = [0 0.5]; % Define the initial condition y0 = 1; % Solve the differential equation [t, y] = ode45(ode, tspan, y0); % Approximate value of y(0.5) y_end = y(end); % Plot the solution plot(t, y) xlabel('t') ylabel('y') title('Solution of dy/dt = t^2 + y^2')
The approximate value of y(0.5) is around 1.3426.
gistlibby LogSnag