Made this question in physics stack, but maybe I'll get a better answer here.
If we apply loop rule while charging the circuit we get:
$$\varepsilon -iR-\frac{q}{C}=0$$
The way I understand, we follow through the circuit just before the battery, as we move through the circuit there is a increase in potential so \$+\varepsilon\$. Then we go through the resistor, since we are moving in the direction of the current, \$-iR\$. In the capacitor, there is a drop in potential, so \$-\frac{q}{C}\$.
The problem starts for me in the part of discharging the capacitor. Now the battery acts like part of a wire, \$\varepsilon=0\$. The top plate of the capacitor is at a higher potential. Current will flow from the top plate to the circuit in the direction of the resistor (opposite of what it was). Now loop rule would stand for (starting from just before the down plate):
$$\frac{q}{C}-iR=0$$
Because capacitor's top plate is at a higher potential, there is a increase in voltage. Loop rule is applied in the same direction of the current, so \$-iR\$.
But the equation resulted in the loop rule application when discharging a capacitor is given by:
$$\frac{q}{C}+iR=0$$
Why? What is the mistake in my reasoning? Please, help me understand. Excuse my bad english. Happy 2016.