Work done by spring over distance

I'm working through a problem involving energy conservation. Unfortunately, I cannot calculate the work done by a spring.

Before:

+------------+
|            |
|  spring    | d1
|            |
+------------+

After:

+------------+
|            |
|  spring    |
|            | d2
|            |
|            |
+------------+


Given the spring constant, d1, and d2, how can I determine the work done? Also, please explain how the formula was calculated instead of just posting an answer.

-
This question teeters on the edge of too much like a particular exercise (which would not be acceptable) and a nice concept driven problem (which would be acceptable). Perspective responders are encouraged to elaborate on the conceptual structure that leads to the answer. –  dmckee Jan 21 '12 at 2:20
Some question that might help responders pitch ther answer at the right level include "Are you familiar with the work energy theorem?" and "Do you know the force exerted by the spring at a particular value of $d$?", and if the answer to both the above questions is yes, "Where are you getting stuck in setting up or solving the math?". –  dmckee Jan 21 '12 at 2:23
I'm leaning toward seeing this as general enough to be a conceptual question, not a specific homework problem. It's basically asking about the derivation of a common formula. Although the answers to the questions you've posed will definitely help clarify that. xaav, it'd be great if you can edit that information into your question. –  David Z Jan 21 '12 at 3:25
I am sorry for phrasing the question incorrectly. I am new to this particular stack exchange site and will try to phrase the question more conceptually next time. –  xaav Jan 21 '12 at 21:55

You know the basic spring equation, right? $F = xK$, where $K$ is the spring constant, in units of force per distance. You also know work (energy) is force times distance, right?

So all you've got to do is integrate $xK dx$ from d1 to d2. (Hint, you can pull $K$ out of the integral.)

You could do it on graph paper if you happened to know d1 and d2.

ADDED: OK, here's the graph paper approach: A graph of Force $F$ versus displacement $x$ looks like this, right?

  |       /
|      /
|     /
F |    /
|   /
|  /
| /
|/_______
x


The slope of the graph is $K$. The area under the graph is work $W$, because it is just the sum of a bunch of vertical slivers with area $F$ times the width $dx$ of each sliver.

  |       /|
|      / |
|     /  |
F |    /   |
|   /|  <---- just get the area of this piece
|  / |   |
| /  |   |
|/___|___|
d1  d2


That help?

-
Thanks for the graphical answer; it really helped explain the problem. –  xaav Jan 21 '12 at 22:02

Work is defined as

$$W=\int_{x_1}^{x_2}\mathbf{F} \cdot d \mathbf{x}$$

The force exerted by a spring is

$$\mathbf{F}=-k\mathbf{x}$$

where $\mathbf{x}$ is the distance from the equilibrium point of the spring.

Plugging the first equation into the second yeilds:

$$\begin{eqnarray} W&=&\int_{x_1}^{x_2}-k\mathbf{x} \cdot d \mathbf{x} \\ &=&\frac{1}{2}kx_1^2-\frac{1}{2}kx_2^2 \end{eqnarray}$$

-
I appreciate your answer, but the first one was explained more conceptually. –  xaav Jan 21 '12 at 21:57