us function ode45 to plot the solution of dy/dt = t2 + y2, y(0)=1 on the interval [0, 0.5]. find the (approximate) value of y(0.5). 10 in matlab

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 chars
21 lines

The approximate value of y(0.5) is around 1.3426.

gistlibby LogSnag