\documentclass[11pt]{article}

\setlength{\topmargin}{-.8in}  
\setlength{\oddsidemargin}{0in}
\setlength{\evensidemargin}{0in}
\setlength{\textwidth}{6.5in}
\setlength{\textheight}{9.5in}


\begin{document}

\title{{Summations}\\
\normalsize{Reading: CLRS A}}
\date{}
\maketitle


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Why study summations? 
\begin{enumerate}
\item We saw that a summation came up in the analysis of
  Insertion-Sort. In general, the running time of a {\em while} loop
  can be expressed as the sum of the running time of each iteration.
\item Summations come up in solving recurrences.
\end{enumerate}




\section{Basic Summations}

\subsection{Arithmetic series}

\fbox{
\parbox{7.5cm} {$\sum_{k=1}^n k=1+2+3+\cdots +n= \frac{n(n+1)}{2} =
\Theta(n^2)$}
}
\vspace{\baselineskip}

\noindent
How can we prove this?
By induction: 
\begin{itemize} 
\item Base case:
  $\begin{array}[t]{ll} n=1 \Rightarrow & \sum_{k=1}^1 1 = \frac{1(1+1)}{2} = 1\\ 
  \end{array}$
  
\item Assume it holds for $n$: $\sum_{k=1}^n k =\frac{n(n+1)}{2}$
  
  Show it holds for $n+1$: $\sum_{k=1}^{n+1} k =\frac{(n+1)(n+2)}{2} =
  \frac{1}{2}n^2 + \frac{3}{2}n + 1$
  
  Proof: \begin{eqnarray*}
    \sum_{k=1}^{n+1} k & = & \sum_{k=1}^n k + (n+1) \\
    &  = & \frac{n(n+1)}{2} + (n+1) \\
    & = & \frac{1}{2}n^2 + \frac{1}{2}n + n + 1 \\
    & = & \frac{1}{2}n^2 + \frac{3}{2}n + 1
  \end{eqnarray*}
\end{itemize}


\vspace{2cm}

Note: In general it can be shown by induction  that
\fbox{
\parbox{3.5cm} { $\sum_{k=1}^n k^d = \Theta(n^{d+1})$}
}


\newpage
\subsection{Geometric series}

\fbox{
\parbox{8cm} { 
  $\sum_{k=0}^n x^k = 1+x+x^2+\cdots x^n=\frac{x^{n+1} - 1}{x - 1}$
}
}

\vspace{1cm}
Proof by induction:
\begin{itemize}
\item Base case: $\begin{array}[t]{ll}
    n=1\Rightarrow & \sum_{k=0}^1 x^k = 1 + x \\
    & \frac{x^{n+1} - 1}{x - 1} = \frac{x^2 - 1}{x - 1} =
    \frac{(x+1)(x-1)}{(x-1)} = x+1
  \end{array}$
\item Induction:
  
  Assume claim holds for $n$: $\sum_{k=0}^n x^k = \frac{x^{n+1} - 1}{x - 1}$
  
  Show claim holds for $n+1$: $\sum_{k=0}^{n+1} x^k = \frac{x^{n+2} - 1}{x - 1}$
  
  Proof: \begin{eqnarray*}
    \sum_{k=0}^{n+1} x^k & = & \sum_{k=0}^n x^k + x^{n+1} \\
    & = & \frac{x^{n+1} - 1}{x - 1} + x^{n+1} \\
    & = & \frac{x^{n+1}-1+x^{n+1}(x-1)}{x-1} \\
    & = & \frac{x^{n+1} - 1 + x^{n+2} - x^{n+1}}{x - 1} \\
    & = & \frac{x^{n+2} - 1}{x - 1} \\
  \end{eqnarray*}
\end{itemize}


\vspace{1cm}
\noindent


\fbox{
  \parbox{8cm}
  {
    if $x <1:   \sum_{k=1}^n x^k < \sum_{k=1}^\infty x^k=\frac{1}{1-x}=\Theta(1)$\\
    if $x > 1: \sum_{k=1}^n x^k < \sum_{k=1}^\infty x^k =\frac{x^n -1 }{x-1}=\Theta(x^n)$\\
    if $x=1: \sum_{k=1}^n 1 = n$
  }
}


\vspace{1cm}
\noindent
Example: $ 1 + \frac{1}{2} + \dots \frac{1}{2^n} = \sum_{k=1}^n \frac{1}{2^k} = \Theta(1)$






\vspace{1cm}
\subsection{Harmonic Series}

\fbox{
\parbox{6.9cm} {$\sum_{k=1}^n \frac{1}{k}=1+\frac{1}{2}+\frac{1}{3}+\cdots
+\frac{1}{n}=\Theta(\log n)$}
}

\vspace{\baselineskip}
We will not do a  proof for this one.





% \vspace{1cm}
% \section{Bounding Summations}

% Most of the summations cannot be computed precisely. In these cases we
% can try to find an asymptotic upper and lower bound for the
% summation. In the ideal case, we get a $\Theta()$ bound.  There are a
% couple of ways to bound summations.

% \newpage
% \subsection{Induction}

% Guess the summation bound and try to prove it by induction. 

% \vspace{0.5cm}
% \noindent 
% Example: Consider for example that we want to prove that $\sum_{k=0}^n
%   3^k = O(3^n)$, that is, that $\sum_{k=0}^n 3^k\leq c\cdot 3^n$ for some
%   $c$. Proof by induction:
%   \begin{itemize}
%   \item Basis: $\begin{array}[t]{ll}
%                n=1 \Rightarrow & \sum_{k=0}^1 3^x=1+3=4 \\
%                & \textrm{we want } 4 \le c \cdot 3 \\
% 	       & \textrm{Ok if } c>4/3               
% 		\end{array}$



%   \item Assume holds for $n$: $\sum_{k=0}^n 3^k\leq c \cdot 3^n$

%   Show holds for $n+1$: $\sum_{k=0}^{n+1} 3^k\leq c \cdot 3^{n+1}$

%   Proof: \begin{eqnarray*}
%          \sum_{k=0}^{n+1} 3^k & = & \sum_{k=0}^n 3^k+3^{n+1} \\
%                               & \leq & c \cdot 3^n+3^{n+1} \\
%                               & = & c \cdot 3^{n+1}(1/3+1/c) \\
%                               & \leq & c \cdot 3^{n+1}
%          \end{eqnarray*}
%          Ok if $1/3+1/c<1$ which holds if $c>3/2$
%   \end{itemize}





% \subsection{Bounding the terms}

% Use the largest (smallest)  value of a term to bound others:

% $$a_1 + a_2 + \dots a_n  \le a_{max}+ a_{max} + \dots +a_{max} = n \cdot a_{max}$$
% $$a_1 + a_2 + \dots a_n  \ge a_{min}+ a_{min} + \dots +a_{min} = n \cdot a_{min}$$

% \vspace{0.5cm}
% \noindent
% Example: \\
% $\sum_{k=1}^n k \leq \sum_{k=1}^n n = n\cdot\sum_{k=1}^n
% 1 = n^2 \Longrightarrow \sum_{k=1}^n k = O(n^2)$.\\
% $\sum_{k=1}^n k \geq \sum_{k=1}^n 1 = n  \Longrightarrow \sum_{k=1}^n k = \Omega(n)$.




% \subsection{Splitting the summation}

% Split the summation in two and bound each part (by bounding the
% terms).

% \vspace{0.5cm}
% \noindent
% Example:  
% $\sum_{k=1}^n k = \sum_{k=1}^{n/2-1} k +
%   \sum_{k=\frac{n}{2}}^n k \geq
%   \sum_{k=1}^{n/2-1} 0 + \sum_{k=\frac{n}{2}}^n k \geq (\frac{n}{2})^2 =
%   \Omega(n^2)$.




\newpage
\section{Summations--overview}
We have a sum. We want a (tight) bound for it. What can we do? 

\begin{itemize}
\item express it in terms of basic summations (for which we know the bound)
\end{itemize}

%%
\noindent 
All summations that we'll encounter in the class will fall in this
category.  Generally speaking, if the summation does not reduce to
one of the few basic summations, we can try to:
\begin{itemize}
\item guess a bound  and prove it by induction 
\item obtain upper and lower bounds by bounding terms and/or splitting. 
For more info, refer to the textbook. 
\end{itemize}

\end{document}


