# Damped Harmonic Oscillator

I'm trying to find the solution to the differential equation for a damped harmonic oscillator, i.e. $m\ddot{x}+c\dot{x}+kx=0$ but using that the damping force can be represented by the frictional force, $f_k$. This gives $$m\ddot{x}+kx+f_k=0 \hspace{3mm} \mbox{ for }\dot{x}>0 \\ m\ddot{x}+kx-f_k=0 \hspace{3mm} \mbox{ for }\dot{x}<0$$

I also have initial conditions $x_{t=0}=x_0$ and $v_{t=0}=0$.

A complementary solution to this equation is $x_c=A\cos({wt-\phi})$ where $A$ is a constant and a particular solution is $x_p=\mp\frac{f_k}{k}$ (negative for $\dot{x}>0$ and positive for $\dot{x}<0$).

Therefore we obtain the general solution $$x(t)=A\cos(wt-\phi)-\frac{f_k}{k} \hspace{3mm} \mbox{ for } \dot{x}>0\\ x(t)=A\cos(wt-\phi)+\frac{f_k}{k} \mbox{ for } \dot{x}<0$$

Unfortunately this doesn't make sense since the output values of this function don't get smaller with time.

It seems that you are calling $c\dot{x}$ as $f_k$, solving the equation as if $f_k$ was a parameter, then trying to substitute this constant somehow back. This is not a way to go.
Also there is no point it single out cases $\dot{x}>0$ and $\dot{x} < 0.$ Both are covered by $c \dot{x}=0$ (assuming by "friction" you mean really something which is trying to stop a particle for $c>0$). In your case by changing sign the $\dot{x}$ term is slowing down or speeding up the particle based on the sign of variable. Actually this does not matted as you do not solve the equation properly.