I am currently using pgf plots to make a few graphs; however, when I go to typeset the document I receive a strange error message that prevents the PDF from being produced. The error message states: "File ended while scanning use of \pgfplots@addplotimpl@expression@curly." I have attached the error message and code below.
Thank you.
%latex
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage[mathscr]{euscript}
\usepackage{pgfplots}
\usepackage{tikz}
% Theorem Styles
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
% Definition Styles
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}%[section]
\newtheorem{example}[theorem]{Example}%[section]
\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{note}[theorem]{Note}
\newtheorem{question}[theorem]{Question}%[section]
\input {xy}
\xyoption{all}
\newcommand{\R}{\mathbb{R}}
\begin{document}
%+Title
\title{Article Title}
\maketitle
%-Title
%+Contents
\tableofcontents
%-Contents
\section{Differentiable Function}
The curve $ \{ (x,y) \ : \ y=f(x) \}$ where $f:\R \to \R$ can be approximated with a tangent line.
\vspace{0.05in}
\newline
The surface $ \{ (x,y,z) \ : \ z=f(x,y) \}$ where $f:\R^2 \to \R$ can be approximated with a tangent plane.
\vspace{0.05in}
\newline
In single-variable calculus, we defined a function $f:\R \to \R$ to be differentiable at $x_0$ if the following limit existed:
\begin{align*}
f'(x_0)=\lim_{h \to 0} \frac{f(x_0+h)-f(x_0)}{h}
\end{align*}
Notice that this expression represents the slope of the secant line:
\vspace{0.1in}
\begin{center}
\pgfplotsset{
compat=1.12,
standard/.style={
axis lines=middle,
enlarge x limits=0.15,
enlarge y limits=0.15,
every axis x label/.style={at={(current axis.right of origin)},anchor=north west},
every axis y label/.style={at={(current axis.above origin)},anchor=north east},
}
}
\begin{tikzpicture}
\begin{axis}[
standard,
xlabel = $x$,
ylabel = {$y$},
xtick={\empty},
ytick={\emtpy},
extra x ticks={1,4},
extra x tick labels={$x_0$,$x_0+h$},
]
\addplot [
domain=0:5,
samples=100,
color=black,
]
{x^2};
\addplot [
domain=0:5,
samples=100,
color=black,
]
{5*x-4}
\end{axis}
\end{tikzpicture}
\end{center}
\begin{note}
$f(x)=\|x\|$ is not differentiable at $x=0$ because $\lim_{h \to 0}\frac{f(0+h)-f(0)}{h}$ does not exist:
\begin{align*}
\lim_{h \to 0^+} \frac{f(0+h)-f(0)}{h}=\lim_{h \to 0^+} \frac{h}{h}=1 \\
\lim_{h \to 0^-} \frac{f(0+h)-f(0)}{h}=\lim_{h \to 0^-} \frac{h}{h}=-1
\end{align*}
\end{note}
Suppose that $f'(x_0)$ exists. We then know that:
\begin{align*}
\lim_{h \to 0} \frac{f(0+h)-f(0)}{h}-f'(x_0)=0 \\
\lim_{h \to 0} \frac{f(0+h)-f(0)-hf'(x_0)}{h}=0
\end{align*}
We can use $f(x_0)+hf'(x_0)$ as a linear approximation of $f(x_0+h)$:
\begin{center}
\begin{tikzpicture}
\begin{axis}[
standard,
clip=true,
clip mode=individual,
restrict y to domain=0:2.3,
axis lines=middle,
xlabel = $x$,
ylabel = {$y$},
xtick={\empty},
ytick={\empty},
extra x ticks={1,3},
extra x tick labels={$x_0$,$x_0+h$},
extra y ticks={1, 1.73, 2},
extra y tick labels={$f(x_0)$, $f(x_0+h)$, $f(x_0+h)+h'(x_0+h)$},
ymax=3,
xmax=5
]
\addplot [
domain=0:4.5,
samples=100,
color=black,
]
{(1/2)*x+(1/2)} node [above,pos=1] {$f(x_0)+hf'(x_0)$}
\addplot [
domain=0.1:4,
samples=100,
color=black,
]
{sqrt(x)}
\addplot [dashed,
domain=0.1:4,
samples=2,
]
{1}
\addplot [dashed,
domain=0:4,
samples=2,
]
{sqrt(3)}
\addplot [dashed,
domain=0:4,
samples=2,
]
{2}
\end{axis}
\end{tikzpicture}
\end{center}
\begin{definition} Function is never really linear but it looks more and
more linear as we zoom in.
\end{definition}
\begin{definition}
Let $f:\R \to \R$ be a function at $a \in \R$. We say $f$ is differentiable at $a$ if the following limit exists:
\end{definition}
\marginpar{Hardest concept of the course}
\end{document}
Best Answer
You need a semi-colon at the end of each
\addplot
statement. You also have a typo in the\empty
macro one place, and you're using an undefined stylestandard
.Other notes:
The
\newline\vspace{0.05in}
is a bad idea I think, just add an empty line to signify a paragraph break. If you insist on having no indentation and some vertical space between paragraphs (which I wouldn't do), add\usepackage{parskip}
.Don't use
align*
for everything. If there is just one equation, useequation*
. If there are several equations that shouldn't be aligned e.g. at an equals sign, usegather*
.Don't have empty lines (paragraph breaks) before and after displayed math such as
gather*
.amsart
loads at leastamsmath
.