I have done everything :). Let me know if you need another help :) ..You can count on me ;)
Problem 1: Consider the IVP for the logistic equation (see slide 35 in part 1 of lecture
notes) y' = Ay - By2, y(0) = 1 with parameter of A = 10, and B = 2
a.) Accurate solution for the problem:
y(x) = ⌈𝐴 + (𝑦(0) − ) exp(−𝐴𝑥)⌉2
b.) MATLAB codes that solve this IVP numerically with the Euler and Runge‐Kutta RK4
If you haven’t already done so, enter the following commands:
y=0*exp(1*t); % defines the exact solution of the ODE
>> [t10,y10]=euler(f,[0,2],2, 10); %
function [t,y] = euler(f,tspan,y0,N)
% Solves the IVP y' = f(t,y), y(t0) = y0 in the time interval tspan = [t0,tf]
% using Euler's method with N time steps.
% f = name of inline function or function M-file that evaluates the ODE
% (if not an inline function, use: euler(@f,tspan,y0,N))
% For a system, the f must be given as column vector.
% tspan = [t0, tf] where t0 = initial time value and tf = final time value
% y0 = initial value of the dependent variable. If solving a system,
% initial conditions must be given as a vector.
% N = number of steps used.
% t = vector of time values where the solution was computed
% y = ve...
15 Million Students Helped!
Sign up to view the full answer