Originally in my code, I had
xtick={-2*pi, -(3/2)*pi, -(1/2)*pi, (1/2)*pi,(3/2)*pi, 2*pi},
to put tick marks at integral multiples of $pi/2$. It would not compile. I had to replace it with cumbersome decimal approximations. Why won't the code compile with expressions like pi? To specify width of the x-axis in the axis environment, I used xmin=-2*pi, and xmax=2*pi,, and to specify the domain of the cosine function, I used domain=-2*pi:2*pi.
\documentclass{amsart}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,backgrounds,patterns}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=4.5in,clip=false,
xmin=-2*pi,xmax=2*pi,
ymin=-1.25,ymax=1.25,
axis lines=middle,
%xtick={-2*pi, -(3/2)*pi, -pi, -(1/2)*pi, (1/2)*pi, pi, (3/2)*pi, 2*pi},
xtick={-6.28318, -4.7123889, -3.14159, -1.5708, 1.5708, 3.14159, 4.7123889, 6.28318},
xticklabel style={font=\footnotesize,fill=white},
xticklabels={$-2\pi$,,$-\pi$,,,$\pi$,,$2\pi$},
ytick={-1},
yticklabel style={font=\footnotesize,fill=white},
yticklabels={$-1$},
extra y ticks={1},
extra y tick labels={$1$},
extra y tick style={yticklabel style={font=\footnotesize,fill=white,anchor=south east}},
ticklabel style={font=\footnotesize,fill=white},
axis line style={latex-latex},
axis line style={shorten >=-7.5pt, shorten <=-7.5pt},
xlabel style={at={(ticklabel* cs:1)},anchor=north west},
ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]
\addplot [samples=501,mark=none, thick, red,domain=-2*pi:2*pi] {cos(deg(x))};
\end{axis}
\end{tikzpicture}
\end{document}





xtick={-6.28318, -4.7123889, ..., 6.28318}. – anderstood Jun 12 '15 at 17:33