\documentclass{amsart}[11pt]
\usepackage{graphicx}

\addtolength{\textwidth}{1.4in}                          
\oddsidemargin=0in                          
\evensidemargin=0in       

\newtheorem{example}{Example} 
\newtheorem{question}[example]{Question}
\newtheorem{definition}[example]{Definition}
\newtheorem{theorem}[example]{Theorem}
\newtheorem{notation}[example]{Notation}
\newtheorem{fact}[example]{Fact}

\begin{document}

\title{Math 242, Lecture 10}
\maketitle

\section{ Averages and moving averages} 

We saw last time that that the average value of a function $f(x)$
between times $a$ and $b$ is $\frac{1}{b-a} \int_a^b f(x) dx$.  

\begin{example}
Find the average value of the function $f(x) = 2 + x^2$ from $x = 3$ to $x = 4$. 
\end{example}

One of the main uses of averages is as part of a summary of a set of data.  
Moving averages summarize data over periods of time.   

\begin{definition}
The moving average of a function $f(t)$ with lag-time $n$-units is the function $\overline{f}(x)$
whose value at time $x$ is the average value of $f(t)$ between times $x - n$ and $x$.  
\end{definition}


\begin{example}
Find the four-quarter moving average of the following quarterly sales data.
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|c||c|c|c|c|c|c|c|c|}     \hline
1&3&2& 4 & 1.5 & 3.2 & 2.8 & 4.1&
1.4 & 3.6 & 2.5 & 5 & 2 & 4 & 3 & 4.8 \\ \hline 
\end{tabular}
\end{center}

\end{example}


Why would you want to do this?   

Moving averages are most often used for quickly changing
or seasonal data.    For example, a stock price can change a lot from day-to-day or 
even hour-to-hour.   Most investors hold onto stocks for longer periods, so summaries
of changes over weeks or months could be more helpful.    
In another example
some businesses, like retail, are seasonal.  So to get a good comparison of how business
is changing, you don't necessarily want to compare from month to month
(``gee, another big spike in December followed by a big letdown in January'').  
You want to either compare this December with last December or - and this
is part of what moving averages are about - compare the last twelve months
of sales {\em on average} to the previous twelve months of sales.    
Moving averages allow us to have the best of both worlds - they can 
be used for month-to-month comparisons, but by taking an average over a
whole period, they aren't sensitive to seasonality or large variability.  
You can see these advantages clearly in previous example.  Moving averages
are used {\em everywhere} in financial and insurance analysis, in particular
so one can understand underlying trends.  

Getting back to math, we can find an integral whose value is 
the average value of $f(t)$ between times $x - n$ and $x$.  
Namely, we plug into the formula for average value and get 
$\frac{1}{x - (x-n)}\int_{x-n}^x f(t) dt$, which
is equal to $\frac{1}{n} \int_{x-n}^x f(t) dt$.  

\begin{theorem}
The n-unit moving average of a function $f(t)$, namely $\overline{f}(x)$,
is equal to $\frac{1}{n} \int_{x-n}^x f(t) dt$.  
\end{theorem}

\begin{example}
Find the one- and four-unit moving averages of the function $f(t) = t^2 - 1$.  
Graph all three functions and explain the behavior we see.  
\end{example}


\section{ Present and future values of a revenue stream  
a first example}  

This application of the integral is important in finance,  
and according to professors of finance, it is more important
to understand that a (Riemann) sum leads to an integral
than to memorize the relevant integrals.    Understanding
the technique for getting to the right answer always trumps
memorizing a formula,   since technique can be applied to 
new problems more often.  

As we saw last term, the value of investments over time
is governed by exponential functions;   $P$ dollars
today becomes $P e^{rt}$ dollars in $t$ years if the rate 
of return is (constant at) $r$.    We are also familiar
with the need to adjust economic statistics
for ``today's dollars''.  

\begin{definition}
The future value of $P$ dollars today after $t$ years, assuming
an investment and/or inflation rate of $r$ over that time is
$P e^{rt}$.     The present value of $P$ dollars 
$t$ years from now is $P e^{-rt}$.  
\end{definition}

Current value is used to determine the worth of a promise
of money in the future.  

\begin{example}
Compute the current value of  \$10000, paid five years from
now, assuming an inflation rate of 4\%.    
\end{example}

Often in business and economics, money is paid (back)
in installments,   as with student
loans, mortgages and retirement accounts.    
How can we determine the current or future value
of installment payments?  

\begin{example}
\$100 deposited per month in an account earning 5\% interest
has a present value of 
$100 + 100 e^{-0.05 \frac{1}{12}} + \cdots + 100 e^{-0.05 \frac{11}{12}}$
dollars   or in {\em summation notation} $\sum_{i=0}^12 100 e^{-0.05 \frac{i}{12}}$
dollars.
\end{example}

Digression:   summation notation is a convenient shorthand for writing
sums.   For example, instead of $(3 x_1 + 5) + (3x_2 + 5) + \cdots + (3 x_{23} + 5)$,
  we write $\sum_{i=1}^{23} (3 x_i + 5)$.  

What if, instead of deposited as \$100 per month,   \$1200 was 
deposited as a continuous income stream, evenly over the year?  
Then, over a short  fraction of the year  
$\Delta t = \frac{1}{N}$th of a year,   we would deposit
$1200 \Delta t$ dollars.    Its present value would be 
$(1200 \Delta t) e^{-0.5 t}$, where $t$ is a time at which this
money is deposited.    The sum of all of these pieces
is $\sum_{t_i=\frac{1}{N}}^1 (1200 \Delta t) e^{-0.5 t_i}$.   

 We have gone through the steps of setting up a Riemann
 sum, leading to an integral;   by passing to a limit and using
the definite integral, we see that the present value 
will be $\int_0^1 1200 e^{0.5 t}$.    (Note how
much this income stream is worth   - making payments more
frequently can make a big difference!)  

\end{document}
 