Confidence Interval for squared term evaluated at the mean in Stata When running an OLS regression with a squared term,
$$
y = a + b_1(X) + b_2(X^2) + e
$$
I know that the partial effect of $X$ is $b_1 + 2b_2(\bar X)$ to get the overall effect of $X$ on $Y$ evaluated at the mean. Using
reg y x c.x#c.x
margins, dydx(*) atmeans

does this in Stata and it also includes a 95% CI for the overall effect. My question now is: how does margins calculate the standard error and the 95% CI of the overall effect of $X$ at the mean?
 A: The partial effect is just a linear combination, so the variance of that partial effect is:
$\mathrm{var}(b_1) + (2\overline{x})^2\mathrm{var}(b_2)+2(2 \overline{x})\mathrm{cov}(b_1,b_2)$
The standard error is just the square root of that variance. The sampling distribution of the partial effect is assumed to be a normal (Gaussian) distribution, so you can use that to compute the confidence intervals. 
As you can see below, margins reaches the same conclusion:
. sysuse nlsw88
(NLSW, 1988 extract)

. qui: reg wage c.ttl_exp##c.ttl_ex
. 
. // use -margins-
. margins, dydx(*) atmeans

Conditional marginal effects                      Number of obs   =       2246
Model VCE    : OLS

Expression   : Linear prediction, predict()
dy/dx w.r.t. : ttl_exp
at           : ttl_exp         =    12.53498 (mean)

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
     ttl_exp |   .3211941    .025843    12.43   0.000     .2705427    .3718455
------------------------------------------------------------------------------
. 
. // do this manually
. sum ttl_exp if e(sample), meanonly

. scalar b = _b[ttl_exp] + 2*_b[c.ttl_exp#c.ttl_exp]*r(mean)
. 
. matrix V = e(V)
. scalar se = sqrt(V[1,1] + (2*r(mean))^2*V[2,2] + 2*2*r(mean)*V[1,2])
. 
. di b
.3211941

. di se
.02584303

. di b - invnormal(0.975)*se
.2705427

. di b + invnormal(0.975)*se
.3718455

