\documentclass[a4paper,12pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{graphicx} %BIlder einbinden
\usepackage{amsmath} %erweiterte Mathe-Zeichen
\usepackage{amsfonts} %weitere fonts
\usepackage[utf8]{inputenc} %Umlaute & Co
\usepackage{hyperref} %Links
\usepackage{ifthen} %ifthenelse
\usepackage{enumerate}
\usepackage{pdfpages}
\usepackage{algpseudocode} %Pseudocode
\usepackage{dsfont} % schöne Zahlenräumezeichen
\usepackage{amssymb, amsthm} %noch stärker erweiterte Mathe-Zeichen
\usepackage{tikz} %TikZ ist kein Zeichenprogramm
\usetikzlibrary{trees,automata,arrows,shapes}
\usepackage{qtree}
\usepackage{listings}
\lstset{language=Matlab}

\pagestyle{empty}


\topmargin-50pt

\newcounter{aufgabe}
\def\tand{&}

\newcommand{\makeTableLine}[2][0]{%
  \setcounter{aufgabe}{1}%
  \whiledo{\value{aufgabe} < #1}%
  {%
    #2\tand\stepcounter{aufgabe}%
  }
}

\newcommand{\aufgTable}[1]{
  \def\spalten{\numexpr #1 + 1 \relax}
  \begin{tabular}{|*{\spalten}{p{1cm}|}}
    \makeTableLine[\spalten]{A\theaufgabe}$\Sigma$~~\\ \hline
    \rule{0pt}{15pt}\makeTableLine[\spalten]{}\\
  \end{tabular}
}

\def\header#1#2#3#4#5#6#7{\pagestyle{empty}
\begin{minipage}[t]{0.47\textwidth}
\begin{flushleft}
{\bf #4}\\
#5
\end{flushleft}
\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
\begin{flushright}
#6 \vspace{0.5cm}\\
%                 Number of Columns    Definition of Columns      second empty line
% \begin{tabular}{|*{5}{C{1cm}|}}\hline A1&A2&A3&A4&$\Sigma$\\\hline&&&&\\\hline\end{tabular}\\\vspace*{0.1cm}
\aufgTable{#7}
\end{flushright}
\end{minipage}
\vspace{1cm}
\begin{center}
{\Large\bf Assignment #1}

{(Hand-in date #3)}
\end{center}
}



%counts the exercisenumber
\newcounter{n}

%Kommando für Aufgaben
%\Aufgabe{AufgTitel}{Punktezahl}
\newcommand{\Aufgabe}[2]{\stepcounter{n}
\textbf{Exercise \arabic{n}: #1} (#2 Punkte)\\}

\newcommand{\Normal}[3]{\mathcal{N}\left(#1,#2,#3\right)}
\newcommand{\Normalf}[3]{\frac{\left|#3\right|^{-\frac{1}{2}}}{\sqrt{2\pi}}e^{-\frac{\left(#1 - #2 \right)^2\cdot \left(#3\right)^{-1}}{2}}}




\begin{document}
    %\header{BlattNr}{Tutor}{Abgabedatum}{Vorlesungsname}{Namen}{Semester}{Anzahl Aufgaben}
    \header{8}{}{2015-06-23}{Mobile Robots}{
        \textit{Jan-Peter Hohloch}\\ \textit{Maximus Mutschler}
    }{SS 15}{2}
    \vspace{1cm}

    \Aufgabe{Excercise 1}{10}
    \includegraphics[width=\textwidth]{localize.png}\\
    %\lstinputlisting{localize_jp/motion_diff.m}
    %\lstinputlisting{localize_jp/measurement.m}
    d)
        The uncertainty in one direction decreases. This causes the estimated trajectory to be quite wiggly (overfitting). We overtrust the measurement.\\
        For $Q_t$ near to $0$, we get:
        \begin{align*}
            K_t&=\overline{\Sigma}_tC^T\left(C\overline{\Sigma}_tC^T+0\right)^{-1}\\
            &=C^{-1}\\
            \mu_t&=\overline{\mu}_t+C^{-1}z_t-\overline{\mu}_t\\
            &=C^{-1}z_t\\
            \Sigma_t&=0
        \end{align*}
        That is we assume no variance and fully trust the measurement.\pagebreak\\
\Aufgabe{Excercise2}{8}
\begin{enumerate}[(a)]
    \item $\Normal{x_t}{\mu_t}{\Sigma_t}=\eta\Normal{z_t}{Cx_t}{Q_t}\Normal{x_t}{\bar{\mu}_t}{\bar{\Sigma}_t}$
    \item \begin{align*}
        &\Normalf{x_t}{\mu_t}{\Sigma_t}\\&=\eta\Normalf{z_t}{Cx_t}{Q_t}\Normalf{x_t}{\bar{\mu}_t}{\bar{\Sigma}_t}\\
        &=\eta\frac{1}{2\pi}\left|Q_t\right|^{-\frac{1}{2}}\cdot\left|\bar{\Sigma}_t\right|^{-\frac{1}{2}}\cdot e^{-\frac{1}{2}\left(z_t^2Q_t^{-1}-2z_tCx_tQ_t^{-1}+\left(Cx\right)^2Q_t^{-1}+x_t^2\bar\Sigma_t^{-1}-2x_t\mu_t\bar\Sigma_t^{-1}+\mu_t^2\bar\Sigma_t^{-1}\right)}\\
        &\eta_1e^{-\frac{1}{2}\Sigma_t^{-1}x_t^2+\Sigma^{-1}_tx_t\mu_t-\frac{1}{2}\Sigma_t^{-1}\mu_t^2}\\&=\eta_2 e^{-\frac{1}{2}\left(z_t^2Q_t^{-1}-2z_tCx_tQ_t^{-1}+\left(Cx\right)^2Q_t^{-1}+x_t^2\bar\Sigma_t^{-1}-2x_t\mu_t\bar\Sigma_t^{-1}+\mu_t^2\bar\Sigma_t^{-1}\right)}\\
    \end{align*}
    \item $\Sigma_t = \left(C^2Q_t^{-1}+\bar\Sigma_t^{-1}\right)^{-1}$\\
    $\Sigma_t = \left(z_tCQ_t^{-1}+\bar\mu_t\bar\Sigma^{-1}\right)^{-1}\mu_t$
    \item From the lecture and from above we get:\\
    \begin{math}
    \begin{array}{lllr}
        \Sigma_t&=\left(I-K_tC\right)\bar\Sigma_t\\
        &=\bar\Sigma_t-\frac{\bar\Sigma_t^2C^2}{C^2\bar\Sigma_t+Q_t}\\
        \Sigma_t&=\left(C^2Q_t^{-1}+\bar\Sigma_t^{-1}\right)^{-1}\\
        &=\frac{1}{\frac{C^2}{Q_t}+\frac{1}{\bar\Sigma_t}}\\
        &=\frac{Q_t\bar\Sigma_t}{C^2\bar\Sigma_t+Q_t}\\
        \Rightarrow & \bar\Sigma_t-\frac{\bar\Sigma_t^2C^2}{C^2\bar\Sigma_t+Q_t} &= \frac{Q_t\bar\Sigma_t}{C^2\bar\Sigma_t+Q_t}\\
        \Leftrightarrow & I-\frac{\bar\Sigma_tC^2}{C^2\bar\Sigma_t+Q_t} &= \frac{Q_t}{C^2\bar\Sigma_t+Q_t}\\
        \Leftrightarrow & Q_t &= C^2\bar\Sigma_t+Q_t-\bar\Sigma_tC^2\\
        \Leftrightarrow & Q_t &= Q_t &\qed
    \end{array}\end{math}
    \item From the lecture and from above we get:\\
    \begin{math}
    \begin{array}{llr}
    \bar\mu+K(z-C\bar\mu) &= \Sigma\left(\frac{zC}{Q}+\bar\mu\bar\Sigma^{-1}\right)\\
    \bar\mu+K(z-C\bar\mu) &= (I-KC)\bar\Sigma\left(\frac{zC}{Q}+\bar\mu\bar\Sigma^{-1}\right)\\
    \bar\mu+K(z-C\bar\mu) &= \bar\Sigma\left(\frac{zC}{Q}+\bar\mu\bar\Sigma^{-1}\right)-KC\bar\Sigma\left(\frac{zC}{Q}+\bar\mu\bar\Sigma^{-1}\right)\\
    K(z-C\bar\mu) &= z\bar\Sigma\frac{C}{Q}-zKC\bar\Sigma\frac{C}{Q}-KC\bar\mu\\
    Kz &= z\bar\Sigma\frac{C}{Q}-zKC\bar\Sigma\frac{C}{Q}\\
    QK &= \bar\Sigma C - K\bar\Sigma C^2\\
    K(Q+C^2\bar\Sigma) &= \bar\Sigma C\\
    K&=K&\qed
    \end{array}\end{math}
\end{enumerate}

\end{document}

