When a weak acid is very dilute, it is necessary to take into account the autoionization of water. We are going to write the two equilibria that take place in solution:
$H_2O + H_2O \rightleftharpoons H_3O^+ + OH^-$
$HA +H_2O\rightleftharpoons H_3O^+ + A^-$
M-y y y
Both M, x and y are expressed in molarity. It must be taken into account that the concentration of protons in the medium is given by x+y.
We write the equilibrium constants:
Solving x from the equation of $K_a$:
Replacing these values in the $K_w$:
The value of y is obtained by solving the equation by the method of successive approximations.
Once y is obtained, its value is replaced in the equation of x. The sum x+y gives us the $[H_3O^+]$ and therefore the pH of the dilute weak acid solution.