% -*- latex -*-
% FILE: "/home/evmik/jobs/wm/2015_fall_practical_computing_for_scientists/hw07/hw07.tex"
% LAST MODIFICATION: "Sun, 18 Oct 2015 19:26:21 -0400 (evmik)"
% (C) 2010 by Eugeniy Mikhailov, <evgmik@gmail.com>
% $Id:$
\documentclass[letter,12pt]{article}

%---------------------------------------------------------------
\usepackage{listings}
\usepackage{color}
\usepackage{fullpage}
%---------------------------------------------------------------

\begin{document}
\newcommand{\problem}[1]{%
	{\flushleft  \bf #1\\}
}
\newcommand{\hw}[1]{%
	\begin{center}
		\Large  \bf Homework #1%
	\end{center}%
}
\newcommand{\mat}[1]{% matlab code
{\color{blue}\texttt{#1}}%
}

%---------------------------------------------------------------
\hw{07}
General comments: 
\begin{itemize}
	\item Do not forget to run some test cases. 
\end{itemize}


\problem{Problem 1 (2 points)}
%---------------------------------------------------------------
Prove (analytically) that the golden section algorithm $R$ is still given by the same
expression even if we need to choose $a'=x_1$ and
$b'=b$.

\problem{Problem 2 (3 points)}
%---------------------------------------------------------------
Assume that the initial spacing  between  initial bracket points is $h$.
Estimate (analytically) how many iterations it requires to narrow the bracket to
the $10^{-9}\times h$ space.


\problem{Problem 3 (5 points)}
%---------------------------------------------------------------
Implement the golden section algorithm.
Do not forget to check your code with simple
test cases.
Find where the function
$E1(x)=x^2-100*(1-\exp(-x))$ has a minimum. 


\problem{Problem 4 (5 points)}
%---------------------------------------------------------------
For the coin flipping game described on lecture 14, find the optimal
(maximizing your gain)
betting fraction using the golden section algorithm and Monte Carlo
simulation. Feel free to reuse provided complimentary codes. 

Note: you need a lot of game runs (at least a 1000) to have reasonably
small uncertainty for the merit function evaluations. I would suggest
to average at least  1000 runs with length of 100 coin flips  each.

\problem{Problem 5 (5 points)}
%---------------------------------------------------------------
Find the point where function 
\begin{eqnarray*}
F(x,y,z,w,u)=(x-3)^2 + (y-1)^4 + (u-z)^2 + (u-2*w)^2 + (u-6)^2 + 12
\end{eqnarray*}
has a minimum. What is the value of
$F(x,y,z,w,u)$ at this point?

\end{document}
%---------------------------------------------------------------
