% -*- latex -*-
% FILE: "/home/evmik/jobs/wm/2015_fall_practical_computing_for_scientists/hw04/hw04.tex"
% LAST MODIFICATION: "Tue, 22 Sep 2015 22:56:51 -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{04}

General requirements/comments: 
\begin{itemize}
	\item Pay attention to error bars and {\bf report them}.
	\item Everywhere in this homework use built in \mat{fittype}
		to define fitting function with the following call to \mat{fit}
		to do the fitting.
	\item All data files are provided at the class web page.
\end{itemize}


\problem{Problem 1 (5 points)}
%---------------------------------------------------------------
Recall one of the problems from the previous homework 2.

Download  data   file  'hw02dataset.dat'  from  the   class  webpage.  It
represents the result  of someone's attempt  to find  the resistance of a  sample via
measuring voltage  drop ($V$),  which is  the data in  the 1st  column, and
current ($I$), listed in the 2nd  column, passing through the resistor.
Judging  by the  number of  samples it  was an  automated
measurement.

Using Ohm's law $V=R I$  and a linear fit of the data  with one free parameter ($R$)
find the resistance ($R$) of this sample. What are the
errorbars/uncertainty of this estimate? Does it come close to the one which
you obtained via the method used in homework 2? Do not use fitting available
via GUI interface, construct your own.

\problem{Problem 2 (5 points)}
%---------------------------------------------------------------
You are making a speed detector based on the Doppler effect. Your device detects
dependence of the signal strength vs time, which is recorded in the
'hw\_fit\_cos\_problem.dat' file (first column is time and second is the
signal strength).

Fit the data with 
\begin{eqnarray*}
	A \cos(\omega t +\phi)
\end{eqnarray*}
where $A$,  $\omega$ and $\phi$ are the amplitude, the frequency and the phase of the signal, and $t$ is time.

Find fit parameters (the amplitude, the frequency and the phase of the
signal) and their uncertainties. 

\problem{Bonus (2 points)}
This is for the physicists among us.
Provided that the above radar was using radio frequency range, could you estimate
velocity measurement uncertainty? Is it a good detector to measure ground car
velocity?


\problem{Problem 3 (5 points)}
%---------------------------------------------------------------
Experiment to do at home. Make a pendulum of variable length (0.1m, 0.2m,
0.3m, and so on up to 1m). Measure how many back and forth swings that the
pendulum with each particular length does in 20 seconds (clearly you will have to round to the nearest
integer).
Save your observations into the simple text file with 'tab' separated
columns. The first column should be the length of the pendulum in meters,
the second column the number of full swings in 20 seconds.

Write a script which loads this data file, and extract acceleration due to
gravity ($g$) from the properly fitted experimental data.
Recall that period of the oscillation of
a pendulum with the length $L$ is given by the following formula
\begin{eqnarray*}
	T = 2 \pi \sqrt{ \frac{L}{g} }
\end{eqnarray*}

\problem{Problem 4 (5 points)}
%---------------------------------------------------------------
In optics, the propagation of the laser beams is often described in the
Gaussian beams formalism. Among other things, it says that optical beam
intensity cross section is described by the Gaussian profile (hence, the name of
the beams)
\begin{eqnarray*}
	I(x) = A \exp{\left( -\frac{(x-x_o)^2}{w^2} \right)} + B
\end{eqnarray*}
where $A$ is the amplitude, $x_o$ is the position of the maximum intensity,
$w$ is the characteristic width of the beam (width at $1/e$ intensity
level), and $B$ is the background illumination of the sensor.

Extract  the  $A$, $x_o$, $w$, and  $B$ with their uncertainties  from the real
experimental data  contained in the file  '{gaussian\_beam.dat}', where the
first column is the position ($x$) in  meters and second column is the beam
intensity in arbitrary units. 

Is the suggested model good to describe the experimental data? Why so?

\problem{Bonus (2 points)}
Fit the data from the file '{data\_to\_fit\_with\_Lorenz.dat}' with the above Gaussian
profile. Is resulting fit is the good one or not? Why so? Compare it to the
Lorentzian model, which we discussed during the lecture 7.

\end{document}
