Where did half of the capacitor charging energy go?
The problem of the "energy stored on a capacitor" is a classic one because it has some counterintuitive elements. To be sure, the battery puts out energy QVb in the process of charging the capacitor to equilibrium at battery voltage Vb. But half of that energy is dissipated in heat in the resistance of the charging pathway, and only QVb/2 is finally stored on the capacitor at equilibrium. The counter-intuitive part starts when you say "That's too much loss to tolerate. I'm just going to lower the resistance of the charging pathway so I will get more energy on the capacitor." This doesn't work, because the energy loss rate in the resistance I2R increases dramatically, even though you do charge the capacitor more rapidly. It's not at all intuitive in this exponential charging process that you will still lose half the energy into heat, so this classic problem becomes an excellent example of the value of calculus and the integral as an engineering tool.
Part of the intuitive part that goes into setting up the integral is that getting the first element of charge dq onto the capacitor plates takes much less work because most of the battery voltage is dropping across the resistance R and only a tiny energy dU = dqV is stored on the capacitor. Proceeding with the integral, which takes a quadratic form in q, gives a summed energy on the capacitor Q2/2C = CVb2/2 = QVb/2 where the Vb here is the battery voltage. So the bottom line is that you have to put out 2 joules from the battery to put 1 joule on the capacitor, the other joule having been irretrievably lost to heat - the 2nd Law of Thermodynamics bites you again, regardless of your charging rate. The non-intuitive nature of this problem is the reason that the integral approach is valuable.
Though it will not be shown here, if you proceed further with this problem by making the charging resistance so small that the initial charging current is extremely high, a sizable fraction of the charging energy is actually radiated away as electromagnetic energy. This crosses the threshold into antenna theory because not all the loss in charging was thermodynamic - but still the loss in the process was half the energy supplied by the battery in charging the capacitor.
So the energy supplied by the battery is E = CVb2, but only half that is on the capacitor - the other half has been lost to heat, or in the extremely low charging resistance case, to heat and electromagnetic energy.