\documentclass[12pt,a4paper]{article}

\usepackage{amstext}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{stmaryrd}
\usepackage{enumerate}
\usepackage{alltt}
\usepackage[latin1]{inputenc}
\usepackage{cancel}
\usepackage{fancyhdr}
\usepackage{listings}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage{wasysym}
\usepackage{rotating}

\title{}
\author{}
\date{}

\pagestyle{fancy}

\lhead{Assignment 2}
\chead{}
\rhead{}
\lfoot{COPCV}
\cfoot{Page \thepage}
\rfoot{SS 2009}

\begin{document}

\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

\newcommand{\exercise}[1]{\subsection{#1}}
\renewcommand{\theenumi}{\textbf{\alph{enumi}}}

\newcommand{\AND}{\ensuremath{\wedge}}
\newcommand{\OR}{\ensuremath{\vee}}
\newcommand{\SetR}{\ensuremath{\mathbb{R}}}
\newcommand{\SetN}{\ensuremath{\mathbb{N}}}
\newcommand{\SetC}{\ensuremath{\mathbb{C}}}
\newcommand{\SetZ}{\ensuremath{\mathbb{Z}}}
\newcommand{\SetQ}{\ensuremath{\mathbb{Q}}}
\newcommand{\SetB}{\ensuremath{\mathbb{B}}}
\newcommand{\QED}{\ensuremath{\hspace*{\fill}\square}}
\newcommand{\FLASH}{\ensuremath{\hspace*{\fill}\lightning}}
\newcommand{\OnotO}{\ensuremath{\mathcal{O}}}
\newcommand{\bild}[2]{
	\begin{figure}[htpb]
		\centering
			\includegraphics[#1]{#2}\\[0.2cm]
	\end{figure}
	}

\newcommand{\m}[1]{\begin{pmatrix}#1\end{pmatrix}}
\newcommand{\+}{\phantom{-}}
\newcommand{\f}{\frac}

%\maketitle

%\thispagestyle{empty}

%\newpage
\setcounter{page}{1}
\setcounter{section}{2}

\exercise{Sub-Pixel Refinement I}
\begin{eqnarray}
	f(0) & = & a \cdot 0^2 + b \cdot 0 + c \label{part1firsteq} \\
	f(-1) & = & a \cdot 1 + b \cdot (-1) + c \label{part1secondeq} \\
	f(1) & = & a \cdot 1 + b \cdot 1 + c \label{part1thirdeq}
\end{eqnarray}
From (\ref{part1firsteq}) we know that $c_0 = c$. From (\ref{part1secondeq}), we get
$$c_{-1} = a - b + c_0$$
and from (\ref{part1thirdeq})
$$c_{+1} = a + b + c_0.$$
Rearranging these two latter equations, s.t. on one hand side only $a$ appears, we get
\begin{eqnarray*}
	c_{-1} + b - c_0 & = & c_{+1} - b - c_0 \\
	\Leftrightarrow 2b & = & c_{+1} - c-{-1} \\
	\Leftrightarrow b & = & \frac{c_{+1} - c_{-1}}{2}
\end{eqnarray*}
This can now be used to compute $a$:
\begin{eqnarray*}
	c_{+1} & = & a + b + c_0 \\
	\Leftrightarrow a & = & c_{+1} - b - c_0 \\
	& = & c_{+1} - \frac{c_{+1} - c_{-1}}{2} - c_0 \\
	a & = & \frac{c_{+1} - 2 c_0 - c_{-1}}{2}
\end{eqnarray*}
\QED

\exercise{Sub-Pixel Refinement II}
\textbf{Remark:} There is a small bug in the given result for the case $c_{+1} < c_{-1}$ where the stated result for the variable $b$ is not correct.
\begin{eqnarray*}
	f(-1) & = & a \cdot |-1 + b| + c = c_{-1} \\
	f(0) & = & a \cdot |b| + c = c_0 \\
	f(1) & = & a \cdot |1 + b| + c = c_{+1}
\end{eqnarray*}
We know from the hint that $-1 \leq b \leq 1$. So we have to consider only the cases $b<0$ and $b\geq0$:
\begin{itemize}
	\item $b<0$:
		\begin{eqnarray}
			-ab + a + c & = & c_{-1} \label{part2firsteqble0} \\
			-ab + c & = & c_0 \label{part2secondeqble0} \\
			ab + a +c & = & c_{+1} \label{part2thirdeqble0}
		\end{eqnarray}
		Now we can substract (\ref{part2firsteqble0}) and (\ref{part2secondeqble0}), resulting in
		$$a = c_{-1} - c_0.$$
		Adding up (\ref{part2firsteqble0}) and (\ref{part2secondeqble0}) results in
		\begin{eqnarray*}
			2a  + 2c & = & c_{+1} + c_{-1} \\
			2 (c_{-1} - c_0) + 2c & = & c_{+1} - c_{-1} \\
			2 c & = & c_{+1} + c_{-1} - 2 c_{-1} + 2 c_0 \\
			c & = & \frac{c_{+1} + 2 c_0 - c_{-1}}{2}
		\end{eqnarray*}
		Finally, we can calculate $b$ as
		$$b = \frac{c_{+1} - c_{-1}}{2 (c_{-1} - c_0)}.$$
	\item $b \geq 0$:
		\begin{eqnarray}
			-ab + a + c & = & c_{-1} \label{part2firsteqbgeq0} \\
			ab + c & = & c_0 \label{part2secondeqbgeq0} \\
			ab + a + c & = & c_{+1} \label{part2thirdeqbgeq0}
		\end{eqnarray}
		If we substract (\ref{part2secondeqbgeq0}) from (\ref{part2thirdeqbgeq0}), we get
		$$a = c_{+1} - c_0.$$
		Adding up (\ref{part2firsteqbgeq0}) and (\ref{part2thirdeqbgeq0}) gives
		\begin{eqnarray*}
			2a + 2c & = & c_{+1} + c_{-1} \\
			2 (c_{+1} - c_0) + 2c & = & c_{+1} + c_{-1} \\
			2c & = & c_{+1} + c_{-1} - 2 c_{+1} + 2 c_0 \\
			c & = & \frac{c_{-1} + 2 c_0 - c_{+1}}{2}
		\end{eqnarray*}
		Now we can calculate the (right!) $b$:
		\begin{eqnarray*}
			ab + c & = & c_0 \\
			b & = & \frac{c_0 - c}{a} \\
			& = & \frac{c_0 - \frac{c_{-1} + 2 c_0 - c_{+1}}{2}}{c_{+1} - c_0} \\
			b & = & \frac{c_{+1} - c_{-1}}{2 (c_{+1} - c_0)}
		\end{eqnarray*}
\end{itemize}
\QED


\end{document}
