% -*- latex -*-
% FILE: "/home/evmik/jobs/wm/2011_fall_practical_computing_for_scientists/hw02/hw02.tex"
% LAST MODIFICATION: "Sun, 04 Sep 2011 15:42:34 -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}%
}


%---------------------------------------------------------------
%\title{Homework 02}
%\author{Eugeniy E. Mikhailov}
%\date{\today}
%\date{}
%\maketitle
\hw{02}

Prerequisites: read help about 'plot', 'linspace', and 'print'. Do not
forget about test cases.

\problem{Problem 1 (4 points)}
%---------------------------------------------------------------
Plot the function $f(x)=\exp(-x^2/10)*\sin(x)$ for 400 linearly spaced points of $x$
in the region from $0$ to $2 \pi$. 
Points should be joined with solid lines.

Do not use any cycles or loops. Include the resulting figure in your report.

\problem{Problem 2 (4 points)}
%---------------------------------------------------------------
Plot functions $x^2$ and $x^3/2+0.5$ for $100$ linearly spaced points of $x$
in the region from $-1$ to $+1$. 
$x^2$ should be red solid line and $x^3$ should be black dashed line.
Do not worry about black and white printouts as long as colors are present
in pdf report file.

Do not use any cycles or loops. Include the resulting figure in your report.

\problem{Problem 3 (3 points)}
%---------------------------------------------------------------
Write a script which calculates
\begin{equation}
	1+\sum_{i=1}^N \frac{1}{x^i}
\end{equation}
for $N=10$ and $x=0.1$

Use loops as much as you wish from now.

\problem{Problem 4 (3 points)}
%---------------------------------------------------------------
Write a script which calculates
\begin{equation}
	\sum_{i=1}^N \frac{1}{i}
\end{equation}
for $N=100$, $N=1000$, $N=10000$.

Is the sum converging to certain value? What is it?

{\bf Bonus (2 points):} What is value of the sum for $N \to \infty$ and why
is it so drastically different from numerical results?

\problem{Problem 5 (3 points)}
%---------------------------------------------------------------
Write a script which calculates for $N=100$.
\begin{equation}
	S_N = \sum_{k=1}^N a_k
\end{equation}
where $a_k={1}/{k^{2k}}$ for odd $k$ and $a_k={1}/{k^{3k}}$ for even $k$. 

Hint: you may find {\bf mod} function useful to check for even and odd
numbers.


\problem{Problem 6 (3 points)}
%---------------------------------------------------------------
Make a plot of $S_N$ from problem 5  as a function of $N$ where $N$ spans the range between
50 and 150. Mark plot points with circles and make {\bf no lines}
connecting points.

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