I have been looking all over the Exchange and online to try to find how to plot functions like 1/x^3. I get an error in the dimension. I am using the \addplot command under tikz. I have tried different domains but to no avail. Any help would be appreciated.
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{subcaption}
\usetikzlibrary{arrows.meta}
\pgfplotsset{compat=1.17}
\pgfplotsset{every x tick label/.append style={font=\footnotesize, yshift=0.6ex}}
\pgfplotsset{every y tick label/.append style={font=\footnotesize, xshift=0.5ex}}
\begin{document}
\subsubsection*{Negative Integer Powers}
The graphs of power functions that have negative integer exponents have \emph{two} distinct shapes (see Figures 3 and 4 below).
\begin{minipage}[h]{3in}
\begin{tikzpicture}
\begin{axis}[
grid style={blue!50},
axis x line = center,
axis y line = center,
xmin = -5, xmax = 5,
ymin = -5, ymax = 5,
xtick = {-5,-4,...,5},
ytick = {-5,-4,...,5},
grid = both,
]
\addplot[samples=300,domain=-3:3,ultra thick,color=blue]{1/(x^2)};
\end{axis}
\end{tikzpicture}
\captionof{figure}{$y=x^n$ $\bigcup$-shaped}
\end{minipage}
\qquad
\begin{minipage}[h]{3in}
\begin{tikzpicture}
\begin{axis}[
grid style={blue!50},
axis x line = center,
axis y line = center,
xmin = -5, xmax = 5,
ymin = -5, ymax = 5,
xtick = {-5,-4,...,5},
ytick = {-5,-4,...,5},
grid = both,
]
\addplot[samples=300,domain=-3:-0.1,ultra thick,color=blue]{1/(x^3)};
\addplot[samples=300,domain=0.1:3,ultra thick,color=blue]{1/(x^3)};
\end{axis}
\end{tikzpicture}
\captionof{figure}{Graph of $y=x^{-3}$ or $y=1/x^3$}
\end{minipage}
\end{document}
It worked, but the dimensions and figures don't align.
Nick


domain=-3:-0.2anddomain=0.2:3and it should be fine. – Luis Sibaja Mar 04 '21 at 02:22