All pastes #812868 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-12-12 01:58 UTC
rendered paste body
clear all;
close all;
a = .1;
b = .001;
f = @(t,x) a*x - b*(x.^(3./2));
f2 = @(t,x,x1) a*x1 -b*(3/2)*(x.^(1/2))*x1
f3 = @(t,x,x1,x2) ((-3*a)/4)*(1/(x.^(1/2)))*x1*x1+b*(3/2)*(x.^(1/2))*x2;
[answer,answer2] = Euler2(f,120,0,120,100);


itmax=1000;
emax=1.e-03;
emin=1.e-06;
hmin=1.e-06;
hmax=2.0;
iflag=1;



[answer3, answer4] = RK45_Adaptive(f,0.0,100,1,120,itmax,emax,emin,hmin,hmax,iflag);
[answer5, answer6] = Taylor3(f, f2, f3, 120, 0, 120, 100);

[t, x] = ode45(f, [0 120], [100]);
plot(t,x,'r'); 
hold on;
plot(answer,answer2,'b');
plot(answer3,answer4,'g');
plot(answer5,answer6,'m');