And here's an example.
This is a system of an object (black square) attached to a spring (and the spring is attached to a wall). To simplify, the spring is massless and perfect, and the whole thing is on a table with no friction. Furthermore, nothing here moves up or down, so we consider this as a system of only one dimension in space, the X dimension.
The only object we care about is the black square, which we treat as a single object with mass M. (So we pretend all mass is at a single point, rather than the system being made out of many particles.) So what we want to compute is the position function x describing the position of the square in terms of time t. We choose our coordinate system such that x = 0 corresponds to the position where the spring is relaxed, exerting no force.
Since this is a one-object system, we ought to be able to compute x(t) such that it has exactly two unknowns in it. Then if we also specified the initial position and velocity, we could obtain values for those two unknowns.
The first step (after choosing the coordinate system) is always the same: determine all forces acting on the object. Since we ignore the Y direction, there is only one force, that of the spring. Physics™ has found out that ideal springs exert a force linear to the displacement. Importantly, it's opposite to the displacement; if I pull the string right, the force draws it left; if I pull it left, the force draws it right. How strong the force is depends on the spring, and this is captured by a constant K. The unit here is newton per meter.
Therefore, the force is F = -K*x(t). The spring constant multiplied by the displacement. This is then newton/meter * meter, so gives a force in newton. This works without any additional constant since we've assumed x=0 is precisely the point where the spring is relaxed, so if x = 0, then F = -K*0 = 0.
Now we apply Newton's law F = m*a. Since our only force is the spring force, that means -K*x(t) = m*a. Since acceleration is really the second derivative of position, that means -K*x(t) = m*x''(t). Or rearranged,
x''(t) = -K/m * x(t)
This is a second-order differential equation. In particular, it says that, if we take the derivative of x twice, the sign becomes negative and it's multiplied by a constant. And there's a type of function that behaves exactly like this! It's the sin and cos function. If I take the derivative of cos(x) twice, I get -cos(x). If I take the derivative of cos(w * x) twice where w is a constant, I get -w^2 * cos(x). So if I define w = sqrt(K/m), then x(t) = cos(w*t) is a solution! x''(t) = -w^2 x(t) = -K/m * x(t), just as above.
However, just cos(w*t) isn't the only function that does this. I can also multiply it by a constant, and I can shift the phase by a constant. Neither will change the behavior with respect to taking derivatives.
So a more general solution is A * cos(w*t + P), with A and P constants.
Now there's a neat result from math that says that if we have a solution with two unknowns for this differential equation, it's the only solution. (Or rather, the only family of solutions, since it's really a set for each possible value of the unknowns.) That also makes sense physically, since we had a system with one object, hence 2 pieces of information are required, and without those we have 2 unknowns Note that cos may as well be sin since we allow arbitrary shifts of phase anyway. In fact, the equation A * cos(w*t + P) can be equivalently written as C * cos(w*t) + D*sin(w*t), where C and D are two different constants. It's the same family of solutions; each one can be transformed into the other one. But A * cos(w*t + P) is prettier because it shows that it's just a single trigonometric function with arbitrary phase and amplitude.
Alas, x(t) = A * cos(w*t + P), where A and P are unknown, t is time, and w= sqrt(K/m), where K is the spring constant and m the mass of my object.
That means the solution is a periodic motion around the initial position. The block will oscillate right and left indefinitely. And the reason why it does this is because the spring force is a restoring force; it always points back into the mid point. So as the object moves right it has kinetic energy (movement energy), which is converted into potential energy (stretching the spring). Then it's converted back as the string pulls. Then it's converted into potential energy again as the object moves left. And back into kinetic (movement) energy as it accelerates right. Since the total energy is conserved, this repeats forever.
Now if I specify initial position and velocity, I can solve for A and P. But first, one takes the derivative
x(t) = A * cos(w*t + P)
x'(t) = -Aw * sin(w*t + P)
For example, say the object starts at x=0 with no velocity. Then,
0 = x'(0) = -Aw * sin(0*t + P) = -Aw * sin(P). So either A = 0 or P = 0. If A = 0, then x(t) ≡ 0. If P = 0, then
0 = x(0) = A*cos(w*0 + P) = A*cos(0) = A.
So again A = 0 and hence x(t) ≡ 0. Meaning if I my system starts at x = 0 and with no velocity, it never moves. That makes sense!
Now assume instead no initial velocity but x(0) = C is some constant. Then again, 0 = x'(0) gives A = 0 or P = 0. But
C = x(0) = A*cos(w*0 + P) = A*cos(P)
yields a contradiction if A = 0. Hence P = 0. Therefore
C = A*cos(0) = A.
So in this case, my equation is
x(t) = C * cos(w*t). So the object oscillates in a perfect cosine curve with frequency w/2pi forever. (This doesn't mean it takes the shape of a cosine curve; it only goes left and right. Rather, the cosine curve is its position relative to time. There's no Y dimension in space!)
This is the mechanism underlying pendulums, swing sets, sound, electromagnetic waves, etc. Oh btw it's also the primary mechanism behind computation in the brain. Thanks for coming to my TED talk.