4

The following code gives me exactly what I need as displayed in the image. It's however displaying error messages when I run. How do I get rid of the errors displayed. Below is the code and equation.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
 \begin{equation*}
\begin{split}
{\alpha}^{(k+1)}&=\frac{-n}{\sum\limits_{i=1}^{m}\ln\left( 
e^{{\lambda}^{(k)}/x_i^{\beta^{(k)}}}-1\right)-2\sum\limits_{i=1}^{m} \cfrac{\left( 
e^{{\lambda}^{(k)}/x_i^{\beta^{(k)}}}-1\right)^{\alpha^{(k+1)}}\ln\left( 
e^{{\lambda}^{(k)}/x_i^{\beta^{(k)}}}-1\right)}{\left( 
e^{{\lambda}^{(k)}/x_i^{\beta^{(k)}}}-1\right)^{\alpha^{(k+1)}}+1}  \\&+\sum\limits_{i=1}^{m} 
{R_i} C(x_i;{\alpha}^{(k)},{\beta}^{(k)},{\lambda}^{(k)} )        }
 \end{split}
\end{equation*}
\end{document}

! Missing } inserted.
<inserted text> 
                }
l.12  \end{split}
                 
? 

enter image description here

6
  • Please provide a Minimal Working Example so that people can actually test your code. Also, it's be easier to comment on the error if you showed the error message. Thank you.
    – Miyase
    Aug 13, 2022 at 14:00
  • 2
    you have \frac{-n}{ in the first line with a matching } in the second column second line. You have to finish the fraction in the same cell as you start it. Aug 13, 2022 at 14:09
  • Is the second line supposed to be a part of the denominator shown in line 2, or it is a separate additive term? Please advise.
    – Mico
    Aug 13, 2022 at 17:15
  • second line is part of the denominator as shown in line 2 Aug 13, 2022 at 19:49
  • 1
    @MUIADOMINICMUTISO you already have answers my comment was that you have \frac{-n}{... \\ & ... } and you can never do that: if you start a fraction (or any group) you must finish it before the \\ or & that ends the aligment cell. Aug 13, 2022 at 21:36

3 Answers 3

6

After correcting your code, I also changed equation*/split environments to align*. The code is structured a little bit to see better what's happening after compilation and how parts of the code correspond to the outcome. You could also think about using intermediate terms as the equation is too long to fit a page

enter image description here

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\begin{align*}
    \alpha^{(k+1)} &= \frac{-n}{A - 2B + C}
    \intertext{with}
     A &= \sum\limits_{i=1}^{m}
             \ln\Bigl(
                 e^{\lambda^{(k)}/x_i^{\beta^{(k)}}} - 1
             \Bigr) \\
     B &= \sum\limits_{i=1}^{m}
             \cfrac{
                 \Bigl(
                     e^{{\lambda}^{(k)}/x_i^{\beta^{(k)}}} - 1
                 \Bigr)^{\alpha^{(k+1)}}
                 \ln \Bigl(
                     e^{{\lambda}^{(k)}/x_i^{\beta^{(k)}}} - 1
                 \Bigr)
             }{
                 \Bigl(
                     e^{{\lambda}^{(k)}/x_i^{\beta^{(k)}}} - 1
                 \Bigr)^{\alpha^{(k+1)}} + 1
             } \\
     C &= \sum\limits_{i=1}^{m}
             R_i
             C\Bigl(
                x_i;\alpha^{(k)},\beta^{(k)},\lambda^{(k)}
             \Bigr)
\end{align*}
\end{document}
2

I would like to suggest you simplify the notation along the following lines. Actually, since your code contains some syntax errors, I couldn't decide which of the following two equations for \alpha^{(k+1)} is correct.

enter image description here

\documentclass{article}
\usepackage{mathtools} % for \coloneqq macro
\begin{document}
\noindent
Put $U_i\coloneqq\exp\bigl( \lambda^{(k)}/x_i^{\beta^{(k)}} \bigr) -1$ 
and $V_i\coloneqq U_i^{\alpha^{(k+1)}}$. 
Then either
\begin{equation*}
\alpha^{(k+1)}
=-n\bigg/ \biggl(\,
    \sum_{i=1}^{m}\ln U_i 
  -2\sum_{i=1}^{m} \frac{V_i\ln U_i}{V_i+1}\biggr)
   +\sum_{i=1}^{m} R_i C\bigl(x_i;\alpha^{(k)},\beta^{(k)},\lambda^{(k)}\bigr)\,.
\end{equation*}
or
\begin{equation*}
\alpha^{(k+1)}
=-n\bigg/ \biggl(\,
    \sum_{i=1}^{m}\ln U_i 
  -2\sum_{i=1}^{m} \frac{V_i\ln U_i}{V_i+1}
   +\sum_{i=1}^{m} R_i C\bigl(x_i;\alpha^{(k)},\beta^{(k)},\lambda^{(k)}\bigr) \biggr) \,.
\end{equation*}
\end{document}
1

I got the same error when using mathjax with nested equation containing spaces..

Error Instance raising \begin{aligned} ended with \end{split}


$$\begin{aligned}
& \,\,\,\, -   {\partial \over \partial m}  \log \sum_z q_e(z|x) q_r(y|z) 
\\

&= \sum_z  q_w(z|x)  \left[ \begin{aligned}
\log {q_e(z|x) q_r(y|z)  \over q_w(z|x)} 
  {\partial \over \partial m}  \log q_w(z|x)  \\
 +  {\partial \over \partial m}  \log q_e(z|x) q_r(y|z) \\
 - {\partial \over \partial m}\log q_w(z|x)  \end{aligned} 
\right]  -   {\partial \over \partial m}  l  \\

&= \sum_z {\partial \over \partial m}\left[ 
 q_w(z|x) \log {q_e(z|x) q_r(y|z)  \over q_w(z|x)} 
    \right ]
   -   {\partial \over \partial m}  l  \\
&= {\partial \over \partial m} \sum_z \left[ 
 q_w(z|x) \log {q_e(z|x) q_r(y|z)  \over q_w(z|x)} 
    \right ]
   -   {\partial \over \partial m}  l  \\
-{\partial \over \partial m} D_{KL} &= {\partial \over \partial m} ELBO
   -   {\partial \over \partial m}  l 
\end{aligned}$$

Removing all newlines would remove the error, yielding

$$\begin{aligned}
& \,\,\,\, -   {\partial \over \partial m}  \log \sum_z q_e(z|x) q_r(y|z) 
\\
&= \sum_z  q_w(z|x)  \left[ \begin{aligned}
\log {q_e(z|x) q_r(y|z)  \over q_w(z|x)} 
  {\partial \over \partial m}  \log q_w(z|x)  \\
 +  {\partial \over \partial m}  \log q_e(z|x) q_r(y|z) \\
 - {\partial \over \partial m}\log q_w(z|x)  \end{aligned} 
\right]  -   {\partial \over \partial m}  l  \\
&= \sum_z {\partial \over \partial m} \left[ 
 q_w(z|x) \log {q_e(z|x) q_r(y|z)  \over q_w(z|x)} 
    \right ] -   {\partial \over \partial m}  l  \\
&= {\partial \over \partial m} \sum_z \left[ 
 q_w(z|x) \log {q_e(z|x) q_r(y|z)  \over q_w(z|x)} 
    \right ]  -   {\partial \over \partial m}  l  \\
-{\partial \over \partial m} D_{KL} &= {\partial \over \partial m} ELBO
   -   {\partial \over \partial m}  l 
\end{aligned}$$

Not sure which exact newline causing the problem, but maybe related to mathjax inserting {split} environment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .