For the circuit shown in the figure, the switch S is initially open and the capacitor is uncharged. The switch is then closed at time t = 0. How many seconds after closing the switch will the energy stored in the capacitor be equal to 50.2 mJ?

Hi there!
To start, we can use the equation for the charge of a capacitor versus time.
[tex]q(t) = C\epsilon (1 - e^{-\frac{t}{\tau}})[/tex]
[tex]q(t)[/tex] = Charge on capacitor vs. time
[tex]\epsilon[/tex] = EMF of battery (40 V)
**Note: 'Cε' is equal to the MAXIMUM CHARGE on a capacitor.
Where the time constant is given as:
[tex]\tau = RC[/tex]
[tex]\tau[/tex] = Time Constant (s)
[tex]R[/tex] = Resistance (0.5 MΩ)
[tex]C[/tex] = Capacitance (90 μF)
Let's first convert the given units to the necessary 'J', 'Ω' and 'F' to make things easier:
[tex]J = 50.2 mJ[/tex]
[tex]50.2 mJ * \frac{0.001J}{1mJ} = 0.0502 J[/tex]
[tex]R = 0.5 M\Omega\\\\0.5M\Ohm * \frac{1000000\Omega}{1M\Ohm} = 500000\Omega[/tex]
[tex]F = 90 \mu F[/tex]
[tex]90 \mu F * \frac{0.000001 F}{1\mu F} = 0.00009 F[/tex]
Now, let's calculate the time constant.
[tex]\tau = RC = (500000)(0.00009) = 45 s[/tex]
Time to use the equation for energy stored in a capacitor:
[tex]E_C = \frac{1}{2}\frac{Q^2}{C}[/tex]
Our 'Q' varies with time, so:
[tex]E(t)= \frac{1}{2}\frac{( C\epsilon (1 - e^{-\frac{t}{\tau}}))^2}{C}\\\\E(t) = \frac{1}{2}\frac{( C^2\epsilon^2 (1 - e^{-\frac{t}{\tau}})^2)}{C}\\\\E(t) = \frac{1}{2}( C\epsilon^2 (1 - e^{-\frac{t}{\tau}})^2)[/tex]
Let's now plug values into our equation.
[tex]0.0502 = \frac{1}{2}(0.00009)(40^2) (1 - e^{-\frac{t}{45}})^2[/tex]
Simplifying:
[tex]0.697 = (1 - e^{-\frac{t}{45}})^2[/tex]
Take the square root of both sides.
[tex]0.835 = 1 - e^{-\frac{t}{45}}\\\\ e^{-\frac{t}{45}} = 0.165[/tex]
Take the natural log of both sides.
[tex]-\frac{t}{45} = ln(0.165) \\\\\frac{t}{45} = 1.802\\\\t = \boxed{81.08 s}[/tex]