The equation of motion of the ball is
m(¨x+ω20x)=F0cosωt
This equation has the solution
x=Acos(ω0t+α)+Bcosωt
where A and α arte arbitrary and B is obtained by substitution in the above equation
B=F0/mω20−ω2
The conditions x=0,˙x=0 at t=0 give
Acosα+F0/mω20−ω2=0 and −ω0Asinα=0
This gives α=0, A=−F0/mω20−ω2=F0/mω20−ω2
Finally x=F0/mω20−ω2(cosω0t−cosωt)