# Tikz/addplot with gnuplot - graph of the function x^(-2/3) [closed]

I would like to plot graph for function x^(-2/3) in the domain 1:2 and -2:-0.1. But for negative numbers I have got error (see below). I don't know, how can I set number format "%.7e" for gnuplot used in tikz command \addplot. Perhaps the problem lies elsewhere.

And next, I observe that gnuplot cannot plot function x^(-2/3), but only x^(-0.6666). I have got message empty y range [1:1]

Xelatex Error:

set format "%.7e";; set samples 100; set dummy x; plot [x=-2:-0.1] x**(-0.666); ^
%%"example.pgf-plot.gnuplot", line 2: all points y value undefined!


Code:

\documentclass{scrbook}

\usepackage{tikz,pgfplots}

\begin{document}

\begin{tikzpicture}[thick,scale=0.7,
every node/.style={transform shape} ]

\begin{axis}[
xmin = -1.5, xmax = 2.5, ymin = 0, ymax = 3.5,  % osy
domain = -1:3.5,
restrict y to domain=0:3,
axis equal image,
axis x line = middle,
axis y line = middle,
xlabel={$x$}, ylabel={$y$},
]

\addplot[color=red, samples=100, smooth, ultra thick, unbounded coords=jump, no markers,
domain = 0.1:2] gnuplot{x^(-0.666)};

\addplot[color=red, samples=100, smooth, ultra thick, unbounded coords=jump, no markers,
domain = -2:-0.1] gnuplot{x^(-0.666)};

\end{axis}
\end{tikzpicture}
\end{document}


The graph should be symmetric about the axis y, but it is not.

• You have fallen for integer division. Try x^(2/3.) instead (notice the decimal point). – Henri Menke Aug 12 '16 at 17:54
• Also, you cannot rise a negative number to a fractional power because fractional powers are defined in terms of a logarithm which is not defined for negative numbers (at least not in the real plane). – Henri Menke Aug 12 '16 at 17:56
• I'm voting to close this question as off-topic because this is a limitation of mathematics itself. – Henri Menke Aug 12 '16 at 17:56
• – Henri Menke Aug 12 '16 at 17:58

The plot of y=x^(-2/3) is not symmetric about the y axis (maybe you're actually trying to plot y=1/(cuberoot(x^2))?).

For negative values of x, you'll get a complex result. You can extract the real part of the result using gnuplot's real function, and plot that instead:

And in case you're actually trying to plot y=1/(cuberoot(x^2)) (which is equal to x^(2/3) in the positive domain), you can use 1/(x^2)^(1./3). That gives you a function that's symmetric about the y axis:

\documentclass{scrbook}

\usepackage{tikz,pgfplots}

\begin{document}

\begin{tikzpicture}[thick,scale=0.7,
every node/.style={transform shape} ]

\begin{axis}[
xmin = -2.5, xmax = 2.5, ymin = -3.5, ymax = 3.5,  % osy
restrict y to domain=-3:3,
axis equal image,
axis x line = middle,
axis y line = middle,
xlabel={$x$}, ylabel={$y$},
]

\addplot[color=red, samples=100, smooth, ultra thick, unbounded coords=jump, no markers,
domain = 0.1:2] gnuplot{x^(-2.0/3)};

\addplot[color=red, samples=100, smooth, ultra thick, unbounded coords=jump, no markers,
domain = -2:-0.1] gnuplot{real(x^(-2.0/3))};

\end{axis}
\end{tikzpicture}
\end{document}


\documentclass{scrbook}

\usepackage{tikz,pgfplots}

\begin{document}

\begin{tikzpicture}[thick,scale=0.7,
every node/.style={transform shape} ]

\begin{axis}[
xmin = -2.5, xmax = 2.5, ymin = -3.5, ymax = 3.5,  % osy
restrict y to domain=-3:3,
axis equal image,
axis x line = middle,
axis y line = middle,
xlabel={$x$}, ylabel={$y$},
]

\addplot[color=red, samples=100, smooth, ultra thick, unbounded coords=jump, no markers,
domain = 0.1:2] gnuplot{1/((x^2)^(1./3))};

\addplot[color=red, samples=100, smooth, ultra thick, unbounded coords=jump, no markers,
domain = -2:-0.1] gnuplot{1/(x^2)^(1./3)};

\end{axis}
\end{tikzpicture}
\end{document}