
%                    program heat2
%
%     This program computes the solution of the heat equation 
%   u_t - ku_xx = 0 on the half line x > 0  with either Dirichlet
%   condition at x = 0 ( u(0,t) = 0) or Neumann condition at x = 0
%   ( u_x(0,t) = 0 ). The initial data is a step function 
%   f(x) = 1 for 1 < x < 2 and zero elsewhere.  The solution is 
%   written in terms of the error function. The vector "dirch"
%   has the values of the Dirichlet solution, while "neumann"
%   has the values of the Neumann solution.
%       At run time the use must enter the time t of the snapshot,
%   snap1. The solutions of both problems are plotted together on 
%   0 < x < 10. 


t = input('Enter the value of t ')

x = 0:.05:10;

d = sqrt(4*t);

dirch = .5*(erf((2-x)/d) -erf((1-x)/d) - erf((2+x)/d) + erf((1+x)/d) );

neumann = .5*(erf((2-x)/d) -erf((1-x)/d) +erf((2+x)/d) -erf((1+x)/d) );
plot(x,dirch,x, neumann)

axis([0 10 0 1 ])

