% Taylor Approximations I
% MATH 266B Exercise 1
\documentclass[12pt]{article}
\usepackage{times}
\pagestyle{empty}
\addtolength{\textwidth}{1.2in}
\addtolength{\textheight}{1.2in}
\addtolength{\oddsidemargin}{-.58in}
\addtolength{\evensidemargin}{-.58in}
\renewcommand{\baselinestretch}{1.0}
\parindent = 0cm
\parskip = .1cm
\begin{document}
\begin{center}
{\Large Taylor Approximations I
\footnote{Copyright \copyright 2003 Winfried Just, Department Mathematics,
Ohio University. All rights reserved.}}
\end{center}
In this exercise, we will visualize how Taylor polynomials approximate
a given function. Let $f(x) = ln x$. Define this function in
\textsc{MatLab}:
\smallskip
\verb$>> f = inline('log(x)')$\\
\smallskip
As we have shown in class, the first four Taylor polynomials for $f(x)$
at $a = 1$ are:
\noindent
$P_{1}(x) = x - 1$
\noindent
$P_{2}(x) = x - 1 + \frac{1}{2}(x - 1)^2$
\noindent
$P_{3}(x) = x - 1 - \frac{1}{2}(x - 1)^2 + \frac{1}{3}(x - 1)^3$
\noindent
$P_{4}(x) = x - 1 - \frac{1}{2}(x - 1)^2 + \frac{1}{3}(x - 1)^3 - \frac{1}{4}(x - 1)^4$\\
\smallskip
Define these functions in \textsc{MatLab} as follows:
\smallskip
\verb$>> P1 = inline('x-1')$\\
\verb$>> P2 = inline('x-1-(x-1)^2/2')$\\
\verb$>> P3 = inline('x-1-(x-1)^2/2+(x-1)^3/3')$\\
\verb$>> P4 = inline('x-1-(x-1)^2/2+(x-1)^3/3-(x-1)^4/4')$\\
\smallskip
Now let us plot these functions. Enter:
\smallskip
\verb$>> hold on$\\
\verb$>> ezplot(f, [0.5, 2])$\\
\verb$>> ezplot(P1, [0.5, 2])$\\
\verb$>> ezplot(P2, [0.5, 2])$\\
\verb$>> ezplot(P3, [0.5, 2])$\\
\verb$>> ezplot(P4, [0.5, 2])$\\
\medskip
Add the title ``\textsc{MatLab} homework number 1'' to your graph and print it for
possible submission.
On your printout, indicate by pencil which graph belongs to which function.
You may have to plot the graphs one by one again and compare with your
printout for this. If you want to do this redo of the graphing, remember to
start with:
\smallskip
\verb$>> hold off$
\medskip
Now let us see what happens if we look at the Taylor polynomials at a
larger interval. If your hold is still set to ``on'' you can do this
by simply entering:
\smallskip
\verb$>> ezplot(P4, [0.5, 3])$
\medskip
Make sure that all five functions are shown on the graph, give it a title,
and print it for possible submission. Indicate on the printout how the
graph shows that although higher-order Taylor polynomials at a point $a$
are better approximations of the given function for $x$ close to $a$, they
are not necessarily better approximations \emph{for all x.}
\end{document}