Zentrum Mathematik
Technische Universität München
Prof. Dr. Massimo Fornasier
Dr. Markus Hansen
WS 2016/17
Sheet 4
Modeling and Simulation with ODE for MSE
The exercises can be handed in until Wed, 23.11.2014, 12.00 in the post box located in the MI
basement!
Exercise 1 (Method of Undetermined Coefficients)
Find a particular solution to the following inhomogeneous ODEs:
(a)
(b)
(c)
(d)
y 00 + 5y 0 + 4y = 10x2 e−3x
y 00 − 16y = 9.6e4x + 30ex
y 00 + y = 2 cos2 x
Hint: Use an addition theorem first.
00
0
2x
y − 4y + 5y = 2e cos x + 3e3x sin x
Solution:
(a) It’s always the first step to consider the corresponding homogeneous problem, so in
our case
y 00 + 5y 0 + 4y = 0.
q
5
2
− 4 = − 52 ± 32 .
The characteristic polynomial is λ +5λ+4, with roots λ1/2 = − 2 ± 25
4
So the general solution of the homogeneous problem is
yh (x) = c1 e−x + c2 e−4x .
Since e−3x is not a solution of the homogeneous problem, the Method of Undetermined coefficients tells us to use the ansatz
yp (x) = (a2 x2 + a1 x + a0 )e−3x .
Plugging into the ODE
yp0 (x) = (2a2 x + a1 − 3a2 x2 − 3a1 x − 3a0 )e−3x
as well as
yp00 (x) = (2a2 − 6a2 x − 3a1 − 6a2 x − 3a1 + 9a2 x2 + 9a1 x + 9a0 )e−3x ,
we obtain the equation
10x2 = 2a2 − 12a2 x − 6a1 + 9a2 x2 + 9a1 x + 9a0
+ 5(2a2 x + a1 − 3a2 x2 − 3a1 x − 3a0 ) + 4(a2 x2 + a1 x + a0 ).
Sorting the terms and comparing coefficients, we obtain the system of equations
10 = 9a2 − 15a2 + 4a2 = −2a2
0 = −12a2 + 9a1 + 10a2 − 15a1 + 4a1 = −2a2 − 2a1
0 = 2a2 − 6a1 + 9a0 + 5a1 − 15a0 + 4a0 = 2a2 − a1 − 2a0 .
. This results finally in
Its solution is given by a2 = −5, a1 = 5 and a0 = − 15
2
15 −3x
yp (x) = −5x2 + 5x −
e .
2
(b) The characteristic polynomial is λ2 − 16, with roots ±4. So here we indeed have the
case that e4x is a solution of the homogeneous equation, and ex is not, so the ansatz
this time is chosen as
yp (x) = Axe4x + Bex .
From this we get yp0 (x) = (A+4Ax)e4x +Bex and yp00 (x) = (4A+4A+16Ax)e4x +Bex .
Plugging this into the ODE, we obtain the equation
(8A + 16Ax)e4x + Bex − 16Axe4x − 16Bex = 9.6e4x + 30ex .
We read off the conditions 8A = 9.6 as well as −15B = 30, and hence A = 1.2 and
B = −2. A particular solution of th inhomogeneous equation thus is
yp (x) = 1.2xe4x − 2ex .
(c) Since the Method of Undetermined coefficients only deals with terms cos(ax) and/or
sin(ax), we first have to bring the right-hand side into such a more suitable form.
Using the addition theorem cos(2x) = 2 cos2 (x) − 1, we hence get the problem
y 00 + y = cos(2x) + 1 .
The characteristic polynomial here is λ2 + 1 with roots ±i, hence a real fundamental
system for the homogeneous equation is {cos(x), sin(x)}. Thus neither 1 nor cos(2x)
are solutions of the homogeneous equations, and we can use the ansatz
yp (x) = A cos(2x) + B sin(2x) + C .
With yp0 (x) = −2A sin(2x) + 2B cos(2x) and yp00 (x) = −4A cos(2x) − 4B sin(2x) we
obtain the equation
−4A cos(2x) − 4B sin(2x) + A cos(2x) + B sin(2x) + C = cos(2x) + 1 ,
and from comparing coefficients we can read off the conditions
−3A = 1,
−3B = 0,
C = 1.
This finally gives
1
yp (x) = − cos(2x) + 1
3
as a particular solution of the inhomogeneous equation.
(d) We first find λ2 − 4λ + 5 as the characteristic polynomial of the homogeneous equations, with roots λ1/2 = 2 ± i. This gives e2x cos x and e2x sin x as the basic solutions.
In turn, this implies the ansatz
yp (x) = Axe2x cos x + Bxe2x sin x + Ce3x sin x + De3x cos x
for the desired particular solution of the inhomogeneous problem. We then get
yp0 (x) = (A + 2Ax + Bx)e2x cos x + (B + 2Bx − Ax)e2x sin x
+ (3C − D)e3x sin x + (3D + C)e3x cos x
as well as
yp00 (x) = (2A + B + 2A + 4Ax + 2Bx + B + 2Bx − Ax)e2x cos x
+ (2B − A + 2B + 4Bx − 2Ax − A − 2Ax − Bx)e2x sin x
+ (9C − 3D − 3D − C)e3x sin x + (9D + 3C + 3C − D)e3x cos x .
Plugging this into the equation and comparing coefficients, we obtain the conditions
xe2x cos x :
e2x cos x :
xe2x sin x :
e2x sin x :
e3x sin x :
e3x cos x :
0 = 3A + 4B − 8A − 4B + 5A = 0
2 = 4A + 2B − 4A = 2B
0 = 3B − 4A − 8B + 4A + 5B = 0
0 = 4B − 2A − 4B = −2A
3 = 8C − 6D − 12C + 4D + 5C = C − 2D
0 = 8D + 6C − 12D − 4C + 5D = D + 2C .
This system has the solution A = 0, B = 1, C = 53 and D = − 56 , and we finally
obtain
3
6
yp (x) = xe2x sin x + e3x sin x − e3x cos x.
5
5
Exercise 2 (Variation of Constants)
We consider the initial value problem (IVP)
y 00 (x) + 4y 0 (x) + 5y(x) = e−2x tan(x),
y(0) = 0,
y 0 (0) = 0.
(a) Determine a real fundamental system for the corresponding homogeneous ODE.
(b) Use the technique of variation of constants to determine particular solution of the
inhomogeneous ODE.
(c) Determine the solution that satisfies the initial conditions.
Solution:
(a) Real fundamental system for the corresponding homogeneous ODE
(i) zeros of the characteristic polynomial
p(λ) = λ2 + 4λ + 5 = (λ + 2)2 + 1 =⇒ p(λ) = 0 for λ1/2 = −2 ± i.
(ii) complex/real fundamental system
complex fundamental system:
z1 (x) = e(−2+i)x and z2 (x) = e(−2−i)x
real fundamental system:
y1 (x) = e−2x cos(x) and y2 (x) = e−2x sin(x)
(b) First approach: Variation of constants after reformulation as ODE system
(b1) We rewrite the IVP as a linear inhomogeneous ODE system of first order with
dimension 2: We put
y(x)
Y (x) =
.
y 0 (x)
The the second order ODE can be reformulated as
0
1
0
y(0)
0
0
Y (x) =
Y (x) + −2x
,
Y (0) =
=
.
0
−5 −4
e
tan(x)
y (0)
0
{z
}
|
{z
}
|
=A
=R(x)
(b2) The Wronski-matrix for the real fundamental system is given by
y1 (x) y2 (x)
e−2x cos(x)
e−2x sin(x)
W(x) =
= −2x
y10 (x) y20 (x)
e (−2 cos(x) − sin(x)) e−2x (−2 sin(x) + cos(x))
Using the ansatz Yp (x) = W(x)Ĉ(x) and plugging it into the ODE gives the
equation system
0
ĉ1 (x)
0
e−2x cos(x)
e−2x sin(x)
= −2x
.
ĉ02 (x)
e
tan(x)
e−2x (−2 cos(x) − sin(x)) e−2x (−2 sin(x) + cos(x))
{z
} | {z } |
{z
}
|
W(x)
Ĉ(x)
R(x)
Explicitly this system reads as
ĉ01 (x) = − tan(x)ĉ02 (x)
(−2 cos(x) − sin(x))ĉ01 (x) + (−2 sin(x) + cos(x))ĉ02 (x) = tan(x)
Inserting the first equation into the second and simplification leads to
ĉ02 (x) = sin(x),
and inserting this into the first equation we arrive at
ĉ01 (x) = − tan(x)ĉ02 (x) = −
sin2 (x)
.
cos(x)
Integrating those two equations we finally obtain
ĉ2 (x) = − cos(x)
ĉ1 (x) = sin(x) +
1 1 − sin(x) ln
.
2
1 + sin x
The latter can be seen as follows:
Z sin(x)
Z x
u2
sin2 (ξ)
u=sin(ξ)
dξ = −
du
ĉ1 (x) = −
cos(ξ)
1 − u2
Z sin(x) 1/2
1/2
1 1 − sin(x) =
1−
du = sin(x) + ln
−
.
1+u 1−u
2
1 + sin(x)
Ultimately, this gives as a particular solution
Yp (x) = W(x)Ĉ(x)
e−2x cos(x)
e−2x sin(x)
sin(x) + 12 ln| 1−sin(x)
|
1+sin x
= −2x
e (−2 cos(x) − sin(x)) e−2x (−2 sin(x) + cos(x))
− cos(x)
!
1−sin(x)
1
−2x
ln|
|
cos(x)e
2
1+sin
x
= 1
.
1−sin(x)
−
ln|
|(sin(x)
+
2
cos(x))
−
2
e−2x
2
1+sin x
(b’) Second approach via Lagrange’s formula:
Recall that for an equation of the form
y 00 + p(x)y 0 + q(x)y = r(x)
a particular solution is given by
Z
yp (x) = −y1
y2 r
dx + y2
W
Z
y1 r
dx ,
W
where y1 , y2 is a fundamental system of solution of the homogeneous ODE, and
W is the corresponding Wronskian determinant. In our case y1 (x) = e−2x cos x,
y2 (x) = e−2x sin x, and thus
W (x) = y1 y20 −y2 y10 = e−4x cos x(−2 sin x+cos x)−e−4x sin x(−2 cos x−sin x) = e−4x .
Thus we need to consider the integral
Z −2x
Z
Z
e
sin xe−2x tan x
sin2 x
y2 r
dx =
dx
dx
=
W
e−4x
cos x
2
(x)
But this integral is known from (b2) (there we had ĉ01 (x) = − sin
, hence
cos(x)
Z
y2 r
1 1 − sin(x) dx = − sin x − ln
.
W
2
1 + sin(x)
Similarly, we obtain
Z −2x
Z
Z
e
cos xe−2x tan x
y1 r
dx =
dx = sin(x)dx = − cos(x),
W
e−4x
and also this we might recognize as −ĉ2 (x). This finally gives the particular solution
1 1 − sin(x) 1 1 − sin(x) cos(x)e−2x ,
yp (x) = −y1 − sin x − ln
− y2 cos(x) = ln
2
1 + sin(x)
2
1 + sin(x)
which turns out to coincide with the first component of Yp (x) from (b2).
(c) Hence the general solution of the first order ODE system is
Y (x) =Yh (x) + Yp (x) =
c1
e−2x cos(x)
e−2x sin(x)
−2x
−2x
c2
e (−2 cos(x) − sin(x)) e (−2 sin(x) + cos(x))
{z
} | {z }
|
C
W(x)
+
1
2
1
ln| 1−sin(x)
| cos(x)e−2x
2
1+sin x
− ln| 1−sin(x)
|(sin(x) + 2 cos(x))
1+sin x
!
− 2 e−2x
with constant vector C = (c1 , c2 )T ∈ R2 .
Determination of the constants with initial conditions
0
1 0
c1
0
c
0
= Y (0) =
+
=⇒ 1 =
.
0
−2 1
c2
−1
c2
1
Thus we obtain as a solution of the IVP with the first order ODE-system
Y (x) =
e−2x sin(x)+ 21 ln| 1−sin(x)
| cos(x)e−2x
1+sin x
!
.
e−2x (−2 sin(x) + cos(x)) 12 − ln| 1−sin(x)
|(sin(x)
+
2
cos(x))
−
2
e−2x
1+sin x
From this we can read off the solution of the original second order ODE as the first
component of the previous solution vector:
1 1 − sin(x)
−2x
y(x) = e
sin(x) + ln|
| cos(x)| .
2
1 + sin x
Remark: You might wonder: Why bother with the first approach, if it gives exactly the
same result as Lagrange’s formula? The answer is two-fold: First, the formula is harder
to memorize than the (theoretically) simple Variation of constants ansatz. But more
important: Every linear ODE of arbitrarily high order n can be reformulated as a system
of first order ODEs of dimension n, and the Variation of constants approach works for
every n with the same ansatz (though some of the difficulties are only hidden away in
the handling of large matrices, and solving large systems of linear equations), whereas
the explicit formulas become increasingly complex (and impossible to memorize). In fact,
as we will see soon also numerical schemes for ODEs are built for systems of first order
equations rather than for higher order ODEs.
Exercise 3 (An application)
We consider a serial oscillatory circuit, consisting of a power supply U , a resistor R, a
capacitor with capacity C, and an inductor with inductivity L. This being a serial circuit,
we have
U = UC + UR + UL
Q
UR = R · I = R · Q̇ ,
UL = L · I˙ = L · Q̈.
UC = ,
C
From this, we immediately obtain an ODE for the charge Q within the capacitor:
LQ̈ + RQ̇ +
1
Q = U.
C
Now consider a circuit with parameters L = 0.05, R = 10 and C =
1
.
2500
(a) Determine the charge Q and the current I = Q̇ when there is no outside power
supply (U = 0) for the initial state Q(0) = 2 and I(0) = 0.
(b) Now consider an outside power source U (t) = U0 cos(ωt) with U0 = 500 and ω = 100.
Determine Q(t) and I(t) for initial conditions Q(0) = 0.1, I(0) = 20.
(c*) For the above parameters, consider the dependence of the maximum of the charge
Q and current I on the frequency ω.
Solution:
(a) Here we need to solve the ODE
0.05Q̈ + 10Q̇ + 2500Q = 0.
That’s a second order linear ODE with constant coefficients, so primarily we need
to find the roots of the characteristic polynomial
λ2 + 200λ + 50000 = 0.
√
The roots are λ1/2 = −100 ± −40000 = −100 ± 200i. From this we immediately
get the real fundamental system
Q1 (t) = e−100t cos(200t)
Q2 (t) = e−100t sin(200t).
and
To incorporate the initial conditions we need to consider the linear system
2 = Q(0) = c1 Q1 (0) + c2 Q2 (0) = c1
and
0 = Q̇(0) = −100c1 + 200c2 .
Its solution is c1 = 2, c2 = 1, so the solution of our IVP is given by
Q(t) = e−100t (2 cos(200t) + sin(200t)),
and the corresponding current is
I(t) = −100e−100t (2 cos(200t) + sin(200t)) + e−100t (−400 sin(200t) + 200 cos(200t))
= −500e−100t sin(200t).
(b) We use the method of Undetermined coefficients: We plug the ansatz Qp (t) =
A cos(100t)+B sin(100t) into the equation (note that neither cos(100t) nor sin(100t)
is a solution of the homogeneous equation), and obtain
500 cos(100t)
= −500A cos(100t) − 500B sin(100t) − 1000A sin(100t) + 1000B cos(100t)
+ 2500A cos(100t) + 2500B sin(100t)
= (−500A + 1000B + 2500A) cos(100t)
+ (−500B − 1000A + 2500B) sin(100t)
= (2000A + 1000B) cos(100t) + (2000B − 1000A) sin(100t) .
Comparison of coefficients now yields
500 = 2000A + 1000B
with solution B =
1
10
and
2000B − 1000A = 0,
and A = 15 . This gives the particular solution
Qp (t) =
1
1
cos(100t) +
sin(100t).
5
10
For the IVP we now need to consider the system
1
1
= Q(0) = c1 Q1 (0)+c2 Q2 (0)+Qp (0) = c1 +
10
5
and
20 = −100c1 +200c2 +10.
1
This gives c1 = − 10
and c2 = 0, and the final solution is
Q(t) = −
1 −100t
1
1
e
cos(200t) + cos(100t) +
sin(100t).
10
5
10
(c) We do this here for general parameters, and for U (t) = U0 cos(ωt) (perhaps a little
surprising, but this makes the computation clearer). Plugging the ansatz for Undetermined coefficients into the ODE we get this time
U0 cos(ωt)
= −Lω 2 A cos(ωt) − Lω 2 B sin(ωt) − RωA sin(ωt) + RωB cos(ωt)
+ C1 A cos(ωt) + C1 B sin(ωt)
= −Lω 2 A + RωB + C1 A cos(ωt) + −Lω 2 B − RωA + C1 B sin(ωt) .
This gives the equations
U0 = −Lω 2 A + RωB + C1 A and 0 = −Lω 2 B − RωA + C1 B,
with solution
A=
ω 2 − ω02
U0
· 2 2
L δ ω + (ω 2 − ω02 )2
and B =
δω
U0
· 2 2
,
L δ ω + (ω 2 − ω02 )2
1
and δ = R
.
where ω02 = LC
L
To get the maximum charge (and for this we only consider the particular solution;
as before the part from the homogeneous equation is decaying over time, so it is
negligible) as usual we first need to look for critical points by calculating roots of
the derivative. With Q̇p (t) = −Aω sin(ωt) + Bω cos(ωt) we have
A
= cot(ωt0 )
B
or
B
= tan(ωt0 ),
A
and hence
1
B 1
A
arctan
= arccot
.
ω
A
ω
B
With the relations 1 + cot2 (x) = sin21(x) and 1 + tan2 (x) = cos12 (x) we then find for the
value at the critical point
t0 =
Qmax = Q(t0 ) = A cos(ωt0 ) + B sin(ωt0 )
√
1
1
= Ap
+ Bp
= A2 + B 2
1 + (B/A)2
1 + (A/B)2
U0
1
p
.
=
2
2
L δ ω + (ω 2 − ω02 )2
!
˙ = Q̈(t) = −Aω 2 cos(ωt1 )−Bω 2 sin(ωt1 ) = 0, and hence
For the current, we have I(t)
1
B 1
A
arccot −
= arctan − .
ω
A
ω
B
For the extremal value we obtain
t1 =
I(t1 ) = −Aω sin(ωt1 ) + Bω cos(ωt1 )
1
1
B 2 − A2
= −Aω p
+ Bω p
= ω√
A2 + B 2
1 + (B/A)2
1 + (A/B)2
ωU0 δ 2 ω 2 − (ω 2 − ω02 )2
.
=
L (δ 2 ω 2 + (ω 2 − ω02 )2 )3/2
As a last step, we shall look for the maximum of Qmax (ω). We get
dQmax
U0
= − (δ 2 ω 2 + (ω 2 − ω02 )2 )−3/2 (2δ 2 ω + 2(ω 2 − ω02 )2ω).
dω
2L
2
2
2
The derivative vanishes for 2δ
q ω + 2(ω − ω0 )2ω = 0, so either for ω = 0 (which is a
local minimum) or for ω1 = ω02 − 12 δ 2 . This shows a quite well-known phenomenon
for oscillatory circuits: The maximum charge and currents do not occur for the
eigenfrequencies of the ideal oscillator ω0 (with Rq= 0) or for the damped oscillator
(which for general parameters in our notation is
ω02 − 41 δ 2 ).
Information and material related to the lecture can be found at the lecture webpage
http://www-m15.ma.tum.de/Allgemeines/ModelingSimulation
© Copyright 2026 Paperzz