 
  To get started, select "MATLAB Help" from the Help menu.
 
>> help taystep

 
  Use 3rd order Taylor series to advance
  x(t) to x(t+h), where x' = x^2 - t.
 

>> x1 = taystep( 0, -1/2, 0.05 )

xp =

    0.2500


xpp =

   -1.2500


xppp =

    1.3750


x1 =

   -0.4890

>> 
>> x2 = taystep( 0.05, x1, 0.05 )

xp =

    0.1892


xpp =

   -1.1850


xppp =

    1.2306


x2 =

   -0.4810

>> x3= taystep(0.1,x2,0.05)

xp =

    0.1314


xpp =

   -1.1264


xppp =

    1.1182


x3 =

   -0.4758

>> t = 0:0.05:4

t =

  Columns 1 through 7 

         0    0.0500    0.1000    0.1500    0.2000    0.2500    0.3000

  Columns 8 through 14 

    0.3500    0.4000    0.4500    0.5000    0.5500    0.6000    0.6500

  Columns 15 through 21 

    0.7000    0.7500    0.8000    0.8500    0.9000    0.9500    1.0000

  Columns 22 through 28 

    1.0500    1.1000    1.1500    1.2000    1.2500    1.3000    1.3500

  Columns 29 through 35 

    1.4000    1.4500    1.5000    1.5500    1.6000    1.6500    1.7000

  Columns 36 through 42 

    1.7500    1.8000    1.8500    1.9000    1.9500    2.0000    2.0500

  Columns 43 through 49 

    2.1000    2.1500    2.2000    2.2500    2.3000    2.3500    2.4000

  Columns 50 through 56 

    2.4500    2.5000    2.5500    2.6000    2.6500    2.7000    2.7500

  Columns 57 through 63 

    2.8000    2.8500    2.9000    2.9500    3.0000    3.0500    3.1000

  Columns 64 through 70 

    3.1500    3.2000    3.2500    3.3000    3.3500    3.4000    3.4500

  Columns 71 through 77 

    3.5000    3.5500    3.6000    3.6500    3.7000    3.7500    3.8000

  Columns 78 through 81 

    3.8500    3.9000    3.9500    4.0000

>> x = zeros(size(t));
>> x(1) = -0.5;
>> t(1)

ans =

     0

>> for i=2:81,
     x(i) = taystep(t(i-1),x(i-1),0.05);
end;

xp =

    0.2500


xpp =

   -1.2500


xppp =

    1.3750


xp =

    0.1892


xpp =

   -1.1850


xppp =

    1.2306


xp =

    0.1314


xpp =

   -1.1264


xppp =

    1.1182


xp =

    0.0764


xpp =

   -1.0727


xppp =

    1.0326


xp =

    0.0241


xpp =

   -1.0228


xppp =

    0.9694


xp =

   -0.0259


xpp =

   -0.9755


xppp =

    0.9249


xp =

   -0.0735


xpp =

   -0.9300


xppp =

    0.8960


xp =

   -0.1189


xpp =

   -0.8857


xppp =

    0.8798


xp =

   -0.1621


xpp =

   -0.8419


xppp =

    0.8738


xp =

   -0.2031


xpp =

   -0.7982


xppp =

    0.8757


xp =

   -0.2419


xpp =

   -0.7542


xppp =

    0.8834


xp =

   -0.2785


xpp =

   -0.7098


xppp =

    0.8948


xp =

   -0.3129


xpp =

   -0.6647


xppp =

    0.9081


xp =

   -0.3450


xpp =

   -0.6189


xppp =

    0.9217


xp =

   -0.3748


xpp =

   -0.5725


xppp =

    0.9339


xp =

   -0.4022


xpp =

   -0.5256


xppp =

    0.9435


xp =

   -0.4273


xpp =

   -0.4783


xppp =

    0.9491


xp =

   -0.4500


xpp =

   -0.4308


xppp =

    0.9499


xp =

   -0.4704


xpp =

   -0.3834


xppp =

    0.9451


xp =

   -0.4884


xpp =

   -0.3364


xppp =

    0.9341


xp =

   -0.5040


xpp =

   -0.2901


xppp =

    0.9167


xp =

   -0.5174


xpp =

   -0.2448


xppp =

    0.8927


xp =

   -0.5285


xpp =

   -0.2009


xppp =

    0.8625


xp =

   -0.5375


xpp =

   -0.1587


xppp =

    0.8262


xp =

   -0.5444


xpp =

   -0.1184


xppp =

    0.7845


xp =

   -0.5494


xpp =

   -0.0803


xppp =

    0.7381


xp =

   -0.5525


xpp =

   -0.0446


xppp =

    0.6877


xp =

   -0.5539


xpp =

   -0.0116


xppp =

    0.6343


xp =

   -0.5537


xpp =

    0.0188


xppp =

    0.5787


xp =

   -0.5521


xpp =

    0.0463


xppp =

    0.5219


xp =

   -0.5491


xpp =

    0.0710


xppp =

    0.4647


xp =

   -0.5450


xpp =

    0.0928


xppp =

    0.4081


xp =

   -0.5399


xpp =

    0.1118


xppp =

    0.3528


xp =

   -0.5339


xpp =

    0.1281


xppp =

    0.2995


xp =

   -0.5271


xpp =

    0.1418


xppp =

    0.2487


xp =

   -0.5198


xpp =

    0.1530


xppp =

    0.2009


xp =

   -0.5119


xpp =

    0.1619


xppp =

    0.1565


xp =

   -0.5036


xpp =

    0.1687


xppp =

    0.1157


xp =

   -0.4950


xpp =

    0.1736


xppp =

    0.0787


xp =

   -0.4863


xpp =

    0.1767


xppp =

    0.0455


xp =

   -0.4774


xpp =

    0.1782


xppp =

    0.0161


xp =

   -0.4685


xpp =

    0.1783


xppp =

   -0.0096


xp =

   -0.4596


xpp =

    0.1773


xppp =

   -0.0317


xp =

   -0.4508


xpp =

    0.1752


xppp =

   -0.0504


xp =

   -0.4421


xpp =

    0.1723


xppp =

   -0.0660


xp =

   -0.4336


xpp =

    0.1687


xppp =

   -0.0787


xp =

   -0.4252


xpp =

    0.1645


xppp =

   -0.0888


xp =

   -0.4171


xpp =

    0.1598


xppp =

   -0.0964


xp =

   -0.4093


xpp =

    0.1549


xppp =

   -0.1020


xp =

   -0.4016


xpp =

    0.1497


xppp =

   -0.1058


xp =

   -0.3943


xpp =

    0.1443


xppp =

   -0.1079


xp =

   -0.3872


xpp =

    0.1389


xppp =

   -0.1087


xp =

   -0.3804


xpp =

    0.1335


xppp =

   -0.1083


xp =

   -0.3739


xpp =

    0.1281


xppp =

   -0.1069


xp =

   -0.3676


xpp =

    0.1228


xppp =

   -0.1048


xp =

   -0.3616


xpp =

    0.1176


xppp =

   -0.1020


xp =

   -0.3558


xpp =

    0.1126


xppp =

   -0.0988


xp =

   -0.3503


xpp =

    0.1077


xppp =

   -0.0952


xp =

   -0.3451


xpp =

    0.1031


xppp =

   -0.0914


xp =

   -0.3400


xpp =

    0.0986


xppp =

   -0.0874


xp =

   -0.3352


xpp =

    0.0943


xppp =

   -0.0833


xp =

   -0.3306


xpp =

    0.0903


xppp =

   -0.0792


xp =

   -0.3262


xpp =

    0.0864


xppp =

   -0.0751


xp =

   -0.3219


xpp =

    0.0828


xppp =

   -0.0711


xp =

   -0.3179


xpp =

    0.0793


xppp =

   -0.0672


xp =

   -0.3140


xpp =

    0.0760


xppp =

   -0.0634


xp =

   -0.3103


xpp =

    0.0730


xppp =

   -0.0598


xp =

   -0.3067


xpp =

    0.0701


xppp =

   -0.0563


xp =

   -0.3033


xpp =

    0.0673


xppp =

   -0.0530


xp =

   -0.3000


xpp =

    0.0648


xppp =

   -0.0499


xp =

   -0.2968


xpp =

    0.0623


xppp =

   -0.0470


xp =

   -0.2937


xpp =

    0.0601


xppp =

   -0.0442


xp =

   -0.2908


xpp =

    0.0579


xppp =

   -0.0416


xp =

   -0.2879


xpp =

    0.0559


xppp =

   -0.0392


xp =

   -0.2852


xpp =

    0.0540


xppp =

   -0.0369


xp =

   -0.2825


xpp =

    0.0522


xppp =

   -0.0348


xp =

   -0.2800


xpp =

    0.0505


xppp =

   -0.0328


xp =

   -0.2775


xpp =

    0.0489


xppp =

   -0.0309


xp =

   -0.2751


xpp =

    0.0474


xppp =

   -0.0292


xp =

   -0.2727


xpp =

    0.0460


xppp =

   -0.0276

>> for i=2:81,
x(i) = taystep(t(i-1),x(i-1),0.05);
end;
>> plot(t,x)
>> t1 = 0:0.01:4;
>> x1 = zeros(size(t1));
>> size(t1)

ans =

     1   401

>> for i=2:401,
  x1(i) = taystep(t1(i-1),x1(i-1),0.01);
end;
>> figure(2)
>> plot(t1,x1)
>> x1(0) = -0.5;
???  Index into matrix is negative or zero.

>> x1(1) = -0.5;
>> for i=2:401,
x1(i) = taystep(t1(i-1),x1(i-1),0.01);
end;
>> plot(t1,x1)
>> opts = odeset('reltol',1.e-9,'abstol'=1.e-9);
??? opts = odeset('reltol',1.e-9,'abstol'=1.e-9);
                                         |
Error: ")" expected, "=" found.

>> opts = odeset('reltol',1.e-9,'abstol',1.e-9);
>> [tg,xg] = ode45('west',[0,4],-0.5,opts);
>> [tg,xg] = ode45('west',t,-0.5,opts);
>> size(tg)

ans =

    81     1

>> err = x - xg;
??? Error using ==> -
Matrix dimensions must agree.

>> size(xg)

ans =

    81     1

>> size(x)

ans =

     1    81

>> err = x - xg';
>> plot( t, err )
>> figure(3)
>> plot(t,err)
>> [tg1,xg1] = ode45('west',t1,-0.5,opts);
>> figure(4)
>> plot(t1,x1-xg1')
>> 2.5e-6/(20*1.e-9)

ans =

  125.0000

>> [tw,xw] = ode45('west',[0,4],-0.5);
>> size(xw)

ans =

    41     1

>> [tw,xw] = ode45('west',[0,4],-0.5,opts);
>> size(xw)

ans =

   329     1

>> h = xw(2:329) - xw(1:328);
>> semilogy( t(2:329), abs(h) )
???  Index exceeds matrix dimensions.

>> semilogy( tw(2:329), abs(h) )
>> figure(5)
>> 
>> semilogy( tw(2:329), abs(h) )
>> 