# Having trouble in matrix creation

I want to write down this algorithm in latex I write down the code in Latex. This is my code:

\begin{enumerate}
\item  Algorithm EIF\_ initialize($u_{1:t}$):
\item  \begin{gather}\begin{pmatrix} \mu_{0,x} \\
\mu_{0,y} \\ \mu_{0,\theta} \end{pmatrix}   =
\begin{pmatrix} 0 \\ 0 \\0 \end{pmatrix}\end{gather}
\item for all control u_t = (v_t,\omega_t)^T do
\item  \begin{pmatrix}
\mu_{t,x} \\ \mu_{t,y} \\ \mu_{t,\theta}
\end{pmatrix}
= \begin{pmatrix}
\mu_{t-1,x} \\ \mu_{t-1,y} \\ \mu_{t-1,\theta}
\end{pmatrix} \plus \begin{pmatrix}
-v_t/\omega_t sin\mu_{t-1,\theta}+ v_t/\omega_t
sin(\mu_{t-1,\theta}+\omega_t\Delta t) \\
v_t/\omega_t cos\mu_{t-1,\theta} -v_t/\omega_t
cos(\mu_{t-1,\theta}+\omega_t\Delta t) \\
\omega_t\Delta t
\end{pmatrix}
\item endfor
\item return \mu_{0:t}
\end{enumerate}


It throws many errors also the output is look like Which is not exact.

Errors are like that:

Missing $inserted. \item for all control u_Command \item invalid in math mode. \item Something's wrong--perhaps a missing \item. \item \begin Something's wrong--perhaps a missing \item. \item \begin Undefined control sequence. \end{pmatrix} \begin{pmatrix} \plus Command \item invalid in math mode. \item Missing$ inserted.

\item e Missing } inserted.

\item e Extra }, or forgotten \endgroup.

\item e Missing $inserted. \item return \mu Command \end{enumerate} invalid in math mode. \end{enumerate} Something's wrong--perhaps a missing \item. \end{enumerate} Something's wrong--perhaps a missing \item. \end{enumerate} Missing$ inserted.

\end{enumerate} Overfull \hbox (111.12874pt too wide) in paragraph

• Well, just by looking one sees that you often forget to switch to math mode, e.g. \item for all control u_t = (v_t,\omega_t)^T do should be replaced by \item for all control $u_t = (v_t,\omega_t)^T$ do – marmot Sep 24 '18 at 20:41
1. You need to use math environments for "everything math", see the  I inserted. 2. I also replaced sin and cos with \sin and \cos. 3. There was also a \plus which I replaced with + (might be wrong). 4. I also removed one \item (might be wrong). 5. You can switch the equation numbers on/off with gather/align and gather*/align* (see code and result). 6. I also included real fractions. You might want to go back to the plain notation or \nicefrac. 7. I changed some fonts according to the example you gave. Please note that I used a dirty trick in the first line since many math typefaces do not cover bold italics. You might want to go back to  u_{1:t}$. Here is the code: \documentclass{memoir} \usepackage{amsmath,nicefrac} \begin{document} \begin{enumerate} \item \textbf{Algorithm EIF\_initialize(\textit{u}\textsubscript{1:\textit t}):} \slshape \item \begin{gather} \begin{pmatrix} \mu_{0,x} \\ \mu_{0,y} \\ \mu_{0,\theta} \end{pmatrix} =\begin{pmatrix} 0 \\ 0 \\0 \end{pmatrix} \end{gather} \item for all control$u_t = (v_t,\omega_t)^Tdo \begin{align*} \begin{pmatrix} \mu_{t,x} \\ \mu_{t,y} \\ \mu_{t,\theta}\\ \end{pmatrix} =\begin{pmatrix} \mu_{t-1,x} \\ \mu_{t-1,y} \\ \mu_{t-1,\theta} \end{pmatrix} +\begin{pmatrix} -\frac{v_t}{\omega_t} \sin\mu_{t-1,\theta}+ \frac{v_t}{\omega_t} \sin(\mu_{t-1,\theta}+\omega_t\Delta t) \\ \frac{v_t}{\omega_t} \cos\mu_{t-1,\theta} -\frac{v_t}{\omega_t} \cos(\mu_{t-1,\theta}+\omega_t\Delta t) \\ \omega_t\Delta t \\ \end{pmatrix} \end{align*} \item endfor \item return\mu_{0:t}$\end{enumerate} \end{document} • +1 but I guess you could replace the gather by ordinary $....\$ the more so since there were no equation numbers in the screen shot. – marmot Sep 24 '18 at 20:48