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 ?
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}}.} $$