\documentclass[12pt]{article}
\usepackage{amssymb,amsmath,amscd,amsthm,upquote}
\usepackage{fullpage}
\usepackage{pdfpages}
\begin{document}

\title{Lab: Estimating Pi using Series}
\date{}
\maketitle
\vspace{.2in}
Submit a concise and annotated file of the Matlab code you use to answer these questions on Moodle, as well as your answers to this worksheet. 
\subsubsection*{First Approximation of $\pi$}
Euler proved that
\[\sum_{n=1}^{\infty} \frac{1}{n^2}= \frac{\pi^2}{6} \]
\begin{enumerate}
\item[1.]
Use a For loop in Matlab to find the sum of the first 20 terms of this series. Give your answer to three decimal places.\\\\
$\displaystyle\sum_{n=1}^{20}\frac{1}{n^2}=$\\\\
Now use your answer to estimate $\pi$. \\\\
$\pi \approx$\\\\
Repeat those steps to estimate $\pi$ using the first 100 terms of the series.\\\\
$ \displaystyle\sum_{n=1}^{100} \frac{1}{n^2}=$\\\\
$\pi \approx$
\end{enumerate}
\subsubsection*{Error and approximation}
The error in approximating an infinite series by a finite series is given by the size of the ``tail" of the series:
\[ E_k = \sum_{n=1}^{\infty} a_n - \sum_{n=1}^k a_n = \sum_{n=k+1}^{\infty} a_n \]
We can bound the size of the error (find a number bigger than the error) using an improper integral, in particular an improper integral that is bigger than the `` tail" of the series. 
\begin{enumerate}
\item[2.] Think about the Integral Test and Comparison Test for series. Remember the geometric argument: To show a series converges, draw a sketch of the rectangles whose area is equal to the sum of the series. Then sketch the function for which those series is an Right Riemann sum and is above the series. Make sure the area under the function is bigger than the area of the series. What function are you integrating, what are the limits of integration? Fill in the answers below.

$\displaystyle\sum_{n=21}^{\infty} \frac{1}{n^2} < \int$\\\\
$\displaystyle\sum_{n=101}^{\infty} \frac{1}{n^2}< \int$

\item[3.]Evaluate the integrals and give a bound on the error.\\\\
$E_{20} <$\\\\
$E_{100} <$\\\\

\item[4.]
Can you make a guess about the size of the error $E_k$ as $k\to \infty$ based on your answers to question 3?
\vspace{.75 in}
\end{enumerate}
\subsubsection*{Error for Alternating series:}
The error for approximating an infinite alternating series by its $k$th partial sum is given by
\[E_k= \left|\sum_{n=1}^{\infty} (-1)^{n-1}a_n - \sum_{n=1}^k (-1)^{n-1}a_n \right|<a_{k+1} \]
The series $\displaystyle \sum_{n=1}^{\infty} \left(-\frac23\right)^{n-1}$ converges by the Alternating Series Test. 
\begin{enumerate}
\item[5.] What's another test you could use to show this series converges? (Your answer should also help you decided the exact sum of the series.)\\$\displaystyle \sum_{n=1}^{\infty} \left(-\frac23\right)^{n-1}=$\\\\

\vspace{.75in}
\item[6.] Use a For loop and Print in Matlab to create a list of the first 15 terms of the series.\\\\

\item[7.] Use a For loop in Matlab to create a table to the first 15 partial sums of the series. 

\item[8.] Using the formula from the beginning of this section, 
Find the $k$ such that the $k$th partial sum is within 0.01 of the sum of the series. In other words, for what $k$ is the error less than 0.01?\\\\
$k=$
\end{enumerate}

\subsubsection*{Approximating $\pi$ again}
Since $\arctan 1 = \pi/4$, you can approximate $\pi$ using the Taylor series for $f(x)=\arctan(x)$.\\
\begin{enumerate}
\item[9.] Use the definition of a Taylor polynomial to calculate the third-degree Taylor Polynomial of $f(x)=4\arctan x$ about $x=0$.\\\\
$P_{3}(x) = $\\
\item[10.] Use the internet or calculate by hand the Taylor series for $4\arctan x$ using the fact that $d/dx(\arctan x)=1/(1+x^2)$\\\\
$4 \arctan x = \sum$\\\\
\item[11.] Use your answer to 10 and a For loop in Matlab to to calculate the 9th-degree Taylor Polynomial for $f(x)=4 \arctan x$. 
$
P_9(x)=$\\\\
$\pi \approx P_9(1)=$

\item[11.] Use Matlab to plot $f(x)=4\arctan x$, $P_3(x)$, $P_9(x)$ on the same set of axes. 
\end{enumerate}
\subsubsection*{Error again}
A bound for the error when approximating a Taylor Series about $a$ by a Taylor Polynomial is given by
\[E_k(x)=|f(x)-P_n(x)|\leq \frac{M}{(n+1)!}|x-a|^{n+1} \]
where $|f^{n+1}|\leq M$ on the interval between $a$ and $x$.\\\\
The goal in this section is to calculate the error of the approximation of $\pi$ in question 10, i.e. to calculate the error for for $P_9(1)$ for $f(x)=4\arctan(x)$.
\begin{enumerate}
\item[12.] You should be able to figure out most of these values in this formula:\\\\
$n=$\\\\
$x=$\\\\
$a=$\\\\

\item[13.] However it's tricky to find $M$. In Matlab, calculate the 10th derivative (why 10?) of $f(x)=4\arctan(x)$, and plot it. You might need to look up the $\texttt{diff}$ command. \\\\
$f^{(10)}(x)=$\\\\
Include a plot of this function in your online submission.
\item[14.] Now calculate the max value of $f^{(10)}(x)$. Use the $\texttt{max}$ command in Matlab.\\\\
$\max f^{(10)} = $\\
\item[15.] Now use the formula given above to write down a bound for the error $E_9(1)$.\\\\
$E_9(1)=$\\

\item[16.] How does the error bound compare to the actual error (up to 5 decimal places)? The actual error is $4\arctan(1) - P_9(1)$.\\\\
Actual error $=\pi -P_9(1)=$\\
\end{enumerate}

\subsubsection*{Meta-math}
\begin{enumerate}
\item[17.] In your opinion, compared to the method for approximating $\pi$ in the first section, which method is easier? Why?
\end{enumerate}
\end{document}