Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
Lecture 5
In the Lecture we discuss the use of complex numbers and complex functions to solve linear second
order (in)homogeneous ordinary differential equations by using the Ansatz of complex exponential time
dependence. Here we will discuss the tools available in Mathematica to study such equations. In
particular, recall that we used the Solve command for algebraic equations. Now we want to employ the
DSolve command for differential equations.
First consider the homogeneous (undriven) equation for a mass on a spring with viscous damping.
Note that DSolve expects derivatives to be indicated by primes, 's, and that the desire function or
depedent variable (second argument) and independent variable (third argument) be clearly indicated.
We have
In[89]:= DSolve@m x''@tD + b x'@tD + k x@tD 0, x@tD, tD
Out[89]= ::x@tD ® ã
-b- b2-4 k m t
2 m C@1D + ã
-b+ b2-4 k m t
2 m C@2D>>
If we don't tell Mathematica that x ia function t, it tells us
In[90]:= DSolve@m x''@tD + b x'@tD + k x@tD 0, x, tD
Out[90]= ::x ® FunctionB8t<, ã
-b- b2-4 k m t
2 m C@1D + ã
-b+ b2-4 k m t
2 m C@2DF>>
We get just what we expect from our standard (real) exponential Ansatz, x[t] ~
eΑt
® Α = -b
2 m±
b2
4 m2
-k
m. Note also that Mathematica includes the 2 undetermined constants
(labeled in the form C[1], C[2]) which will be determined by initial conditions. This confirms the analysis
in Eq. (5.29) and following in the Lecture. Mathematica will also solve for these constants directly if the
inital conditions are provided in extra equations, as in
In[91]:= sol = DSolve@8m x''@tD + b x'@tD + k x@tD 0, x@0D == 1, x'@0D 0<, x@tD, tD
Out[91]= ::x@tD ®1
2 b2 - 4 k m
-b ã
-b- b2-4 k m t
2 m + b ã
-b+ b2-4 k m t
2 m + ã
-b- b2-4 k m t
2 m b2
- 4 k m + ã
-b+ b2-4 k m t
2 m b2
- 4 k m >>
To pull on the solution for manipulation we define
In[92]:= sol1 = x@tD . sol@@1DD
Out[92]=
1
2 b2 - 4 k m
-b ã
-b- b2-4 k m t
2 m + b ã
-b+ b2-4 k m t
2 m + ã
-b- b2-4 k m t
2 m b2
- 4 k m + ã
-b+ b2-4 k m t
2 m b2
- 4 k m
And test the initial conditions
In[93]:= sol1 . t ® 0
Out[93]= 1
In[94]:= sol1' . t ® 0
Out[94]= 0 &
Let's try it with constants defined via
In[95]:= k = 1; b = 1; m = 1;
In[96]:= sol2 = DSolve@8m x''@tD + b x'@tD + k x@tD 0, x@0D == 1, x'@0D 0<, x@tD, tD
Out[96]= ::x@tD ®1
3
ã-t2
3 CosB3 t
2
F + 3 SinB3 t
2
F >>
The expected damped oscillation that looks like (note the initial conditions are explicit in the plot).
In[97]:= Plot@x@tD . sol2@@1DD, 8t, 0, 10<, PlotRange ® 8-.2, 1<, AxesLabel ® 8"t", "x@tD"<D
Out[97]=
2 4 6 8 10
t
-0.2
0.2
0.4
0.6
0.8
1.0
x@tD
Now consider the inhomogeneous (harmonically driven) form of the equation (see Eqns. (5.23) to (5.25)
(note that Mathematica still rememebers our values for m, b and k)
In[98]:= sol3 = DSolve@m x''@tD + b x'@tD + k x@tD F 1 Cos@Ω0 t + j1D, x@tD, tD
2 Lec5_227_08.nb
Out[98]= ::x@tD ® ã-t2
C@2D CosB3 t
2
F +
ã-t2
C@1D SinB3 t
2
F + F1 - 3 CosB3 t
2
F CosBj1 -1
2
t I 3 - 2 Ω0MF -
3 CosB3 t
2
F CosB3 t
2
+ j1 + t Ω0F - CosBj1 -1
2
t I 3 - 2 Ω0MF SinB3 t
2
F -
CosB3 t
2
+ j1 + t Ω0F SinB3 t
2
F + 3 SinB3 t
2
F SinBj1 -1
2
t I 3 - 2 Ω0MF +
CosB3 t
2
F SinB3 t
2
- j1 - t Ω0F + CosB3 t
2
F SinB3 t
2
+ j1 + t Ω0F -
3 SinB3 t
2
F SinB3 t
2
+ j1 + t Ω0F - CosB3 t
2
F CosBj1 -1
2
t I 3 - 2 Ω0MF Ω0 +
CosB3 t
2
F CosB3 t
2
+ j1 + t Ω0F Ω0 - 3 CosBj1 -1
2
t I 3 - 2 Ω0MF
SinB3 t
2
F Ω0 + 3 CosB3 t
2
+ j1 + t Ω0F SinB3 t
2
F Ω0 + SinB3 t
2
F
SinBj1 -1
2
t I 3 - 2 Ω0MF Ω0 + 3 CosB3 t
2
F SinB3 t
2
- j1 - t Ω0F Ω0 -
3 CosB3 t
2
F SinB3 t
2
+ j1 + t Ω0F Ω0 + SinB3 t
2
F SinB3 t
2
+ j1 + t Ω0F Ω0 +
3 CosB3 t
2
F CosBj1 -1
2
t I 3 - 2 Ω0MF Ω0
2+
3 CosB3 t
2
F CosB3 t
2
+ j1 + t Ω0F Ω0
2-
CosBj1 -1
2
t I 3 - 2 Ω0MF SinB3 t
2
F Ω0
2- CosB
3 t
2
+ j1 + t Ω0F SinB3 t
2
F Ω0
2-
3 SinB3 t
2
F SinBj1 -1
2
t I 3 - 2 Ω0MF Ω0
2+
CosB3 t
2
F SinB3 t
2
- j1 - t Ω0F Ω0
2+ CosB
3 t
2
F SinB3 t
2
+ j1 + t Ω0F Ω0
2+
3 SinB3 t
2
F SinB3 t
2
+ j1 + t Ω0F Ω0
2+ 2 CosB
3 t
2
F CosBj1 -1
2
t I 3 - 2 Ω0MF
Ω0
3- 2 CosB
3 t
2
F CosB3 t
2
+ j1 + t Ω0F Ω0
3- 2 SinB
3 t
2
F
SinBj1 -1
2
t I 3 - 2 Ω0MF Ω0
3- 2 SinB
3 t
2
F SinB3 t
2
+ j1 + t Ω0F Ω0
3
I2 3 I-1 + 3 Ω0 - Ω0
2M I1 + 3 Ω0 + Ω0
2MM>>
Yikes - lots of apparent complexity so simplify
Lec5_227_08.nb 3
In[99]:= Simplify@x@tD . sol3@@1DDD
Out[99]=
1
1 - Ω0
2 + Ω0
4
ã-t2
-ãt2
F1 I-Cos@j1 + t Ω0D - Sin@j1 + t Ω0D Ω0 + Cos@j1 + t Ω0D Ω0
2M +
C@2D CosB3 t
2
F + C@1D SinB3 t
2
F I1 - Ω0
2+ Ω
0
4M
More muscle
In[100]:= FullSimplify@x@tD . sol3@@1DDD
Out[100]= ã-t2
C@2D CosB3 t
2
F + C@1D SinB3 t
2
F +
F1 HCos@j1 + t Ω0D + Ω0 HSin@j1 + t Ω0D - Cos@j1 + t Ω0D Ω0LL1 - Ω
0
2 + Ω0
4
Now we recognize the first (damped) term as the complementary solution, i.e., the solution to the
homogeneous equation (which knows about the damping and the natural frequency), while the second
term is the particular solution for the specific driving function (and driving frequency). To see this is the
same as Eq. (5.25) we would have to expand the single cosine function (with the 2 phases) in terms of
the phase due to the spring system.
Now with inital conditions and a specific diving force we have
In[101]:= F1 = 2; Ω0 = 1; j1 = Π 3;
In[102]:= sol4 =
DSolve@8m x''@tD + b x'@tD + k x@tD F 1 Cos@Ω0 t + j1D, x@0D == 1, x'@0D 0<, x@tD, tD
Out[102]= ::x@tD ®1
3
ã-t2
3 CosB3 t
2
F - 3 3 CosB3 t
2
F +
3 3 ãt2
Cos@tD CosB3 t
2
F2
+ 3 ãt2
CosB3 t
2
F2
Sin@tD - 3 SinB3 t
2
F -
3 SinB3 t
2
F + 3 3 ãt2
Cos@tD SinB3 t
2
F2
+ 3 ãt2
Sin@tD SinB3 t
2
F2
>>
In[103]:= FullSimplify@x@tD . sol4@@1DDD
Out[103]= 3 Cos@tD + Sin@tD +1
3
ã-t2
-3 I-1 + 3 M CosB3 t
2
F - I3 + 3 M SinB3 t
2
F
4 Lec5_227_08.nb
In[104]:= Plot@x@tD . sol4@@1DD, 8t, 0, 15<, PlotRange ® 8-2, 3<, AxesLabel ® 8"t", "x@tD"<D
Out[104]=
2 4 6 8 10 12 14
t
-2
-1
1
2
3
x@tD
Note there is a brief period (as in the previous plot) where the complementary solution damps out and
after which the initial conditions are "forgotten". Then for large times we settle into the behavior given
by the particular solution corresponding to the specific driving function. Note that the coefficients in the
complementary solution (C[1]) & C[2]) are chosen so that the full solution (complementary plus particu-
lar) obeys the given inital conditions, as illustrated in the plot. This is not the case for the individual bits
alone.
Complementary
In[105]:= PlotB1
3
ã-t2
-3 J-1 + 3 N CosB3 t
2
F - J3 + 3 N SinB3 t
2
F ,
8t, 0, 15<, PlotRange ® 8-2, 3<, AxesLabel ® 8"t", "x_comp@tD"<F
Out[105]=
2 4 6 8 10 12 14
t
-2
-1
1
2
3
x_comp@tD
Particular
Lec5_227_08.nb 5
In[106]:= PlotB 3 Cos@tD + Sin@tD, 8t, 0, 15<,
PlotRange ® 8-2, 3<, AxesLabel ® 8"t", "x_part@tD"<F
Out[106]=
2 4 6 8 10 12 14
t
-2
-1
1
2
3
x_part@tD
But the sum of the 2 (linear superposition) satisfies the inhomogeneous equation AND the initial
condiitons.
6 Lec5_227_08.nb