# Toeplitz matrix in LaTeX

How do I create a Toeplitz matrix like the following in LaTeX?

-
Thanks a lot my friend –  tanha Apr 29 at 8:10

\documentclass{article}
\usepackage{mathtools}
\begin{document}

$%\arraycolsep=4pt G = \begin{bmatrix*}[r] 1 \\ 2&1\\ -1&2&1\\ &-1&2&1\\ &&-1&2&1\\ &&&-1&2&1\\ &&&&&&\ddots\\ &&&&&&&\ddots\\ &&&&&&&&\ddots\\ &&&&&&&&&1 \end{bmatrix*}$
\end{document}


-
I think the last row must contain all non-zero elements: -1 2 1 –  Robert Fuster Apr 28 at 9:00
Thanks a lot my friend –  tanha Apr 29 at 8:10

Here you go:

\documentclass{article}
\pagestyle{empty}% for cropping
\usepackage{amsmath}
\begin{document}
\begin{equation*}
G =
\begin{bmatrix}
1 \cr
2&1\cr
-1&2&1\cr
&-1&2&1\cr
&&-1&2&1\cr
&&&-1&2&1\cr
&&&&&&\ddots\cr
&&&&&&&\ddots\cr
&&&&&&&&\ddots\cr
&&&&&&&&&1\cr
\end{bmatrix}
\end{equation*}
\end{document}


To get nicer alignment of the minus-signs you could use an array with right-aligned columns

\documentclass{article}
\pagestyle{empty}% for cropping
\usepackage{amsmath}
\begin{document}
\begin{equation*}
G =
\left[
\begin{array}{*{10}r}
1 \cr
2&1\cr
-1&2&1\cr
&-1&2&1\cr
&&-1&2&1\cr
&&&-1&2&1\cr
&&&&&&\ddots\cr
&&&&&&&\ddots\cr
&&&&&&&&\ddots\cr
&&&&&&&&&1\cr
\end{array}
\right]
\end{equation*}
\end{document}


-
to get the right alignment, it's simpler to load the mathtools package and write: begin{bmatrix*}[r] … \end{bmatrix*}. –  Bernard Apr 28 at 8:36
Is there a reason to use \cr instead of \? –  Manuel Apr 28 at 14:53
@Manuel Because I often use plain TeX and there is no \\. In this case both are equivalent. Also \cr is primitive, hence it doesn't need to get expanded, you may save half a nano-second by that. –  Henri Menke Apr 28 at 15:06
Thanks a lot my friend –  tanha Apr 29 at 8:10