y(t) = A cos(ωt + ϕ)

\begin{aligned}v(t) & = \frac{dy}{dt} \\ & = −ωA sin(ωt + ϕ) \end{aligned}

\begin{aligned}a(t) & = \frac{dv}{dt} \\ & = −ω^{2}A cos(ωt + ϕ) \end{aligned}

KE = \frac{1}{2}mv^{2}

KE = \frac{1}{2}mω^{2}A^{2} sin^{2}(ωt + ϕ)

PE = \frac{1}{2}k(y − y_{eq})^{2}

= \frac{1}{2}ky^{2} , if we choose y_{eq} = 0

PE = \frac{1}{2}kA^{2} cos^{2}(ωt + ϕ)