From a3ef6c437ebc166a9c86c4ef6bfbfeefb987a726 Mon Sep 17 00:00:00 2001 From: Arthur Herbette Date: Tue, 14 Apr 2026 14:01:39 +0200 Subject: [PATCH 1/2] replace two images in chapter 6 by a tikz diagrams --- Notes/TIKZ/determinant-algo-slow.tikz | 27 +++++++ Notes/TIKZ/echelon-gaussian-elimination.tikz | 75 ++++++++++++++++++++ Notes/algorithms.tex | 4 +- 3 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 Notes/TIKZ/determinant-algo-slow.tikz create mode 100644 Notes/TIKZ/echelon-gaussian-elimination.tikz diff --git a/Notes/TIKZ/determinant-algo-slow.tikz b/Notes/TIKZ/determinant-algo-slow.tikz new file mode 100644 index 0000000..65e1ea3 --- /dev/null +++ b/Notes/TIKZ/determinant-algo-slow.tikz @@ -0,0 +1,27 @@ + +\begin{tikzpicture}[ + level distance=2cm, + level 1/.style={->, sibling distance=4cm}, + level 2/.style={->, sibling distance=2cm}, + every node/.style={align=center} +] + +\node {$\left[\begin{array}{ccc} 3 & 7 & 5 \\ 2 & 9 & 8 \\ 1 & 3 & 3 \end{array}\right]$} +child { + node {$\left[\begin{array}{cc} 3 & 8 \\ 3 & 3 \end{array}\right]$} + child { node {$[3]$} } + child { node {$[3]$} } +} +child { + node {$\left[\begin{array}{cc} 2 & 8 \\ 1 & 3 \end{array}\right]$} + child { node {$[3]$} } + child { node {$[4]$} } +} +child { + node {$\left[\begin{array}{cc} 2 & 9 \\ 1 & 3 \end{array}\right]$} + child { node {$[3]$} } + child { node {$[4]$} } +}; + +\end{tikzpicture} + diff --git a/Notes/TIKZ/echelon-gaussian-elimination.tikz b/Notes/TIKZ/echelon-gaussian-elimination.tikz new file mode 100644 index 0000000..8540891 --- /dev/null +++ b/Notes/TIKZ/echelon-gaussian-elimination.tikz @@ -0,0 +1,75 @@ +\begin{tikzpicture}[scale=0.6] + +% Colors +\definecolor{mypurple}{RGB}{170,110,200} +\definecolor{myred}{RGB}{210,120,140} +\definecolor{myblue}{RGB}{0,150,180} + +\definecolor{green}{RGB}{0,140,0} + +\draw[thick, green] + (2,-0.5) -- (6.3,-0.5) -- (6.3 ,1) + -- (6.3,1) + -- (6.3,1.8) + -- (4.8,1.8) + -- (4.8,2.6) + -- (3.3,2.6) + -- (3.3,3.4) + -- (2,3.4) + -- cycle; + +\node[green] at (3,1.2) {$0$'s only}; + +\draw[thick, myblue] + (2,4.2) + -- (6.3 ,4.2) + -- (6.3,2) + -- (5,2) + -- (5,2.8) + -- (3.5,2.8) + -- (3.5,3.6) + -- (2,3.6) + -- (2,4.2); + + + +\draw[thick, myred] + (6.5, 4.2) + -- (10, 4.2) + -- (10, 2) + -- (6.5, 2) + -- (6.5, 4.2); + +\draw[thick, mypurple] + (6.5, 1.8) + -- (10, 1.8) + -- (10, -0.5) + -- (6.5, -0.5) + -- (6.5, 1.8); +% Red X marks +\foreach \x/\y in { + 2.3/3.9, + 3.8/3.1, + 5.3/2.3 +}{ + \draw[red, thick] (\x-0.15,\y-0.15) -- (\x+0.15,\y+0.15); + \draw[red, thick] (\x-0.15,\y+0.15) -- (\x+0.15,\y-0.15); +} + +% "Nonzero" label +\node[red] at (3.5,6) {Nonzero}; + +% Red arrows +\draw[red, ->, thick] (3.1,5.8) to[out=-150,in=90] (2.3,4.25); +\draw[red, ->, thick] (3.6,5.8) to[out=-90,in=90] (3.8,3.3); +\draw[red, ->, thick] (4.1,5.8) to[out=-90,in=90] (5.3,2.5); + +\node[myblue] at (0.25,1.2) {$i$}; +\draw[myblue, ->, thick](0.75, 1.2) -- (1.5, 1.2); +\node[myblue] at (5.5, 5.75) {$j$}; +\draw[myblue, ->, thick](5.5, 5.25) -- (5.5,4.5); + +\node[mypurple] at (9, 0) {next}; + +\end{tikzpicture} + diff --git a/Notes/algorithms.tex b/Notes/algorithms.tex index e353873..967735f 100644 --- a/Notes/algorithms.tex +++ b/Notes/algorithms.tex @@ -214,7 +214,7 @@ \chapter{Algorithms and running time analysis} \begin{figure} \centering - \includegraphics[height=5cm]{figures/DeterminantAlgoSlow.jpg} + \input{./TIKZ/determinant-algo-slow.tikz} \caption{An example of the recursion tree of the algorithm from Example~\ref{exe:det}. The tree corresponds to the run of the algorithm on input $\protect\smat{ 3 & 7 & 5 \\ 2&9&8 \\ 1 & 3 & 3 }.$ } \end{figure} @@ -295,7 +295,7 @@ \section{Analysis of Gaussian elimination} \begin{figure} \centering - \includegraphics[height=5cm]{figures/Echelon.jpg} + \input{./TIKZ/echelon-gaussian-elimination.tikz} \caption{Gaussian elimination: The matrix $A'$ before the $i$-th iteration of the while loop. \label{fig:9}} \end{figure} From 80dbf4d614dd0f2a391dd31e03baf4b9f5df0488 Mon Sep 17 00:00:00 2001 From: Arthur Herbette Date: Tue, 14 Apr 2026 14:07:43 +0200 Subject: [PATCH 2/2] fix typos in determinant-algo-slow --- Notes/TIKZ/determinant-algo-slow.tikz | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Notes/TIKZ/determinant-algo-slow.tikz b/Notes/TIKZ/determinant-algo-slow.tikz index 65e1ea3..115db40 100644 --- a/Notes/TIKZ/determinant-algo-slow.tikz +++ b/Notes/TIKZ/determinant-algo-slow.tikz @@ -15,12 +15,12 @@ child { child { node {$\left[\begin{array}{cc} 2 & 8 \\ 1 & 3 \end{array}\right]$} child { node {$[3]$} } - child { node {$[4]$} } + child { node {$[1]$} } } child { node {$\left[\begin{array}{cc} 2 & 9 \\ 1 & 3 \end{array}\right]$} child { node {$[3]$} } - child { node {$[4]$} } + child { node {$[1]$} } }; \end{tikzpicture}