[Tex/LaTex] Reduce a matrix to row echelon form:
matricestikz-matrix
Related Solutions
If you need the vertical and horizontal lines around the matrix blocks, the following solution (which also doesn't require TikZ) may be of interest. (I've updated the example to reflect the update in your question, which appears to require an extra \ddots
row/column.)
Note that I use the array
environment rather than the matrix
(or pmatrix
) environment as it's necessary to right-align the contents of some columns.
\documentclass{article}
\usepackage{amsmath,array}
\renewcommand\arraycolsep{4pt} % default value: 6pt
% short-hand commands for multicolumn entries with vertical bar
% on left and right hand sides, respectively
\newcommand{\mcl}[1]{\multicolumn{1}{|r}{#1}}
\newcommand{\mcr}[1]{\multicolumn{1}{r|}{#1}}
\begin{document}
\begin{equation*}
\left( \,\begin{array}{rcr rcr rr c rr}
\cline{1-3}
\mcl{1} & & \mcr{} \\
\mcl{} & \ddots & \mcr{} \\
\mcl{} & & \mcr{1} \\
\cline{1-6}
& & & \mcl{-1} & & \mcr{} \\
& & & \mcl{} & \ddots & \mcr{} \\
& & & \mcl{} & & \mcr{-1}\\
\cline{4-8}
& & & & & & \mcl{\cos \omega} & \mcr{-\sin \omega}\\
& & & & & & \mcl{\sin \omega} & \mcr{ \cos \omega}\\
\cline{7-8}
& & & & & & & & \ddots\\
\cline{10-11}
& & & & & & & & & \mcl{\cos \omega} & \mcr{-\sin \omega}\\
& & & & & & & & & \mcl{\sin \omega} & \mcr{ \cos \omega}\\
\cline{10-11}
\end{array}\,\right)
\end{equation*}
\end{document}
Addendum: Using the \boxed
macro, the code that sets up this matrix can be simplified considerably:
\documentclass{article}
\usepackage{amsmath,array}
\renewcommand\arraycolsep{4pt} % default value: 6pt
\begin{document}
\begin{equation*}
\left( \,
\begin{array}{r@{}r@{}r r r} % @{} is used twice to suppress intercolumn whitespace
\boxed{ \begin{array}{rrr} % First block
1 \\
& \ddots\\
& & 1 \\
\end{array} } \\
& \boxed{ \begin{array}{rrr} % Second block
-1 \\
& \ddots\\
& & -1\\
\end{array} } \\
& & \boxed{ \begin{array}{rr} % Third block
\cos \omega & -\sin \omega\\
\sin \omega & \cos \omega\\
\end{array} } \\
& & & \ddots\\ % Fourth "block" -- not boxed
& & & & \boxed{ \begin{array}{rr} % Fifth block
\cos \omega & -\sin \omega\\
\sin \omega & \cos \omega\\
\end{array} } \\
\end{array}\,\right)
\end{equation*}
\end{document}
\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}
Best Answer
Since this is very quick to do (except for punching in the entries) here is a version with
nicematrix
. I agree with @fractal, though, that this is not the purpose of the site.There are zillions of alternatives, some will require less packages at the expense of having less control, others will criticize the spacing here (but it is to reproduce the screen shot) and so on and so forth. The question whether such matrices really help the reader to understand what's going on is off-topic, this is merely to say that if you really need to it is easy to create such things.