# Analytical solution of driven damped oscillator with aperiodic conditions

I derived a solution for a driven damped oscillator using the DSolve functionality of Wolfram Mathematica. I chose the following Ansatz:

DSolve[{
0 == -Fmax (1 - Cos[t]) + k x[t] +
d Derivative[1][x][t] +
m Derivative[2][x][t],
x[0] == xStart, x'[0] == vStart}, x[t], t]


Mathematica is able to solve this analytically and I can derive solutions if I pass parameters to the variables.

Anyhow, the derived solution fails at the moment, the given parameters for mass (m), spring constant (k) and dampening (d) fulfill the condition for aperiodic behavior

d=2*Sqrt[m*k]


due to the fact, that a division by zero occurs. The overall solution is given by a big fraction with a denominator containing the following factor

Sqrt[d^2 - 4 k m]


This factor becomes zero in case aperiodic conditions occur which leads to a devision by zero.

Now the fun starts ... I case I pass the aperiodic conditions before giving the system to DSolve:

DSolve[{
0 == -Fmax (1 - Cos[t]) + k x[t] +
2 Sqrt[k m] Derivative[1][x][t] +
m Derivative[2][x][t],
x[0] == xStart, x'[0] == vStart}, x[t], t]


DSolve easily derives a working solution without dividing by zero.

It seems to me, as Mathematica is simplifying the more general solution, in a way that I can't use the aperiodic conditions anymore, even though there is a working solution for that case. My question is, can I somehow tell DSolve, to take into account the aperiodic conditions?

Sure, I can workaround the problem with Piecewise[], but for further calculations a general solution without Piecewise[] would be more suitable.

Thanks in advance for you time and help,

Greetings Tschibi

• Welcome! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– user9660
Aug 31 '16 at 16:03

Mathematica or any CAS for that matter, gives a general solution, and does not customize for specific conditions. There are three cases to consider here: Underdamped, critically damped, and overdamped. Each has to be solved separately and gives a different solution since the roots are different.

$$mx^{\prime\prime}\left( t\right) +cx^{\prime}\left( t\right) +kx\left( t\right) =F-F\cos\left( t\right)$$

Writing in standard form for vibration analysis (to make it easy to follow and this is the standard also)

\begin{align*} x^{\prime\prime}\left( t\right) +\frac{c}{m}x^{\prime}\left( t\right) +\frac{k}{m}x\left( t\right) & =\frac{F}{m}-\frac{F}{m}\cos\left( t\right) \\ x^{\prime\prime}\left( t\right) +2\xi\omega x^{\prime}\left( t\right) +\omega^{2}x\left( t\right) & =\frac{F}{m}-\frac{F}{m}\cos\left( \varpi t\right) \end{align*}

Where $\varpi$ is the forcing frequency (1 rad per second in this case), $\omega$ is the natural frequency $\omega=\sqrt{\frac{k}{m}}$ and $\xi$ is damping ratio, which is the most important quantity here as it decides which solution will come out $$\xi=\frac{c}{c_{r}}$$

Where $c$ is the damping coefficient and $c_{r}$ is critical damping coefficient given by $c_{r}=2\sqrt{km}$. There are three solutions for the above ODE depending on $\xi<1$ (underdamped)$,\xi=1$ (critically damped) and $\xi>1$ (over damped)

For underdamped, which is when $\xi<1$ or $c<c_{r}$ or $c<2\sqrt{km}$. The roots of the characteristic equation\ $\lambda^{2}+2\xi\omega+\omega^{2}=0$ for the homogeneous part of the ODE are

$$-\xi\omega\pm i\omega\sqrt{1-\xi}$$

Hence

$$x_{h}\left( t\right) =e^{-\xi\omega t}\left( A\cos\omega_{d}t+B\sin \omega_{d}t\right)$$

Where $\omega_{d}$ is the damped natural frequency, defined only for underdamped case, and given by $\omega_{d}=\omega\sqrt{1-\xi^{2}}$. Adding the particular solution, which for $\frac{F}{m}$ is $x_{p}=\frac{1}{m}\frac{F}{k}$ and for $\frac{F}{m}\cos\left( \varpi t\right)$ the particular solution is $x_{p}=\frac{1}{m}\frac{F}{k}\frac{1}{\sqrt{\left( 1-r^{2}\right) ^{2}+\left( 2\xi r\right) ^{2}}}\sin\left( \varpi-\theta\right)$ where $r=\frac{\varpi}{\omega}$ and $\theta=\arctan\left( \frac{c\varpi} {k-m\varpi^{2}}\right) =\arctan\left( \frac{2\xi r}{1-r^{2}}\right)$. Hence the complete solution for underdamped is

$$x\left( t\right) =e^{-\xi\omega t}\left( A\cos\omega_{d}t+B\sin\omega _{d}t\right) +\frac{1}{m}\frac{F}{k}-\frac{1}{m}\frac{F}{k}\frac{1} {\sqrt{\left( 1-r^{2}\right) ^{2}+\left( 2\xi r\right) ^{2}}}\sin\left( \varpi-\theta\right)$$

Now $A,B$ are found from initial conditions. For the case of critically damped, $\xi=1$ or $c=2\sqrt{km}$ the roots become $-\xi\omega$ only and hence $x_{h}\left( t\right) =\left( A+Bt\right) e^{-\xi\omega t}$ and therefore, the full solution is

$$x\left( t\right) =\left( A+Bt\right) e^{-\xi\omega t}+\frac{1}{m}\frac {F}{k}-\frac{1}{m}\frac{F}{k}\frac{1}{\sqrt{\left( 1-r^{2}\right) ^{2}+\left( 2\xi r\right) ^{2}}}\sin\left( \varpi-\theta\right)$$

For the case of overdamped, when $\xi>1$ or $c>2\sqrt{km}$ then roots become

$$\left\{ \frac{-c}{2m}+\sqrt{\left( \frac{c}{2m}\right) ^{2}-\frac{k}{m}% },\frac{-c}{2m}-\sqrt{\left( \frac{c}{2m}\right) ^{2}-\frac{k}{m}}\right\}$$

or

$$\left\{ -\omega\xi+\omega\sqrt{\xi^{2}-1},-\omega\xi-\omega\sqrt{\xi^{2}% -1}\right\}$$

And since $\xi>1$ then both roots are real, and there is no oscillation. Let the above roots be $p_{1},p_{2}$, hence the solution is

$$x_{h}\left( t\right) =Ae^{p_{1}t}+Be^{p_{2}t}$$

And the complete solution is

$$x\left( t\right) =Ae^{p_{1}t}+Be^{p_{2}t}+\frac{1}{m}\frac{F}{k}-\frac{1} {m}\frac{F}{k}\frac{1}{\sqrt{\left( 1-r^{2}\right) ^{2}+\left( 2\xi r\right) ^{2}}}\sin\left( \varpi-\theta\right)$$

Where again, the constants $A,B$ are found from initial conditions. Hence in summary

For $c<2\sqrt{km}$
$$x\left( t\right) =e^{-\xi\omega t}\left( A\cos\omega _{d}t+B\sin\omega_{d}t\right) +\frac{1}{m}\frac{F}{k}-\frac{1}{m}\frac{F} {k}\frac{1}{\sqrt{\left( 1-r^{2}\right) ^{2}+\left( 2\xi r\right) ^{2}} }\sin\left( \varpi-\theta\right)$$

For $c=2\sqrt{km}$
$$x\left( t\right) =\left( A+Bt\right) e^{-\xi\omega t}+\frac{1}{m}\frac{F}{k}-\frac{1}{m}\frac{F}{k}\frac{1}{\sqrt{\left( 1-r^{2}\right) ^{2}+\left( 2\xi r\right) ^{2}}}\sin\left( \varpi -\theta\right)$$

For $c>2\sqrt{km}$ $$x\left( t\right) =Ae^{p_{1}t}+Be^{p_{2}t}+\frac{1}{m} \frac{F}{k}-\frac{1}{m}\frac{F}{k}\frac{1}{\sqrt{\left( 1-r^{2}\right) ^{2}+\left( 2\xi r\right) ^{2}}}\sin\left( \varpi-\theta\right)$$

Where $r=\frac{\varpi}{\omega}$ and $\theta=\arctan\left( \frac{c\varpi }{k-m\varpi^{2}}\right) =\arctan\left( \frac{2\xi r}{1-r^{2}}\right) ,\omega=\sqrt{\frac{k}{m}}$ and $\xi$ is damping ratio $\xi=\frac{c}{c_{r}}$ And $c_{r}=2\sqrt{km}$

You can use Mathematica now to obtain the solution given the initial conditions, by using the above three cases each time. i.e. knowing if the system is underdamped, critically damped, or overdamped, you use the correct solution for that case.

Try this:

dsl = DSolveValue[{0 == -Fmax (1 - Cos[t]) + k x[t] +
d Derivative[1][x][t] + m Derivative[2][x][t], x[0] == xStart,
x'[0] == vStart}, x[t], t];
dsl1 = dsl /. d -> 2*Sqrt[m*k] + ϵ // Simplify;
lim=Limit[dsl1, ϵ -> 0]


yielding the following:

(* (1/(k m (k + m)^2))E^(-((k t)/Sqrt[
k m])) (E^((k t)/Sqrt[k m]) Fmax k^2 m - 3 Fmax k m^2 +
2 E^((k t)/Sqrt[k m]) Fmax k m^2 - Fmax m^3 +
E^((k t)/Sqrt[k m]) Fmax m^3 - Fmax m^2 Sqrt[k m] t -
Fmax (k m)^(3/2) t + k^3 m t vStart + 2 k^2 m^2 t vStart +
k m^3 t vStart + k^3 m xStart + 2 k^2 m^2 xStart + k m^3 xStart +
k^3 Sqrt[k m] t xStart + 2 k (k m)^(3/2) t xStart +
m (k m)^(3/2) t xStart -
E^((k t)/Sqrt[k m]) Fmax k (k - m) m Cos[t] -
2 E^((k t)/Sqrt[k m]) Fmax (k m)^(3/2) Sin[t])  *)


looking like this

Plot[lim /. {Fmax -> 1, m -> 1, k -> 1, xStart -> 0, vStart -> 1}, {t,
0, 5}]


Is it, what you are looking for?

• Thank you for your help, never thought of this interesting approach. Unfortunately this will give the specific solution for my problem at the given aperiodic conditions. I was able to solve this using DSolve[] also without your tweak. What I can't achieve, is a general solution (where d is still a parameter) that wont devide by zero if d is replaced by "2*Sqrt[m*k]". I did a workaround by using Piecewise[] but this solution brings more problems during my further calculations. Again thank you for your fast help and this interesting approach. Aug 31 '16 at 17:19
• @Tschibi I may be wrong, but from the school time I remember that this solution is a special case. It cannot be obtained simply by the analytical continuation you mentioned. For this reason a special trick might help. Sep 1 '16 at 6:46
• @Tschibi The problem is that as d -> 2 Sqrt[k*m], the two independent eigenfunctions E^(1/2 (-(d/m) ± Sqrt[d^2 - 4 k m]/m) t) of the homogeneous linear system approach each other and the basis for the solution space suddenly & discontinuously collapses. One has to fill out the basis with a function like t * E^(-((Sqrt[k m] t)/m)). I would be surprised if there is a way to represent all solutions in a single formula without using Piecewise or some other trickery. Sep 1 '16 at 11:32
• @AlexeiBoulbitch It seems your limit-based solution does not agree with the DSolve solution when d is replaced by 2 Sqrt[k*m]. Is it supposed to? Sep 1 '16 at 11:44
• @All, again thank you for your help and effort. It looks like I have to separate this special case using, Piecewise[]. Anyhow, your different approaches and tricks, helped me to slim down my actual code and made it more efficient, so I can continue with my work. Sep 1 '16 at 12:43