About power dissipation of capacitors and inductors & I-V phase difference

For instance, The Art of Electronics (by Horowitz & Hill) states that

ideal capacitors cannot dissipate power, even though current can flow through them, because the voltage and current are 90° out of phase.

This reasoning has always baffled me since $$\\small P = V \cdot I\$$ and if we consider multiplying two sinewaves that are 90° out of phase, the resulting wave is not a flat zero line.

The fact that ideal capacitors and inductors store the power (later releasing it) seems to explain the phenomenon and make a lot of sense, but the phase explanation seems be the more common one.

As I see it the current "leading" the voltage across a capacitor is pretty easy to understand somewhat intuitively, but if the power dissipation would depend on it, both capacitors and inductors would instead dissipate half the power compared to resistors (assuming alternating voltage/current of course).

So, am I just getting something totally wrong or is the out-of-phase explanation flawed?

edit:

I finally found the error in my own reasoning. I somehow thought that multiplying two identical sinewaves with each other would result a wave that would be centered on the same axis as the original ones ie. also having positive and negative values. But with in-phase sinewaves the negative values of course line up and result in only positive values. Only when the waves (functions) are exactly 90 degrees out of phase is their product centered on zero axis and thus "spends" as much time on the negative side as on the positive.

• In which element would the power dissipate? In a DC circuit, you can charge an ideal capacitor with constant current to store energy, Q=C•V=I•t, and end up with some voltage. You can also discharge the capacitor with constant current down to zero volts and based on the formula you get exact same amount of energy out as there is nothing like a resistance in the ideal capacitor that would create losses or convert power to heat such as a resistor. Jan 14 at 23:37
• @Justme As I said, I have no problem understanding the mechanism nor do I think that an ideal capacitor should dissipate the energy. What I don't understand is how the phase differences are affecting the dissipation (or lack of it). Jan 15 at 3:18

If the voltage across a capacitor is described as sin(x), then the current through the capacitor (being 90 degrees out of phase) can be described as cos(x). The power is given by the product of voltage and current. For a capacitor, this is proportional to sin (x)*cos(x). This product is given by sin(2x)/2 which is a sine wave. Thus it is positive for half the time and negative for half the time. This means that power goes into the capacitor half the time (stored in the electric field) and that same power is released back to the circuit during the other half. The net power dissipated in the capacitor is zero.

• In terms of both power and energy, this means that power goes into the capacitor half the time (storing energy in the electric field) and that energy is returned back to the circuit reversing the power direction during the other half. Jan 15 at 0:26
• I was going to argue that the same happens with a resistor when it hit me and I finally found the error in my own reasoning. I somehow thought that multiplying two identical sinewaves with each other would result in a wave that would be centered on the same axis as the original ones ie. also having positive and negative values. But with in-phase sinewaves the negative values of course line up and result in only poistive values. Jan 15 at 3:57