Discuss the principle of conservation of energy in mechanical systems. How does this principle apply to the analysis of a simple harmonic oscillator, such as a mass-spring system?