This notebook presents an example of the heat equation with mixed boundary conditions. This example was worked on in the classroom of the postgraduate mathematics program of the Hellenic Open University, in which I am a student.
Expansion of the function with respect to the eigenfunctions of the Sturm-Liouville problem
f(x)2x-1
′′
X
′
X
In[]:=
Clear["Global`*"]
In[]:=
FPS[x_,N_]:=FullSimplifyc[n]*X[n,x]
N
∑
n=1
In[]:=
X[n_,x_]=Cos
1
2
(2n-1)*Pi*x
8
Out[]=
Cos(-1+2n)πx
1
8
2
In[]:=
f[x_]=2*x-1
Out[]=
-1+2x
Notice that the function does not satisfy the boundary conditions of the problem
In[]:=
c[n_]=Simplifyf[x]*X[n,x]x,n∈Integers
4
∫
0
Out[]=
-
4(-1+2n)π)
2
(16+7n
(-1)
2
(π-2nπ)
We are testing an expansion of 20 terms
In[]:=
FS[x_]=FPS[x,20];
In[]:=
pFS=Plot[FS[x],{x,0,4},PlotStyle{Red,Thick,Dashed},PlotRangeAll]
Out[]=
In[]:=
s=Plot[f[x],{x,0,4},PlotRangeAll]
Out[]=
In[]:=
Show[pFS,s]
Out[]=
Now, we are going to solve the Heat-equation using the above mixed boundary conditions
In[]:=
Clear["Global`*"]
We define the eigenvalues
In[]:=
λ[n_]=^2
(2*n-1)*π
8
Out[]=
1
64
2
(-1+2n)
2
π
We define the eigenfunctions
In[]:=
X[n_,x_]=Cos
(2n-1)*Pi*x
8
Out[]=
Cos(-1+2n)πx
1
8
Norms of Eigenfunctions
In[]:=
Norma[n_]=SimplifySqrtX[n,x]^2x,n∈Integers
4
∫
0
Out[]=
2
Normalized eigenfunctions
In[]:=
Y[n_,x_]=X[n,x]/Norma[n]
Out[]=
Cos(-1+2n)πx
1
8
2
In[]:=
NY[12,x]*Y[12,x]x
4
∫
0
Out[]=
1.
Fourier series coefficients
In[]:=
a[n_]=Simplifyf[x]*Y[n,x]x,n∈Integers
4
∫
0
Out[]=
4
∫
0
Cos(-1+2n)πxf[x]
1
8
2
Partial Fourier series sum for the solution of the heat equation
In[]:=
U[x_,t_,N_]:=a[n]*Exp[-λ[n]*t]*Y[n,x]
N
∑
n=1
Now we define the initial condition
In[]:=
f[x_]=Cos[Pi*x/8]^4
Out[]=
4
Cos
πx
8
Partial sum of solution series for a finite number of terms
In[]:=
u[x_,t_]=U[x,t,10]
Out[]=
32Cos
-t
2
π
64
πx
8
15π
32Cos
-
9t
2
π
64
3πx
8
35π
32Cos
-
25t
2
π
64
5πx
8
315π
32Cos
-
49t
2
π
64
7πx
8
3465π
32Cos
-
81t
2
π
64
9πx
8
15015π
32Cos
-
121t
2
π
64
11πx
8
45045π
32Cos
-
169t
2
π
64
13πx
8
109395π
32Cos
-
225t
2
π
64
15πx
8
230945π
32Cos
-
289t
2
π
64
17πx
8
440895π
32Cos
-
361t
2
π
64
19πx
8
780045π
Now we are going to create the graphs and we will compare them with the numerical solution
In[]:=
fig1=Plot3D[u[x,t],{t,0,30},{x,0,4},PlotRangeAll,ColorFunction"BlueGreenYellow"]
Out[]=
In[]:=
solution=V/.First[NDSolve[V[x,t]V[x,t],V[x,0]f[x],K[0,t]0,V[4,t]0,{V},{t,0,30},{x,0,4},MaxStepSize10000,MaxSteps10000]]
∂
t
∂
{x,2}
Out[]=
InterpolatingFunction
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
Heat equation problem with mixed boundary conditions
by Athanasios Paraskevopoulos
Wolfram Community, STAFF PICKS, June 27, 2023
https://community.wolfram.com/groups/-/m/t/2943996
by Athanasios Paraskevopoulos
Wolfram Community, STAFF PICKS, June 27, 2023
https://community.wolfram.com/groups/-/m/t/2943996
