6

I'm trying to implement the matrix and vector below, the number of columns in the matrix is equal to the number of rows in the vector but it's not showing properly. The matrix is composed of three inner matrices: diag(p1,p2), Identity and diag(p3,p4). The identity in the middle is NxN! and the vector is [1 1 x1 ....xN 1 1]^T

\begin{align}
\begin{bmatrix}
p_1 & 0 & \ldots & \ldots & 0\\0 & p_2 & \ldots & \ddots & 0\\ \vdots & \vdots & \Huge{\mathbf{I}} & \ldots & 0\\0 & 0 & \ldots & p_3 & 0\\0 & 0 & \ldots & 0 & p_4 
\end{bmatrix}\begin{bmatrix}1\\1\\d_1\\ \vdots\\d_N\\1\\1\\ \end{bmatrix}
\label{Eq:matrix}
\end{align}
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. — The matrix has five columns, the vector has seven rows? – Qrrbrbirlbel Aug 4 '13 at 19:21
5

You could do the following:

Code

\documentclass[varwidth]{standalone}
\usepackage{amsmath}
\newcommand*{\mat}{\mathbf}
\begin{document}
\begin{equation*}
\begin{bmatrix}
    p_1    & 0      & \ldots        & \ldots & \ldots        & 0      & 0      \\
    0      & p_2    & \ldots        & \ldots & \ldots        & 0      & 0      \\
    \vdots & \vdots & \mat{I}_{1,1} &        &               & \vdots & \vdots \\
    \vdots & \vdots &               & \ddots &               & \vdots & \vdots \\
    \vdots & \vdots &               &        & \mat{I}_{N,N} & \vdots & \vdots \\
    0      & 0      & \ldots        & \ldots & \ldots        & p_3    & 0      \\
    0      & 0      & \ldots        & \ldots & \ldots        & 0      & p_4
\end{bmatrix}
%
\begin{bmatrix}
    1 \\ 1 \\ d_1 \\ \vdots \\ d_N \\ 1 \\ 1
\end{bmatrix}
%
\text{ or }
%
\begin{bmatrix}
    1 \\ 1 \\ d_1 \vphantom{\vdots} \\ \vdots \\ d_N \vphantom{\vdots} \\ 1 \\ 1
\end{bmatrix}
\label{Eq:matrix}
\end{equation*}
\end{document}

Output

enter image description here

| improve this answer | |
  • Thank you, but it is still the same problem i ran into where the size of the vector is not the same as the matrix. – user34626 Aug 4 '13 at 19:37
  • @user34626 You were talking about matrix columns and vector rows. So you simply want the vector have the same visual height as the matrix with the same number of rows? Add \vphantom{\vdots} to the rows with d_1 and d_N. Now the even have visually the same size. This works with your original code, too, of course. – Qrrbrbirlbel Aug 4 '13 at 19:40
5

Here is two possible options, although I am not entirely happy with it:

enter image description here

Code:

\documentclass{article}
\usepackage{amsmath}
%
\begin{document}
\begin{align*}
\begin{bmatrix}
p_1 & 0 & 0  & \multicolumn{2}{c}{\cdots} & 0\\
0 & p_2 &  0     &  \multicolumn{2}{c}{\cdots}  & 0\\ 
  0 & 0 &        &        &  \\
\vdots & \vdots  & \Huge{\mathbf{I}} &   & 0 & 0\\
  0 & 0 &        &        &  \\
0 & 0 & \cdots   & 0 &p_3 & 0\\
0 & 0 & \cdots   & 0 &0 & p_4 
\end{bmatrix}\begin{bmatrix}
    1\\
    1\\
    d_1
    \\
    \vdots\\
    d_N\\
    1\\
    1\\ 
\end{bmatrix}
\end{align*}
Another option:
\begin{align*}
\begin{bmatrix}
p_1 & 0 & 0  & \cdots& 0 & 0\\
0 & p_2 &  0     & \cdots  &0  & 0\\ 
  0 & 0 &        &        & 0  & 0 \\
\vdots & \vdots  & \multicolumn{2}{c}{\Huge{\mathbf{I}}}    & \vdots & \vdots\\
  0 & 0 &        &   &0    & 0  \\
0 & 0 & \cdots   & 0 &p_3 & 0\\
0 & 0 & \cdots   & 0 &0 & p_4 
\end{bmatrix}\begin{bmatrix}
    1\\
    1\\
    d_1
    \\
    \vdots\\
    d_N\\
    1\\
    1\\ 
\end{bmatrix}
\end{align*}
\end{document}
| improve this answer | |
4

It's a not even block diagonal it's a diagonal matrix so you can skip the matrix version

\documentclass{article}
\usepackage{mathtools}
\DeclarePairedDelimiter{\diagfences}{(}{)}
\newcommand{\diag}{\operatorname{diag}\diagfences}
%
\begin{document}
\[
\diag{p_1,p_2,\underbracket[0.5pt][2pt]{1,1,\ldots,1,1}_{N},p_3,p_4}
\begin{bmatrix}
    1\\
    1\\
    d_1
    \\
    \vdots\\
    d_N\\
    1\\
    1\\ 
\end{bmatrix}
\label{Eq:matrix}
\]
\end{document}

enter image description here

| improve this answer | |
  • True, but it looks better showing it in matrix form. – user34626 Aug 4 '13 at 19:52
  • 1
    @user34626 Not for my taste. Unnecassry matrix parsing for the reader. But of course it's taste issue. – percusse Aug 4 '13 at 19:56

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.