I'm trying to use the summation symbol in fractions, but I found that the superscript and subscript of the summation symbol go to the side, is this allowed mathematically? Or am I writing the Latex code wrong?
$$
\begin{aligned}
w = \frac{
\frac{1}{m} \sum_{i = 0}^{m} (-2x_1y_1)
}{
2\frac{1}{m} \sum_{i = 0}^{m} x_1^2
}
\end{aligned}
$$

