# How do I account for the direction of friction acting on a spring?

I would like to set up the equations of motion for a simple spring oscillator.

Let's have a spring lying horizontally; we attach a small mass $m$ to the (massless) spring.

The force of the spring on the mass is

$$F_\text{spring} = - k x$$

where $k$ is the spring constant, and $x$ is the displacement from the position of rest.

Since I am considering the system in motion, I only need to account for the kinetic friction. I know that the magnitude for the kinetic friction is:

$$F_\text{fric} = F_g \mu$$

where $\mu$ is the coefficient of kinetic friction, $F_g$ equals the Normal Force on the surface and is also equal to the gravitational force.

But the direction of the force is always antilinear to the direction of motion.

How do I set this up correctly in my approach for the equations of motion? My approach is

$$m a = -k x - \operatorname{sign}(x) F_\text{fric}$$

where $a$ is the acceleration of the mass point, and $\operatorname{sign}$ is the sign function.

Is this correct?

$$ma=-kx - \mathrm{sign}(v) F_{\mathrm{fric}}.$$