# Displaying long equations in multiple lines

I compiled this Tex codes in https://www.latex4technics.com/. The codes are correctly compiled in MathJax but failed in Latex. I am confused about this. How can I have my long equation displayed in multiple lines in Latex? Can I left-align it?

$$\begin{split} \delta_{CNN}= f_n\left(w_n\ast f_{n-1}\left(\cdots \left(w_2\ast f_1\left(w_1\ast\left[ \begin{matrix}\mu_1\\\mu_2\\\end{matrix}\right]\right. \nonumber \\ \left.+b_1\right)+b_2\right)\cdots\right)+b_n\right), \end{split}$$

• Welcome to TeX SX! You're missing the correct number of \left. and of \right. Anyway, it it is better to specify by hand the size of the delimiters, with \bigl(,\Bigl(, \biggl, \Biggl, and similarly for the right delimiters. Also, are you sure it has to be split? Commented Jan 3, 2021 at 18:05
• mathjax isn't LaTeX. Period.
– Mico
Commented Jan 3, 2021 at 18:24

You don't really need two lines. Here is a simplified code:

\documentclass{article}
\usepackage{amsmath, amssymb}

\begin{document}

$\delta_{CNN}= f_n\left(w_n\ast f_{n-1}\left(\cdots\left(w_2\ast f_1\left(w_1\ast\begin{bmatrix}\mu_1\\ \mu_2\end{bmatrix}% +b_1\right)+b_2\right)\cdots\right)+b_n\right),$

\end{document}


If you must split the equation across two rows, you should replace all \left auto-sizing directives in row 1 with \Bigl and all \right directives in row 2 with \Bigr. Then, get rid of the remaining \left. and \right. directives.

Incidentally, even if you provided correct number of \right. directives in row 1 and the correct number of \left. directives in row 2, the auto-sizing approach wouldn't generate the desired result because there's no "tall" object in the second row.

Finally, do insert & markers to create alignment points.

\documentclass{article}
\usepackage{amsmath} % for 'split' and 'bmatrix' environments
\begin{document}

$$\begin{split} \delta_{\mathrm{CNN}} &= f_n\Bigl(w_n\ast f_{n-1}\Bigl(\cdots\Bigl(w_2\ast f_1\Bigl(w_1\ast \begin{bmatrix} \mu_1 \\ \mu_2 \end{bmatrix} \\[1ex] &\quad +b_1\Bigr)+b_2\Bigr)\cdots\Bigr)+b_n\Bigr)\,. \end{split}$$
\end {document}