This should clear it up for you...
http://math.stackexchange.com/questions/543655/using-hookes-law-to-find-the-work-required-to-stretch-a-spring
A force of 4 pounds is required to hold a spring stretched 0.1 feet beyond its natural length. How much work (in foot-pounds) is done in stretching the spring from its natural length to 0.6 feet beyond its natural length?
2 answers
F = k x
4 = k (.1)
k = 40 pounds/foot
Energy = Work = (1/2) k x^2
= (1/2)(40)(.6)^2 foot pounds
to get that with calculus
work in = F dx
= k x dx
= k x^2/2 + constant
if W = 0 when x = 0 than the constant is 0
so
W = (1/2) k x^2
4 = k (.1)
k = 40 pounds/foot
Energy = Work = (1/2) k x^2
= (1/2)(40)(.6)^2 foot pounds
to get that with calculus
work in = F dx
= k x dx
= k x^2/2 + constant
if W = 0 when x = 0 than the constant is 0
so
W = (1/2) k x^2