Potential Energy for spring
?PEspring = -si?s Fspring? ds where Fspring = -kx
Recall that the minus sign in the PE equation comes from the fact that to store energy, we need to provide a force opposite that of the spring. This relation then gives:
?PEspring = -si?s -kx dx = ½kx2 - ½kxi2
If we choose xi to be the equilibrium position and call this zero, then we have:
Note that this PE does depend on position (x).