% -*- latex -*-
% FILE: "/home/evmik/jobs/wm/2015_fall_practical_computing_for_scientists/hw06/hw06.tex"
% LAST MODIFICATION: "Tue, 13 Oct 2015 22:29:46 -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{06}

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

\problem{Problem 1 (5 points)}
%---------------------------------------------------------------
Estimate the Euler's number $e \approx 2.71\ldots$ via evaluation of
the following integral with the Monte-Carlo method
\begin{eqnarray*}
	e=\int_0^1 (e^x+1) dx
\end{eqnarray*}




\problem{Problem 2 (5 points)}
%---------------------------------------------------------------

For the  problem above. Plot  (in loglog  space) the absolute deviation  of
the integral from  its true  value  as a  function  of the  random  points number  ($N$)
spanning logarithmically from  10 to $10^6$. For  each $N$ do  it at least 100  times, mark
such  points as  small dots  (use matlab \mat{'.'}  marker specifier)  on your  plot,
calculate and show on the same plot the mean of  the integral value error
estimation at a particular $N$ with a circle marker (use matlab \mat{'o'} marker specifier).

Does the $e$ estimate error drops as $1/\sqrt{N}$? Show this dependence on the
same plot.

\problem{Problem 3 (5 points)}
%---------------------------------------------------------------
Consider the LCG random generator with $a=11$, $c=2$, $m=65535$, and
$r_1=1$. What is the best case scenario for the length/period of the random
sequence of a LC generator with $m=65535$? Estimate the actual length of the
non repeating sequence.

\problem{Problem 4 (5 points)}
%---------------------------------------------------------------
Modify the colony life script example to take in account helping neighbors.
Leave the probability to heal  a cell without alive neighbors as it is,
double the healing probability for a cell with one alive neighbor, and triple it
if a cell has alive neighbors on both sides. We assume that illness does not prevent a
helping/healing action, i.e. a neighbor must be alive to help
but it might have an illness too.

{\bf Make sure that you are using matlab random generator,  i.e., \mat{rand}}.

Is the saying ``the best neighbor is the dead neighbor'' still true?



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