Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to reproduce the following calculation of a determinant in latex:

enter image description here

Any ideas? I thought of using the tabular environment but unfortunately I'm not able to align the "=" correctly.

share|improve this question
2  
Please, add a Minimal Working Example, so the people could easily think and try with your problem. –  Manuel Jan 11 '13 at 20:01
add comment

3 Answers

up vote 7 down vote accepted

I just have one question: The numbers in the determine itself are all right aligned. You can see it in column 3, row 1 and 2 in the picture I posted. The 2 is just above the -2 and they are both right aligned, no matter if there is a minus or not. Do you have any idea how to realize that? -- user24295

No, I don't, but according to comments by percusse and Manuel you can do that by loading mathtools instead of amsmath and use \begin{vmatrix*}[r] … \end{vmatrix*}. I haven't checked though by myself. But I do recomment keep the standard alignement provided by \begin{vmatrix} ... \end{vmatrix}.


UPDATE with align. Thanks to cmhughes's advice I've replaced eqnarray with alignand &=& with &=. ADDED. As commented by egreg eqnarray should be avoided (see e.g. here and here) due to spacing discrepancies.

The updated code is:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align}
\det A &=\left. 
\begin{array}{c}
\;\;\text{*)} \\ 
-1\text{)} \\ 
-2\text{)} \\ 
-2\text{)}
\end{array}
\right. 
\begin{vmatrix}
1 & 3 & 2 & -6 \\ 
1 & 2 & -2 & -5 \\ 
2 & 4 & -2 & -9 \\ 
2 & 4 & -6 & -9  \notag
\end{vmatrix}
=
\begin{vmatrix}
1 & 3 & 2 & -6 \\ 
0 & -1 & -4 & 1 \\ 
0 & -2 & -6 & 3 \\ 
0 & -2 & -10 & 3
\end{vmatrix}
\\ \notag
&& \\ 
&=\left. 
\begin{array}{c}
\;\;\text{*)} \\ 
-2\text{)} \\ 
-2\text{)}
\end{array}
\right. 
\begin{vmatrix}
1 & 4 & 1 \\ 
2 & 6 & 3 \\ 
2 & 10 & 3
\end{vmatrix}
=
\begin{vmatrix}
1 & 4 & 1 \\ 
0 & -2 & 1 \\ 
0 & 2 & 1
\end{vmatrix}
=
\begin{vmatrix}
-2 & 1 \\ 
2 & 1
\end{vmatrix}
=-4\notag
\end{align}

\end{document} 

The Output is:

enter image description here


We can use the following code (with eqnarray)

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{eqnarray*}
\det A\; &=&\left. 
\begin{array}{c}
\;\;\text{*)} \\ 
-1\text{)} \\ 
-2\text{)} \\ 
-2\text{)}
\end{array}
\right. 
\begin{vmatrix}
1 & 3 & 2 & -6 \\ 
1 & 2 & -2 & -5 \\ 
2 & 4 & -2 & -9 \\ 
2 & 4 & -6 & -9
\end{vmatrix}
=
\begin{vmatrix}
1 & 3 & 2 & -6 \\ 
0 & -1 & -4 & 1 \\ 
0 & -2 & -6 & 3 \\ 
0 & -2 & -10 & 3
\end{vmatrix}
\\
&& \\
&=&\left. 
\begin{array}{c}
\;\;\text{*)} \\ 
-2\text{)} \\ 
-2\text{)}
\end{array}
\right. 
\begin{vmatrix}
1 & 4 & 1 \\ 
2 & 6 & 3 \\ 
2 & 10 & 3
\end{vmatrix}
=
\begin{vmatrix}
1 & 4 & 1 \\ 
0 & -2 & 1 \\ 
0 & 2 & 1
\end{vmatrix}
=
\begin{vmatrix}
-2 & 1 \\ 
2 & 1
\end{vmatrix}
=-4
\end{eqnarray*}

\end{document}

to type

enter image description here

share|improve this answer
4  
Please, don't recommend eqnarray under any circumstances. –  egreg Jan 11 '13 at 20:26
1  
Very nice except the eqnarray. Here is one out of many reasons. (vote capped for today) –  percusse Jan 11 '13 at 20:29
1  
s/eqnarray/align/g and s/&=&/&=/g should do the trick –  cmhughes Jan 11 '13 at 20:35
1  
Very nice done. Thank you @Américo Tavares for your help. I just have one question: The numbers in the determine itself are all right aligned. You can see it in column 3, row 1 and 2 in the picture I posted. The 2 is just above the -2 and they are both right aligned, no matter if there is a minus or not. Do you have any idea how to realize that? –  Martin Jan 11 '13 at 20:39
2  
@AméricoTavares To right align the columns you could use \begin{vmatrix*}[r] … \end{vmatrix*}. –  Manuel Jan 11 '13 at 21:29
show 13 more comments

You can define an xvmatrix environment for the "eXtended" matrix, where you specify the coefficients as a first column:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newenvironment{xvmatrix}% eXtended vmatrix
  {\left.\array{@{}r |@{\,}*\c@MaxMatrixCols c}}
  {\endarray\kern-\arraycolsep\right|}

\begin{document}

\begin{align*}
\det A &=
\begin{xvmatrix}
 *) & 1 & 3 &  2 & -6 \\ 
-1) & 1 & 2 & -2 & -5 \\ 
-2) & 2 & 4 & -2 & -9 \\ 
-2) & 2 & 4 & -6 & -9
\end{xvmatrix}
=
\begin{vmatrix}
1 & 3 & 2 & -6 \\ 
0 & -1 & -4 & 1 \\ 
0 & -2 & -6 & 3 \\ 
0 & -2 & -10 & 3
\end{vmatrix}
\\
&=
\begin{xvmatrix}
 *) & 1 &  4 & 1 \\ 
-2) & 2 &  6 & 3 \\ 
-2) & 2 & 10 & 3
\end{xvmatrix}
=
\begin{vmatrix}
1 & 4 & 1 \\ 
0 & -2 & 1 \\ 
0 & 2 & 1
\end{vmatrix}
=
\begin{vmatrix}
-2 & 1 \\ 
2 & 1
\end{vmatrix}
=-4
\end{align*}

\end{document}

enter image description here

share|improve this answer
    
And if that's always the notation, you could add ) to the environment so you don't need to write it all the times. Apart from that, I don't find this notation pleasant (*), etc. on the left of the matrix), I don't suggest any other, but I think this is not beautiful. –  Manuel Jan 11 '13 at 21:27
    
@Manuel I thought about adding the ) to the definition, but maybe leaving it in the cell makes clearer what the number is for. I don't like the notation, either. There's no need to use the Laplace development at any stage, the usual Gaussian elimination suffices. –  egreg Jan 11 '13 at 21:30
1  
Nitpicking: In the OP's picture, the numbers are right aligned. –  mafp Jan 12 '13 at 1:23
1  
@mafp I never right align the coefficients of a matrix. Adding that feature is possible, though. –  egreg Jan 12 '13 at 10:45
    
@egreg Oh, I would not write the whole determinant computation that way. But it is what the OP asked for. It works with mathtools, and then vmatrix[r], right? –  mafp Jan 12 '13 at 13:12
add comment

I do not consider a good habit introducing such a notation, my experience is that it only confuses people. Mathematical formalism is there for a reason. You can try the following:

enter image description here

\documentclass{article}
\pagestyle{empty}
\usepackage{amsmath}
\begin{document}

\begin{align*}
  \det A&=
  \underbrace{\begin{vmatrix}
    1 & 0 & 0 & 0 \\ 
    -1 & 1 & 0 & 0 \\ 
    -2 & 0 & 1 & 0 \\ 
    -2 & 0 & 0 & 1
  \end{vmatrix}}_{=1}
  \cdot
  \begin{vmatrix}
    1 & 3 & 2 & -6 \\ 
    1 & 2 & -2 & -5 \\ 
    2 & 4 & -2 & -9 \\ 
    2 & 4 & -6 & -9
  \end{vmatrix}
  =
  \begin{vmatrix}
    1 & 3 & 2 & -6 \\ 
    0 & -1 & -4 & 1 \\ 
    0 & -2 & -6 & 3 \\ 
    0 & -2 & -10 & 3
  \end{vmatrix}
  \\
  &=
  \underbrace{\begin{vmatrix}
    1 & 0 & 0 \\ 
    -2 & 1 & 0 \\ 
    -2 & 0 & 1
  \end{vmatrix}}_{=1}
  \cdot
  \begin{vmatrix}
    1 & 4 & 1 \\ 
    2 & 6 & 3 \\ 
    2 & 10 & 3
  \end{vmatrix}
  =
  \begin{vmatrix}
    1 & 4 & 1 \\ 
    0 & -2 & 1 \\ 
    0 & 2 & 1
  \end{vmatrix}
  =
  \begin{vmatrix}
    -2 & 1 \\ 
    2 & 1
  \end{vmatrix}
  =-4
\end{align*}

\end{document}

Somehow, it would make more sense if you tried to demonstrate the column manipulation, because then the triangle unit-determinant matrix would come on the right side. But even this is completely clear IMHO.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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