function w = U(x,t,n) w = 0; for m=1:n w = w+(-1)^(m+1)*80/(m*pi)*exp(-m^2*pi^2*t/40^2).*sin(m*pi*x/40); end