Elastic potential energy in spring [closed]

We generate the formula from $W=Fs$, but why is it when we form the formula the $F$ becomes the average force applied, making the equation

$$W=(1/2)(0+F)x \, ?$$

closed as off-topic by Cosmas Zachos, Jon Custer, honeste_vivere, Ryan Unger, YashasJul 23 '17 at 2:10

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Homework-like questions should ask about a specific physics concept and show some effort to work through the problem. We want our questions to be useful to the broader community, and to future users. See our meta site for more guidance on how to edit your question to make it better" – Jon Custer, honeste_vivere, Yashas
If this question can be reworded to fit the rules in the help center, please edit the question.

Because the force applied changes with $x$.
Note that Hookes Law for springs is: $$F = k \Delta x$$
This means that in the $W = F s$ equation, we cannot directly use it because $F$ is not constant throughout the entire $\Delta x$ movement.