LaTeX forum ⇒ Math & ScienceRule of Sarrus Topic is solved

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Math12345
Posts: 8
Joined: Sun Aug 07, 2011 7:20 am

Rule of Sarrus

Postby Math12345 » Sun Aug 07, 2011 7:28 am

I have a problem! I need to write the Sarrus rule for 3x3 determinant, indicating additional two columns (to the right of the matrix) and diagonal lines for positive and negative products. How should I proceed? any idea?
Thanks in advance and greetings
Last edited by Math12345 on Mon Aug 08, 2011 11:42 am, edited 1 time in total.

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Sun Aug 07, 2011 11:12 am

A usual environment like array won't help you on here. The pgf/tikZ package can help you to construct a matrix with the necessary properties and the capability to connect the matrix elements with lines (or arrows). Let's take the example from the Wikipedia article [1].
  1. \documentclass{minimal}
  2. \usepackage{tikz}
  3. \usetikzlibrary{calc,matrix}
  4.  
  5. \begin{document}
  6. \begin{tikzpicture}
  7. \matrix [%
  8. matrix of math nodes,
  9. column sep=1em,
  10. row sep=1em
  11. ] (sarrus) {%
  12. a_{11} & a_{12} & a_{13} & a_{11} & a_{12} \\
  13. a_{21} & a_{22} & a_{23} & a_{21} & a_{22} \\
  14. a_{31} & a_{32} & a_{33} & a_{31} & a_{32} \\
  15. };
  16.  
  17. \path ($(sarrus-1-3.north east)+(0.5em,0)$) edge[dotted] ($(sarrus-3-3.south east)+(0.5em,0)$)
  18. (sarrus-1-1) edge (sarrus-2-2)
  19. (sarrus-2-2) edge (sarrus-3-3)
  20. (sarrus-1-2) edge (sarrus-2-3)
  21. (sarrus-2-3) edge (sarrus-3-4)
  22. (sarrus-1-3) edge (sarrus-2-4)
  23. (sarrus-2-4) edge (sarrus-3-5)
  24. (sarrus-3-1) edge[dashed] (sarrus-2-2)
  25. (sarrus-2-2) edge[dashed] (sarrus-1-3)
  26. (sarrus-3-2) edge[dashed] (sarrus-2-3)
  27. (sarrus-2-3) edge[dashed] (sarrus-1-4)
  28. (sarrus-3-3) edge[dashed] (sarrus-2-4)
  29. (sarrus-2-4) edge[dashed] (sarrus-1-5);
  30.  
  31. \foreach \c in {1,2,3} {\node[anchor=south] at (sarrus-1-\c.north) {$+$};};
  32. \foreach \c in {1,2,3} {\node[anchor=north] at (sarrus-3-\c.south) {$-$};};
  33. \end{tikzpicture}
  34. \end{document}

For further adjustments and modifications take a look at the very comprehensive package manual.

[1] Rule of Sarrus — Wikipedia, the free encyclopedia


Best regards and welcome to the board
Thorsten
Attachments
Sarrus.png
Rendered output of the given code.
Sarrus.png (8.52 KiB) Viewed 6868 times
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

Math12345
Posts: 8
Joined: Sun Aug 07, 2011 7:20 am

Postby Math12345 » Sun Aug 07, 2011 2:19 pm

Thanks Torsten for the code.
However, when trying to run it I get the message
  1. l.3 \usetikzlibrary{calc,matrix}
  2. Please type another input file name:

And then nothing more....
I am not so skilled in Latex and am not sure how to ommit it.

Best, and thanks.

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Sun Aug 07, 2011 2:44 pm

Submit the complete log file produced by my example code by upload to the forum server.
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

User avatar
Stefan Kottwitz
Site Admin
Posts: 9595
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sun Aug 07, 2011 2:46 pm

You could check if you use the current version of pgf/TikZ, which is 2.10. If not, I recommend updating it.

Stefan
LaTeX.org admin

Math12345
Posts: 8
Joined: Sun Aug 07, 2011 7:20 am

Postby Math12345 » Sun Aug 07, 2011 5:31 pm

Thanks Torsten and Stefan,
I noticed that I didn't have PGF/TikZ installed on my Mac at all. I downloaded version 2.10 but here is no information what so ever how to install it or were to put the files. As soon as I solve this problem I will check the code from Thorsten. If you have an idea how to handle the installation, please advice (I use TexShop)

All the best.

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Sun Aug 07, 2011 5:43 pm

Math12345 wrote:[…] If you have an idea how to handle the installation, please advice (I use TexShop) […]

I guess that the TeX Live Utility will be very helpful in this regard. I don't know how to get it. Perhaps it is already installed with MacTeX.
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Postby frabjous » Sun Aug 07, 2011 5:43 pm

Don't try to install it manually. Use the package manager of your TeX distribution. E.g., try (from a terminal):

  1. sudo tlmgr install pgf


You might also look into the possibility of a GUI frontend for your distribution; some info here for MacTeX.

Math12345
Posts: 8
Joined: Sun Aug 07, 2011 7:20 am

Postby Math12345 » Mon Aug 08, 2011 12:51 am

IT WORKS !!!!!!
I'd like to say THANK YOU to all wonderful contributors!
:)


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 3 guests