# Why is work done in a spring positive?

We know that a stretched spring obeys Hooke's law, such that $F=-kx$
We can find the potential energy of stretching/compressing this spring by x, given by :
${U}_{x}-{U}_{0}=-{\int }_{0}^{x}F.dx=\frac{1}{2}k{x}^{2}$
Setting ${U}_{0}=0$ as reference, we have ${U}_{x}=\frac{1}{2}k{x}^{2}$
However, this is also sometimes described as the work done by the spring.
Shouldn't the work done W be given by $\int F.dr$, such that $W=-\mathrm{\Delta }U=-\frac{1}{2}k{x}^{2}$ in this case ?
Isn't the work done by the spring negative ?
Also, in this case the potential energy comes to be negative.. In general, can we set any point as reference and set it to be 0 and perform the integral between any two limits, to get either a positive or a negative U ?
For example, in forces of the nature ${r}^{-n},\left(n>1\right)$ we usually take the reference at $r=\mathrm{\infty }$ and integrate from $\mathrm{\infty }$ to some point r. In case of forces of the nature ${r}^{n}$, we usually take 0 as the reference and integrate from 0 to some r. In general, we are free to choose any reference and any limit, even though some are much more convenient, right ? In theory, we can choose any point, right ?
As long as we have :
${U}_{a}-{U}_{b}=-{\int }_{b}^{a}F.dx$
we can choose any a and b, and set either of ${U}_{a}$ or ${U}_{b}$ to be the reference and equal to 0, right ?
You can still ask an expert for help

• Questions are typically answered in as fast as 30 minutes

Solve your problem for the price of one coffee

• Math expert for every subject
• Pay only if we can solve it

pagellera10
Setting x=0 as the reference point means you are looking at the work done by the spring from x=0 to the end position x. Since $W=-\mathrm{\Delta }U=-\frac{1}{2}k{x}^{2}$, this will always be negative, which makes sense since the spring force always points towards x=0, and thus will point opposite the displacement.
In general
${W}_{a\to b}=-\left(U\left({x}_{b}\right)-U\left({x}_{a}\right)\right)=\frac{1}{2}k\left({x}_{a}^{2}-{x}_{b}^{2}\right)$
and this is positive whenever ${x}_{a}^{2}>{x}_{b}^{2}$