% SIMIODETemplate-TeacherORStudent.tex and simiode.cls for LaTeX2e
% Version 29 July 2015.
%
% This class (simiode.cls) is a modification of that used by
% the journal PRIMUS - Problems, Resources, and Issues in
% Mathematics Undergraduate Studies.
%
% See http://www.tandfonline.com/loi/upri .
%
% The class was developed by  Marc Frantz with suggestions of the
% PRIMUS Editorial Board, especially John Thoo.
%
% This template is to be used with the  class file "simiode.cls".
%
% The latest version of this class and template files
% can be found at
%
%       <http://www.SIMIODE.org> in the Author section.
%
% A "Quick Start Guide" appears below.
%
% This file must be processed with version LaTeX2e or higher.
%
\documentclass{simiode}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% With this version of the tex file and the associated SIMIODE.cls file you can produce BOTH a Student Version and a Teacher Version of your modeling scenario or technique narrative.
%
% Basically the Student Version contains the title STUDENT VERSION along with the NAME OF SCENARIO, with no abstract, no keywords, no tags, no author identifiers, and no COMMENTS section. The Student Version contains only the STATEMENT of the modeling scenario with appropriate figures, data, instructions, and perhaps a bibliography appropriate for student resourcing, but nothing in the bibliography which would "give away" the nature of the modeling scenario, etc.
%
%The Teacher Version contains the material in the Student Version, namely the title NAME OF SCENARIO, now headed with   TEACHER VERSION, but also full author  identification, abstract, key words, tag words, and, following the STATEMENT, a section of COMMENTS which can be discussion of presentation  ideas, "solutions," techniques, etc.
%
% Authors can prepare a full Teacher Version using the notions immediately below  to create a pdf for review (but in review please eliminate all information about the author as we use a double-blind referee system. Such information will be restored when accepted and published in SIMIODE at www.simiode.org.
%
%***********   Toggle the following line to turn the teacher version on (1) or off (0). ***********
%
%
\def\TeacherEdition{0} % Toggle this line's value.
\newcommand{\teacher}[1]{\ifnum\TeacherEdition=1 #1 \fi}
%
%
% The \teacher{ } command wraps any text that will appear only in the teacher version of
% the document. See this file for examples. This has been done for you in the document below.
% Rename the pdf after you compile each final version.
% This option was created  by Eric Sullivan, Carroll College, Helena MT.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{amsmath,amssymb}
\usepackage{color}
\usepackage{graphicx}
\usepackage{hyperref}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% NOTE regarding double spacing %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Manuscripts should be submitted doubled spaced.  This is
% accomplished via the \baselinestretch command below.
% However, you may obtain an idea of how your article will
% look in final form, so that you can better plan your
% presentation.  To see your manuscript formatted very
% similarly to the on-line published format of  SIMIODE,
% comment the following line out by inserting a percent sign % (%) at its beginning.

\renewcommand{\baselinestretch}{1.3}

%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% NOTE regarding macros %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Any macros defined for your paper should be contained in
% the top matter. Likewise, any environment definitions such
% as \newtheorem or \newenvironment should also go in the
% top matter.
%
% Do not \input your macros as separate files within your
% final version because more files make it harder for the
% editors and users to keep track of and/or modify and
% append your paper.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Top matter is above and
% the beginning of the document below.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\newpage
% You only need to change the NAME OF SCENARIO in the next line and delete the footnote. See above for instructions on toggling from Teacher Version to Student Version.
\title{\ifnum\TeacherEdition=1 TEACHER VERSION  \else STUDENT VERSION \fi\\MODELING THE STEEPING OF \\ SOUTHERN SWEET ICED TEA}




\markboth{Modeling the Steeping of Southern Sweet Iced Tea}{Modeling the Steeping of Southern Sweet Iced Tea}


\author{Troy Henderson\\
University of Mobile\\
Mobile AL 36613 USA\\
thenderson@umobile.edu
}


\makeStitlePDFLaTex


\begin{abstract}
We offer raw data collected from a webcam and a thermometer for evaluating the strength of steeping tea.  We ask students to build a mathematical model using the data to predict how long the tea should steep before essentially reaching saturation.  
\end{abstract}


\section*{SCENARIO DESCRIPTION}

There are many preferences among Southerners regarding iced tea.  Some prefer unsweetened iced tea, but most prefer sweet tea.  Among those that prefer sweet tea, the preferred sweetness varies.  Some like to sweeten their iced tea with artificial sweeteners.  Among those that use sugar to sweeten their tea, some like lightly sweetened iced tea, others like moderately sweetened, and still others like their tea extremely sweet.  That is, the preference of sugar concentration is probably the biggest difference between different sweet teas.

Another difference between iced teas is the type of tea used in brewing.  There are instant teas, iced tea mixes, flavored teas, decaffeinated teas, cold brew tea bags, and classic fresh brew tea bags.  Yet another preference Southerners have among their ice teas is the brand of tea.  Some of the most common brands are \href{http://www.liptontea.com}{Lipton},\textsuperscript{\textregistered} \href{http://www.luzianne.com}{Luzianne},\textsuperscript{\textregistered} \href{http://www.reddiamond.com}{Red Diamond},\textsuperscript{\textregistered} and \href{http://www.tetleyusa.com}{Tetley}.\textsuperscript{\textregistered}


\begin{figure}[!h]
\begin{center}	
\begin{minipage}[t]{2.7 in}

\begin{center}
\includegraphics[width=2.6in]{lipton_front.eps}


\caption{\label{fig:lipton_front} Lipton\textsuperscript{\textregistered} Family Size Tea Bags}
\end{center}
\end{minipage}
 \ \quad \
\begin{minipage}[t]{2.7 in}

\begin{center}
\includegraphics[width=2.6in]{lipton_back.eps}



\caption{\label{fig:lipton_back} Manufacturer's brewing directions}
\end{center}
\end{minipage}
\end{center}

\end{figure}
\newpage
The following directions are used by the author when brewing sweet tea. The number of tea bags used and  brewing time are the primary differences between these  and the manufacturer's directions.

\vspace*{.2 true cm}
\begin{tabular}{p{0.9\linewidth}}
\textbf{Directions}\\
Bring $9\frac{1}{2}$ cups of water to a boil.  Pour boiling water onto $1\frac{1}{3}$ cups of granulated sugar, and stir until the sugar has dissolved.  Bob two \href{http://www.liptontea.com}{Lipton}\textsuperscript{\textregistered} family size tea bags (see Figures~\ref{fig:lipton_front} and \ref{fig:lipton_back} for package images) in the water several (10-12) times.  Let the tea steep for about an hour (or so).  Remove the tea bags, and stir in 8 cups of cold water.  Refrigerate for several hours (if possible) before serving.
\end{tabular} 



\begin{tabular}{p{0.9\linewidth}}
\textbf{Note:} If the directions above are followed, then the total amount of water used is $17\frac{1}{2}$ cups (which is about 1.1 gallons), and thus the tea pitcher used must be able to sustain this capacity.  It is also worth noting that the sugar concentration used is about 1.22 (or essentially $1\frac{1}{4}$) cups/gallon.
\end{tabular} 

\begin{itemize}
\item [] \textbf{Question 1:} \textit{How long should the tea brew so that its concentration essentially reaches steady state?} 
\item []\textbf{Question 2:} \textit{How does this steady state concentration compare to the concentration attained using twice the number of tea bags brewed for the manufacturer's suggested 3-5 minutes?} 
\end{itemize}

In order to answer these questions, we must determine a way to quantify the concentration level of the tea.  Since the color of the brewed tea gets darker the longer the tea brews, we assume that the tea concentration stabilizes when the \textit{darkness} of the brewed tea stabilizes.  To that end, we monitor the \textit{darkness} of the tea by periodically taking photos of the brewing tea throughout the steeping process.

\section*{Data Collection}

We begin our data collection by using a spotlight positioned on one side of the tea pitcher and a webcam on the opposite side.  The Linux command \texttt{uvccapture} is used to periodically (i.e. every 5 seconds) take snapshots of the steeping tea using a Logitech HD Pro Webcam C910.  Figure \ref{fig:initframe} shows the initial frame captured by the webcam, and demonstrates that the pitcher initially contains the sugar and no water.


\begin{figure}[!h]
\begin{center}
\includegraphics[width=3in]{initial.eps}
\caption{Initial Frame Captured by Webcam}\label{fig:initframe}
\end{center}

\vspace*{-.6 true cm}
\end{figure}

A custom Perl script was written to processes a portion of an image and return a quadruplet of the form (R,G,B,L) representing the red/green/blue/luminance of this region.  The output RGBL quadruplet is the average red/green/blue/luminance values of each pixel within the circular region of the image with provided center and radius.  The relative luminance, $L$, is determined by the standard \cite[p.~4]{ITU2015} formula \[ L = 0.2126\cdot R + 0.7152\cdot G + 0.0722\cdot B \]
where $R$, $G$, and $B$, are the red, green, and blue components, respectively.  These collected $R$, $G$, and $B$ values, as well as the computed $L$ values, are illustrated in Figure \ref{fig:rgbl} with colors red, green, blue, and black, respectively.

\begin{figure}[!h]
\begin{center}
\includegraphics[width=3.5in]{steep_0.eps}
\end{center}
\vspace*{-.5 true cm}
\caption{Steeping RGBL Values}\label{fig:rgbl}
\end{figure}

Comparing the $R/G/B/L$ with the individual images captured by the webcam, it is apparent that there were several instances when the webcam automatically increased the brightness in order to provide a presumably better image.  However, since these automatic adjustments are not desired for consistent data acquisition, the data was manually adjusted in order to correct this behavior.  Figure~\ref{fig:rgbl_corrected} illustrates these corrected $R/G/B/L$ values versus time.

\begin{figure}[!h]
\begin{center}
\includegraphics[width=3.5in]{steep_1.eps}
\end{center}
\vspace*{-.5 true cm}
\caption{Repaired RGBL Values}\label{fig:rgbl_corrected}
\end{figure}

The initial (i.e. near $t=0$) discontinuities for $R/G/B/L$ are due to the bobbing of the tea bags which transforms the essentially clear water (i.e. $R=G=B=L=1$) into a darker color in a small amount of time.  As the bobbing ceases, the $R/G/L$ values appear to settle into their decaying patterns, whereas the $B$ values remain essentially constant.

The  data file, file {\tt steep.d},  is available in the Support Documents of this Modeling Scenario and contains the corrected average $R/G/B/L$ values for each time $t$.  The data file contains 5 columns,  $(t,R,G,B,L)$. Each $t$ is measured in minutes and each $R/G/B/L$ is in the interval $[0,1]$.


\teacher{
\section*{NOTES FOR TEACHERS}
\subsection*{Modeling the Data -- Exponential Model}

In order to determine how long the tea should steep, we first need to model $L$.  Because $L$ resembles a decaying exponential model, we choose to model $L$ using the function \[f_1(t) = A + Ce^{kt}\] under the assumption that $A$ is no larger than the smallest value of $L$.  Using GNU Octave's Levenberg-Marquardt non-linear regression method {\tt leasqr} on a subset of $L$ (i.e. by first removing the initial apparent discontinuity formed by bobbing the tea bags), we determine that the optimal values of $A$, $C$, and $k$ which minimize the sum of the square differences between $L$. Upon substituting these optimal parameter values,  $f_1(t)$ then yields \[f_1(t) = 0.153750 + 0.172515\cdot e^{-0.095953\cdot t}.\]
Figure \ref{fig:Lf1(t)} shows the graph of $L$ and $f_1(t)$.

\begin{figure}[!h]
\begin{center}
\includegraphics[width=3.5in]{steep_2.eps}
\end{center}

\vspace*{-.3 true cm}
\caption{Modeling $L$ with $f_1(t)$}\label{fig:Lf1(t)}
\end{figure}

The root mean square error between $L$ and this ``optimal'' decaying exponential function is about 0.798\%.  Although $L$ initially appeared to resemble a decaying exponential function, Figure \ref{fig:Lf1(t)} clearly illustrates that such a model can be improved.  To understand why $f_1(t)$ fails to adequately model $L$, we note that $f_1(t)=A+Ce^{kt}$ is the general solution to the differential equation
					\[\frac{dy}{dt}=k(y-A)\]
where $k$ is a constant growth/decay rate.  A reasonable explanation as to why this model does not adequately represent $L$ is that $k$ does not necessarily have to be constant.  For example, if we assume that $k$ is constant, then we are concluding that the process of heating the water (to boiling) before steeping the tea is unnecessary since the water temperature is the only component, other than the tea concentration, that is changing throughout the entire steeping process.


\subsubsection*{Model Improvement}

We now consider the scenario where $k$ depends on the temperature $T$ of the water.  Since $T$ is changing with time $t$, we assume that $k=k(T)=k(T(t))=k(t)$.  Since we assume that $k$ is not constant (with respect to $T$), then $k=mT+b$ is the most elementary form of a non-constant function of $T$.  Furthermore, if we assume that $T$ follows the Newton's Law of Cooling model (which,  in our case says that $T'(t) = \lambda (T(t) - A)$ for some parameter $\lambda$ and  fixed  ambient temperature, $A$), $T$ must be of the form $T(t)=A+Be^{\lambda t}$.  Therefore, $k$ has the form

\vspace*{-.4 true cm}
\begin{eqnarray*}
k(t) & = & m\left(A+Be^{\lambda t}\right)+b\, ,\\
& = & \alpha + \beta e^{\lambda t}\, .
\end{eqnarray*}
Thus, we consider  (\ref{eq:themodel}) for modeling $L$
\begin{equation}
\frac{dy}{dt} = \left(\alpha + \beta e^{\lambda t}\right)(y-\gamma)\, ,\label{eq:themodel}
\end{equation}
where $\gamma$ is the steady state value of $L$.  The general solution for  (\ref{eq:themodel}) is
\[ y(t) = \gamma + C e^{\alpha t + \frac{\beta}{\lambda}e^{\lambda t}}. \]
Using Octave's {\tt leasqr} function to determine the parameters $\alpha$, $\beta$, $\gamma$, $\lambda$, and $C$,  minimizing the sum of square errors between observed data and model prediction gives $\alpha\approx-0.0265$, $\beta\approx-0.1886$, $\gamma\approx0.1407$, $\lambda\approx-0.15$, and $C\approx0.0683$. Therefore, $\frac{\beta}{\lambda}\approx1.2577$ and so
\[f_2(t) = 0.1407 + 0.0683\cdot e^{-0.0265\cdot t + 1.2577e^{-0.15\cdot t}}\]
is the model for $L$ approximated by GNU Octave's {\tt leasqr} function.  Since the form of $f_2(t)$ is a generalization of the form of $f_1(t)$, it is clear that $f_2(t)$ models $L$ better than $f_1(t)$.  This is demonstrated graphically in Figure \ref{fig:Lf2(t)}, and the root mean square error between $L$ and $f_2(t)$ is about $0.167\%$ which is about $\frac{1}{5}$ of the root mean square error between $L$ and $f_1(t)$.

\begin{figure}[!h]
\begin{center}
\includegraphics[width=3.5in]{steep_3.eps}
\end{center}

\vspace*{-.3 true cm}
\caption{Modeling $L$ with $f_2(t)$}\label{fig:Lf2(t)}
\end{figure}

\vspace*{-.7 true cm}
\subsection*{Interpretation}

We define
\[ p=\frac{y(0)-y}{y(0)-\lim\limits_{\tau\to\infty}y(\tau)} \]
to be the real number in $[0,1]$ which represents the (linear) \textit{progress} of $y$ toward reaching its limiting value from its initial value.  For example, if $y=y(0)$, then $p=0$.  That is, initially, $y$ has made no \textit{progress} toward reaching its limiting value.  Similarly, as $y$ approaches its limiting value, it follows that $p$ approaches 1.  That is, in this case, $y$ approaches complete (i.e. 100\%) \textit{progress} toward reaching its limiting value.  Using this definition of $p$, it follows that
\[ y = (1-p)\cdot y(0) + p\cdot\lim\limits_{\tau\to\infty} y(\tau) \]

Table~\ref{table:steeptimes} shows \textit{progress} values with corresponding times $t$ to reach each \textit{progress}

\begin{table}[!h]
\begin{center}
\begin{tabular}{|l|r|}\hline
\hfill$p$\hfill\null & \hfill$t$\hfill\null \\\hline\hline
0.5000 & 4.15\\
0.7500 & 12.32\\
0.8000 & 16.97\\
0.8500 & 25.18\\
0.9000 & 39.51\\
0.9421 & 60.00\\
0.9500 & 65.50\\
0.9800 & 100.03\\
0.9900 & 126.16\\\hline
\end{tabular}
\end{center}
\caption{Time to reach linear \textit{progress} $p$}\label{table:steeptimes}
\end{table}

\vspace*{-.7 true cm}

\subsection*{Conclusion}

\noindent\textbf{Question 1:} \textit{How long should the tea brew so that its concentration essentially reaches steady state?} 

We conclude that the tea has reached about 94.21\% saturation in an hour of steeping.  If an hour is not available, then 90\% saturation can be achieved in about 40 minutes.
\vspace*{.2 true cm}

\noindent\textbf{Question 2:} \textit{How does this steady state concentration compare to the concentration attained using twice the number of tea bags brewed for the manufacturer's suggested 3-5 minutes?} 

Since the tea has reached 50\% saturation in about 4.15 minutes, we conclude that the manufacturer's directions of 4 tea bags steeping for 3-5 minutes yields about the same strength as allowing 2 tea bags to steep for an hour (or so).  Therefore, if financial economy is more important than temporal economy, the conclusion is to use half the number of suggested tea bags and brew the tea for at least an hour.

}

\begin{thebibliography}{99}
\bibitem{ITU2015}
Internaitonal Telecommuncation Union. 2015. Parameter values for the HDTV standards 
for production and international  programme exchange.   Recommendation  ITU-R  BT.709-6. \url{https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.709-6-201506-I!!PDF-E.pdf}. Accessed 24 June 2016.

\end{thebibliography}
\end{document}
