\chapter{Lineare Algebra}% \label{cha:Lineare Algebra} \section{Vektoren}% \label{sec:Vektoren} \begin{itemize} \item Alle Vektoren werden \textbf{fett} geschrieben: $\underbrace{x=1}_{\text{Skalar}},\qquad\underbrace{\bm{x}=\begin{bmatrix} 1\\2\\4 \end{bmatrix}}_{\text{Vektor}}$ \item ein Vektor $\bm{x}$ ist immer ein Spaltenvektor: $\bm{x}=\begin{bmatrix} 1\\2\\4 \end{bmatrix}$ \item ein transponierter Vektor $\bm{x}^T$ ist immer ein Reihenvektor: $\bm{x}^T=\begin{bmatrix} 1 & 2 & 4 \end{bmatrix}$ \item Multiplikation eines Vektors mit einem Skalar: $2\begin{bmatrix} 1\\2\\4 \end{bmatrix} = \begin{bmatrix} 2\\4\\8\end{bmatrix}$ \item Vektoraddition: $\begin{bmatrix} 1\\2\\4 \end{bmatrix} + \begin{bmatrix} 2\\1\\4 \end{bmatrix} = \begin{bmatrix} 3\\3\\8 \end{bmatrix}$ \item Skalarprodukt $\langle \bm{v},\bm{w}\rangle$ der Vektoren $\bm{v}=\begin{bmatrix} 1\\2\\4 \end{bmatrix}$ und $\bm{w}=\begin{bmatrix} 2\\4\\8 \end{bmatrix}$: $\langle \bm{v},\bm{w}\rangle = 1\cdot 2 + 2\cdot 4 + 4\cdot 8 = 42$ \item Länge eines Vektors: $||\bm{v}|| = \langle \bm{v},\bm{v}\rangle^{\frac{1}{2}} = (1^2 + 2^2 + 4^2)^{\frac{1}{2}} = \sqrt{21}$ \end{itemize} \section{Matrizen}% \label{sec:Matrizen} \begin{itemize} \item Matrizen werden \uppercase{groß} und \textbf{fett} geschrieben: $\bm{X}=\begin{bmatrix} 1&3\\2&3\\4&7 \end{bmatrix}\qquad\bm{A}=\begin{bmatrix}1&3&5&4\\2&3&7&2 \end{bmatrix}$ \item Mehrere Vektoren können zu einer Matrix zusammengefasst werden. Hierbei werden die Vektoren meistens zu Zeilen und repräsentieren einen Einzelnen Datensatz: $$\bm{x}_1 = \begin{bmatrix} 37\\72\\175 \end{bmatrix} \qquad \bm{x}_2 = \begin{bmatrix} 10\\30\\61 \end{bmatrix}\qquad \bm{x}_3 = \begin{bmatrix} 25\\65\\121 \end{bmatrix}\qquad \bm{x}_4 = \begin{bmatrix} 66\\67\\175 \end{bmatrix}$$ $$\bm{X} = \begin{bmatrix} \bm{x}_1^T\\\bm{x}_2^T\\\bm{x}_3^T\\\bm{x}_4^T \end{bmatrix} = \begin{bmatrix} 37&72&175\\10&30&61\\25&65&121\\66&67&175 \end{bmatrix}$$ \item Multiplikation mit einem Skalar: $ 3\bm{M} = 3\begin{bmatrix} 3 & 4 & 5 \\ 1 & 0 & 1 \end{bmatrix} = \begin{bmatrix} 9 & 12 & 15\\ 3 & 0 & 3 \end{bmatrix}$ \item Addition von Matrizen: $ \bm{M} + \bm{N} = \begin{bmatrix} 3 & 4 & 5 \\ 1 & 0 & 1 \end{bmatrix} + \begin{bmatrix} 1 & 2 & 1 \\ 3 & 1 & 1 \end{bmatrix} = \begin{bmatrix} 4 & 6 & 6 \\ 4 & 1 & 2 \end{bmatrix}$ \item Transponierte Matrizen: $ \bm{M} = \begin{bmatrix} 3 & 4 & 5 \\ 1 & 0 & 1 \end{bmatrix}, \bm{M}^T = \begin{bmatrix} 3 & 1\\ 4 & 0\\ 5 & 1 \end{bmatrix}$ \item Matrix-Vektor-Produkt: $$ \bm{Wv} = \underbrace{\begin{bmatrix} \bm{w}_1 & \cdots & \bm{w}_n \end{bmatrix}}_{\bm{W}}\underbrace{\begin{bmatrix} v_1 \\ \vdots \\ v_n \end{bmatrix}}_{\bm{v}} = \begin{bmatrix} v_1\bm{w}_1 + \cdots + v_n\bm{w}_n \end{bmatrix} $$ $$ \bm{Wv} = \begin{bmatrix} 3 & 4 & 5 \\ 1 & 0 & 1 \end{bmatrix}\begin{bmatrix} 3\\0\\2 \end{bmatrix} = \begin{bmatrix} 3\cdot1 + 4\cdot0 + 5\cdot2 \\ 1\cdot1 + 0\cdot0 + 1\cdot2 \end{bmatrix} = \begin{bmatrix} 13\\3 \end{bmatrix}$$ \item Matrix-Matrix-Produkt: $$ \bm{WV} = \begin{bmatrix} 3 & 4 & 5\\ 1 & 0 & 1 \end{bmatrix}\begin{bmatrix} 1 & 0\\0 & 3\\2 & 4 \end{bmatrix} = \begin{bmatrix} 3\cdot1+4\cdot0+5\cdot2 & 3\cdot0+4\cdot3+5\cdot4\\ 1\cdot1+0\cdot0+1\cdot2 & 1\cdot0+0\cdot3+1\cdot4 \end{bmatrix} = \begin{bmatrix} 13 & 32\\ 3 & 4 \end{bmatrix}$$ \begin{itemize} \item Dimensionen: $\underbrace{m\times n}_{\bm{W}}\cdot\underbrace{n\times j}_{\bm{V}} = \underbrace{m\times j}_{\bm{U}}$ \item nicht kommutativ: $\bm{VW} \neq \bm{WV}$ \item Assoziativ: $\bm{V}(\bm{WX}) = (\bm{VW})\bm{X}$ \item Transponiertes Produkt: $(\bm{VW})^T = \bm{W}^T\bm{V}^T$ \end{itemize} \item Reihen"~ und Spaltendurchschnitt: $$\bm{X} = \begin{bmatrix} \bm{X}_{1,1} & \cdots & \bm{X}_{1,m}\\ \vdots & \ddots & \vdots\\ \bm{X}_{n,1} & \cdots & \bm{X}_{n,m} \end{bmatrix}$$ \begin{itemize} \item Vektor von Reihen-Durchschnitten: $$\begin{bmatrix} \frac{1}{m}\sum_{i=1}^{m} X_{1,i}\\ \vdots \\ \frac{1}{m}\sum_{i=1}^{m} X_{n,i} \end{bmatrix} = \bm{X}\begin{bmatrix} \frac{1}{m}\\\vdots\\\frac{1}{m} \end{bmatrix} = \bm{Xa}, \text{ mit } \bm{a} = \begin{bmatrix} \frac{1}{m}\\\vdots\\\frac{1}{m} \end{bmatrix}$$ \item Vektor von Spalten-Durchschnitten: $$ \begin{bmatrix} \frac{1}{n}\sum_{i=1}^{n} X_{i,1} & \cdots & \frac{1}{n}\sum_{i=1}^{n}X_{i,m} \end{bmatrix} = \begin{bmatrix} \frac{1}{n} & \cdots & \frac{1}{n} \end{bmatrix}\bm{X} = \bm{b}^T\bm{X}, \text{ mit }\bm{b} = \begin{bmatrix} \frac{1}{n}\\\vdots\\\frac{1}{n} \end{bmatrix}$$ \end{itemize} \item Matrix Inverse: \begin{itemize} \item Definition: $\bm{WW}^{-1} = \bm{I},\qquad\bm{W}^{-1}\bm{W} = \bm{I}$ \item Identiätsmatrix $\bm{I} = \begin{bmatrix} 1 & \cdots & 0 \\ \vdots & \ddots & \vdots \\ 0 & \cdots & 1 \end{bmatrix}$ \item \textbf{nur} quadratische Matrizen können invertiert werden \end{itemize} \end{itemize} \section{Matrix-Calculus}% \label{sec:Matrix-Calculus} \begin{itemize} \item Die Ableitung einer skalare Funktion, die auf einem Vektor ausgewertet wird ergibt einen Gradientenvektor: $$\nabla_{\bm{x}}f = \frac{\partial f(\bm{x})}{\partial \bm{x}} = \begin{bmatrix} \frac{\partial f(\bm{x})}{\partial x_1} \\\vdots\\ \frac{\partial f(\bm{x})}{\partial x_d}\end{bmatrix}$$ \item Die Ableitung einer Vektor-Funktion, die auf einem Vektor ausgewertet wird ergibt eine Jacobische Matrix $$\nabla_{\bm{x}}\bm{f} = \frac{\partial \bm{f}(\bm{x})}{\partial \bm{x}} = \begin{bmatrix} \frac{\partial f_1(\bm{x})}{\partial x_1} & \cdots & \frac{\partial f_k(\bm{x})}{\partial x_1} \\ \vdots & \ddots & \vdots \\ \frac{\partial f_1(\bm{x})}{\partial x_d} & \cdots & \frac{\partial f_k(\bm{x})}{\partial x_d}\end{bmatrix}$$ \item die Ableitung einer skalaren Funktion, die auf einer Matrix ausgewertet wird ergibt eine Matrix: $$\nabla_{\bm{W}}f = \frac{\partial f(\bm{W})}{\partial \bm{W}} = \begin{bmatrix} \frac{\partial f(\bm{W})}{\partial W_{11}} & \cdots & \frac{\partial f(\bm{W})}{\partial W_{1d}} \\ \vdots & \ddots & \vdots \\ \frac{\partial f(\bm{W})}{\partial W_{k1}} & \cdots & \frac{\partial f(\bm{W})}{\partial W_{kd}}\end{bmatrix}$$ \item die Ableitung einer Vektor-Funktion, die auf einer Matrix ausgewertet wird ergibt einen 3D-Tensor (sehr kompliziert, wird (fast) nie benötigt) \item Grundlegende Formeln:\\ \begin{tabular}{l c|c|c} & \bfseries Skalar & \bfseries Vektor & \bfseries Matrix\\ &&&\\ \textbf{Linear} & $\frac{\partial a x}{\partial x} = a$ & $\nabla_{\bm{x}}\bm{Ax} = \bm{A}^T$ & \begin{tabular}{@{}c@{}} $\nabla_{\bm{X}}\bm{a}^T\bm{Xb} = \bm{ab}^T $ \\ $\nabla_{\bm{X}}tr(\bm{AXB}) = \bm{A}^T\bm{B}^T$ \end{tabular}\\ &&&\\ \textbf{Quadratisch} & $\frac{\partial x^2}{\partial x} = 2x$ & $\begin{aligned} \nabla_{\bm{x}}\bm{x}^T\bm{x} &= 2\bm{x} \\ \nabla_{\bm{x}}\bm{x}^T\bm{Ax} &= (\bm{A}^T + \bm{A})\bm{x}\\&=2\bm{Ax}\text{ wenn $A$ symmetrisch ist }\end{aligned}$ & \end{tabular} \end{itemize}