% -*- latex -*-
% FILE: "/home/evmik/jobs/wm/2015_fall_practical_computing_for_scientists/sample_hw_report/sample_report.tex"
% LAST MODIFICATION: "Wed, 26 Aug 2015 11:35:47 -0400 (evmik)"
% (C) 2010 by Eugeniy Mikhailov, <evgmik@gmail.com>
% $Id:$


%---------------------------------------------------------------
% This is style of APS journal, physicists should aim to use it
\documentclass[prl,12pt,notitlepage,aps,onecolumn,superscriptaddress]{revtex4-1}

%---------------------------------------------------------------
% This would be default, but I do not like title page formattin, too much
% empty space.
% If above fails, comment it up with '%' symbols and uncomment below line
% \documentclass[letter,12pt]{article} 

%---------------------------------------------------------------
\usepackage{listings} % allow to include nicely formated listings
\usepackage{xcolor}   % we can add and use colors
\usepackage{fullpage} % default article style is to greedy about margins
\usepackage{graphicx} % REQUIRED TO WORK WITH FIGURES
\usepackage{amsmath,amssymb} % much better math and equation handling
%---------------------------------------------------------------

%---------------------------------------------------------------
% {{{ listing schema definitions used by 'listings' pacjage
\definecolor{listcommentcolor}{rgb}{0.0,0.3,0} %dark green
\colorlet{listbg}{white!100} % white
%\definecolor{listbg}{rgb}{0.90,0.90,0.90} %light grey
\lstset{backgroundcolor=\color{listbg}}
\lstset{commentstyle=\color{listcommentcolor}}
\lstset{keywordstyle=\color{blue}}
\lstset{stringstyle=\color{magenta}}
\lstset{language=matlab}
\lstset{tabsize=2}
\lstset{showstringspaces=false}
\lstset{basicstyle = \ttfamily}
\lstset{language=matlab}
\lstset{linewidth=\textwidth}
\lstset{commentstyle=\color{listcommentcolor}\textit, stringstyle=\upshape,showspaces=false}
\lstset{frame=trBL,frameround=tttt}
\lstset{basicstyle=\small}
% }}}
%---------------------------------------------------------------

%---------------------------------------------------------------
\begin{document}
%---------------------------------------------------------------
\title{Sample of homework report}
\author{Eugeniy E. Mikhailov}
\date{\today}
\maketitle

%---------------------------------------------------------------
\section{Problem 1}
%---------------------------------------------------------------

%---------------------------------------------------------------
\subsection{Problem statement}
%---------------------------------------------------------------
Write a function which finds a maximum out of two user supplied numbers.

%---------------------------------------------------------------
\subsection{Solution}
%---------------------------------------------------------------

First we need to compare two numbers which leads to the straightforward if-else
construct which selects the proper answer. However there is one special case
when both inputs are the same. The comparison should
have $\ge$ comparison operator to include this case into decision
tree. See the resulting function {\it find\_max} in the listing~\ref{lst:find_max}.
% note in above that instead of find_max, I am using find\_max
% i.e. prepend the underscore with a slash, otherwise LaTeX will
% think that it is in the "math" mode and will make 'm' and subscript.
% but when I use \ref command there is no need to screen '_'

%---------------------------------------------------------------
% latex will read content of 'find_max.m' file and nicely format it
\lstinputlisting[caption=Find max  code,label=lst:find_max]{find_max.m}
%---------------------------------------------------------------

%---------------------------------------------------------------
\subsection{Test cases}
%---------------------------------------------------------------
To check the validity of the code I tried 3 possible combination of the
input parameters. When first argument is  smaller then second, when
first argument is lager then second, and finally when they are both the
same. The results of the tests are as expected (see
listing~\ref{lst:find_max_output}).
%---------------------------------------------------------------
% here I show the example how you can have nicely formated output
% of the Matlab output which just copied and pasted from Matlab command
% window
\lstset{language=matlab}
\lstset{linewidth=\textwidth}
\lstset{commentstyle=\textit, stringstyle=\upshape,showspaces=false}
\lstset{frame=trBL,frameround=tttt}
\lstset{caption=Find max code tests,label=lst:find_max_output}
\begin{lstlisting}
>> find_max(1,10)
ans =  10
>> find_max(10,1)
ans =  10
>> find_max(10,10)
ans =  10
\end{lstlisting}

%---------------------------------------------------------------

%---------------------------------------------------------------
\section{Very simple example of a figure use}
%---------------------------------------------------------------
Let's consider a diffraction of light on a mask. We will use a mask
depicted in the figure~\ref{fig:mask}. The parameters of this mask are:
resolution $1386\times600$~pixels, physical size $2.8\times1.2$~cm.

\begin{figure}[h] % 'h' stands for here, there are other specifiers too.
	\center
	\includegraphics[width=0.5\columnwidth,angle=0]{mask_WM}
	%%% -------------------------------------------^^^^^^^^^^ figure filename
	%%% notice that there is no extention of the file since it is
	%%% optional and latex will try it best to chose the right one.
	%%% You might provide it and use {mask_WM.png} but it will limit
	%%% you at further steps.
	%%%
	%%% IMPORTANT: LaTex is piccky it can work only with a handful of
	%%% formats depending on a particular version.
	%%%
	%%% Bare latex can work with 'eps' and 'ps' formats only
	%%% while pdflatex can work with 'jpg', 'pdf', 'png' among the
	%%% most common ones, strangely it does not work with 'eps' and 'ps'
	%%%
	%%% IT IS YOUR RESPONSIBILITY to provide a figure file in proper
	%%% format.

	\caption{
		\label{fig:mask} % a short way to address this figure via
				 % \ref{} in the text. See above
		Mask with WM letters.
	}
\end{figure}

The resulting light (with wavelength $\lambda=670$~nm)  diffraction image at
distance 1.1~m is shown in the figure~\ref{fig:diffracted_image}. 
The formed image has the following parameters $693\times300$ pixels, with
physical size $3\times1.4$ cm.

\begin{figure}[h]
	\center
	\includegraphics[width=0.5\columnwidth,angle=0]{image_wm_diffracted}
	\caption{
		\label{fig:diffracted_image}
		Resulting diffracted image of original mask.
	}
\end{figure}


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