I am learning about RC transient responses and if a charged capacitor is connected to a single resistor, its voltage will decrease exponentially. I understand this and how its equation is derived. I also understand how the energy stored in a capacitor is obtained.

So, given an infinite amount of time, all of the energy will be dissipated in the resistor. I would like to prove that the integral of p(t)dt between 0 and infinity is equal to 0.5CV₀². I've tried substituting in i²(t)R for p(t) and then equating i to -Cdv(t)/dt but I end up with something that isn't even an integral anymore, namely of the form RC²∫dv(t)/dt between 0 and infinity.

What sort of substitution should I make to allow this to be integrated? Thank you for reading.