diff --git a/documents/Numerik/Klausur1/Aufgabe1.tex b/documents/Numerik/Klausur1/Aufgabe1.tex index 25e5706..52a645e 100644 --- a/documents/Numerik/Klausur1/Aufgabe1.tex +++ b/documents/Numerik/Klausur1/Aufgabe1.tex @@ -13,19 +13,24 @@ \textbf{Lösung:} -\[P = -\begin{pmatrix} - 0 & 1 & 0 \\ - 1 & 0 & 0 \\ - 0 & 0 & 1 -\end{pmatrix}\] - -durch scharfes hinsehen. - -Nun $L, R$ berechnen: - -\begin{align} - &\begin{gmatrix}[p] +\begin{align*} + & + & + A^{(0)} &= \begin{gmatrix}[p] + 3 & 15 & 13 \\ + 6 & 6 & 6 \\ + 2 & 8 & 19 + \rowops + \swap{0}{1} + \end{gmatrix} + &\\ + P^{(1)} &= \begin{pmatrix} + 0 & 1 & 0\\ + 1 & 0 & 0\\ + 0 & 0 & 1 + \end{pmatrix}, + & + A^{(1)} &= \begin{gmatrix}[p] 6 & 6 & 6 \\ 3 & 15 & 13 \\ 2 & 8 & 19 @@ -33,128 +38,48 @@ Nun $L, R$ berechnen: \add[\cdot (-\frac{1}{2})]{0}{1} \add[\cdot (-\frac{1}{3})]{0}{2} \end{gmatrix} - \\ - = \begin{pmatrix} - 1 & 0 & 0 \\ - -\frac{1}{2} & 1 & 0 \\ - -\frac{1}{3} & 0 & 1 - \end{pmatrix} \cdot - &\begin{gmatrix}[p] + &\\ + L^{(2)} &= \begin{pmatrix} + 1 & 0 & 0\\ + -\frac{1}{2} & 1 & 0\\ + -\frac{1}{3} & 0 & 1 + \end{pmatrix}, + & + A^{(2)} &= \begin{gmatrix}[p] 6 & 6 & 6 \\ 0 & 12 & 10 \\ 0 & 6 & 17 \rowops \add[\cdot (-\frac{1}{2})]{1}{2} \end{gmatrix} - \\ - = \begin{pmatrix} - 1 & 0 & 0 \\ - 0 & 1 & 0 \\ - 0 & -\frac{1}{2} & 1 - \end{pmatrix} \cdot - \begin{pmatrix} - 1 & 0 & 0 \\ - -\frac{1}{2} & 1 & 0 \\ - -\frac{1}{3} & 0 & 1 - \end{pmatrix} \cdot - &\begin{gmatrix}[p] + &\\ + L^{(3)} &= \begin{pmatrix} + 1 & 0 & 0\\ + 0 & 1 & 0\\ + 0 & -\frac{1}{2} & 1 + \end{pmatrix}, + & + A^{(3)} &= \begin{gmatrix}[p] 6 & 6 & 6 \\ 0 & 12 & 10 \\ 0 & 0 & 12 - \colops - \add[\cdot (-1)]{0}{1} - \add[\cdot (-1)]{0}{2} \end{gmatrix} - \\ - = \begin{pmatrix} - 1 & 0 & 0 \\ - -\frac{1}{2} & 1 & 0 \\ - -\frac{1}{12} & - \frac{1}{2} & 1 - \end{pmatrix} \cdot - &\begin{gmatrix}[p] - 6 & 0 & 0 \\ - 0 & 12 & 10 \\ - 0 & 0 & 12 - \colops - \add[\cdot (-\frac{10}{12})]{1}{2} - \end{gmatrix} - \cdot - \begin{pmatrix} - 1 & -1 & -1 \\ - 0 & 1 & 0 \\ - 0 & 0 & 1 +\end{align*} + +Es gilt: + +\begin{align} + L^{(3)} \cdot L^{(2)} \cdot \underbrace{P^{(1)}}_{=: P} \cdot A^{0} &= \underbrace{A^{(3)}}_{=: R}\\ + \Leftrightarrow P A &= (L^{(3)} \cdot L^{(2)})^{-1} \cdot R \\ + \Rightarrow L &= (L^{(3)} \cdot L^{(2)})^{-1}\\ + &= \begin{pmatrix} + 1 & 0 & 0\\ + \frac{1}{2} & 1 & 0\\ + \frac{1}{3} & \frac{1}{2} & 1 \end{pmatrix} - \\ - = \begin{pmatrix} - 1 & 0 & 0 \\ - -\frac{1}{2} & 1 & 0 \\ - -\frac{1}{12} & - \frac{1}{2} & 1 - \end{pmatrix} \cdot - &\begin{gmatrix}[p] - 6 & 0 & 0 \\ - 0 & 12 & 0 \\ - 0 & 0 & 12 - \colops - \mult{0}{\cdot \frac{1}{6}} - \mult{1}{\cdot \frac{1}{12}} - \mult{2}{\cdot \frac{1}{12}} - \end{gmatrix} - \cdot - \begin{pmatrix} - 1 & -1 & -1 \\ - 0 & 1 & 0 \\ - 0 & 0 & 1 - \end{pmatrix} - \cdot - \begin{pmatrix} - 1 & 0 & 0 \\ - 0 & 1 & -\frac{10}{12} \\ - 0 & 0 & 1 - \end{pmatrix} - \\ - = \begin{pmatrix} - 1 & 0 & 0 \\ - -\frac{1}{2} & 1 & 0 \\ - -\frac{1}{12} & - \frac{1}{2} & 1 - \end{pmatrix} \cdot - &\begin{gmatrix}[p] - 1 & 0 & 0 \\ - 0 & 1 & 0 \\ - 0 & 0 & 1 - \end{gmatrix} - \cdot - \begin{pmatrix} - 1 & -1 & -\frac{1}{6} \\ - 0 & 1 & -\frac{5}{6} \\ - 0 & 0 & 1 - \end{pmatrix} - \cdot - \begin{pmatrix} - \frac{1}{6} & 0 & 0 \\ - 0 & \frac{1}{12} & 0 \\ - 0 & 0 & \frac{1}{12} - \end{pmatrix} - \\ - = \underbrace{\begin{pmatrix} - 1 & 0 & 0 \\ - -\frac{1}{2} & 1 & 0 \\ - -\frac{1}{12} & - \frac{1}{2} & 1 - \end{pmatrix}}_L \cdot - &\begin{gmatrix}[p] - 1 & 0 & 0 \\ - 0 & 1 & 0 \\ - 0 & 0 & 1 - \end{gmatrix} - \cdot \underbrace{\frac{1}{72} - \begin{pmatrix} - 12 & -6 & -1 \\ - 0 & 6 & -5 \\ - 0 & 0 & 6 - \end{pmatrix}}_R \end{align} -ACHTUNG: Ich habe mich irgendwo verrechnet! -Siehe \href{http://www.wolframalpha.com/input/?i=%7B%7B1%2C0%2C0%7D%2C%7B-1%2F2%2C1%2C0%7D%2C%7B-1%2F12%2C-1%2F2%2C1%7D%7D*%7B%7B12%2C-6%2C-1%7D%2C%7B0%2C6%2C-5%7D%2C%7B0%2C0%2C6%7D%7D}{WolframAlpha} +Nun gilt: $P A = L R = A^{(1)}$ (Kontrolle mit \href{http://www.wolframalpha.com/input/?i=%7B%7B1%2C0%2C0%7D%2C%7B0.5%2C1%2C0%7D%2C%7B1%2F3%2C0.5%2C1%7D%7D*%7B%7B6%2C6%2C6%7D%2C%7B0%2C12%2C10%7D%2C%7B0%2C0%2C12%7D%7D}{Wolfram|Alpha}) \subsection*{Teilaufgabe b} @@ -182,7 +107,7 @@ Falls $A$ symmetrisch ist, gilt: & \Leftrightarrow \text{es gibt eine Cholesky-Zerlegung $A=GG^T$ mit $G$ ist reguläre untere Dreiecksmatrix}\\ \end{align*} -Mit dem Hauptminor-Kriterium gilt: +\subsubsection*{Lösung 1: Hauptminor-Kriterium} \begin{align} \det(A_1) &= 9 > 0\\ @@ -193,3 +118,15 @@ Mit dem Hauptminor-Kriterium gilt: \end{vmatrix} = 9 - 16 < 0\\ &\Rightarrow \text{$A$ ist nicht positiv definit} \end{align} + +\subsubsection*{Lösung 2: Cholesky-Zerlegung} +\begin{align} + l_{11} &= \sqrt{a_{11}} = 3\\ + l_{21} &= \frac{a_{21}}{l_{11}} = \frac{4}{3}\\ + l_{31} &= \frac{a_{31}}{l_{11}} = 4\\ + l_{22} &= \sqrt{a_{21} - {l_{21}}^2} = \frac{2 \sqrt{5}}{3}\\ + \dots +\end{align} + +ACHTUNG: Noch nicht fertig! Irgendwo muss was negatives unter einer +Wurzel kommen! diff --git a/documents/Numerik/Klausur1/Aufgabe2.tex b/documents/Numerik/Klausur1/Aufgabe2.tex index bf71571..2d8376d 100644 --- a/documents/Numerik/Klausur1/Aufgabe2.tex +++ b/documents/Numerik/Klausur1/Aufgabe2.tex @@ -7,43 +7,35 @@ wobei $L$ eine invertierbare, untere Dreiecksmatrix ist. Geben Sie die Formel zur Berechnung von $y_i$ an. -\textbf{Lösung:} TODO! %TODO! +\textbf{Lösung:} + +\[y_i = \frac{b_i - \sum_{k=i}^{i-1} l_{ik} \cdot y_k}{l_{ii}}\] + +\subsection*{Teilaufgabe b} +\[Ax = b ? PAx = Pb ? LRx = Pb \] + +Pseudocode: \begin{algorithm}[H] \begin{algorithmic} - \Require $p \in \mathbb{P}, a \in \mathbb{Z}, p \geq 3$ - \Procedure{CalculateLegendre}{$a$, $p$} - \If{$a \geq p$ or $a < 0$}\Comment{rule (III)} - \State \Return $\Call{CalculateLegendre}{a \mod p, p}$ \Comment{now: $a \in [0, \dots, p-1]$} - \ElsIf{$a == 0$ or $a == 1$} - \State \Return $a$ \Comment{now: $a \in [2, \dots, p-1]$} - \ElsIf{$a == 2$} \Comment{rule (VII)} - \If{$p \equiv \pm 1 \mod 8$} - \State \Return 1 - \Else - \State \Return -1 - \EndIf \Comment{now: $a \in [3, \dots, p-1]$} - \ElsIf{$a == p-1$} \Comment{rule (VI)} - \If{$p \equiv 1 \mod 4$} - \State \Return 1 - \Else - \State \Return -1 - \EndIf \Comment{now: $a \in [3, \dots, p-2]$} - \ElsIf{!$\Call{isPrime}{a}$} \Comment{rule (II)} - \State $p_1, p_2, \dots, p_n \gets \Call{Factorize}{a}$ - \State \Return $\prod_{i=1}^n \Call{CalculateLegendre}{p_i, p}$ - \Else \Comment{now: $a \in \mathbb{P}, \sqrt{p-2} \geq a \geq 3$} - \If{$\frac{p-1}{2} \equiv 0 \mod 2$ or $\frac{a-1}{2} \equiv 0 \mod 2$} - \State \Return $\Call{CalculateLegendre}{p, a}$ - \Else - \State \Return $(-1) \cdot \Call{CalculateLegendre}{p, a}$ - \EndIf - \EndIf + \Require Matrix $A$, Vektor $b$ + \Procedure{CalculateLegendre}{$A$, $b$} + \State $P, L, R \gets \Call{LRZerlegung}{A}$ + \State $b^* \gets Pb$ + \State $c \gets \Call{VorwärtsSubstitution}{L, b^*}$ + \State $x \gets \Call{RückwärtsSubstitution}{R, c}$ + \State \Return $x$ \EndProcedure \end{algorithmic} - \caption{Calculate Legendre symbol} - \label{alg:calculateLegendreSymbol} + \caption{Calculate TODO} + \label{alg:TODO} \end{algorithm} -\subsection*{Teilaufgabe b} \subsection*{Teilaufgabe c} +Der Gesamtaufwand ist: +\begin{itemize} + \item LR-Zerlegung, $\frac{1}{3}n^3 - \frac{1}{3} n^2$ + \item Vektormultiplikation, $2n$ + \item Vorwärtssubstitution, $\frac{1}{2} n^2$ + \item Rückwärtssubstitution, $\frac{1}{2} n^2$ +\end{itemize} diff --git a/documents/Numerik/Klausur1/Aufgabe3.tex b/documents/Numerik/Klausur1/Aufgabe3.tex index 3d0108e..deb4383 100644 --- a/documents/Numerik/Klausur1/Aufgabe3.tex +++ b/documents/Numerik/Klausur1/Aufgabe3.tex @@ -1 +1,20 @@ \section*{Aufgabe 3} +\[f' (x,y) = \begin{pmatrix} + 3 & \cos y\\ + 3 x^2 & e^y +\end{pmatrix}\] + +Und jetzt die Berechnung + +\[f'(x, y) \cdot (x_0, y_0) = f(x,y)\] + +LR-Zerlegung für $f'(x, y)$: + +\begin{align} + L &= \begin{pmatrix}1 &0 \\ \frac{1}{9} & 1\end{pmatrix}\\ + R &= \begin{pmatrix}3 & \cos y \\ 0 & e^y - x^2 \cos y\end{pmatrix}\\ + P &= I_2\\ +-f ( \frac{-1}{3}, 0) &= \begin{pmatrix} 2\\ -\frac{1}{27}\end{pmatrix}\\ +c &= \begin{pmatrix} 2\\ \frac{7}{27} \end{pmatrix}\\ +(x_1, y_1) &= \begin{pmatrix} \frac{5}{3}\\ \frac{7}{27}\end{pmatrix} +\end{align} diff --git a/documents/Numerik/Klausur1/Aufgabe5.tex b/documents/Numerik/Klausur1/Aufgabe5.tex index 701ee58..fcc6a2d 100644 --- a/documents/Numerik/Klausur1/Aufgabe5.tex +++ b/documents/Numerik/Klausur1/Aufgabe5.tex @@ -1 +1,7 @@ \section*{Aufgabe 5} +\subsection*{Teilaufgabe a} +Die Ordnung $n$ einer Quadraturformel gibt an, dass diese Polynome +bis zum Grad $\leq n - 1$ exakt löst. + +\subsection*{Teilaufgabe b} +\subsection*{Teilaufgabe c} diff --git a/documents/Numerik/Klausur1/Klausur1.pdf b/documents/Numerik/Klausur1/Klausur1.pdf index 06f8082..4b8ae36 100644 Binary files a/documents/Numerik/Klausur1/Klausur1.pdf and b/documents/Numerik/Klausur1/Klausur1.pdf differ diff --git a/tikz/hidden-markov-model-abc-2/Makefile b/tikz/hidden-markov-model-abc-2/Makefile new file mode 100644 index 0000000..8d7b4f1 --- /dev/null +++ b/tikz/hidden-markov-model-abc-2/Makefile @@ -0,0 +1,35 @@ +SOURCE = hidden-markov-model-abc-2 +DELAY = 80 +DENSITY = 300 +WIDTH = 512 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + make + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg + rsvg-convert -a -w $(WIDTH) -f svg $(SOURCE).svg -o $(SOURCE)2.svg + inkscape $(SOURCE)2.svg --export-plain-svg=$(SOURCE).svg + rm $(SOURCE)2.svg diff --git a/tikz/hidden-markov-model-abc-2/Readme.md b/tikz/hidden-markov-model-abc-2/Readme.md new file mode 100644 index 0000000..6264966 --- /dev/null +++ b/tikz/hidden-markov-model-abc-2/Readme.md @@ -0,0 +1,3 @@ +Compiled example +---------------- +![Example](hidden-markov-model-abc-2.png) diff --git a/tikz/hidden-markov-model-abc-2/hidden-markov-model-abc-2.png b/tikz/hidden-markov-model-abc-2/hidden-markov-model-abc-2.png new file mode 100644 index 0000000..82b762b Binary files /dev/null and b/tikz/hidden-markov-model-abc-2/hidden-markov-model-abc-2.png differ diff --git a/tikz/hidden-markov-model-abc-2/hidden-markov-model-abc-2.tex b/tikz/hidden-markov-model-abc-2/hidden-markov-model-abc-2.tex new file mode 100644 index 0000000..f3124f2 --- /dev/null +++ b/tikz/hidden-markov-model-abc-2/hidden-markov-model-abc-2.tex @@ -0,0 +1,21 @@ +\documentclass[varwidth=true, border=2pt]{standalone} +\usepackage{units} +\usepackage{ifthen} +\usepackage{tikz} +\usetikzlibrary{calc} + +\begin{document} +\tikzstyle{vertex}=[draw,black,fill=blue,circle,minimum size=10pt,inner sep=0pt] +\tikzstyle{edge}=[very thick] +\begin{tikzpicture}[scale=2.5] + \node (x)[vertex,fill=gray!10,align=left,label=below:$x$] at (0,0) {$A~\nicefrac{6}{10}$\\$B~\nicefrac{2}{10}$\\$C~\nicefrac{2}{10}$}; + \node (y)[vertex,fill=gray!10,align=left,label=below:$y$] at (1,0) {$A~\nicefrac{1}{10}$\\$B~\nicefrac{1}{10}$\\$C~\nicefrac{8}{10}$}; + \node (z)[vertex,fill=gray!10,align=left,label=below:$z$] at (2,0) {$A~\nicefrac{5}{10}$\\$B~\nicefrac{2}{10}$\\$C~\nicefrac{3}{10}$}; + + \path[thick,->] (x) edge node [anchor=center,above,sloped] {$\nicefrac{2}{10}$} (y); + \path[thick,->] (y) edge node [anchor=center,above,sloped] {$\nicefrac{8}{10}$} (z); + \path[thick,->] (x) edge[loop above, looseness=5] node [anchor=center,above,sloped] {$\nicefrac{8}{10}$} (x); + \path[thick,->] (y) edge[loop above, looseness=5] node [anchor=center,above,sloped] {$\nicefrac{2}{10}$} (y); + \path[thick,->] (z) edge[loop above, looseness=5] node [anchor=center,above,sloped] {$1$} (z); +\end{tikzpicture} +\end{document} diff --git a/tikz/hidden-markov-model-abc-2/hidden-markov-model-hmm-thumb.png b/tikz/hidden-markov-model-abc-2/hidden-markov-model-hmm-thumb.png new file mode 100644 index 0000000..885f365 Binary files /dev/null and b/tikz/hidden-markov-model-abc-2/hidden-markov-model-hmm-thumb.png differ