Question 3

Contents

Initial condition and time

x0 = 0.7233;
t0 = 0;

ode23

Compute and plot the numerical solution using ode23

[t1,x1] = ode23(@(t,x)(1-x)*x-0.2, [t0,100], x0);
plot(t1,x1,'DisplayName','ode23');
hold on;
xlabel('t');
ylabel('x');
legend('Location','SouthEast');

ode15s

Compute and plot the numerical solution using ode15s

[t2,x2] = ode15s(@(t,x)(1-x)*x-0.2, [t0,100], x0);
plot(t2,x2,'DisplayName','ode15s');

Analytical Solution

Compute the analytical solution at 1001 points

t3 = linspace(0,100,1001);
x3 = sqrt(5)/10*tanh((t3-t0)*sqrt(5)/10+atanh((2*x0-1)*sqrt(5)))+0.5;
plot(t3,x3,'DisplayName','Analytical Soln.');