function solution = pdesol

%data

nx = 10^6;      %number spatial gridpoints
steps = 5;      %number of timesteps
T = 100;          %stopping time
L = 10;         %length of spatial grid
dx = L/nx;      %length of subinterval in x grid
dt = T/steps;   %length of time step interval


%initialize

w(1:nx+1) = log((1-dx) + ((1:nx+1)*dx));
u(1:nx+1) = 0;

figure;
subplot(steps+1,1, 1), plot(w(1:nx), 'r'), title('u_0(x)');

%main

for i = 1:steps
    u(1) = 0;
    u(nx+1) = log(1 + L) + 0.5*(i*dt);
    for j = 2:nx
        wxf = w(j+1) - w(j);
        wxb = w(j) - w(j-1);
        wxx = w(j+1) - 2*w(j) - w(j-1);
        u(j) = w(j) - 0.5*dt*( (0.5*wxf*wxf + 0.5*wxb*wxb)/wxx);
    end
        subplot(steps+1, 1, i+1), plot(u(1:50),'b'), title('u(x)');
    w(1:nx+1) = u(1:nx+1);
    u(1:nx+1) = 0;

end
    %alpha(2:nx) = -1*(u(2:nx) - u(1:nx-1))/(u(3:nx+1) - 2*u(2:nx) - u(1:nx-1));
    %subplot(steps+2, 1, steps+2), plot(alpha(2:nx), 'b'), title('alpha(x)');
