How come the formula $W=Fd$ doesn't apply for energy stored in springs? I always thought that work is like the energy transferred and it is given by $W=Fd$, but this concept gets problematic for springs.
If the force $F$ is applied to a spring which compresses it by a length $d$, then apparently the energy stored in the spring is $$E_{p}=\frac{1}{2}kd^2=\frac{Fd}{2}$$
Why is the energy transferred to the spring not $Fd$?
 A: Because $W = Fd$ only holds for a very special case. The general definition of work
is given via
$$W = \int_\gamma \vec F (\vec r) \cdot \text{d}\vec r$$
where $\gamma$ represents a trajectory in $\mathbb{R}^3$ and $\vec F (\vec r )$ represents a vector field.
The case where $W=Fd$ holds is when $\vec F (\vec r)$ is constant over all space and the trajectory is parallel to the force. For example when pulling a stone of mass $m$ to height $d$ in a straight line along the $z$-axis we get
$$
W = \int_\gamma \vec F (\vec r) \cdot \text{d}\vec r = \int_0^d mg\ \text d z = mgd\ \hat{=}\ Fd.
$$
But the force when pushing or pulling a spring is proportional to how much you pulled it - it depends on the position. So we see when elongating a spring by a length $l$ along the $x$-axis we get
$$W = \int_\gamma \vec F (\vec r) \cdot \text{d}\vec r = \int_0 ^l kx\ \text d x = \frac 1 2 k l^2\ \hat{=}\ \frac{F(l)\,l} 2
$$
Note: The signs depends on the system you look at, so for certain systems you would have a minus sign with the force.
A: I think that this question shows a misunderstanding of calculus rather than that of the
physics.
For constant forces, the work is defined as:
$$ W = F \cdot s$$
For applying this to calculate work of variable forces
Consider an interval of extension $(x_o, x_o+h)$, if we were to shrink the size of $h$ to become very small, then we can say that the force is more or less constant over this interval under consideration, and hence we can apply the definition of work for constant force:
$$ \Delta W = F \Delta h$$
Shrinking $h$ to zero and summing this quantity over all such intervals possible from $x_o$ to $x_{f}$, where $x_f$ is the final displacement, we get the work by an integral::
$$ W = \int_{x_o}^{x_f} F dh$$
