Random effects for second order in R mixed models I am fitting a mixed effects model in R using nlme 
lme(y~x+I(x^2),random=~x|subject,data=train)

Is this the correct way or should it be 
lme(y~x+I(x^2),random=~x+I(x^2)|subject,data=train)

What is the difference in the interpretation of fitting these two models
 A: "Correct" is somewhat context-dependent (both models could be sensible under the appropriate circumstances), but in general I would say that the second - including both the linear and the quadratic term in the random effects - makes more sense as a default. The default can reasonably be stated as "put all terms in the random effect that can XXX be estimated from the experimental design"; depending on whom you listen to in the current Barr et al. vs. Bates et al. controversy, XXX should be replaced either with "in principle" (Barr et al.) or  "practically" (Bates et al.).
If you leave out the quadratic term, you are essentially asserting that the constant and linear terms vary across subjects, but the quadratic term doesn't.  I don't see any very sensible justification for this assumption (again, there might be one for your system): the statistical model is
$$
\begin{split}
y_i & \sim \textrm{Normal}(\mu_i,\sigma^2) \\
\mu_i & = (\beta_0 + b_{0,g_i}) + (\beta_1 + b_{1,g_i}) x + (\beta_2 +b_{2,g_i}) x^2 \\
b_{.,g_i} & \sim \textrm{MVN}(0,\Sigma)
\end{split}
$$
where $\Sigma$ is the variance-covariance matrix of the random effects and $g_i$ is the index of the group to which observation $i$ belongs.  If you omit the I(x^2) term in the random effect, you're zeroing out $b_{2,g_i}$.
