Magnetization and Demagnetization of an Inductor when we apply the AC voltage to an Inductor the Average power over a complete cycle is zero. the figure in my book explains it. but I couldn't understand it, I could have directly asked the question but giving the reference may help you to give me the right concept which i need. I understand the theory but the last line of every para which indicates the sign of the product and with the help of that predicting the energy flow is exactly what I couldn't get. can you please help me with the formula and concept i am missing to know the direction of flow of energy.

 A: In circuit theory, the power absorbed by a branch of the circuit (a two-terminal device, or one branch of a multi-terminal device) is given by
$$P=IV$$
But we have to be careful about how we define terms to get this right. 
If current is flowing in to the terminal with the more positive voltage, then the device is absorbing power (generally, converting electric energy to some other form). If current is flowing in to the terminal with the more negative voltage, then the device is generating power (generally, converting some other kind of energy into electric energy).
To make sure we keep things straight, we normally use the passive current convention. This means we label the two terminals of each device with "+" and "-", and we consider the current through the device to be positive when it goes in to the "+" terminal, or negative when it goes in to the "-" terminal. Similarly, we consider the voltage applied to the device to be positive when the "+" terminal is at a higher potential than the "-" terminal, and negative when it's the other way around. 
For example, with a resistor, we have Ohm's law:
$$I=V/R$$
And we see that current always flows in to the more positive terminal.
For a battery powering the rest of the circuit, we expect current to come out of the positive terminal and return to the negative terminal. But current flows the opposite way when we re-charge the battery.
In the case of an inductor in an AC circuit, we see that when current is at its most positive (flowing in to the "+" terminal) voltage is just passing through 0.  Then current starts dropping, but is still positive as voltage goes negative (because $L\frac{\rm{d}i(t)}{\rm{d}t}=v(t)$). In this part of the cycle the power is negative (because $i>0$ and $v<0$), so the device is delivering energy to the rest of the circuit. In the next part of the cycle, $i<0$ and $v<0$ (but increasing), so power is positive --- the rest of the circuit is delivering power to the inductor, and it is storing the received energy in its magnetic field. In the next quarter-cycle, $i<0$ and $v>0$, so the power is negative; now the inductor is returning energy to the circuit again. Finally, in the fourth quarter cycle, $i>0$ and $v>0$, so power absorbed by the inductor is positive, it is converting electric energy to magnetic energy again.
