We will apply
Theorem 11.9 with
\(A = \{1, \dots, x\}\) and
\(P = \{p\colon 2 \lt p \leq z\}\text{.}\) For each
\(p \in P\text{,}\) let
\(R_p\) consist of the residue classes of
\(0,-2\text{,}\) so that
\(\omega(p) = 2\text{.}\) For
\(d\) odd squarefree,
\(\omega(d) = 2^{\nu(d)}\) for
\(\nu(d)\) the number of prime factors of
\(d\text{.}\) One checks easily (exercise; see
(11.5.1)) that
\begin{equation}
\left|\#A_d - x \frac{\omega(d)}{d} \right| \leq 2^{\nu(d)}\text{.}\tag{11.5.1}
\end{equation}
Since
\begin{equation*}
\sum_{p\leq z} \frac{\log p}{p} = O(\log z)
\end{equation*}
from a prior homework, we can take
\(\kappa = 2\) in
Theorem 11.9. This yields
\begin{equation*}
S(A,P,z) = x W(z) + O \left( x \log^3 z \exp \left( - \frac{\log x}{\log z}
\right) \right)\text{,}
\end{equation*}
where the big-O constant does not depend on \(x\) or \(z\text{.}\) We now take
\begin{equation*}
\log z = \frac{\log x}{A \log \log x}
\end{equation*}
for a suitable constant \(A\text{.}\) Since
\begin{equation*}
W(z) \leq \prod_{3 \leq p \leq z} \left(1 - \frac{1}{p} \right)^2 = O((\log z)^{-2})
\end{equation*}
by
Exercise 4.5.7, we deduce that
\(S(A,P,z)= O(x(\log \log x)^2/(\log x)^2)\text{.}\)
To conclude, note that
\(S(A,P,z)\) includes all primes
\(z+2 \leq p \leq x\) such that
\(p+2\) is also prime. The number of twin primes up to
\(x\) that we missed is at most
\(z = x^{1/(A \log \log x)}\text{,}\) so this doesn’t affect the claim.