function u=svexmp3(T,XX,TT,N)
%diffusion equation with zero Neuman BC in (0,pi)
%initial condition = 1 for |x-pi/2|<1/10 and zero otherwise
x=linspace(0,pi,XX);
t=linspace(0,T,TT);
u=zeros(TT,XX);
%u(x,t)=(1/5*pi)+sum(2/(n*pi)*(sin(n*(pi/2+1/10))-sin(n*(pi/2-1/10)))*exp(-2*n^2*t(i))*cos(n*x)
for i=1:TT
    u(i,:)=u(i,:)+(1/(5*pi));
    for n=1:N
    u(i,:)=u(i,:)+(2/(n*pi))*(sin(n*(pi/2+1/10))-sin(n*(pi/2-1/10)))*exp(-2*n^2*t(i))*cos(n*x);
    end
end

figure(1)
subplot(6,1,1)
plot(x,u(1,:))
subplot(6,1,2)
plot(x,u(TT/5,:))
subplot(6,1,3)
plot(x,u(2*TT/5,:))
subplot(6,1,4)
plot(x,u(3*TT/5,:))
subplot(6,1,5)
plot(x,u(4*TT/5,:))
subplot(6,1,6)
plot(x,u(TT,:))