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.