solved by Luca Imponenti
Consider the L2-ODE-CC (5) p.7b-7 with the window function f(x) p.9-8 as excitation:
y
″
−
3
y
′
+
2
y
=
f
(
x
)
{\displaystyle y''-3y'+2y=f(x)\!}
and the initial conditions
y
(
0
)
=
1
,
y
′
(
0
)
=
0
{\displaystyle y(0)=1\ ,\ y'(0)=0\!}
1. Find
y
n
(
x
)
{\displaystyle y_{n}(x)\!}
such that:
y
n
″
+
a
y
n
′
+
b
y
n
=
r
n
(
x
)
{\displaystyle y_{n}''+ay_{n}'+by_{n}=r_{n}(x)\!}
with the same initial conditions as above.
Plot
y
n
(
x
)
{\displaystyle y_{n}(x)\!}
for
n
=
2
,
4
,
8
{\displaystyle n=2,4,8\!}
for x in
[
0
,
10
]
{\displaystyle [0,10]\!}
2. Use the matlab command ode45 to integrate the L2-ODE-CC, and plot the numerical solution to compare with the analytical solution.
Level 1:
n
=
0
,
1
{\displaystyle n=0,1\!}
One period of the window function p9.8 is described as follows
f
(
x
)
=
{
0
−
1.75
<
x
<
l
0.25
A
0.25
<
x
<
2.25
{\displaystyle f(x)={\begin{cases}0&\ \ -1.75<x<l0.25\\A&\ \ 0.25<x<2.25\\\end{cases}}}
From the above intervals one can see that the period,
p
=
4
{\displaystyle p=4\!}
and therefore
L
=
2
{\displaystyle L=2\!}
Applying the Euler formulas from
−
1.75
{\displaystyle -1.75}
to
2.25
{\displaystyle 2.25\!}
the Fourier coefficients are computed:
a
0
=
1
2
L
∫
−
1.75
2.25
f
(
x
)
d
x
{\displaystyle a_{0}={\frac {1}{2L}}\int _{-1.75}^{2.25}f(x)\ dx\!}
a
0
=
1
4
(
∫
−
1.75
0.25
0
d
x
+
∫
0.25
2.25
A
d
x
)
{\displaystyle a_{0}={\frac {1}{4}}(\int _{-1.75}^{0.25}0\ dx+\int _{0.25}^{2.25}A\ dx)\!}
a
0
=
+
1
4
(
0
+
∫
0.25
2.25
A
d
x
)
{\displaystyle a_{0}=+{\frac {1}{4}}(0+\int _{0.25}^{2.25}A\ dx)\!}
a
0
=
1
4
(
2.25
A
−
0.25
A
)
{\displaystyle a_{0}={\frac {1}{4}}(2.25A-0.25A)\!}
a
0
=
A
2
{\displaystyle a_{0}={\frac {A}{2}}\!}
The integral from
−
1.75
{\displaystyle -1.75\!}
to
0.25
{\displaystyle 0.25\!}
can be omitted from this point on since it is always zero.
a
n
=
1
L
∫
0.25
2.25
f
(
x
)
c
o
s
(
n
π
x
L
)
d
x
{\displaystyle a_{n}={\frac {1}{L}}\int _{0.25}^{2.25}f(x)cos({\frac {n\pi x}{L}})\ dx\!}
a
n
=
1
2
∫
0.25
2.25
A
c
o
s
(
n
π
x
2
)
d
x
{\displaystyle a_{n}={\frac {1}{2}}\int _{0.25}^{2.25}Acos({\frac {n\pi x}{2}})\ dx\!}
a
n
=
2
A
2
n
π
(
s
i
n
(
2.25
n
π
2
)
−
s
i
n
(
0.25
n
π
2
)
{\displaystyle a_{n}={\frac {2A}{2n\pi }}(sin({\frac {2.25n\pi }{2}})-sin({\frac {0.25n\pi }{2}})\!}
a
n
=
A
n
π
(
s
i
n
(
9
n
π
8
)
−
s
i
n
(
n
π
8
)
{\displaystyle a_{n}={\frac {A}{n\pi }}(sin({\frac {9n\pi }{8}})-sin({\frac {n\pi }{8}})\!}
and
b
n
=
1
L
∫
0.25
2.25
f
(
x
)
s
i
n
(
n
π
x
L
)
d
x
{\displaystyle b_{n}={\frac {1}{L}}\int _{0.25}^{2.25}f(x)sin({\frac {n\pi x}{L}})\ dx\!}
b
n
=
1
2
∫
0.25
2.25
A
s
i
n
(
n
π
x
2
)
d
x
{\displaystyle b_{n}={\frac {1}{2}}\int _{0.25}^{2.25}Asin({\frac {n\pi x}{2}})\ dx\!}
b
n
=
2
A
2
n
π
(
c
o
s
(
2.25
n
π
2
)
−
c
o
s
(
0.25
n
π
2
)
{\displaystyle b_{n}={\frac {2A}{2n\pi }}(cos({\frac {2.25n\pi }{2}})-cos({\frac {0.25n\pi }{2}})\!}
b
n
=
A
n
π
(
A
c
o
s
(
n
π
8
)
−
A
c
o
s
(
9
n
π
8
)
{\displaystyle b_{n}={\frac {A}{n\pi }}(Acos({\frac {n\pi }{8}})-Acos({\frac {9n\pi }{8}})\!}
The coefficients give the Fourier series:
f
(
x
)
=
a
0
+
∑
n
=
1
∞
[
a
n
c
o
s
(
n
π
x
L
)
+
b
n
s
i
n
(
n
π
x
L
)
]
{\displaystyle f(x)=a_{0}+\sum _{n=1}^{\infty }[a_{n}cos({\frac {n\pi x}{L}})+b_{n}sin({\frac {n\pi x}{L}})]\!}
f
(
x
)
=
A
2
+
∑
n
=
1
∞
[
A
n
π
(
s
i
n
(
9
n
π
8
)
−
s
i
n
(
n
π
8
)
)
c
o
s
(
n
π
x
2
)
{\displaystyle f(x)={\frac {A}{2}}+\sum _{n=1}^{\infty }[{\frac {A}{n\pi }}(sin({\frac {9n\pi }{8}})-sin({\frac {n\pi }{8}}))cos({\frac {n\pi x}{2}})\!}
+
A
n
π
(
c
o
s
(
n
π
8
)
−
c
o
s
(
9
n
π
8
)
)
s
i
n
(
n
π
x
2
)
]
{\displaystyle +{\frac {A}{n\pi }}(cos({\frac {n\pi }{8}})-cos({\frac {9n\pi }{8}}))sin({\frac {n\pi x}{2}})]\!}
Homogeneous Solution
edit
Considering the homogeneous case of our ODE:
y
″
−
3
y
′
+
2
y
=
0
{\displaystyle y''-3y'+2y=0\!}
The characteristic equation is
λ
2
−
3
λ
+
2
=
0
{\displaystyle \lambda ^{2}-3\lambda +2=0\!}
(
λ
−
1
)
(
λ
−
2
)
=
0
{\displaystyle (\lambda -1)(\lambda -2)=0\!}
λ
1
=
1
,
λ
1
=
2
{\displaystyle \lambda _{1}=1,\lambda _{1}=2\!}
Therefore our homogeneous solution is of the form
y
h
=
c
1
e
x
+
c
2
e
2
x
{\displaystyle y_{h}=c_{1}e^{x}+c_{2}e^{2x}\!}
Considering the case with f(x) as excitation
y
″
−
3
y
′
+
2
y
=
A
2
+
∑
k
=
1
n
A
k
π
[
(
s
i
n
(
9
k
π
8
)
−
s
i
n
(
k
π
8
)
)
c
o
s
(
k
π
x
2
)
{\displaystyle y''-3y'+2y={\frac {A}{2}}+\sum _{k=1}^{n}{\frac {A}{k\pi }}[(sin({\frac {9k\pi }{8}})-sin({\frac {k\pi }{8}}))cos({\frac {k\pi x}{2}})\!}
+
(
c
o
s
(
k
π
8
)
−
c
o
s
(
9
k
π
8
)
)
s
i
n
(
k
π
x
2
)
]
{\displaystyle +(cos({\frac {k\pi }{8}})-cos({\frac {9k\pi }{8}}))sin({\frac {k\pi x}{2}})]\!}
The solution will be of the form
y
n
=
A
0
+
∑
k
=
1
n
A
k
c
o
s
(
k
π
x
2
)
+
∑
k
=
1
n
B
k
s
i
n
(
k
π
x
2
)
{\displaystyle y_{n}=A_{0}+\sum _{k=1}^{n}A_{k}cos({\frac {k\pi x}{2}})+\sum _{k=1}^{n}B_{k}sin({\frac {k\pi x}{2}})\!}
Taking the derivatives
y
n
′
=
−
A
n
π
2
∑
k
=
2
n
k
s
i
n
(
k
π
x
2
)
+
B
n
π
2
∑
k
=
2
n
k
c
o
s
(
k
π
x
2
)
{\displaystyle y_{n}'=-A_{n}{\frac {\pi }{2}}\sum _{k=2}^{n}ksin({\frac {k\pi x}{2}})+B_{n}{\frac {\pi }{2}}\sum _{k=2}^{n}kcos({\frac {k\pi x}{2}})\!}
y
n
″
=
−
A
n
π
2
4
∑
k
=
3
n
k
2
c
o
s
(
k
π
x
2
)
−
B
n
π
2
4
∑
k
=
3
n
k
2
s
i
n
(
k
π
x
2
)
{\displaystyle y_{n}''=-A_{n}{\frac {\pi ^{2}}{4}}\sum _{k=3}^{n}k^{2}cos({\frac {k\pi x}{2}})-B_{n}{\frac {\pi ^{2}}{4}}\sum _{k=3}^{n}k^{2}sin({\frac {k\pi x}{2}})\!}
Plugging these back into the ODE:
−
π
2
4
∑
k
=
3
n
A
k
k
2
c
o
s
(
k
π
x
2
)
−
π
2
4
∑
k
=
3
n
B
k
k
2
s
i
n
(
k
π
x
2
)
−
3
[
−
π
2
∑
k
=
2
n
A
k
k
s
i
n
(
k
π
x
2
)
{\displaystyle -{\frac {\pi ^{2}}{4}}\sum _{k=3}^{n}A_{k}k^{2}cos({\frac {k\pi x}{2}})-{\frac {\pi ^{2}}{4}}\sum _{k=3}^{n}B_{k}k^{2}sin({\frac {k\pi x}{2}})-3[-{\frac {\pi }{2}}\sum _{k=2}^{n}A_{k}ksin({\frac {k\pi x}{2}})\!}
+
π
2
∑
k
=
2
n
B
k
k
c
o
s
(
k
π
x
2
)
]
+
2
[
A
0
+
∑
k
=
1
n
A
k
c
o
s
(
k
π
x
2
)
+
∑
k
=
1
n
B
k
s
i
n
(
k
π
x
2
)
]
{\displaystyle +{\frac {\pi }{2}}\sum _{k=2}^{n}B_{k}kcos({\frac {k\pi x}{2}})]+2[A_{0}+\sum _{k=1}^{n}A_{k}cos({\frac {k\pi x}{2}})+\sum _{k=1}^{n}B_{k}sin({\frac {k\pi x}{2}})]\!}
=
A
2
+
∑
k
=
1
n
A
k
π
[
(
s
i
n
(
9
k
π
8
)
−
s
i
n
(
k
π
8
)
)
c
o
s
(
k
π
x
2
)
+
(
c
o
s
(
k
π
8
)
−
c
o
s
(
9
k
π
8
)
)
s
i
n
(
k
π
x
2
)
]
{\displaystyle ={\frac {A}{2}}+\sum _{k=1}^{n}{\frac {A}{k\pi }}[(sin({\frac {9k\pi }{8}})-sin({\frac {k\pi }{8}}))cos({\frac {k\pi x}{2}})+(cos({\frac {k\pi }{8}})-cos({\frac {9k\pi }{8}}))sin({\frac {k\pi x}{2}})]\!}
Setting the two constants equal
2
A
0
=
A
2
{\displaystyle 2A_{0}={\frac {A}{2}}\!}
A
0
=
A
4
{\displaystyle A_{0}={\frac {A}{4}}\!}
This is valid for all values of n. Since the coefficients of the excitation
s
i
n
(
9
k
π
8
)
−
s
i
n
(
k
π
8
)
{\displaystyle sin({\frac {9k\pi }{8}})-sin({\frac {k\pi }{8}})\!}
and
c
o
s
(
k
π
8
)
−
c
o
s
(
9
k
π
8
)
{\displaystyle cos({\frac {k\pi }{8}})-cos({\frac {9k\pi }{8}})\!}
are zero for all even n, then the coefficients
A
k
{\displaystyle A_{k}\!}
and
B
k
{\displaystyle B_{k}\!}
will also be zero, so we must only find these coefficients for odd n's.
Now carrying out the sum to
n
=
1
{\displaystyle n=1\!}
and comparing like terms yields the following sets of equations. Written in matrix form:
[
2
0
0
2
]
∗
[
A
1
B
1
]
=
[
A
π
(
s
i
n
(
9
π
8
)
−
s
i
n
(
π
8
)
)
A
π
(
c
o
s
(
π
8
)
−
c
o
s
(
9
π
8
)
)
]
{\displaystyle {\begin{bmatrix}2&0\\\\0&2\end{bmatrix}}*{\begin{bmatrix}A_{1}\\B_{1}\end{bmatrix}}={\begin{bmatrix}\ {\frac {A}{\pi }}(sin({\frac {9\pi }{8}})-sin({\frac {\pi }{8}}))\\\ {\frac {A}{\pi }}(cos({\frac {\pi }{8}})-cos({\frac {9\pi }{8}}))\end{bmatrix}}\!}
Assuming
A
=
1
{\displaystyle A=1\!}
this matrix can be solved to obtain
A
1
=
−
0.1218
,
B
1
=
0.2941
{\displaystyle A_{1}=-0.1218\ ,\ B_{1}=0.2941\!}
For the remaining coefficients to be solved all sums will be used so a more general equation may be written:
[
2
−
(
π
k
)
2
4
−
3
π
k
2
−
3
π
k
2
2
−
(
π
k
)
2
4
]
∗
[
A
k
B
k
]
=
[
A
π
k
(
s
i
n
(
9
π
k
8
)
−
s
i
n
(
π
k
8
)
)
A
π
k
(
c
o
s
(
π
k
8
)
−
c
o
s
(
9
π
8
)
)
]
{\displaystyle {\begin{bmatrix}2-{\frac {(\pi k)^{2}}{4}}&{\frac {-3\pi k}{2}}\\{\frac {-3\pi k}{2}}&2-{\frac {(\pi k)^{2}}{4}}\end{bmatrix}}*{\begin{bmatrix}A_{k}\\B_{k}\end{bmatrix}}={\begin{bmatrix}\ {\frac {A}{\pi k}}(sin({\frac {9\pi k}{8}})-sin({\frac {\pi k}{8}}))\\\ {\frac {A}{\pi k}}(cos({\frac {\pi k}{8}})-cos({\frac {9\pi }{8}}))\end{bmatrix}}\!}
Results of these calculations are shown below:
A
=
[
A
1
A
2
.
.
A
7
A
8
]
=
[
−
0.1218
0
0.0084
0
0.0014
0
0.0001
0
]
,
B
=
[
B
1
B
2
.
.
B
7
B
8
]
=
[
0.2941
0
0.0019
0
0.0014
0
0.0007
0
]
{\displaystyle A={\begin{bmatrix}A_{1}\\A_{2}\\.\\.\\A_{7}\\A_{8}\end{bmatrix}}={\begin{bmatrix}-0.1218\\0\\0.0084\\0\\0.0014\\0\\0.0001\\0\end{bmatrix}},\ B={\begin{bmatrix}B_{1}\\B_{2}\\.\\.\\B_{7}\\B_{8}\end{bmatrix}}={\begin{bmatrix}0.2941\\0\\0.0019\\0\\0.0014\\0\\0.0007\\0\end{bmatrix}}\!}
The solution to the particular case can be written for all n (assuming A=1):
y
n
=
1
4
+
∑
k
=
1
n
A
k
c
o
s
(
k
π
x
2
)
+
∑
k
=
1
n
B
k
s
i
n
(
k
π
x
2
)
{\displaystyle y_{n}={\frac {1}{4}}+\sum _{k=1}^{n}A_{k}cos({\frac {k\pi x}{2}})+\sum _{k=1}^{n}B_{k}sin({\frac {k\pi x}{2}})\!}
The general solution is
y
=
y
h
+
y
p
{\displaystyle y=y_{h}+y_{p}\!}
where
y
h
=
c
1
e
x
+
c
2
e
2
x
{\displaystyle y_{h}=c_{1}e^{x}+c_{2}e^{2x}\!}
Different coefficients
c
1
,
c
2
{\displaystyle c_{1}\ ,\ c_{2}\!}
will be calculated for each n. These coefficients are easily solved for by applying the given initial conditions. Below are the calculations for n=2.
y
=
c
1
e
x
+
c
2
e
2
x
+
1
4
+
∑
k
=
1
2
A
k
c
o
s
(
k
π
x
2
)
+
∑
k
=
1
2
B
k
s
i
n
(
k
π
x
2
)
{\displaystyle y=c_{1}e^{x}+c_{2}e^{2x}+{\frac {1}{4}}+\sum _{k=1}^{2}A_{k}cos({\frac {k\pi x}{2}})+\sum _{k=1}^{2}B_{k}sin({\frac {k\pi x}{2}})\!}
Applying the first initial condition
y
(
0
)
=
1
{\displaystyle y(0)=1\!}
y
(
0
)
=
c
1
+
c
2
+
A
1
+
A
2
=
1
{\displaystyle y(0)=c_{1}+c_{2}+A_{1}+A_{2}=1\!}
Taking the derivative
y
′
=
c
1
e
x
+
2
c
2
e
2
x
−
∑
k
=
2
2
k
π
2
A
k
s
i
n
(
k
π
x
2
)
+
∑
k
=
2
2
k
π
2
B
k
c
o
s
(
k
π
x
2
)
{\displaystyle y'=c_{1}e^{x}+2c_{2}e^{2x}-\sum _{k=2}^{2}{\frac {k\pi }{2}}A_{k}sin({\frac {k\pi x}{2}})+\sum _{k=2}^{2}{\frac {k\pi }{2}}B_{k}cos({\frac {k\pi x}{2}})\!}
Applying the second initial condition
y
′
(
0
)
=
0
{\displaystyle y'(0)=0\!}
y
′
(
0
)
=
c
1
+
2
c
2
+
2
π
2
B
2
=
0
{\displaystyle y'(0)=c_{1}+2c_{2}+{\frac {2\pi }{2}}B_{2}=0\!}
Solving the two equations for two unknowns yields:
c
1
=
2.2436
,
c
2
=
−
1.1218
{\displaystyle c_{1}=2.2436\ ,\ c_{2}=-1.1218\!}
So the general solution for n=2 is:
y
=
2.2436
e
x
−
1.1218
e
2
x
+
1
4
+
∑
k
=
1
2
A
k
c
o
s
(
k
π
x
2
)
+
∑
k
=
1
2
B
k
s
i
n
(
k
π
x
2
)
{\displaystyle y=2.2436e^{x}-1.1218e^{2x}+{\frac {1}{4}}+\sum _{k=1}^{2}A_{k}cos({\frac {k\pi x}{2}})+\sum _{k=1}^{2}B_{k}sin({\frac {k\pi x}{2}})\!}
Below is a plot showing the general solutions for n=2,4,8:
Using ode45 the following graph was generated for n=0:
and for n=1