sin(x), sin^{2}(x)
, with the following code:Code: Select all
\documentclass[a4paper]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{tabular}{@{}c@{}}
\begin{tikzpicture}
\begin{axis}[
width = \axisdefaultwidth,
height = 0.3\textheight,
xlabel = $x$,
ylabel = $\psi(x)$,
title = {Wavefunction in periodic potential.},
xmin = 0, xmax = 10,
ymin = -1.2, ymax = 1.2,
xtick = {0, 2, ..., 10},
xticklabels = {$0$, $a$, $2a$, $3a$, $4a$, $5a$},
]
\addplot [color = red, domain = 0 : 10, smooth] plot {cos(deg(\x*pi))}
node [pos = 0.3, above right] {$cos(x)$};
\addplot [color = blue, domain = 0 : 10, smooth] plot {sin(deg(\x*pi))}
node [pos = 0.9, above left] {$sin(x)$};
\addlegendentry{$\psi_{+}(x)$};
\addlegendentry{$\psi_{-}(x)$};
\end{axis}
\end{tikzpicture}
\\
\begin{tikzpicture}
\begin{axis}[
width = \axisdefaultwidth,
height = 0.3\textheight,
xlabel = $x$,
ylabel = $\rho(x)$,
title = {Probability density in periodic potential.},
xmin = 0, xmax = 10,
ymin = 0, ymax = 2.5,
xtick = {0, 2, ...,10},
xticklabels = {$0$, $a$, $2a$, $3a$, $4a$, $5a$},
]
\addplot [color = red, domain = 0 : 10, smooth] plot {2*cos(deg(\x*pi))^2}
node [pos= 0.3, above right] {$cos^{2}(x)$};
\addplot [color = blue, domain = 0 : 10, smooth] plot {2*sin(deg(\x*pi))^2}
node [pos = 0.9, above left] {$sin^{2}(x)$};
\addlegendentry{$\rho_{+}(x)$};
\addlegendentry{$\rho_{-}(x)$};
\end{axis}
\end{tikzpicture}
\end{tabular}
\end{document}
$sin(x)$
and $cos(x)$
are not smooth and drifting on the y-axis. The $sin^{2}(x)$
and $cos^{2}(x)$
are horrendous.The intended result is to plot 5 peaks where the cos(x) has its maximums over a, 2a, 3a, etc. similar to the grey plots.
Why are the plots like this? What am I doing wrong?