# Side to side sum+product of matrices

I have been trying to write these matrices which are the results of a cointegration problem. However, I'm struggling to write down the second member of my matrices. As you can this is my code:

\begin{pmatrix}
\Delta A \\ \Delta BC \\ \Delta NB \\  \Delta NS \\  \Delta ON \\ \Delta Q  \\
\end{pmatrix}
\]
=
\begin{pmatrix} 0.36 & 0.09 & 0.04 & -0.40 & 0.26 & -0.36\\ 0.28 & -0.08& 0.04& -0.14& 0.28& -0.13\\ 0.16 & -0.01 & -0.08 & -0.009 & 0.57 & -0.64\\ 0.36 & 0.19 & -0.34 & -0.20 & 0.35 & 0.03\\ 0.18 & 0.15 & 0.08 & -0.07 & -0.03 & -0.32\\ 0.08 & 0.41 & -0.10 & -0.20 & 0.34 & -0.48\\ \end{pmatrix} \begin{pmatrix} \Delta A(-1) \\ \Delta BC(-1) \\ \Delta NB(-1) \\ \Delta NS(-1) \\ \Delta ON(-1) \\ \Delta Q(-1) \\ \end{pmatrix} + \begin{pmatrix} -0.84 & 0.21 & -0.11 & 0.110 & 0.13 & 0.34\\ 0.21 & -0.43 & 0.14 & 0.06 & 0.30 & -0.22\\ 0.27 & 0.13 & -0.54 & 0.25 & -0.27 & 0.16\\ -0.27 & -0.23 & 0.43 & -0.46 & 0.53 & -0.05\\ 0.05 & 0.13 & -0.02 & -0.10 & -0.03 & -0.02\\ 0.23 & -0.32 & 0.21 & -0.11 & 0.41 & -0.34\\ \end{pmatrix} \begin{pmatrix} A(-1) \\ BC(-1) \\ \ NB(-1) \\ \ NS(-1) \\ \ON(-1) \\ \Q(-1) \\ \end{pmatrix} + \begin{pmatrix} 12.10 \\ -4.97 \\ -1.12 \\ 4.56 \\ 0.10 \\ -5.85 \\ \end{pmatrix}  Can someone tells me how i improves my codes in order to get the results on the picture? • is this a discrete time state space representation of a nonlinear system ? – percusse Jan 23 '14 at 22:35 • @percusse, Nope. It is the representation of the Vector of error correction model. I derived this from the cointegration approach. – ntamjo achille Jan 24 '14 at 21:02 • Well in some coordinate transformation it's the same thing. You are updating recursively I think so better keep the matrices away from the equations of motion to emphasize the mechanism. – percusse Jan 24 '14 at 21:04 ## 4 Answers The multline* environment can help you here. It is a multiline math environment from amsmath that left aligns the first line, right aligns the last, and center aligns the rest. Add a linebreak with \\, and replace pmatrix with bmatrixto get braces rather than parentheses as matrix delimiters. Also note that empty lines are normally not allowed in display math environments. \documentclass{scrartcl} \usepackage{amsmath} \begin{document} \begin{multline*} \begin{bmatrix} \Delta A \\ \Delta BC \\ \Delta NB \\ \Delta NS \\ \Delta ON \\ \Delta Q \\ \end{bmatrix} = \begin{bmatrix} 0.36 & 0.09 & 0.04 & -0.40 & 0.26 & -0.36\\ 0.28 & -0.08& 0.04& -0.14& 0.28& -0.13\\ 0.16 & -0.01 & -0.08 & -0.009 & 0.57 & -0.64\\ 0.36 & 0.19 & -0.34 & -0.20 & 0.35 & 0.03\\ 0.18 & 0.15 & 0.08 & -0.07 & -0.03 & -0.32\\ 0.08 & 0.41 & -0.10 & -0.20 & 0.34 & -0.48\\ \end{bmatrix} \begin{bmatrix} \Delta A(-1) \\ \Delta BC(-1) \\ \Delta NB(-1) \\ \Delta NS(-1) \\ \Delta ON(-1) \\ \Delta Q(-1) \\ \end{bmatrix} + \\ \begin{bmatrix} -0.84 & 0.21 & -0.11 & 0.110 & 0.13 & 0.34\\ 0.21 & -0.43 & 0.14 & 0.06 & 0.30 & -0.22\\ 0.27 & 0.13 & -0.54 & 0.25 & -0.27 & 0.16\\ -0.27 & -0.23 & 0.43 & -0.46 & 0.53 & -0.05\\ 0.05 & 0.13 & -0.02 & -0.10 & -0.03 & -0.02\\ 0.23 & -0.32 & 0.21 & -0.11 & 0.41 & -0.34\\ \end{bmatrix} \begin{bmatrix} A(-1) \\ BC(-1) \\ \ NB(-1) \\ \ NS(-1) \\ ON(-1) \\ Q(-1) \\ \end{bmatrix} + \begin{bmatrix} 12.10 \\ -4.97 \\ -1.12 \\ 4.56 \\ 0.10 \\ -5.85 \\ \end{bmatrix} \end{multline*} \end{document} I would use align* to do this since you have two lines. \begin{align*} \begin{bmatrix} \Delta A \\ \Delta BC \\ \Delta NB \\ \Delta NS \\ \Delta ON \\ \Delta Q \end{bmatrix} &= \begin{bmatrix} 0.36 & 0.09 & 0.04 & -0.40 & 0.26 & -0.36\\ 0.28 & -0.08& 0.04& -0.14& 0.28& -0.13\\ 0.16 & -0.01 & -0.08 & -0.009 & 0.57 & -0.64\\ 0.36 & 0.19 & -0.34 & -0.20 & 0.35 & 0.03\\ 0.18 & 0.15 & 0.08 & -0.07 & -0.03 & -0.32\\ 0.08 & 0.41 & -0.10 & -0.20 & 0.34 & -0.48 \end{bmatrix} \begin{bmatrix} \Delta A(-1) \\ \Delta BC(-1) \\ \Delta NB(-1) \\ \Delta NS(-1) \\ \Delta ON(-1) \\ \Delta Q(-1) \end{bmatrix} \\ &{\quad{}} + \begin{bmatrix} -0.84 & 0.21 & -0.11 & 0.110 & 0.13 & 0.34\\ 0.21 & -0.43 & 0.14 & 0.06 & 0.30 & -0.22\\ 0.27 & 0.13 & -0.54 & 0.25 & -0.27 & 0.16\\ -0.27 & -0.23 & 0.43 & -0.46 & 0.53 & -0.05\\ 0.05 & 0.13 & -0.02 & -0.10 & -0.03 & -0.02\\ 0.23 & -0.32 & 0.21 & -0.11 & 0.41 & -0.34 \end{bmatrix} \begin{bmatrix} A(-1) \\ BC(-1) \\ NB(-1) \\ NS(-1) \\ ON(-1) \\ Q(-1) \end{bmatrix} + \begin{bmatrix} 12.10 \\ -4.97 \\ -1.12 \\ 4.56 \\ 0.10 \\ -5.85 \ \end{bmatrix} \end{align*} • Yeah it is working now with your code. Thanks – ntamjo achille Jan 23 '14 at 17:32 As I just noted on another answer... This is using the under-development tabstackengine package, first introduced here at Writing a table with equally spaced columns, based on the widest column (source code available at Measuring align). The package extends the stackengine package by adding tabbing capability. This answer, Can I tab inside of align environment?, gives some of the syntax of the package. I apologize that I have been lax in completing the package and getting it out the door, so the only way to see it in action is by searching this site for tabstackengine. But I noticed on this question that all answers have center alignment on the matrices which looks unappealing to me, so I thought I would provide an alternative. By using stacks to compose the individual vectors and matrices, the alignment may be individually specified for each one. Thus, I retained center alignment on the terms involving symbolic variables and right alignment for matrices involving real numbers. The space between the two matrix rows is controlled by the [10pt] optional argument to \stackunder. To get the minus signs to be unary, I needed to enclose them in braces. That would appear to be a deficiency of the package that I have not yet resolved, but the workaround is the braces. \documentclass{article} \usepackage{fixltx2e} \usepackage{tabstackengine} \stackMath \setstacktabbedgap{1ex} \begin{document} \[ \renewcommand\stackalignment{l} \stackunder[10pt]{% \renewcommand\stackalignment{c} \bracketVectorstack{ \Delta A \\ \Delta BC \\ \Delta NB \\ \Delta NS \\ \Delta ON \\ \Delta Q } = \renewcommand\stackalignment{r} \bracketMatrixstack{ 0.36 & 0.09 & 0.04 & {-}0.40 & 0.26 & {-}0.36\\ 0.28 & {-}0.08& 0.04& {-}0.14& 0.28& {-}0.13\\ 0.16 & {-}0.01 & {-}0.08 & {-}0.009 & 0.57 & {-}0.64\\ 0.36 & 0.19 & {-}0.34 & {-}0.20 & 0.35 & 0.03\\ 0.18 & 0.15 & 0.08 & {-}0.07 & {-}0.03 & {-}0.32\\ 0.08 & 0.41 & {-}0.10 & {-}0.20 & 0.34 & {-}0.48 } \renewcommand\stackalignment{c} \bracketVectorstack{ \Delta A({-}1) \\ \Delta BC({-}1) \\ \Delta NB({-}1) \\ \Delta NS({-}1) \\ \Delta ON({-}1) \\ \Delta Q({-}1) } +% }{% \hspace{12ex}% \renewcommand\stackalignment{r} \bracketMatrixstack{ {-}0.84 & 0.21 & {-}0.11 & 0.110 & 0.13 & 0.34\\ 0.21 & {-}0.43 & 0.14 & 0.06 & 0.30 & {-}0.22\\ 0.27 & 0.13 & {-}0.54 & 0.25 & {-}0.27 & 0.16\\ {-}0.27 & {-}0.23 & 0.43 & {-}0.46 & 0.53 & {-}0.05\\ 0.05 & 0.13 & {-}0.02 & {-}0.10 & {-}0.03 & {-}0.02\\ 0.23 & {-}0.32 & 0.21 & {-}0.11 & 0.41 & {-}0.34 } \renewcommand\stackalignment{c} \bracketVectorstack{ A({-}1) \\ BC({-}1) \\ NB({-}1) \\ NS({-}1) \\ ON({-}1) \\ Q({-}1) } + \renewcommand\stackalignment{r} \bracketVectorstack{ 12.10 \\ {-}4.97 \\ {-}1.12 \\ 4.56 \\ 0.10 \\ {-}5.85 }% }
\end{document} Similar in spirit to the answer by @StevenBSegletes (and borrowing some code from the answer by Torbjørn T.), but using the dcolumn package and the basic array environment to align the columns of numbers on their decimal markers: \documentclass{article}
\usepackage{amsmath,dcolumn}
\newcolumntype{d}{D..{2.2}} % for decimal-aligned numbers
\begin{document}
\begin{multline*}
\begin{bmatrix}
\Delta A \\ \Delta BC \\ \Delta NB \\  \Delta NS \\  \Delta ON \\ \Delta Q  \\
\end{bmatrix}
=
\left[\begin{array}{@{} *{6}{d}}
0.36 & 0.09 & 0.04 & -0.40 & 0.26 & -0.36\\
0.28 & -0.08& 0.04& -0.14& 0.28& -0.13\\
0.16 & -0.01 & -0.08 & -0.009 & 0.57 & -0.64\\
0.36 &  0.19 &  -0.34 & -0.20 &  0.35 &  0.03\\
0.18 &   0.15 & 0.08 &  -0.07 & -0.03 & -0.32\\
0.08 & 0.41 & -0.10 & -0.20 & 0.34 & -0.48\\
\end{array}\right]
\begin{bmatrix}
\Delta A(-1) \\ \Delta BC(-1) \\ \Delta NB(-1) \\  \Delta NS(-1) \\  \Delta ON(-1) \\  \Delta Q(-1) \\
\end{bmatrix}
+ \\
\left[\begin{array}{*{6}{d}}
-0.84 & 0.21 & -0.11 & 0.110 & 0.13 & 0.34\\
0.21 & -0.43 & 0.14 & 0.06 & 0.30 & -0.22\\
0.27 & 0.13 & -0.54 & 0.25 & -0.27 & 0.16\\
-0.27 &  -0.23 &  0.43 & -0.46 &  0.53 & -0.05\\
0.05 &   0.13 & -0.02 &  -0.10 & -0.03 & -0.02\\
0.23 & -0.32 & 0.21 & -0.11 & 0.41 & -0.34\\
\end{array}\right]
\begin{bmatrix}
A(-1) \\ BC(-1) \\ \ NB(-1) \\  \ NS(-1) \\  ON(-1) \\  Q(-1) \\
\end{bmatrix}
+
\left[\begin{array}{d}
12.10 \\ -4.97 \\ -1.12 \\  4.56 \\  0.10 \\  -5.85 \\
\end{array}\right]
\end{multline*}
\end{document}