Solutions to Heat Equation

Dirichlet Boundary Conditions

Here we present the solution to the heat equation on a rod of length l with Dirchlet Boundary Condtions. We consider a quadratic function as initial data: f(x)=x(l-x).

Calculation of (Subscript[b, n]):

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

Fourier series approximation:

f[x_,t_,m_,l_]:=Sum[-((4 (-1+(((-1))^n)) (l^2))/((n^3) (π^3)))*Exp[-n^2*π^2/l^2*t]*Sin[n*π*x/l],{n,1,m}];

Plot of the time varying solution for three different Fourier modes. Here L is the length and M1, M2, M3 are the number of Fourier modes to take. What we should notice is that the higher order Fourier modes contribute little for larger values of t.

L=3;
M1=1;
M2=2;
M3=5;
Animate[Plot[{f[x,t,M1,L],f[x,t,M2,L],f[x,t,M3,L]},{x,0,L},PlotRange->{0,(L/2)^2+1}],{t,0,1}]

Neumann Boundary Conditions

Here we present the solution to the heat equation on a rod of length l with Neumann. We consider a quartic function as initial data: f(x)=x^2(l-x)^2.

Calculation of (Subscript[a, 0]):

Simplify[2/l*Integrate[x^2*(l-x)^2,{x,0,l}],Assumptions->n∈Integers]

Calculation of (Subscript[a, n]):

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

Fourier series approximation:

g[x_,t_,m_,l_]:=((l^4)/30)+Sum[-((24 (1+(((-1))^n)) (l^4))/((n^4) (π^4)))*Exp[-n^2*π^2/l^2*t]*Cos[n*π*x/l],{n,1,m}];

Plot of the time varying solution for three different Fourier modes. Here L is the length and M1, M2, M3 are the number of Fourier modes to take. What we should notice is that the higher order Fourier modes contribute little for larger values of t.

L=3;
M1=1;
M2=2;
M3=10;
Animate[Plot[{g[x,t,M1,L],g[x,t,M2,L],g[x,t,M3,L]},{x,0,L},PlotRange->{0,(L/2)^4+1}],{t,0,1}]