Dirichlet boundary conditions

Heat sources Exp[-t]

(2/Pi)Integrate[Sin[((n Pi)/Pi)x],{x,0,Pi}]

Plot[{Sign[x],Sum[(4/((2 k -1)Pi))Sin[(((2 k -1 ) Pi)/Pi)x],{k,1,20}]},{x,-Pi,Pi}]

FullSimplify[DSolve[{y'[t]+(1^2) y[t]==((4 Exp[-t])/(1 Pi)),y[0]==0},y[t],t]]

FullSimplify[DSolve[{y'[t]+(n^2) y[t]==((4 Exp[-t])/(n Pi)),y[0]==0},y[t],t]]

(-((4 (E^(-t))-4 (E^(-(n^2) t)))/(n π-(n^3) π)))/.{n->2k-1}

Sum[-((4 (E^(-t))-4 (E^(-(((-1+2 k))^2) t)))/((-1+2 k) π-(((-1+2 k))^3) π))Sin[((2k-1 )/1)x],{k,2,10}]

Plot3D[((4 (E^(-t)) t)/π)Sin[x]+Sum[-((4 (E^(-t))-4 (E^(-(((-1+2 k))^2) t)))/((-1+2 k) π-(((-1+2 k))^3) π))Sin[((2k-1 )/1)x],{k,2,20}],{x,0,Pi},{t,0,6},PlotPoints->{100,100} ,Mesh->False]

FullSimplify[DSolve[{y'[t]+1 y[t]==((4 t Exp[-t])/(1 Pi)),y[0]==0},y[t],t]]

FullSimplify[DSolve[{y'[t]+(n^2) y[t]==((4 t Exp[-t])/(n Pi)),y[0]==0},y[t],t]]

((((E^(-(n^2) t)) (4+4 (E^((-1+(n^2)) t)) (-1+(-1+(n^2)) t)))/(n (((-1+(n^2)))^2) π)))/.{n->2 k -1}

Plot3D[((2 (E^(-t)) (t^2))/π)Sin[x]+Sum[(((E^(-(((-1+2 k))^2) t)) (4+4 (E^((-1+(((-1+2 k))^2)) t)) (-1+(-1+(((-1+2 k))^2)) t)))/((-1+2 k) (((-1+(((-1+2 k))^2)))^2) π))Sin[((2k-1 )/1)x],{k,2,20}],{x,0,Pi},{t,0,6},PlotPoints->{100,100} ,Mesh->False]

Heat sources Exp[-t] Sin[x]

FullSimplify[DSolve[{y'[t]+(1^2) y[t]==Exp[-t],y[0]==0},y[t],t]]

FullSimplify[DSolve[{y'[t]+(n^2) y[t]==0,y[0]==0},y[t],t]]

Plot3D[(E^(-t)) tSin[x],{x,0,Pi},{t,0,6},PlotPoints->{100,100} ,Mesh->False]

Neuman boundary conditions

Heat sources Exp[-t]

TrigToExp[FullSimplify[DSolve[{y'[t]+(0^2) y[t]==Exp[-t],y[0]==0},y[t],t]]]

FullSimplify[DSolve[{y'[t]+(n^2) y[t]==0,y[0]==0},y[t],t]]

Plot3D[1- (E^(-t)),{x,0,Pi},{t,0,6},PlotPoints->{100,100} ,Mesh->False]

Heat sources Exp[-t] Sin[x]

We first need to expend Sin[x] into a cosine series.

(1/Pi)Integrate[Sin[x] ,{x,0,Pi}]

(2/Pi)Integrate[Sin[x] Cos[x] ,{x,0,Pi}]

(2/Pi)Integrate[Sin[x] Cos[k x] ,{x,0,Pi}]

For k even

((4 )/((1-4(k^2)) π))

So

Plot[{Exp[0] Sin[x],(2/Pi)+(4/Pi)Sum[(1/((1-4(k^2))))Cos[2 k x],{k,1,20}] },{x,0,Pi}]

FullSimplify[DSolve[{y'[t]+(((0))^2) y[t]==(2/Pi)Exp[-t],y[0]==0},y[t],t]]

Simplify[Expand[y[t]/.DSolve[{y'[t]+(((n))^2) y[t]==Exp[-t],y[0]==0},y[t],t]],n>0]

FullSimplify[DSolve[{y'[t]+(((2k-1))^2) y[t]==0,y[0]==0},y[t],t]]

FullSimplify[DSolve[{y'[t]+(((2k))^2) y[t]==(4/((1-4(k^2))Pi))Exp[-t],y[0]==0},y[t],t]]

Plot3D[((2-2 (E^(-t)))/π)+(4/Pi)Sum[-((4 (E^(-4 (k^2) t)) (-1+(E^((-1+4 (k^2)) t))))/((((1-4 (k^2)))^2) π))Cos[2 k x],{k,1,10}],{x,0,Pi},{t,0,6},PlotPoints->{100,100} ,Mesh->False]

Manipulate[Plot[((2-2 (E^(-t)))/π)+(4/Pi)Sum[-((4 (E^(-4 (k^2) t)) (-1+(E^((-1+4 (k^2)) t))))/((((1-4 (k^2)))^2) π))Cos[2 k x],{k,1,10}],{x,0,Pi},PlotRange->{0,.7}],{t,0,6}]

Integrate[Integrate[Exp[-t] Sin[x],{x,0,Pi}],{t,0,Infinity}]/Pi

N[%]

Simplify[Expand[((4 (E^(-4 (k^2) t)) (-1+(E^((-1+4 (k^2)) t))))/((((1-4 (k^2)))^2) π))]]