![pgfplots를 사용하여 유리수 지수와 관련된 함수를 그리는 방법은 무엇입니까?](https://rvso.com/image/327790/pgfplots%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20%EC%9C%A0%EB%A6%AC%EC%88%98%20%EC%A7%80%EC%88%98%EC%99%80%20%EA%B4%80%EB%A0%A8%EB%90%9C%20%ED%95%A8%EC%88%98%EB%A5%BC%20%EA%B7%B8%EB%A6%AC%EB%8A%94%20%EB%B0%A9%EB%B2%95%EC%9D%80%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%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}