How do I write a mixed-effect regression model (MRM)? So I am trying to write a MRM with both random intercept and random slope. I know the general model is as follows,

yij = b0 + b1xij + vi0 + vi1xij + eij

However, I want to actually write my variables into the model, but I am not sure how to do so. I've looked at the Wikipedia and other sources, but I haven't found an example that includes writing out the model.

sex, age, age * age, sex * age and sex * age * age

 A: I will re-write your model using the common notation from the multi-level modelling literature (eg Goldstein 2011)
$$ y_{ij} = \beta_0 + \beta_1x_{1ij} + u_{0j} + u_{1j}x_{1ij} + e_{ij} $$
This model contains only 1 fixed effect, (say sex), ($x_1$), for which there is also random slopes. $i$ indexes lower-level units, clustered in higher-level units indexed by $j$, with $u_{0j}$ being the random intercepts and $u_{1j}$ the random slopes for $x_1$.  
Equivalently, we can make the random intercepts and slopes more apparent by writing:
$$ y_{ij} = (\beta_0+ u_{0j}) + (\beta_1 + u_{1j})x_{1ij} + e_{ij} $$
The usual assumptions are:
$$
\begin{align}\left[\begin{matrix} u_{0j} \\ u_{1j} \end{matrix}\right] & \sim \mathcal{N}(0,\Omega_{u}), \\ \Omega_u & = \left[\begin{matrix}\sigma^2_{u 0}  \\  \sigma_{u 01} & \sigma^2_{u 1}\end{matrix}\right], \\ e_{ij} & \sim \mathcal{N}(0,\sigma^{2}_{e})\end{align}
$$
If we add another fixed effect, say age, (with no random slope for it), denoted by $x_2$, we would have:
$$ y_{ij} = \beta_0 + \beta_1x_{1ij} + \beta_2x_{2ij} + u_{0j} + u_{1j}x_{1ij} + e_{ij} $$
If we would like to have random slopes for age also, then we can write:
$$ y_{ij} = \beta_0 + \beta_1x_{1ij} + \beta_2x_{2ij} + u_{0j} + u_{1j}x_{1ij} +  u_{2j}x_{2ij} + e_{ij} $$
If we now introduce the interaction between sex and age, without random slopes for it, we can write: 
$$ y_{ij} = \beta_0 + \beta_1x_{1ij} + \beta_2x_{2ij} + \beta_3(x_1x_2)_{ij} + u_{0j} + u_{1j}x_{1ij} +  u_{2j}x_{2ij} + e_{ij} $$
We can proceed similarly for age*age and sex*age*age:
$$ y_{ij} = \beta_0 + \beta_1x_{1ij} + \beta_2x_{2ij} + \beta_3(x_1x_2)_{ij} + \beta_4(x_2^2)_{ij} + \beta_5(x_1x_2^2)_{ij} + u_{0j} + u_{1j}x_{1ij} +  u_{2j}x_{2ij} + e_{ij} $$
and this model specifies fixed effects for sex, age, sex*age, age*age and sex*age*age along with random slopes forsex, age, and sex*age. Finally, adding random slopes for sex*age, age*age and sex*age*age we have:
$$ y_{ij} = \beta_0 + \beta_1x_{1ij} + \beta_2x_{2ij} + \beta_3(x_1x_2)_{ij} + \beta_4(x_2^2)_{ij} + \beta_5(x_1x_2^2)_{ij} + u_{0j} + u_{1j}x_{1ij} +  u_{2j}x_{2ij} + u_{3j}(x_1x_2)_{ij} +u_{4j}(x_2^2)_{ij} +u_{5j}(x_1x_2^2)_{ij} + e_{ij} $$
or equivalently:
$$ y_{ij} = (\beta_0+ u_{0j}) + (\beta_1 + u_{1j})x_{1ij} + (\beta_2 + u_{2j})x_{2ij} + (\beta_3 + u_{3j})(x_1x_2)_{ij} + (\beta_4+  u_{4j})(x_2^2)_{ij} + (\beta_5+ u_{5j})(x_1x_2^2)_{ij} + e_{ij} $$
As a side note, this is a quite complex random structure and the software would usually estimate covariances between all the random effects too, since in this model the usual assumptions will be:
$$
\begin{align}
e_{ij} & \sim \mathcal{N}(0,\sigma^{2}_{e}) ,\\
\left[\begin{matrix} u_{0j} \\ u_{1j} \\ u_{2j} \\ u_{3j} \\ u_{4j} \\ u_{5j} \end{matrix}\right] & \sim \mathcal{N}(0,\Omega_{u}), \\ 
\Omega_u &= \left[\begin{matrix}\sigma^2_{u 0}  
\\ \sigma_{u 01} & \sigma^2_{u 1}
\\ \sigma_{u 02} & \sigma_{u 12} & \sigma^2_{u 2}
\\ \sigma_{u 03} & \sigma_{u 13} & \sigma_{u 23}& \sigma^2_{u 3}
\\ \sigma_{u 04} & \sigma_{u 14} & \sigma_{u 24}& \sigma_{u 34}& \sigma^2_{u 4}
\\ \sigma_{u 05} & \sigma_{u 15} & \sigma_{u 25}& \sigma_{u 35}& \sigma_{u 45}& \sigma^2_{u 5} 
\end{matrix}\right]
\end{align}
$$
which is quite a lot of parameters, so don't be surprised if you find that such a model is difficult to estimate in practice - it is usually better to start with a simple random structure. 
Ref:
Goldstein, H., 2011. Multilevel statistical models (Vol. 922). John Wiley & Sons.
Internet version available here
