Condition for resonance In my physics courses, we are now primarily treating oscillations in exponential form. When we dealt with oscillating circuits, the lecturer said that resonance was reached when the imaginary part of the impedance was zero, ie. when the current and the voltage are in phase in the circuit. However, I remember from our mechanical oscillations course that the driving force and displacement were out of phase at resonance. How comes that the mechanical-electrical analogy doesn't seem to work here? 
 A: You are describing two different types of resonances.  
In the mechanical case it is usually most convenient to measure displacement and hence amplitude as a function of frequency.
At frequencies a long way away from resonance the displacement of the driver driver and the displacement of the driven system are approximately in phase.
As the frequency of the driver is increased the driven system starts to lag behind and at resonance the driven system is $\frac\pi 2$ behind the driver.
At even higher frequencies the phase lag of the driven system relative to the driver tends towards $\pi$.  
In the electrical case for an LCR series circuit it is the the current which is measured as a function of the frequency.
In such a system at low frequencies the voltage leads the current by $\frac\pi 2$.
As the frequency is increased that current lag is reduced to become zero at current resonance and then tend to the voltage leading the current by $\frac\pi 2$ at frequencies well above the resonant frequency.  
The mechanical analogue of electrical current is velocity and of charge is displacement. 
 Velocity (current) leads the displacement (charge) by $\frac\pi 2$ and this is the reason for the the difference in phase at amplitude resonance for the mechanical case and current (velocity) resonance for the electrical case.
