## LaTeX forum ⇒ Math & Science ⇒ Display the determinant of a matrix with the rule of Sarrus.

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
vinc
Posts: 9
Joined: Fri Oct 25, 2019 7:12 pm

### Display the determinant of a matrix with the rule of Sarrus.

Good evening

I would like to realize a LaTex page with the calculation of the determinant of a matrix with the rule of Sarrus.

I found this tutorial.

https://tex.stackovernet.com/fr/q/103579

It does not work, I get lots of mistakes.

On my computer I have MikeTex.

See you soon

Stefan Kottwitz
Posts: 9567
Joined: Mon Mar 10, 2008 9:44 pm
Hi vinc,

welcome to the forum!

vinc wrote:It does not work

Which code exactly did you try?

vinc wrote:I get lots of mistakes.

What mistakes? Can you tell us error messages?

Stefan

vinc
Posts: 9
Joined: Fri Oct 25, 2019 7:12 pm
Good evening

here is the code

\usepackage[frenchb]{babel}\usepackage{array, mathtools} \usepackage{amsmath,amsfonts,amssymb}\documentclass[11pt,a4paper]{scrbook}$det(B)=\begin{array}{|ccc|cc|}1 & 1 & 0 & 1 & 1\\-1 & 2 & -1 & -1 & 2\\-1 &-1 & 3 & -1 & -1\\\end{array}$\end{document}

here is the image prints screen.

matrix-example.png (2 KiB) Viewed 3114 times

I can not select the lines. Method of the rule of sarrus.

A simple selection line would suffice.

See you soon

Stefan Kottwitz
Posts: 9567
Joined: Mon Mar 10, 2008 9:44 pm
Here is a way with TikZ:

\documentclass{article}\usepackage{tikz}\usetikzlibrary{matrix,calc}\begin{document}$\det(B) =$\begin{tikzpicture}[baseline = (m-2-2.base) ]  \matrix (m) [matrix of math nodes,               row sep = .5em, column sep = .5em,               every node/.style = {anchor = base east}] {    \ 1 & 1 & 0  & \ 1 & 1  \\     -1 & 2 & -1 &  -1 & 2  \\     -1 &-1 & 3  &  -1 & -1 \\  };  \draw    (m-1-1.north west) -- ++(0em,-5em)    (m-1-4.north west) -- ++(0em,-5em)    (m-1-5.north east) -- ++(0em,-5em)  ;  \draw [color = red]    (m-1-1.south east) -- (m-3-3.north west)    (m-1-2.south east) -- (m-3-4.north west)    (m-1-3.south east) -- (m-3-5.north west)  ;  \draw [color = blue]    (m-1-3.south west) -- (m-3-1.north east)    (m-1-4.south west) -- (m-3-2.north east)    (m-1-5.south west) -- (m-3-3.north east)  ;\end{tikzpicture}\end{document}

matrix.png (11.97 KiB) Viewed 3116 times

Stefan

vinc
Posts: 9
Joined: Fri Oct 25, 2019 7:12 pm
Hello

It did not work, it looks like it is missing a package.

Here is a screenshot of the error.

Here is the code.

\documentclass[11pt,a4paper]{scrbook}\usepackage[utf8x]{inputenc}\usepackage[T1]{fontenc}\usepackage{lmodern}\usepackage{textcomp}\usepackage[a4paper,pdftex,dvips]{geometry}\usepackage[frenchb]{babel}\usepackage{array, mathtools} \usepackage{amsmath,amsfonts,amssymb}\usepackage{tikz}\usetikzlibrary{calc,matrix}\usepackage[font={small,it}]{floatrow}\usepackage{setspace}\usepackage{systeme}\usetikzlibrary{matrix,calc}\begin{document}$det(B)=$\begin{tikzpicture}[baseline = (m-2-2.base) ]matrix (m) [matrix of math nodes, row sep = .5em, column sep = .5em, every node/.style = {anchor = base east}] { 1&1&0&1&1 \\ -1&2&-1&-1&2 \\ -1&-1&3&-1&-1 \\ }; (m-1-1.north west) -- ++(0em,-5em) (m-1-4.north west) -- ++(0em,-5em) (m-1-5.north east) -- ++(0em,-5em);draw [color = red] (m-1-1.south east) -- (m-3-3.north west) (m-1-2.south east) -- (m-3-4.north west) (m-1-3.south east) -- (m-3-5.north west); \draw [color = blue] (m-1-3.south west) -- (m-3-1.north east) (m-1-4.south west) -- (m-3-2.north east) (m-1-5.south west) -- (m-3-3.north east);\end{tikzpicture}\end{document}

I took out \ he rejected them

See you soon

Stefan Kottwitz
Posts: 9567
Joined: Mon Mar 10, 2008 9:44 pm
You forgot the backslash for the matrix command. Write \matrix instead of just matrix.

And remove the unnecessary empty lines in the code. Empty lines are paragraph breaks, and there should not be a paragraph break within a list of options or in the middle of a matrix.

Btw. it's nice that you provide screenshots, but can you please post them directly here? You can post images as attachments, the "Attachments" link is below the text edit field, when editing a post. See your original post above, I did it there for you, so you can see the image inline. And also btw. the "LaTeX" button is more for inline LaTeX commands, for longer code there is the "Code" button, for the editor. It looks nicer, as in my post above. Just to let you know.

Thanks!

Stefan

vinc
Posts: 9
Joined: Fri Oct 25, 2019 7:12 pm
good evening

There is one more problem.

Here is the code below.

$det(B)=$ \begin{tikzpicture}[baseline = (m-2-2.base) ]\matrix (m) [matrix of math nodes,              row sep = .5em, column sep = .5em,               every node/.style = {anchor = base east}] {     1&1&0&1&1  \\     -1&2&-1&-1&2  \\     -1&-1&3&-1&-1 \\  };   (m-1-1.north west) -- ++(0em,-5em)   (m-1-4.north west) -- ++(0em,-5em) ;  (m-1-5.north east) -- ++(0em,-5em) draw [color = red]    (m-1-1.south east) -- (m-3-3.north west)    (m-1-2.south east) -- (m-3-4.north west)   (m-1-3.south east) -- (m-3-5.north west)   ;  \draw [color = blue]    (m-1-3.south west) -- (m-3-1.north east)    (m-1-4.south west) -- (m-3-2.north east)   (m-1-5.south west) -- (m-3-3.north east);\end{tikzpicture}

Error on lines 49 (end{tikzpicture}).

! Missing } inserted.<inserted text>}
! Misplaced \cr.<inserted text> \cr \end{tikzpicture}

See you soon

Stefan Kottwitz
Posts: 9567
Joined: Mon Mar 10, 2008 9:44 pm
It is caused by the paragraph break within the matrix, by that empty line.

Stefan

vinc
Posts: 9
Joined: Fri Oct 25, 2019 7:12 pm
good evening

I almost arrived there, it misses the lines of the table.

$det(B)=$\begin{tikzpicture}[baseline = (m-2-2.base)]\matrix (m) [matrix of math nodes,              row sep = .5em, column sep = .5em,               every node/.style = {anchor = base east}] {    \ 1 & 1 & 0  & \  1 & 1  \\     -1 & 2 &-1  &-   1 & 2  \\     -1 &-1 & 3  &    1 &-1 \\};  (m-1-1.north west) -- ++(0em,-5em)   (m-1-4.north west) -- ++(0em,-5em)   (m-1-5.north east) -- ++(0em,-5em);\draw [color = red]    (m-1-1.south east) -- (m-3-3.north west)    (m-1-2.south east) -- (m-3-4.north west)   (m-1-3.south east) -- (m-3-5.north west);  \draw [color = blue]    (m-1-3.south west) -- (m-3-1.north east)    (m-1-4.south west) -- (m-3-2.north east)   (m-1-5.south west) -- (m-3-3.north east);\end{tikzpicture}

Here is the screen print.

latexdet.png (4.61 KiB) Viewed 3036 times

Thank you !

See you soon

Stefan Kottwitz