TITLE: Piece-wise second order differential equation
QUESTION [1 upvotes]: Suppose I have some function $f(x)$ which is equal to $kx$ when $x$ is negative and $-kx$ when $x$ is positive, and I have the following differential equation : $$\frac{d^2x}{dt^2}=-k|x|=f(x)$$
My idea is to break this into two parts. For $x<0$, we have $|x|=-x$, hence :
$$D^2x=kx$$
Similarly, when $x>0$, we have $|x|=x$, and so :
$$D^2x=-kx$$
I don't see how to proceed from here. For the negative region, I'm getting a solution that is a combination of exponential functions, and for the positive region, I'm getting a solution that is a combination of sinusoidal functions.
However, I also think that, in the negative direction, just as $|x|\rightarrow-x$, we should also change $D^2x\rightarrow -D^2x$. In that case, we can rewrite the entire equation as $$D^2x=-kx$$ and allow $x$ to have positive and negative values. Then the entire solution is a sinusoid.
However, I'm not sure, if in the negative region $D^2x\rightarrow -D^2x$. Is this correct, and if not, how do I solve this equation?
Moreover, if I had a differential equation of the form: $$D^2|x|=-k|x|$$, then I could have removed the mod and solved this equation as $$(D^2-k)x=0$$, and allowed $x$ to be both positive and negative, right ?

REPLY [0 votes]: For $k=0$, $\boxed{x(t) = c_1t+c_2.}$
For $k \neq 0$, start by multiplying both sides of your differential equation by $x'(t)$ and integrating in terms of $t$,
$$
\frac{\mathrm{d}x}{\mathrm{d}t} \frac{\mathrm{d}\phantom{t}}{\mathrm{d}t} \left(\frac{\mathrm{d}x}{\mathrm{d}t}\right) = -k |x|\frac{\mathrm{d}x}{\mathrm{d}t} \Rightarrow  \frac{1}{2} \left(\frac{\mathrm{d}x}{\mathrm{d}t}\right)^2 = -k\int|x| \mathrm{d}x.
$$
Therefore,
$$
\boxed{t + c_1 = \pm \int \frac{\mathrm{d}x'}{\sqrt{-2k\int|x| \mathrm{d}x}}.}
$$

If $x>0$, $\int |x|\mathrm{d}x = \int x\mathrm{d}x = x^2/2 + c_2$. Therefore,
$$
\begin{aligned}
t + c_1 &= \pm \int \frac{\mathrm{d}x}{\sqrt{c_2-kx^2}} = \pm \frac{1}{\sqrt{k}} \tan^{-1}\left(\frac{\sqrt{k}x}{\sqrt{c_2-kx^2}}\right) \\
&\Rightarrow \boxed{x(t) = \pm \sqrt{\frac{c_2}{k}}\sin\left(\sqrt{k}(t+c_1)\right)\mathrm{sgn}\left(\cos\left(\sqrt{k}(t+c_1)\right)\right).}
\end{aligned}
$$
If $x<0$, $\int |x|\mathrm{d}x = -\int x\mathrm{d}x = -x^2/2 + c_2$. Therefore,
$$
\begin{aligned}
t + c_1 &= \pm \int \frac{\mathrm{d}x}{\sqrt{c_2+kx^2}} = \pm \frac{1}{\sqrt{k}} \tanh^{-1}\left(\frac{\sqrt{k}x}{\sqrt{c_2+kx^2}}\right) \\
&\Rightarrow \boxed{x(t) = \pm \sqrt{\frac{c_2}{k}}\sinh\left(\sqrt{k}(t+c_1)\right).}
\end{aligned}
$$
{"set_name": "stack_exchange", "score": 1, "question_id": 4348797}