![Как построить графики функций с рациональными показателями степени с помощью pgfplots?](https://rvso.com/image/327790/%D0%9A%D0%B0%D0%BA%20%D0%BF%D0%BE%D1%81%D1%82%D1%80%D0%BE%D0%B8%D1%82%D1%8C%20%D0%B3%D1%80%D0%B0%D1%84%D0%B8%D0%BA%D0%B8%20%D1%84%D1%83%D0%BD%D0%BA%D1%86%D0%B8%D0%B9%20%D1%81%20%D1%80%D0%B0%D1%86%D0%B8%D0%BE%D0%BD%D0%B0%D0%BB%D1%8C%D0%BD%D1%8B%D0%BC%D0%B8%20%D0%BF%D0%BE%D0%BA%D0%B0%D0%B7%D0%B0%D1%82%D0%B5%D0%BB%D1%8F%D0%BC%D0%B8%20%D1%81%D1%82%D0%B5%D0%BF%D0%B5%D0%BD%D0%B8%20%D1%81%20%D0%BF%D0%BE%D0%BC%D0%BE%D1%89%D1%8C%D1%8E%20pgfplots%3F.png)
Степенные функции, которые я пытаюсь построить, отображаются не полностью, я пробовал менять домены и прочее, но безрезультатно. Могу ли я получить здесь помощь, пожалуйста?
\documentclass{article}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines = center,
xlabel = $x$,
ylabel = {$y$},
xmax = {4},
xmin = {-1},
ymax = {2},
ymin = {-2},
legend pos = outer north east
]
\addplot [
domain=-10:10,
samples=100,
color=black,
]
{x^(1/2)};
\addlegendentry{$y=\sqrt{x}$}
\addplot [
domain=-5:5,
samples=100,
color=blue,
]
{x^(1/4)};
\addlegendentry{$y=x^{\frac{1}{4}}$}
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
axis lines = center,
xlabel = $x$,
ylabel = {$y$},
xmax = {4},
xmin = {-4},
ymax = {2},
ymin = {-2},
legend pos = north west
]
\addplot [
domain=-10:10,
samples=100,
color=black,
]
{x^(1/3)};
\addlegendentry{$y=x^{\frac{1}{3}}$}
\addplot [
domain=-10:10,
samples=100,
color=blue,
]
{x^(1/5)};
\addlegendentry{$y=x^{\frac{1}{5}}$}
\end{axis}
\end{tikzpicture}
\end{document}
решение1
Вы можете адаптировать решение изМатематическая функция PGF для вычисления кубического корнядля генерации функции, вычисляющей третий и пятый корень:
Использованная литература:
Код:
\documentclass{article}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\pgfmathdeclarefunction{CubeRoot}{1}{%
\pgfmathparse{ifthenelse(#1<0,-1,1)*exp((ln(abs(#1)))/3)}%
}
\pgfmathdeclarefunction{FifthRoot}{1}{%
\pgfmathparse{ifthenelse(#1<0,-1,1)*exp((ln(abs(#1)))/5)}%
}
\begin{document}\noindent
\begin{tikzpicture}
\begin{axis}[
axis lines = center,
xlabel = $x$,
ylabel = {$y$},
xmax = {4},
xmin = {-1},
ymax = {2},
ymin = {-2},
legend pos = south east
]
\addplot [
domain=0:4,
samples=100,
color=orange,
line width=1.0pt,
]
{(x)^(1/2)};
\addlegendentry{$y=\sqrt{x}$}
\addplot [
domain=0:5,
samples=100,
color=blue,
line width=1.0pt,
]
{(x)^(1/4)};
\addlegendentry{$y=x^{\frac{1}{4}}$}
\end{axis}
\end{tikzpicture}
\par
\noindent
\begin{tikzpicture}
\begin{axis}[
axis lines = center,
xlabel = $x$,
ylabel = {$y$},
xmax = 4,
xmin = -4,
ymax = 2,
ymin = -2,
legend pos = south east,
clip=true,
]
\addplot [
domain=-4:4,
samples=100,
color=blue,
line width=1.0pt,
]
{CubeRoot(x)};
\addlegendentry{$y=x^{\frac{1}{3}}$}
\addplot [
domain=-4:4,
samples=100,
color=red,
line width=1.0pt,
]
{FifthRoot(x)};
\addlegendentry{$y=x^{\frac{1}{5}}$}
\end{axis}
\end{tikzpicture}
\end{document}