[Tex/LaTex] Array within Align*

alignarraysmatricesvector

LaTeX fresh beginner here. Using TexStudio. In the second row of an equation array (using align*), I am trying to multiply a row vector by a column vector, using the array command. Apparently the array within the align* is causing a problem. The LaTeX won't even compile. Here is my document:

\documentclass[final]{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{bm}
\newcommand{\E}{\mathbb{E}}
\begin{document}

\section{Introduction} \label{intro}
Using the assumption that $\E(\bm{X}_t u_t)=0$, its sample mean form yields:

\begin{align*}
\frac{1}{n} \sum_{t=1}^{n} \bm{X}_t u_t &= \frac{1}{n}(X_{1i}u_1+X_{2i}u_2+\dotsb+X_{ni}u_n) \\
&= \frac{1}{n}
\left[ 
\begin{array}{cccc}
X_{1i} & X_{2i} & \cdots & x_{ni} 
\end{array} 
\right] 
\left[ 
\begin{array}{c}
u_1 \\ \u_2 \\ \vdots \\ \u_k
\end{array} 
\right] \\
&= \frac{1}{n} \bm{x}_i^T \bm{u} =0 \\
\end{align*}

\end{document}

So I want all of the equals to line up. (Unless it's possible for the last one to make the final "=0" display to the right of everything?) But right now I'm mostly worried about the problems with my code and why it won't even compile.

Thanks for your help.

Best Answer

Well, I don't understand what's incorrect with your code (except perhaps that \\ is used to indicate a new line of alignment, and also a new line in your matrices). Anyway, simplifying you code with the bmatrix environment works fine:

    \documentclass[final]{amsart}
    \usepackage{amsmath}
    \usepackage{amsfonts}
    \usepackage{amssymb}
    \usepackage{bm}
    \newcommand{\E}{\mathbb{E}}
    \begin{document}

    \section{Introduction} \label{intro}
    Using the assumption that $\E(\bm{X}_t u_t)=0$, its sample mean form yields:

    \begin{align*}
    \frac{1}{n} \sum_{t=1}^{n} \bm{X}_t u_t &= \frac{1}{n}(X_{1i}u_1+X_{2i}u_2+\dotsb+X_{ni}u_n) \\
    &= \frac{1}{n}
    \begin{bmatrix}%
    X_{1i} & X_{2i} & \cdots & X_{ni}
    \end{bmatrix}
    \begin{bmatrix}
      u_1 \\u _2\\ \vdots \\ u_n
    \end{bmatrix}
    \\
    &= \frac{1}{n} \bm{x}_i^T \bm{u} =0 \\
    \end{align*}

    \end{document} 

enter image description here