[step:Derive the partial summation identities relating $\vartheta$ and $\pi$]For $x \geq 2$, the functions $\pi$ and $\vartheta$ satisfy the following identities. Throughout the rest of the proof, $\mathcal{L}^1$ denotes one-dimensional Lebesgue measure on $\mathbb{R}$.
\begin{align*}
\vartheta(x)
&= \pi(x)\log x - \int_2^x \frac{\pi(t)}{t}\,d\mathcal{L}^1(t),
\end{align*}
and
\begin{align*}
\pi(x)
&= \frac{\vartheta(x)}{\log x}
+ \int_2^x \frac{\vartheta(t)}{t(\log t)^2}\,d\mathcal{L}^1(t).
\end{align*}
We verify the first identity. Let $p_1 < p_2 < \cdots < p_N$ be the primes not exceeding $x$, where $N = \pi(x)$. On each interval $[p_j,p_{j+1})$ the function $\pi$ is constant and equal to $j$, and on $[p_N,x]$ it is constant and equal to $N$. Telescoping gives
\begin{align*}
\int_2^x \frac{\pi(t)}{t}\,d\mathcal{L}^1(t)
&= \sum_{j=1}^{N-1} j \int_{p_j}^{p_{j+1}} \frac{1}{t}\,d\mathcal{L}^1(t)
+ N \int_{p_N}^{x} \frac{1}{t}\,d\mathcal{L}^1(t)\\
&= \sum_{j=1}^{N-1} j(\log p_{j+1} - \log p_j)
+ N(\log x - \log p_N)\\
&= N\log x - \sum_{j=1}^{N} \log p_j\\
&= \pi(x)\log x - \vartheta(x).
\end{align*}
Rearranging gives the first identity.
We verify the second identity directly. Define
\begin{align*}
w: [2, \infty) &\to \mathbb{R} \\
t &\mapsto \frac{1}{\log t}.
\end{align*}
For $1 \leq j \leq N$, set $A_j := \sum_{i=1}^{j} \log p_i$, and set $A_0 := 0$. Thus $A_j = \vartheta(p_j)$ for each $j$. By finite summation by parts,
\begin{align*}
\pi(x)
&= \sum_{j=1}^{N} \log p_j\, w(p_j)\\
&= A_N w(x) - \sum_{j=1}^{N-1} A_j\bigl(w(p_{j+1}) - w(p_j)\bigr) - A_N\bigl(w(x) - w(p_N)\bigr).
\end{align*}
The function $\vartheta$ is constant and equal to $A_j$ on $[p_j, p_{j+1})$ for $1 \leq j \leq N-1$, and constant and equal to $A_N$ on $[p_N,x]$. Since $w$ is continuously differentiable on $[2,x]$ and
\begin{align*}
w'(t) = -\frac{1}{t(\log t)^2},
\end{align*}
the [fundamental theorem of calculus](/theorems/632) on each interval gives
\begin{align*}
- \sum_{j=1}^{N-1} A_j\bigl(w(p_{j+1}) - w(p_j)\bigr) - A_N\bigl(w(x) - w(p_N)\bigr)
&= \int_2^x \frac{\vartheta(t)}{t(\log t)^2}\,d\mathcal{L}^1(t).
\end{align*}
Because $A_N = \vartheta(x)$, we obtain
\begin{align*}
\pi(x)
&= \frac{\vartheta(x)}{\log x}
+ \int_2^x \frac{\vartheta(t)}{t(\log t)^2}\,d\mathcal{L}^1(t).
\end{align*}[/step]