Problem III

Compute the Fourier coefficients for the initial condition on the worksheet.

Simplify[(1/π)Integrate[x*Sin[n*x],{x,-π,π}],Assumptions->n∈Integers]

b[n_]:=-((2 (((-1))^n))/n)

Plot3D[Sum[b[n]*Sin[n *x]Exp[-(n^2)*t],{n,1,20}],{x,-π,π},{t,0,2},AxesLabel->Automatic]

Manipulate[
Plot[Sum[b[n]*Sin[n *x]Exp[-(n^2)*t],{n,1,20}],{x,-π,π},PlotRange->{-3,3},AxesLabel->Automatic]//Quiet,
{t,0,2}]

Inhomogeneous Boundary Conditions, Problem 2

Integrate to find the Fourier coefficients:

Simplify[2Integrate[((1/2)-x)Cos[n π x],{x,0,1}],Assumptions->n∈Integers]

a[n_]:=-((2 (-1+(((-1))^n)))/((n^2) (π^2)))

Plot the solution:

Manipulate[
Plot[x+(1/2)+Sum[a[n]Cos[n π x]Exp[((-1)/2)(n^2) (π^2) t],{n,1,10}],{x,0,1},PlotRange->{0,2},AxesLabel->Automatic]//Quiet,
{t,0,2}]

Plot[
Table[x+(1/2)+Sum[a[n]Cos[n π x]Exp[((-1)/2)(n^2) (π^2) t],{n,1,30}],{t,{0,0.05,0.1,0.2,0.5}}]
,{x,0,1},PlotRange->{0.4,1.6},AxesLabel->Automatic]//Quiet