Dynamics of a Vertical Mass-Spring Simple Harmonic Oscillator with Gravity I am having some trouble obtaining the elastic potential energy and gravitational potential energy of a simple mass spring system.
In this experiment, masses attached to a spring were dropped from a position in which the spring had not be extended. For example, the 20g mass had an equilibrium position of $y=-34.00cm$ and  it reached a maximum vertical displacement of $y=-35.83cm$.
Based on this, I found the amplitude of oscillation to be $17.92cm$
Then, using the spring constant and the mass, I determined the natural frequency:
$\omega=21.21 rad{\cdot}s^{-1}$
I was able to create the following inital value problem:
$$y(t)=c_{1}\cos({\omega}t) + c_{2}\sin({\omega}t)$$
$$y(0)=0$$ 
$$A=17.92\times 10^{-3}m$$
I solved it by To begin the solution considering the case $y=0$:
$$y(t)=c_{1}cos(({\omega})(0)) + c_{2}sin(({\omega})(0))$$
$$y(0)=c_{1}$$
$$0=c_{1}$$
Now, I used the amplitude to determine that $c_{2}=17.91\times 10^{-3}$
Skipping a few simple steps, I created to the following function:
$$y(t)=17.92\times 10^{-2}\cos(21.21t)-17.92\times 10^{-2}$$

Now, onto the elastic potential energy, 
$$E_{e}=\frac{k\times y(t)^2}{2}$$
$$E_{e}=\frac{(9)(17.92\times 10^{-2}\cos(21.21t)-17.92\times 10^{-3})^2}{2}$$
$$E_{e}=0.15-0.29 \cos(21.21 t)+0.14 \cos^2(21.21 t)$$
This function does not at all resemble what it should look like, a simple periodic function.
I have a feeling that my problem is due to my assigned coordinate system.
Any help at all would be immensely appreciated.
 A: You should try to express the solution as (check that it is a solution of the harmonic oscillator equation)
$$y(t)=A \cos(\omega t+\phi) $$
where $A$ is the amplitude and $\phi$ is the initial phase. Let $t=0$ so 
$$y(0)=A\cos(\phi) \rightarrow \cos(\phi)=\frac{y(0)}{A}$$
can you continue from here?
A: I am a little confused as to how you found your amplitude of oscillation. The amplitude is the maximum distance from the equilibrium position. If you say that the equilibrium position is $-34.00$cm, and the maximum vertical displacement is $-35.83$cm, then the amplitude is $1.83$cm.
It appears that you are confusing $y$, the height you measured from some arbitrary point (like the table, or the ground), with the distance from the equilibrium height, $x = y - y_{eq}$. Your working is also suspect. In your derivation you say $0 = c_1$, yet in the next line you say $c_1 = 1.791 \times 10^{-3}$. You should recheck and make sure everything you do makes sense.
Anyway, to answer your question about the potential energy not being a 'simple periodic function', it does not satisfy the same simple harmonic equation $d^2x/dt^2 = - \omega^2 x$that the distance from the equilibrium point does.  However, it Is still periodic, but with half the period, or twice the frequency, $2\omega$. 
