>> help beam_warming

  [u,u_true,x,t] = beam_warming(t_0,t_f,M,N)
  
  solves the advection equation u_t + c u_x = 0 on [0,2 pi]
 
  For initial data cos(x), we assume periodic initial data.  For
  step-function initial, we assume u_x = 0 at the ends.

>> help lax_friedrichs

  [u,u_true,x,t] = lax_friedrichs(t_0,t_f,M,N)
  
  solves the advection equation u_t + c u_x = 0 on [0,2 pi]
 
  For initial data cos(x), we assume periodic initial data.  For
  step-function initial, we assume u_x = 0 at the ends.
 
>> help lax_wendroff

  [u,u_true,x,t] = lax_wendroff(t_0,t_f,M,N)
  
  solves the advection equation u_t + c u_x = 0 on [0,2 pi]
 
  For initial data cos(x), we assume periodic initial data.  For
  step-function initial, we assume u_x = 0 at the ends.


I want to check that all of my codes converge properly.  For example,
Lax-Wendroff should have an error that decreases like O(dt^2+dx^2).
But I have to be careful and take dt and dx to zero at the same rate.
(This came from the truncation error analysis.)  So I'll take dx/dt =
some fixed number and will then check to see if the error goes to zero
like dt^2.  Since this would then imply that it's O(dt^2 + dx^2) at
least.  (Note: it could be O(dt^2 + dx^3) and we would miss the extra
accuracy in dx.)

First compute six solutions:
>> [u1,u_true,x,t] = lax_wendroff(0,1,20,20);
>> [u2,u_true,x,t] = lax_wendroff(0,1,40,40);
>> [u3,u_true,x,t] = lax_wendroff(0,1,80,80);
>> [u4,u_true,x,t] = lax_wendroff(0,1,160,160);
>> [u5,u_true,x,t] = lax_wendroff(0,1,320,320);
>> [u6,u_true,x,t] = lax_wendroff(0,1,640,640);

Now check that their differences aren't at the level of round-off:  
>> (u1(1,21)-u2(1,41))
ans =
   3.1272e-03
>> (u2(1,41)-u3(1,81))
ans =
   7.6089e-04
>> (u3(1,81)-u4(1,161))
ans =
   1.8709e-04
>> (u4(1,161)-u5(1,321))
ans =
   4.6352e-05
>> (u5(1,321)-u6(1,641))
ans =
   1.1534e-05

Now check the ratios:
>> (u1(1,21)-u2(1,41))/(u2(1,41)-u3(1,81))
ans =
   4.1099e+00
>> (u2(1,41)-u3(1,81))/(u3(1,81)-u4(1,161)) 
ans =
   4.0671e+00
>> (u3(1,81)-u4(1,161))/(u4(1,161)-u5(1,321))  
ans =
   4.0362e+00
>> (u4(1,161)-u5(1,321))/(u5(1,321)-u6(1,641))
ans =
   4.0187e+00

Since the ratios are going to 4, this shows that my Lax-Wendroff code
is converging.  Since I know the exact solution, I should also check
that it's converging to the correct solution.  As opposed to just
converging.


>> [u1,u_true,x,t] = beam_warming(0,1,20,20);
>> [u2,u_true,x,t] = beam_warming(0,1,40,40);
>> [u3,u_true,x,t] = beam_warming(0,1,80,80);
>> [u4,u_true,x,t] = beam_warming(0,1,160,160);
>> [u5,u_true,x,t] = beam_warming(0,1,320,320);
>> [u6,u_true,x,t] = beam_warming(0,1,640,640);

>> (u1(1,21)-u2(1,41))
ans =
  -8.5900e-03
>> (u2(1,41)-u3(1,81))
ans =
  -1.7115e-03
>> (u3(1,81)-u4(1,161))
ans =
  -3.7604e-04
>> (u4(1,161)-u5(1,321))
ans =
  -8.7761e-05

>> (u1(1,21)-u2(1,41))/(u2(1,41)-u3(1,81))
ans =
   5.0191e+00
>> (u2(1,41)-u3(1,81))/(u3(1,81)-u4(1,161)) 
ans =
   4.5512e+00
>> (u3(1,81)-u4(1,161))/(u4(1,161)-u5(1,321))  
ans =
   4.2849e+00
>> (u4(1,161)-u5(1,321))/(u5(1,321)-u6(1,641))
ans =
   4.1446e+00

Since the ratios are going to 4, this shows that my Beam-warming code
is converging.  Since I know the exact solution, I should also check
that it's converging to the correct solution.  As opposed to just
converging.

>> [u1,u_true,x,t] = lax_friedrichs(0,1,20,20);
>> [u2,u_true,x,t] = lax_friedrichs(0,1,40,40);
>> [u3,u_true,x,t] = lax_friedrichs(0,1,80,80);
>> [u3,u_true,x,t] = lax_friedrichs(0,1,80,80);
>> [u4,u_true,x,t] = lax_friedrichs(0,1,160,160);
>> [u5,u_true,x,t] = lax_friedrichs(0,1,320,320);;
>> [u6,u_true,x,t] = lax_friedrichs(0,1,640,640);

>> (u1(1,21)-u2(1,41))/(u2(1,41)-u3(1,81))
ans =
   1.4616e+00
>> (u2(1,41)-u3(1,81))/(u3(1,81)-u4(1,161)) 
ans =
   1.7235e+00
>> (u3(1,81)-u4(1,161))/(u4(1,161)-u5(1,321))  
ans =
   1.8596e+00
>> (u4(1,161)-u5(1,321))/(u5(1,321)-u6(1,641))
ans =
   1.9292e+00

Since the ratios are going to 2, this shows that my Lax-Friedrichs
code is converging.  Since I know the exact solution, I should also
check that it's converging to the correct solution.  As opposed to
just converging.
