Selberg sieve weights (source code)

= Selberg sieve weights
{c}

For
$$
h(d)=\prod_{p\mid d}\frac{g(p)}{1-g(p)},\qquad
G(D,z)=\sum_{\substack{\ell<D\\\ell\mid P(z)}}h(\ell),
$$
define
$$
G_d(y,z)=
\sum_{\substack{\ell<y\\\ell\mid P(z)\\(\ell,d)=1}}h(\ell).
$$
The optimizing Selberg weights are
$$
\lambda_d=
\mu(d)\prod_{p\mid d}(1-g(p))^{-1}
\frac{G_d(D/d,z)}{G(D,z)}
$$
for $d<D$ dividing $P(z)$, and zero otherwise. They satisfy $\lambda_1=1$ and diagonalize the main quadratic form to $1/G(D,z)$.