Writing mathematical equations (mixed effect models) I have the following model which i am trying to write the mathematical equation for.
model;
mod = lmer(test ~ IQ + ses + (1 | Class), data = pupils) 

I have the following equation for it but not 100% sure im correct, would anyone be able to confirm or point me in the right direction please;

Example of my equation with only 1 fixed effect, i now need to extend this to 2 fixed effect which i have tried above^

dataset
pupils
      IQ Class ses test ClassSize 
1   15.0     1  23   46     29    
2   14.5     1  10   45     29    
3    9.5     1  15   33     29    
4   11.0     1  23   46     29    
5    8.0     1  10   20     29   
6    9.5     1  10   30     29  

So all of my variables here are numeric apart from class which is categorical

You are considering two linear mixed models (LMMs) for students' test scores: model M1 with random intercepts and model M2 with random intercepts & random slopes. [The news about the second model is in the comments.]
To completely specify a LMM, it's necessary to:
a) provide the model formula (here in R syntax) and 
b) state whether the fixed effects describe the students (individual-level predictors) or the classes (group-level predictors). 
Both IQ and ses are individual-level predictors. However, the sample data also includes ClassSize, a group-level predictor. I'll use to show how to specify hierarchical LMM models; that's where requirement (b) comes in.
Random-intercept model
The model formula:
m1 <- lmer(test ~ IQ + ses + (1 | Class), data = pupils)

The model equation:
$$
\begin{aligned}
  \text{(M1a)} \quad\quad
    Y_i &\sim
    \operatorname{N}\left(
      \color{blue}{\beta_0} + \color{blue}{\beta_1}\operatorname{IQ} + \color{blue}{\beta_2}\operatorname{ses} + \color{red}{\alpha_{c[i]}},
      \sigma^2
    \right)\\
    \color{red}{\alpha_c} &\sim 
    \operatorname{N}\left(
      0,
      \sigma^2_\alpha
    \right)
\end{aligned}
$$
The terms $c[i]$ denotes the class $c$ that student $i$ belongs to. It's not a universally accepted notation but it's clear. I've highlighted the fixed effects in blue and the random effects in red.
Here is an equivalent specification.
$$
\begin{aligned}
  \text{(M1b)} \quad\quad
    Y_i &\sim
    \operatorname{N}\left(
      \color{red}{\alpha_{c[i]}} + \color{blue}{\beta_1}\operatorname{IQ} + \color{blue}{\beta_2}\operatorname{ses},
      \sigma^2
    \right)\\
    \color{red}{\alpha_c} &\sim 
    \operatorname{N}\left(
      \mu_\alpha,
      \sigma^2_\alpha
    \right)
  \end{aligned}
$$
The first version (M1a) corresponds to the parametrization used by lmer. That's why we get three fixed effect coefficients in the model summary: (Intercept), IQ and ses. These are $\beta_0$, $\beta_1$, $\beta_2$, respectively.
The second version (M1b) is easier to generalize in order to include random slopes and/or group-level predictors. It's also the notation used in [1].
The two specficiations are equivalent: $\beta_0 + \alpha_{c[i]}$ in (M1a) corresponds to $\alpha_{c[i]}$ in (M1b). The former is known as non-centered parameterization and the latter as centered parameterization, for obvious reasons [2].
Random-intercept, random-slope model
The model formula:
m2 <- lmer(test ~ IQ + ses + (1 + IQ| Class), data = pupils)

The model equation:
$$
\begin{aligned}
  \text{(M2)}
  && Y_i &\sim
  \operatorname{N}\left(
    \color{red}{\alpha_{c[i]}} + \color{red}{\beta_{1c[i]}}\operatorname{IQ} + \color{blue}{\beta_2}\operatorname{ses},
    \sigma^2
  \right)\\
  &&  \left(
   \begin{array}{c}
   \begin{aligned}
   &\color{red}{\alpha_{c}} \\
   &\color{red}{\beta_{1c}}
   \end{aligned}
   \end{array}
   \right)
  &\sim \operatorname{N}
  \left(
   \left(
     \begin{array}{c}
     \begin{aligned}
     &\mu_{\alpha} \\
     &\mu_{\beta_1}
     \end{aligned}
     \end{array}
     \right)
   ,
   \left(
     \begin{array}{cc}
     \sigma^2_{\alpha} & \rho\sigma_\alpha\sigma_{\beta_1} \\
     \rho\sigma_{\alpha}\sigma_{\beta_1} & \sigma^2_{\beta_1}
     \end{array}
     \right)
   \right)
  \end{aligned}
$$
Yep, the math notation gets pretty involved rather quickly. Important points to note in Eq. (M2): The IQ slope, $\beta_{1c[i]}$ is now random as indicated by the $c[i]$ index. And the random intercept $\alpha_c$ and the random slope $\beta_{1c}$ for class $c$ are correlated with correlation $\rho$.
Hierarchical random-intercept model
I include this to illustrate why it's required to know whether a fixed effect is an individual-level predictor or a group-level predictor.
The model formula for a multi-level model looks very much like the formula for a single-level model, only with one more fixed effect:
m3 <- lmer(test ~ IQ + ses + ClassSize + (1 | Class), data = pupils)

However, the model equation is different. It eloquently highlights the hierarchical structure of a multi-level model. I omit the random slopes to keep the equations to a reasonable quota.
$$
\begin{aligned}
  \text{(M3)}
  && \operatorname{Y}_{i}  &\sim 
  \operatorname{N} \left(\color{red}{\alpha_{c[i]}} + \color{blue}{\beta_1}\operatorname{IQ} + \color{blue}{\beta_2}\operatorname{ses}, \sigma^2 \right) \\
  && \color{red}{\alpha_c}  &\sim 
  \operatorname{N} \left(\gamma_0 + \gamma_1\operatorname{ClassSize}, \sigma^2_{\alpha} \right)
  \end{aligned}
$$
The multi-level model (M3) has two components: a regression for the random intercepts $\alpha_c$ on ClassSize and a regression for the test scores $Y_i$ given the random intercept for class $c[i]$ as well as the individual-level predictors, IQ and ses.

References
The chapters on "Multilevel regression" in [1] describe hierarchical models in great depth. Section 12.5 is about five ways to write the same multi-level model. Five is perhaps one too many.
[1] A. Gelman, J. Hill, and A. Vehtari. Regression and Other Stories. Cambridge University Press, 2020.
[2] O. Papaspiliopoulos, G. O. Roberts, and M. Sköld. A general framework for the parametrization of hierarchical models. Statistical Science, 22(1):59–73, 2007.
