I am having an embarrassingly hard time with the derivation for the potential energy of an infinitesimal element of an elastic rod of area $A$. The picture shown below is an element of the rod that has been extended by $du$ by the force $F$.
I've tried this derivation several times and have yet to obtain the factor of $\frac{1}{2}$ in
$$dU=\frac{1}{2}AY\big(\frac{du}{dx}\big)^2dx,\tag{1} $$
which is given in my lecture notes. Here is my best attempt so far: From the stress strain relation, $\sigma=Y\epsilon$, where $Y$ is Youngs modulus we obtain:
$$\frac{F}{A}=Y\frac{du}{dx}.\tag{2} $$
I asked a similar question a few days ago, and based on that response I've assumed that the work done in extending the rod element from length $dx$ to $du+dx$ is
$$dW=F\big[ (du+dx)-dx\big]\tag{3} $$
$$=YA\frac{du}{dx}du.\tag{4} $$
And I can make it look more like the answer given in my lecture notes if I divide and multiply by $dx$:
$$dW=YA\big(\frac{du}{dx}\big)^2dx.\tag{5}$$
And I am assuming that $dW=dU$ here ($F=-\frac{dU}{du} $ but forget about the negative sign)
I have tried other approaches but they make even less sense to me. A formula that I think will come in handy is the deflection at section x of a rod:
$$\delta(x)=\frac{F}{AY}x ,\tag{6}$$
and I think an integral will come in to play but I'm not sure what I'm integrating over any more (I'm dealing with an infinitesimal element of the rod). So how do I use the infinitesimal Work to find the infinitesimal change in potential energy here to get that factor of $\frac{1}{2}$ (assuming that it does in fact belong in $dU$)?