Home > K25104 > ODEs > explicit_multistep_script_1.m

explicit_multistep_script_1

PURPOSE ^

Usage example for explicit_multistep

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 Usage example for explicit_multistep
 employing 3-step Adams-Bashforth method

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Usage example for explicit_multistep
0002 % employing 3-step Adams-Bashforth method
0003 
0004 f = @(t,y) -y/(1+t);
0005 t0 = 0;
0006 y0 = 1;
0007 h = 0.1;
0008 T = 1;
0009 rho = [0; 0; -1; 1];
0010 sigma = [5/12; -4/3; 23/12; 0];
0011 analytic = @(t) 1./(1+t);
0012 [ y,t,err ] = explicit_multistep( f,t0,y0,h,T,rho, sigma, analytic );
0013 figure;
0014 plot(t,y,'o');           
0015 xlabel('t');
0016 ylabel('y(t)');
0017 hold on;
0018 ezplot(analytic, [0 1]);
0019 legend('numerical','analytic');
0020 f = @(t,y) 2*y/(1+t);
0021 analytic = @(t) (1+t).^2;
0022 [ y,t,err ] = explicit_multistep( f,t0,y0,h,T,rho, sigma, analytic );
0023 figure;
0024 plot(t,y,'o');           
0025 xlabel('t');
0026 ylabel('y(t)');
0027 hold on;
0028 ezplot(analytic, [0 1]);
0029 legend('numerical','analytic');
0030 
0031

Generated on Mon 18-Jan-2016 10:25:49 by m2html © 2005