Learning Scientific Programming with Python (2nd edition)

P2.5.2: The iterative weak acid approximation

Question P2.5.2

The iterative weak acid approximation determines the hydrogen ion concentration, $[\mathrm{H^+}]$ of an acid solution from the acid dissociation constant, $K_a$, and the acid concentration, $c$, by succesive application of the formula $$ [\mathrm{H^+}]_{n+1} = \sqrt{K_a\left( c - [\mathrm{H^+}]_n \right)}, $$ starting with $[\mathrm{H^+}]_0 = 0$. The iterations are continued until $[\mathrm{H^+}]$ changes by less than some pre-determined, small tolerance value.

Use this method to determine the hydrogen ion concentration, and hence the pH ($=-\log_{10}[\mathrm{H^+}]$) of a $c=0.01\;\mathrm{M}$ solution of acetic acid ($K_a = 1.78 \times 10^{-5}$). Use the tolerance TOL = 1.e-10.