Expectation and Variance of Stochastic Differential Equations 

  
*Consider the SDE
  $$dr_t=\kappa(\theta-r_t)\,dt+\sigma dW_t,\ r_0=x,$$
  where $\kappa$, $\theta$ and $\sigma$ are constants. You are given that the solution is
  $$r_t=\theta+(x-\theta)e^{-\kappa t}+\sigma\int_0^te^{-\kappa(t-s)}\,dW_s.$$
  Calculate the mean and variance of $r_t$. You may use the result
  $$\mathbb E\left[\left(\int_0^tY_s\,dW_s\right)^2\right]=\mathbb E\left[\int_0^tY_s^2\,ds\right],$$
  in the calculation of the variance.

Hi, I was wondering if somebody could tell me how to calculate the expectation of an SDE? I believe the expectation of a constant is just equal to the constant.
 A: 
To compute the expectation and the variance, in addition to the given
  hint (Ito Isometry), you need to know that if the integrator
  $W_t$ is an arbitrary martingale, and the integrand $f$ is bounded,
  then the integral is a martingale, and the expectation of the integral
  is again zero (proof). Then we can proceed.

For: $$r_t=\theta+(x-\theta)e^{-\kappa t}+\sigma\int_0^te^{-\kappa(t-s)}\,dW_s$$
The Expectaction of $r_t$
$$\begin{align}
\mathbb{E}[r_t]&=\mathbb{E}\left[\theta+(x-\theta)e^{-\kappa t}+\sigma\int_0^te^{-\kappa(t-s)}\,dW_s\right]\\
&=\theta+(x-\theta)e^{-\kappa t}+\sigma\mathbb{E}\left[\int_0^te^{-\kappa(t-s)}\,dW_s\right]\\
&=\theta+(x-\theta)e^{-\kappa t}
\end{align}$$
The variance of $r_t$
$$\begin{align}
Var[r_t]&=\mathbb{E}[r_t^2]-\left(\mathbb{E}[r_t]\right)^2\\
&=\mathbb{E}\left[\left(\theta+(x-\theta)e^{-\kappa t}+\sigma\int_0^te^{-\kappa(t-s)}\,dW_s\right)^2\right]-\left(\theta+(x-\theta)e^{-\kappa t}\right)^2\\
&=(\theta+(x-\theta)e^{-\kappa t})^2+2\sigma(\theta+(x-\theta)e^{-\kappa t})^2\mathbb{E}\left[\int_0^te^{-\kappa(t-s)}\,dW_s\right]+\sigma^2\mathbb{E}\left[\left(\int_0^te^{-\kappa(t-s)}\,dW_s\right)^2\right]-(\theta+(x-\theta)e^{-\kappa t})^2\\
&=\sigma^2\mathbb{E}\left[\int_0^te^{-2\kappa(t-s)}\,ds\right]\\
&=\sigma^2\int_0^te^{-2\kappa(t-s)}\,ds\\
&=\dfrac{\sigma^2}{2\kappa}(1-e^{-2\kappa t})
\end{align}$$
A: $\newcommand{\IE}{\mathbb{E}}$
As $\IE(dW)=0$ you get the differential equaton for $\IE(r_t)$
$$d\IE(r_t)=\IE(dr_t)=κ(θ−\IE(r_t))dt$$
which has the solution
$$
θ−\IE(r_t)=e^{-κt}(θ−\IE(r_0))\implies \IE(r_t)=θ-e^{-κt}(θ−x)
$$
Using the Ito formula for the square
$$d(r_t)^2=2r_tκ(θ−r_t)dt+2r_tσdW_t+σ^2dt$$ 
results in
$$
d\IE(r^2_t)=(2κθ\IE(r_t)-2κ\IE(r_t^2)+σ^2)dt
$$
so that for the variance $Var(r_t)=\IE(r^2_t)-\IE(r_t)^2$ we get the differential equation
\begin{align}
d[\IE(r^2_t)-\IE(r_t)^2]&=(2κθ\IE(r_t)-2κ\IE(r_t^2)+σ^2)dt-2κ\IE(r_t)(θ−\IE(r_t))dt
\\
&=-2κ[\IE(r_t^2)-\IE(r_t)^2]dt+σ^2dt
\\
\implies
\IE(r^2_t)-\IE(r_t)^2&=\frac{σ^2}{2κ}(1-e^{-2κ}).
\end{align}
A: The SDE you have mentioned in your question is basicaly represents the Ornstein-Uhlenbeck process and for OU process you can find a lot of things in the literature. 
Besides the two answers given already, I will add one more that I found a year ago on this link: expectation and the variance of OU process. 
In a screenshot:

Hope that this additional information helps somehow.
