The equation of motion (E of M) of a system is an equation which expresses the fundamental laws of motion in terms of only (a) the degrees of freedom, (b) derivatives of the degrees of freedom, and (c) constants characterizing the system.
In the example of the SHO, the fundamental law of motion is Newton's law. Because our particle is free to move along the x-axis only, we need consider just the x-components of the motion. Newton's law states for this motion,
The only force acting along the x-direction (because the rod is frictionless) comes from the spring and is in direct proportion to the stretch in the spring through the spring constant k. Moreover, when the spring is stretched, (and ), the force is backwards along the x-axis. Therefore, . Thus, we have
The above equation does not yet qualify as an equation of motion because the acceleration does not fall into the allowed categories (a-c). We amend this simply by replacing the acceleration in the x-direction by its mathematical equivalent and, thereby, derive the equation of motion for the SHO,
Eq. (5) now qualifies as an equation of motion because all terms fall into the above categories: x(t) is in (a), is in (b), and -k, and m are in (c).