Nonlinear (Quadratic) selection gradients formula
Coefficient $1/2$ is a matter of definition/convenience. One could have written $\beta x_i + \gamma x_i^2+\bar{w}$, but then a factor of $2$ would surface in the other forumals.
The other two equations are adapted to one-dimensional case (one trait) from the Lande and Arnold's paper The measurement fo selection on correlated characters. In particular, the equation with covariance is their equation (13a), which follows from their more general equation (4) for quadratic selection. The last equation is the restatement of their (14b).
Update
Here I retake the notation of the above-mentioned article by Lande, but adopt it to the case of a single trait. Then the variance matrix $P$ is just a number (variance). Equations (14a) and (13b) define
$$\gamma=\frac{1}{P^2}C, (A)\\
C=Cov\left[w, (z-\bar{z})^2\right],
$$
which is the definition of $\gamma$ in the OP. It is essential here to use the correct expression for the covariance:
$$
Cov\left[f(z), g(z)\right] = \int \left[f(z)-\bar{f}\right]\left[g(z)-\bar{g}\right]p(z)dz=
\int f(z)g(z)p(z)dz -\bar{f}\bar{g}
$$
In our case we thus have:
$$
C = \int w(z)(z-\bar{z})^2p(z)dz - \bar{w}\overline{(z-\bar{z})^2},
$$
where $\bar{w}=1$ by definition, whereas $\overline{(z-\bar{z})^2}=P$ is the variance of the trait. We thus have
$$
C = \int w(z)(z-\bar{z})^2p(z)dz - P, (B)
$$
where
$$
p(z)=\frac{1}{\sqrt{2\pi P}}e^{-\frac{(z-\bar{z})^2}{2P}}.
$$
Let us now consider the integral
$$
\int \frac{\partial^2w(z)}{\partial z^2}p(z)dz=
\frac{\partial w(z)}{\partial z}p(z)|_{-\infty}^{+\infty} - \int \frac{\partial w(z)}{\partial z }\frac{\partial p(z)}{\partial z }dz=\\
\frac{\partial w(z)}{\partial z}p(z)|_{-\infty}^{+\infty} - 
w(z)\frac{\partial p(z)}{\partial z }|_{-\infty}^{+\infty}+
\int w(z)\frac{\partial^2 p(z)}{\partial z^2 }dz
$$
The first two terms vanish, since $w(z)$ is bounded, whereas $p(z)\rightarrow 0$ as $z\rightarrow \pm \infty$.
We thus have
$$
\int \frac{\partial^2w(z)}{\partial z^2}p(z)dz=
\int w(z)\frac{\partial^2 p(z)}{\partial z^2 }dz=
\int w(z)\frac{\partial^2 }{\partial z^2 }\frac{1}{\sqrt{2\pi P}}e^{-\frac{(z-\bar{z})^2}{2P}}dz=\\
\int w(z)\left[\frac{(z-\bar{z})^2}{P^2}-\frac{1}{P}\right]\frac{1}{\sqrt{2\pi P}}e^{-\frac{(z-\bar{z})^2}{2P}}dz=
\int w(z)\left[\frac{(z-\bar{z})^2}{P^2}-\frac{1}{P}\right]p(z)dz=\\
\frac{1}{P^2}\int w(z)(z-\bar{z})^2p(z)dz - \frac{\bar{w}}{P}=\\
\frac{1}{P^2}\left[\int w(z)(z-\bar{z})^2p(z)dz - P\right]=\frac{C}{P^2}=\gamma,
$$
where we used $\bar{w}=1$, and equations (A) and (B) above.