We have that the spring is going to have a sin or a cos equation. We have that the maximum distance of the spring is 6 inches and it is achieved at t=0. Let's fix this as the positive edge. Until now, we have that the function is of the form:
6sin(at+B). We have that the period is 4 minutes and hence that the time component in the equation needs to make a period (2pi) in 4 minutes. Thus 4min*a=2p, a=2p/4=pi/2. In general, a=2pi/T where a is this coefficient, T is the period. Finally, for B, since sin(pi/2)=1, we have that B=pi/2 because when t=0, we have that 6sin(B)=6. Substituting, we have f(t)=6sin(pi*t/2+pi/2)=6cos(pi*t/2)
by trigonometric identities.