# Homework Help: Solving a spring question using calculus

1. Oct 19, 2012

### docholliday

1. A block of mass 0.3 kg and spring constant 24 N/m is on a frictionless surface. If the block is set into motion when compressed 3.5 cm, what is the maximum velocity of the block? How much is the spring compressed when the block has a velocity of 0.19 m/s?

2. Relevant equations
I found this problem on a previous thread and I solved it using the law of conservation and got .027816 m or 2.7 cm.
However, someone mentioned on the thread it can be solved using calculus. I get I'd have to double integrate the acceleration, but I don't know the time.

3. Attempt
a = -kx(t)/m where
How do I go about integrating that with respect to time, I know final velocity but I don't understand how to do it without knowing the displacement function so I can integrate x(t), since -k/m is a constant.

2. Oct 19, 2012

### cepheid

Staff Emeritus
Welcome to PF, docholliday!

You can't solve the problem through simple integration, it's slightly (only slightly) more complicated than that. As you know, the definition of velocity is the derivative of position with respect to time: v(t) = dx/dt, where position x(t) is a function of time. Similarly, the definition of acceleration is that it is the derivative of velocity: a(t) = dv/dt. Therefore$$a = \frac{d}{dt}\left(\frac{dx}{dt}\right)= \frac{d^2x}{dt^2}$$So acceleration is the second derivative of position with respect to time. Okay, that's all well and good (I'm sure you already knew that), but what can we do with it? Well, start with Newton's second law. In this case, the spring restoring force is the only force that acts on the mass, so we have:

ma = -kx$$m\frac{d^2x}{dt^2} = -kx$$ $$\frac{d^2x}{dt^2} = -\frac{k}{m}x$$This is called the equation of motion for the system, because it is the equation that, when solved, tells you the object's trajectory as a function of time (provided you know its position and speed at some initial time). This is an example of a type of equation called a differential equation. Differential equations are a topic in calculus slightly beyond what's covered in introductory calc. A differential equation is an equation that expresses a relationship between a function and one or more of its derivatives. As you pointed out in your original post, you don't know what the function x(t) is. In fact, what you have to do here is find a function x(t) that satisfies the above equation. That's what it means to "solve" the differential equation. In this case, it's what's called a second-order equation, because the highest-order derivative that appears is a second derivative. In fact, this equation says that the second derivative of the function is proportional to the negative of the function itself. Now, there are many advanced techniques for solving differential equations, but fortunately, we don't need any of them here, because we can find a solution just by guessing. Think about it: what's a function x(t) whose second derivative is equal to the negative of itself? Well, if you think about it, a sine function works, because if you differentiate it once, you get a cosine, and then if differentiate that again, you get negative sine. A cosine function would also work. Furthermore, this is what's called a linear differential equation, which means it has the property that any linear combination of solutions is also a solution. Therefore, the most general form of the solution to this equation is:$$x(t) = A\sin(\omega t) + B\cos(\omega t)$$ where the solutions are oscillating functions (sinusoids), and ω is the angular frequency of the oscillation. If you don't believe me that this is a solution, I encourage you try it out by plugging it back into the differential equation. If you differentiate this x(t) twice, you'll get the result that$$\frac{d^2x}{dt^2} = -\omega^2 x$$which is exactly the same as the original differential equation, provided that $\omega = \sqrt{k/m}$ (which is a result for the frequency of oscillation of a spring that you've no doubt seen before ). So, the solutions to this equation are oscillatory functions: the position of the mass on the end of the spring oscillates with time with simple harmonic motion. In other words, this equation of motion (x'' = -(const)*x) is the one that describes a simple harmonic oscillator. Now, the solution I've given above isn't a specific function, but rather a whole family of functions, because we still have the arbitrary constants A and B that describe the amplitude and phase of the resulting sinusoidal function. How can we figure out what A and B are? Well, if you think about it, what would you need to know about the spring mass system in question in order to figure out the amplitude and phase of its oscillation? You'd need to know where the mass was, and how fast it was moving, initially. In other words, you need to know the initial conditions of the system. To get a unique solution for a differential equation of this type you need initial conditions. For a second-order equation, you need two initial conditions: you need to know the initial value of the function x(0), and the initial value of the first derivative x'(0). In other words, to get a specific solution with a specific amplitude and phase, you need to know where the mass was and how fast it was moving at t = 0.

For example, suppose the mass started off at the position corresponding to the equilibrium position of the spring (neither stretched nor compressed): x(0) = 0. Then, plugging that into the solution above for t = 0, we get:

x(0) = Asin(0) + Bcos(0) = 0 cm

The sine of 0 is already 0, but in order for this to be equal to 0 entirely, the cosine term must also vanish. But cos(0) = 1, so the only way the cos term can be zero is if B = 0, in which case the solution is x(t) = Asin(ωt). This makes sense if you think about it: a pure sine wave has a phase such that it starts off with a value of 0 at t = 0, corresponding to our initial condition. Now, how do we solve for the amplitude, A? Well, for this, we need another initial condition. We need to know the velocity of the mass at t=0. If it is also 0 i.e. if x'(0) = 0, then we have:

x'(0) = ωAcos(0) = 0

But cos(0) ≠ 0, so the only way this initial condition could also be satisfied was if A was also 0, leading to a solution of x(t) = 0 at all times. This is the *trivial* solution to the differential equation, where x is identically zero. If the spring is initially neither compressed nor stretched, and the mass is not initially moving, then the mass will just sit there in the same place forever. A more interesting case is where the mass has some initial velocity v0 in which case, we have x'(0) = ωAcos(0) = v0. Therefore A = v0/ω, and x(t) = (v0/ω)sin(ωt). The amplitude of the motion is determined by how fast the mass is initially moving, which also makes perfect sense.

Let's consider a second example, where the initial conditions are such that x(0) = x0, but x'(0) = 0. So, this time, it's the initial velocity that is zero, but the initial positon is non-zero, because the spring happens to start out with some initial extension. Then, applying the initial conditions, we have:

x(0) = Asin(0) + Bcos(0) = x0

Bcos(0) = B = x0

Applying the initial condition for the first derivative, we just have:

x'(0) = ωAcos(0) -ωBsin(0) = 0

ωA = 0

A = 0

So this, time A = 0 and B = x0, and the solution is x(t) = x0cos(ωt). The amplitude (maximum extent) of the motion is determined by the initial extension of the spring. This makes perfect sense, because a pure cosine wave is one whose phase is such that it starts off at its maximum value and decreases from there.

In the most general case where the mass is somewhere away from the origin, moving with some non-zero speed, so that neither of the initial conditions is zero, but rather x(0) = x0, and x'(0) = v0, it will turn out that A and B are both non-zero. So the phase of the solution will be somewhere in between that of a pure sine wave and that of a pure cosine wave in that case.

I hope this has served as an adequate crash course in differential equations, and has helped illuminate some of the properties of simple harmonic oscillators!

Last edited: Oct 19, 2012
3. Oct 19, 2012

### cepheid

Staff Emeritus
I think it would also be instructive to apply this to your specific example. Here, the spring is compressed to and held at -3.5 cm, and then released. So the initial conditions are x0 = -3.5 cm, and v0 = 0. Therefore, the position as a function of time is given by:

x(t) = x0cos(ωt)

x'(t) = v(t) = -x0ωsin(ωt)

Just solve for the time t when v(t) = 0.19 m/s:

0.19 m/s = -x0ωsin(ωt)

t = (1/ω)arcsin[ -(0.19 m/s)/ { ( -0.035 m)*(√(24 N/m)/(0.3 kg)) } ]

I get t = 0.0729176721 s

Plugging this into the equation for x(t):

x( 0.0729176721 s) =-(0.035 m)cos((√(24 N/m)/(0.3 kg)) * 0.0729176721 s )

= -2.78163621 cm