Fundamental solution set to x''[t] + 4 x[t] == 0:

x1[t_]:=Cos[2t];
x2[t_]:=Sin[2t];

Apply Method of Variation of Parameters to generate particular solution to x''[t] + 4 x[t] == Cos[omega t] :

Clear[omega];
W[t_]:=x1[t]x2'[t]-x1'[t]x2[t]; (* Wronskian *)
f[t_]:=Cos[omega t]; (* forcing function *)
Simplify[-x1[t]Integrate[x2[t]f[ t]/W[t],t]+x2[t]Integrate[x1[t]f[ t]/W[t],t]]

x[t_]:=((Cos[omega t])/(4-(omega^2)))+c1 x1[t]+c2 x2[t]

csol=Solve[{x[0]==0,x'[0]==0},{c1,c2}]

Manipulate[Plot[x[t]/.csol/.{omega->w},{t,0,100},PlotStyle->Black],{w,1,1.99}] (* evaluate the cells above for this to work *)

If we let the forcing frequency equal 1, which is half the natural frequency, we get a combination of high and low frequencies in the vibrations :

omega=1;
Plot[x[t]/.csol,{t,0,100},PlotStyle->Black]

If we let the forcing frequency equal 1.9, which is close to the natural frequency, we see the phenomenon of beats.  When the oscillations due to each frequency drift close to each other, they add up to yield a large amplitude, and when they drift apart (antiphase) they cancel each other out.

omega=1.9;
Plot[x[t]/.csol,{t,0,100},PlotStyle->Black]

Now let the forcing frequency equal the natural frequency.  Note that we get an amplitude growing linearly in time due to the term t*Sin[2t]:

omega=2;
Simplify[-x1[t]Integrate[x2[t]Cos[omega t]/W[t],t]+x2[t]Integrate[x1[t]Cos[omega t]/W[t],t]]

x[t_]:=(1/16) (Cos[2 t]+4 t Sin[2 t])+c1 x1[t]+c2 x2[t];

csol=Solve[{x[0]==0,x'[0]==0},{c1,c2}]

omega=2;
Plot[x[t]/.csol,{t,0,100},PlotStyle->Black]

If we add damping, we don't see amplitudes growing unbounded in time like in the above graph, but we do find a range of frequencies that yield much larger amplitude of vibrations than other frequencies.  When designing a structure, engineers use elasticity theory to estimate this range of dangerous vibrations and attempt to adjust it so it doesn't contain frequencies found in the environment (due to wind, earthquakes, movement of large groups of people, and so on).

Clear[x,omega];
m=1;b=2;k=8;
Solve[m r^2+b r+k==0,r]
xsol=Simplify[DSolve[{m x''[t]+b x'[t]+k x[t]==Cos[omega t],x[0]==0,x'[0]==0},x[t],t]]

Below we find the amplitude of the part of the solution due to the forcing function (the part involving the fundamental solution set decays to zero like Exp[-t], as seen above in the eigenvalues of this damped system).

x[t_]:=A Cos[omega t]+B Sin[omega t];
m x''[t]+b x'[t]+k x[t]==0

ABsol=Solve[{1==2 B omega-A omega^2+8 A,0==-2A omega-B omega^2+8B},{A,B}]

Amplitude=Sqrt[A^2+B^2]/.ABsol;

Plot[Amplitude,{omega,0,15},AxesOrigin->{0,0},AxesLabel->{omega,amplitude}]

The amplitude peaks in a range around the natural frequency Sqrt[7].  We can find the frequency omega corresponding to the largest response of the system:

dAmpl=D[Amplitude,omega];
FindRoot[dAmpl==0,{omega,2.5}]

We can compare the response of the damped system to a harmless frequency like omega=10 (in blue) to the response of the system to the more dangerous frequency omega=2.45 (in red; dangerous in the sense that these larger amplitude vibrations may surpass the safety limit of vibrations that the structure can tolerate).

Plot[{x[t]/.xsol/.omega->10,x[t]/.xsol/.omega->2.45},{t,0,10},PlotStyle->{Blue,Red},PlotRange->All]

For real life examples of resonance occurring in structures, go to YouTube and search for "Tacoma Narrows" and for "London Millenium Bridge Opening" (http://www.youtube.com/watch?v=gQK21572oSU). These examples show why marching troops are ordered to break step when crossing bridges.