[Tex/LaTex] Equation Error – Undefined Control Sequence

alignequations

    \documentclass[12pt,a4paper,oneside]{book}
    \usepackage[utf8]{inputenc}
    \usepackage{textgreek}
    \usepackage{amsmath,amssymb,amsthm}
    \usepackage{mathtools}
    \begin{document} 

    \begin{equation*}
    \begin{aligned}
    \theta_1^*(t) ~ P(\theta_1| Y_1^{obs}, Y_2^{(t-1)},…,Y_p^{(t-1)})\\
Y_1^{*(t)} ~ P(Y_1| Y_1^{obs}, Y_2^{(t-1)},…,Y_p^{(t-1)}, theta_1^{*(t)}) %<----stops here
    \end{aligned}
    \end{equation*}
    \end{document}

Hello, I'm trying to input equations into my thesis and I've been trying for quite sometime now, but it always stops at the line indicated in the code. I dont know what I'm doing wrong. Please could someone help me.

Best Answer

  1. ~ does not produce a visible symbol; you probably want \sim
  2. should be \dots
  3. Y_p^(t-1) should be Y_p^{t-1};
  4. theta should be \theta
  5. | should be \mid or the spacing would be wrong
  6. ^obs should be ^{\mathrm{obs}} so the superscript is in textual mode and a single object
  7. \Y should probably be Y
  8. you are missing an alignment point

Here is the fixed code:

\documentclass[12pt,a4paper,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb,amsthm}

\begin{document}

\begin{equation*}
\begin{aligned}
\theta_1^*(t) &\sim P(\theta_1\mid Y_1^{\mathrm{obs}}, Y_2^{t-1},\dots,Y_p^{t-1})\\
Y_1^*(t) &\sim P(Y_1\mid Y_1^{\mathrm{obs}}, Y_2^{t-1},\dots,Y_p^{t-1},\theta_1^*(t))
\end{aligned}
\end{equation*}
\end{document}

enter image description here

If you wanted a space instead of a ~ symbol:

\documentclass[12pt,a4paper,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb,amsthm}

\DeclareMathOperator{\Prob}{\mathnormal{P}}

\begin{document}

\begin{equation*}
\begin{aligned}
&\theta_1^*(t) \Prob(\theta_1\mid Y_1^{\mathrm{obs}}, Y_2^{t-1},\dots,Y_p^{t-1})\\
&Y_1^*(t) \Prob(Y_1\mid Y_1^{\mathrm{obs}}, Y_2^{t-1},\dots,Y_p^{t-1},\theta_1^*(t))
\end{aligned}
\end{equation*}
\end{document}

enter image description here