# How to get three matrices on the same line?

I am trying to get three different matricies on the same line, but the problem is that when I run the "code" below, I get one matrix above the other two matrices. What should I do in order to get all of them on the same line? The code is:

\begin{align}
\begin{bmatrix}
v_1^{m} \\
v_2^m \\
v_3^m \\
\vdots \\
v_n^m
\end{bmatrix}
\end{align} $= \left[ \begin{array}{ccccccc} (1-2r) & -r & 0 & . & . & . & 0 \\ -r & (1-2r) & -r & . & . & . & . \\ 0 & . & . & . & . & . &. \\ . & . & . & . & . & . & 0 \\ . & . & . & . & -r & (1-2r) & -r \\ 0 & . & . & . & 0 & -r & (1-2r) \end{array} \right] \times \left[ \begin{array}{c} v_1^{m+1}\\ v_2^{m+1}\\ v_3^{m+1}\\ .\\ .\\ v_n^{m+1} \end{array} \right]$

• Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Holene May 9 '15 at 7:24
• the reason the first matrix is above the other two is that the align environment and $...$ each forms a separate display group. align is equivalent to equation in this sense. however, align really shouldn't be used for a one-line display. (this isn't covered in the accepted answer, which is otherwise excellent.) – barbara beeton May 9 '15 at 13:36

Something like this? No need to mix-up arrays and matrices, and for matrix multiplication you don't need the \times operator. Use amsmath's bmatrix for both vectors and the matrix.

\documentclass{article}

\usepackage{amsmath}

\begin{document}
$$\begin{bmatrix} v_1^{m} \\ v_2^m \\ v_3^m \\ \vdots \\ v_n^m \end{bmatrix} = \begin{bmatrix} (1-2r) & -r & 0 & . & . & . & 0 \\ -r & (1-2r) & -r & . & . & . & . \\ 0 & . & . & . & . & . &. \\ . & . & . & . & . & . & 0 \\ . & . & . & . & -r & (1-2r) & -r \\ 0 & . & . & . & 0 & -r & (1-2r) \end{bmatrix} \begin{bmatrix} v_1^{m+1}\\ v_2^{m+1}\\ v_3^{m+1}\\ .\\ .\\ v_n^{m+1} \end{bmatrix}$$
\end{document}


Played around with some \dots and implemented Mico's suggestion streching the array a tiny bit to match the heights of the matrix and the vectors.

\documentclass{article}

\usepackage{amsmath}

\begin{document}
$$\begin{bmatrix} v_1^{m} \\ v_2^m \\ v_3^m \\ \vdots \\ v_n^m \end{bmatrix} = \begin{bmatrix} (1-2r) & -r & 0 & \cdots & 0 \\ -r & (1-2r) & -r & \ddots & \vdots \\ 0 & \ddots & \ddots & \ddots & 0 \\ \vdots & & -r & (1-2r) & -r \\ 0 & \cdots & 0 & -r & (1-2r) \end{bmatrix} \begin{bmatrix} v_1^{m+1}\\ v_2^{m+1}\\ v_3^{m+1}\\ \vdots \\ v_n^{m+1} \end{bmatrix}$$

\renewcommand{\arraystretch}{1.6}$$\begin{bmatrix} v_1^{m} \\ v_2^m \\ v_3^m \\ \vdots \\ v_n^m \end{bmatrix} = \begin{bmatrix} (1-2r) & -r & 0 & \cdots & 0 \\ -r & (1-2r) & -r & \ddots & \vdots \\ 0 & \ddots & \ddots & \ddots & 0 \\ \vdots & & -r & (1-2r) & -r \\ 0 & \cdots & 0 & -r & (1-2r) \end{bmatrix} \begin{bmatrix} v_1^{m+1}\\ v_2^{m+1}\\ v_3^{m+1}\\ \vdots \\ v_n^{m+1} \end{bmatrix}$$

\renewcommand{\arraystretch}{1.7}$$\begin{bmatrix} v_1^{m} \\ v_2^m \\ v_3^m \\ \vdots \\ v_n^m \end{bmatrix} = \begin{bmatrix} (1-2r) & -r & 0 & \cdots & 0 \\ -r & (1-2r) & -r & \ddots & \vdots \\ 0 & \ddots & \ddots & \ddots & 0 \\ \vdots & & -r & (1-2r) & -r \\ 0 & \cdots & 0 & -r & (1-2r) \end{bmatrix} \begin{bmatrix} v_1^{m+1}\\ v_2^{m+1}\\ v_3^{m+1}\\ \vdots \\ v_n^{m+1} \end{bmatrix}$$
\end{document}


Producing

• I'd replace all . (periods) with \cdot, and I'd replace \vdots in the first column vector with \cdot \\ \cdot. (This comment pertains to the first version of the matrix equation.) – Mico May 9 '15 at 7:53
• @Mico Why \cdot \\ \cdot and not \vdots ? – Holene May 9 '15 at 7:54
• Because \vdots produces a row-height mismatch. Better to produce two rows, each with either . or \cdot. Incidentally, I think it would also be OK to get rid of the parentheses around 1-2r. – Mico May 9 '15 at 7:55
• @Mico Aha, I didn't know about the height mismatch. Thanks! – Holene May 9 '15 at 7:57
• The row height mismatch in the first version occurs because the matrix contains two ordinary-height rows whereas the column vectors contain one row with above-average height. That's why I was recommending using . \\ . instead of \vdots in the column vectors, as doing so will even out the row heights. The mismatch in the second example occurs because \vdots and \ddots are taller than \mathstrut (the basic height of a row). Suggested remedy: Insert the instruction \renewcommand{\arraystretch}{1.7} after . – Mico May 9 '15 at 8:15