2

My matrix goes off the page. Usually, when I work with simple equations, I use the code \begin{eqnarray}\end{eqnarray*} to align equations vertically by the equal sign.

enter image description here

Do you know if I can do something similar with the following matrix code? \begin{eqnarray}\end{eqnarray*} doesn't work here.

\documentclass[paper=a4, fontsize=11pt]{scrartcl}
\usepackage{amsmath} 

\usepackage{enumitem}
\begin{document}

 %PROBLEM 2
  Let $\textbf{a}' = \begin{bmatrix}
       3 & 6 &-3 & 5 &  9& 2  \\
     \end{bmatrix}$. Find \textbf{a}$'$\textbf{a} and \textbf{aa}$'$.


 \textbf{a}$'$ is the transpose of $\textbf{a} = \begin{bmatrix}
       3 \\ 6 \\-3 \\ 5 \\  9\\ 2  \\
     \end{bmatrix}$

 \[\textbf{a}'\textbf{a} = \begin{bmatrix}
       3 & 6 &-3 & 5 &  9& 2  \\
     \end{bmatrix} \cdot \begin{bmatrix}
       3 \\ 6 \\-3 \\ 5 \\  9\\ 2  \\
     \end{bmatrix} = \begin{bmatrix}
       3^2 + 6^2 + (-3)^2 + 5^2 +  9^2 + 2^2  \\
     \end{bmatrix} =[164] \]

   \[\textbf{aa}' = \begin{bmatrix}
       3 \\ 6 \\-3 \\ 5 \\  9\\ 2  \\
     \end{bmatrix}\cdot \begin{bmatrix}
       3 & 6 &-3 & 5 &  9& 2  \\
     \end{bmatrix}  = \begin{bmatrix}
       3^2& 3\cdot 6 & 3\cdot (-3) & 3\cdot 5 &  3\cdot 9 & 3\cdot 2  \\
  6\cdot 3& 6^2 & 6\cdot (-3) & 6\cdot 5 &  6\cdot 9 & 6\cdot 2  \\
    (-3)\cdot 3& (-3)\cdot 6 & (-3)^2 & (-3)\cdot 5 &  (-3)\cdot 9 & (-3)\cdot 2  \\
      5\cdot 3& 5\cdot 6 & 5\cdot (-3) & 5^2 &  5\cdot 9 & 5\cdot 2  \\
        9\cdot 3& 9\cdot 6 & 9\cdot (-3) & 9\cdot 5 &  9^2 & 9\cdot 2  \\
         2\cdot 3& 2\cdot 6 & 2\cdot (-3) & 2\cdot 5 &  2\cdot 9 & 2^2  \\
     \end{bmatrix} \\=\begin{bmatrix}
       9& 18 & 9 & 15 &  27 & 6  \\
  18& 36 & -18 & 30 &  54 & 12  \\
    -9& -18 & 9 & -15 &  27 & -6  \\
      15& 30 & 15 & 10 &  45 & 10 \\
        27& 54 & 27 & 45 &  81 & 18  \\
         6& 12 & 6 & 10 &  18 & 4  \\
     \end{bmatrix} \]  

\end{document} 
  • 1
    You can use align* – user11232 Sep 18 '14 at 14:23
  • How exactly to use it? – Olga Sep 18 '14 at 14:23
4

Don't use eqnarray* (ever) but align*.

\documentclass[paper=a4, fontsize=11pt]{scrartcl}
\usepackage{amsmath}
\begin{document}
  \begin{align*}
   \mathbf{aa}' &= \begin{bmatrix}
                    3 \\ 6 \\-3 \\ 5 \\  9\\ 2  \\
                \end{bmatrix}\cdot
                \begin{bmatrix}
                  3 & 6 &-3 & 5 &  9& 2  \\
                \end{bmatrix}\\
             & = \begin{bmatrix}
                    3^2& 3\cdot 6 & 3\cdot (-3) & 3\cdot 5 &  3\cdot 9 & 3\cdot 2  \\
                    6\cdot 3& 6^2 & 6\cdot (-3) & 6\cdot 5 &  6\cdot 9 & 6\cdot 2  \\
                    (-3)\cdot 3& (-3)\cdot 6 & (-3)^2 & (-3)\cdot 5 &  (-3)\cdot 9 &
                    (-3)\cdot  2  \\
                    5\cdot 3& 5\cdot 6 & 5\cdot (-3) & 5^2 &  5\cdot 9 & 5\cdot 2  \\
                    9\cdot 3& 9\cdot 6 & 9\cdot (-3) & 9\cdot 5 &  9^2 & 9\cdot 2  \\
                    2\cdot 3& 2\cdot 6 & 2\cdot (-3) & 2\cdot 5 &  2\cdot 9 & 2^2  \\
                    \end{bmatrix} \\
             & =\begin{bmatrix}
                    9& 18 & 9 & 15 &  27 & 6  \\
                    18& 36 & -18 & 30 &  54 & 12  \\
                    -9& -18 & 9 & -15 &  27 & -6  \\
                    15& 30 & 15 & 10 &  45 & 10 \\
                    27& 54 & 27 & 45 &  81 & 18  \\
                    6& 12 & 6 & 10 &  18 & 4  \\
                \end{bmatrix}
  \end{align*}

\end{document}

enter image description here

If you want everything aligned to the left, use flalign*

\documentclass[paper=a4, fontsize=11pt]{scrartcl}
\usepackage{amsmath,showframe}       %%% remove showframe
\begin{document}
  \begin{flalign*}
   \mathbf{aa}' &= \begin{bmatrix}
                    3 \\ 6 \\-3 \\ 5 \\  9\\ 2  \\
                \end{bmatrix}\cdot
                \begin{bmatrix}
                  3 & 6 &-3 & 5 &  9& 2  \\
                \end{bmatrix}\\
             & = \begin{bmatrix}
                    3^2& 3\cdot 6 & 3\cdot (-3) & 3\cdot 5 &  3\cdot 9 & 3\cdot 2  \\
                    6\cdot 3& 6^2 & 6\cdot (-3) & 6\cdot 5 &  6\cdot 9 & 6\cdot 2  \\
                    (-3)\cdot 3& (-3)\cdot 6 & (-3)^2 & (-3)\cdot 5 &  (-3)\cdot 9 &
                    (-3)\cdot  2  \\
                    5\cdot 3& 5\cdot 6 & 5\cdot (-3) & 5^2 &  5\cdot 9 & 5\cdot 2  \\
                    9\cdot 3& 9\cdot 6 & 9\cdot (-3) & 9\cdot 5 &  9^2 & 9\cdot 2  \\
                    2\cdot 3& 2\cdot 6 & 2\cdot (-3) & 2\cdot 5 &  2\cdot 9 & 2^2  \\
                    \end{bmatrix} \\
             & =\begin{bmatrix}
                    9& 18 & 9 & 15 &  27 & 6  \\
                    18& 36 & -18 & 30 &  54 & 12  \\
                    -9& -18 & 9 & -15 &  27 & -6  \\
                    15& 30 & 15 & 10 &  45 & 10 \\
                    27& 54 & 27 & 45 &  81 & 18  \\
                    6& 12 & 6 & 10 &  18 & 4  \\
                \end{bmatrix}
                &        %%% this & is necessary
  \end{flalign*}

\end{document}

enter image description here

| improve this answer | |
  • 1
    Is there a specific reason not to use eqnarray? – Olga Sep 18 '14 at 14:37
  • 1
    @Olga: Read the answers in: eqnarray vs align – user11232 Sep 18 '14 at 14:45
  • @Harish Kumar: One might also put the matrices in a medsize environment (from nccmath, ~ 80 % of \displaystyle) in order to have more easy-to-read computations. – Bernard Sep 18 '14 at 15:00
  • Thanks. How to make sure that the output is aligned on the left but not center as it is right now? – Olga Sep 18 '14 at 15:00
  • Then use the flalign* environment. – Bernard Sep 18 '14 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.