Separation of Variables
Separation of Variables
For Laplace’s equation on the square
A semi-general problem
A semi-general problem
Suppose we wish to solve Laplace’s equation on the unit square subject to , , , and . Setting and separating variables, we get two ordinary ODEs
Δu=0
u(0,y)=0
u(1,y)=0
u(x,0)=f(x)
u(x,1)=g(x)
u(x,y)=X(x)Y(y)
″
X
and
″
Y
The equation is familiar and has eigenvalues = with corresponding eigenfunctions (x)=sin(nπx).
x
λ
n
2
n
2
π
X
n
The equation then becomes =Y, which has general solution . The solution to the problem thus has the form
y
″
Y
2
n
2
π
Y(y)=+
c
n
-nπy
d
n
nπy
u(x,y)=(+)sin(nπx).
∞
∑
n=1
c
n
-nπy
d
n
nπy
Any function of this form is guaranteed to satisfy Laplace’s equation together with the zero boundary conditions on the left and right side. To satisfy the remaining boundary conditions, we need to choose and such that
c
n
d
n
u(x,0)=(+)sin(nπx)=f(x)
∞
∑
n=1
c
n
d
n
and
u(x,1)=(+)sin(nπx)=g(x).
∞
∑
n=1
c
n
-nπ
d
n
nπ
Put another way, + must be the Fourier sine coefficients of and + must be the Fourier sine coefficients of . If we let denote the Fourier sine coefficients of and we let denote the Fourier sine coefficients of , this leads to the following linear system.
c
n
d
n
f
c
n
-nπ
d
n
nπ
g
a
n
f
b
n
g
In[]:=
Clear[a,b,c,d];Solve[{+,+},{,}]
c
n
d
n
a
n
c
n
-nπ
d
n
nπ
b
n
c
n
d
n
Out[]=
(-),
c
n
nπ
nπ
a
n
b
n
-1+
2nπ
d
n
-+
a
n
nπ
b
n
-1+
2nπ
Example
Example
Let’s try to illustrate the solution for the specific case and .
f(x)=
3
x(1-x)
g(x)=(1-x)
3
x
In[]:=
f[x_]=4x;g[x_]=4(1-x);Plot[{f[x],g[x]},{x,0,1}]
3
(1-x)
3
x
Out[]=
Here are the Fourier coefficients.
In[]:=
$Assumptions={Element[n,Integers],n>0};a[n_]=2f[x]*Sin[n*Pi*x]xb[n_]=2g[x]*Sin[n*Pi*x]x
1
∫
0
1
∫
0
Out[]=
48(-4+4+)
n
(-1)
2
n
2
π
5
n
5
π
Out[]=
-
48(4-4+)
n
(-1)
n
(-1)
2
n
2
π
5
n
5
π
Thus, here are the s and s.
c
n
d
n
In[]:=
Clear[c,d];{c[n_],d[n_]}={c[n],d[n]}/.First[Solve[{c[n]+d[n]a[n],c[n]Exp[-n*Pi]+d[n]Exp[n*Pi]b[n]},{c[n],d[n]}]]
Out[]=
-192+192+48-(192-192-192+192-48-48),(192-192-192+192-48-48)(-+)
1
5
n
5
π
n
(-1)
2
n
2
π
1
-+
5
n
5
π
2nπ
5
n
5
π
5
n
5
π
n
(-1)
nπ
n
(-1)
nπ
2
n
2
π
n
(-1)
nπ
2
n
2
π
n
(-1)
nπ
n
(-1)
nπ
2
n
2
π
n
(-1)
nπ
2
n
2
π
5
n
5
π
2nπ
5
n
5
π
With those coefficients in hand, we can define a high-order approximation to the solution.
In[]:=
u[x_,y_]=(c[n]Exp[-n*Pi*y]+d[n]Exp[n*Pi*y])Sin[n*Pi*x];
50
∑
n=1
OK, let’s check it out.
In[]:=
Plot3D[u[x,y],{x,0,1},{y,0,1},WorkingPrecision20,BoundaryStyleThick,ColorFunction"TemperatureMap",PlotPoints50,MeshFunctions{#3&}]
Out[]=