Is there a direct command to plot the modified Bessel functions?, I could find the below code to plot the bessel functions, but i couldn't find a similar one to plot the modified ones.  \documentclass[border=12pt]{standalone}     \usepackage{pgfplots}          \pgfplotsset{compat=newest}          \directlua{       ffi=require(&quot;ffi&quot;)       ffi.cdef[[       double jn(int n, double x);       double yn(int n, double x);       ]]     }          \pgfmathdeclarefunction{BesselJ}{2}{%       \edef\pgfmathresult{%         \directlua{tex.print(ffi.C.jn(\pgfmathfloatvalueof{#1},\pgfmathfloatvalueof{#2}))}%       }%     }                    \begin{document}          \begin{tikzpicture}       \begin{axis}[         x axis line style={-stealth},         y axis line style={-stealth},         axis lines*=center,         cycle list={[samples of colormap={6 of viridis}]},         enlargelimits=false,         domain=0:20,         restrict y to domain=-2:1.5,         ymin=-1,         ymax=1.3,         samples=100,         no markers]         \pgfplotsinvokeforeach{0,...,2}{           \addplot { BesselJ(#1,x) }; \addlegendentry{$J_{#1}(x)$};       }       \end{axis}     \end{tikzpicture}          \end{document}
123715
I need to plot the Bessel functions of first and second kind (J and Y), and the modified Bessel functions of first and second kind (I and K), with integer order, from order 0 to order 5, using pgfplots. Several solutions have been already presented in other questions, but:  Gnuplot makes available for plots only the Bessel functions of the first and second kind and only of order 0 and 1, so  is not suitable. I would not like to use nor pstricks, neither LuaTeX, so also  and  are not suitable.  is quite similar, but has no answer and no examples in the comments.  How to accomplish this with pgfplots? Also an external solution with numpy, scipy and Matplotlib as in  would be ok (however, the code seems to work only for the J function).    I tried using the code in the last linked , inserting as an \addplot the file example-04.txt. It works for the function J, but it prints unacceptable values (e+09) for function Y, which is very large and negative near 0. The code which generates example-04.txt is Python and here it would be almost certainly OT.
60665
The generating function for a Bessel equation is:      $$g(x,t) = e^{(x/2)(t-1/t))}$$      Using the product $g(x,t)\cdot g(x,-t)$ show that:      a) $$[J_0(x)]^2 + 2[J_1(x)]^2 + 2[J_2(x)]^2 + \cdots = 1$$      and consequently:      b)      $$|J_0(x)|\le 1, \forall x$$      c) $$|J_n(x)| \le \frac{1}{\sqrt{2}}; n=1,2,3,\cdots$$   For a) I tried the product:  $$e^{(x/2)(t-1/t))}\cdot e^{(x/2)(-t+1/t))} = 1$$  I at least arrived at the right side of the equation. Since this generates the bessel functions, I should arrive at something related to $J_n$ in the left side. I know that  $$e^{(x/2)(t-1/t))} = \sum_{n=0\infty}^{\infty} J_n(x)t^n$$  $$e^{(x/2)(-t+1/t))} = \sum_{n=0\infty}^{\infty} J_n(x)(-t)^n$$  but it's not just a matter of multiplying coefficients from the two infinite series, right?  For $b$, I tried to use  but it's not as obvious  I have no idea how to deal with $c$, could somebody help me?
88334
See this example code:  \documentclass{article}  \usepackage{pgfplots} \pgfplotsset{compat=1.10} \begin{document}   \begin{tikzpicture}     \begin{axis}[                  xmin=-0.1,                  xmax=1.1,                  ymin=-1.1,                  ymax=1.1,                  domain=0:1,                  samples=30                 ]       \addplot[blue] {sqrt(x)};       \addplot[purple] {-sqrt(x)};     \end{axis}   \end{tikzpicture} \end{document}   The result appears acceptable far from zero, but near zero it's too much undersampled:    Increasing samples value makes the plot nice, but it considerably slows down processing. As a workaround I could just plot the inverse in a parametric plot (i.e. (y^2,y)), but in my actual code it'd require quite a bit of additional work.  Is there a way to provide a custom sampling function or specify different density of samples in different parts of the domain?
11948
I have some files with TikZ graphics that have suddenly changed appearance since I upgraded to PGF-2.10.  Here is a minimal example:  \documentclass{minimal} \usepackage{tikz} \begin{document} \pgfversion\par \begin{tikzpicture} \draw[blue] plot[domain=-1:1] (\x,{\x^2 + \x^3}); \draw[xshift=4cm,blue] plot[domain=-1:1] (\x,{(\x)^2 + (\x)^3}); \end{tikzpicture} \end{document}   In PGF 2.00 I had this:    while in 2.10 I have this:    The one on the left in PGF 2.10 looks like the graph of y=x^3 but could also be y=x^3 + x|x|.   This has been  on sourceforge and  on the pgf-users mailing list.  Although I haven't checked myself yet, the bug remains open and some of the commenters below report that problems still exist in the CVS version.   Geoffrey Jones notes the bug is in the 2.00 CVS version:     Hi Matthew, not an answer, just an FYI   that's too large for the comment box.   My compile of your code through pgf   v2.00 produces the result you see with   v2.10, above:       I.e., the difference you observe seems   to pre-date v2.10.   There is a workaround by inserting parentheses.  But since I have so many old lecture files I'd rather find a solution that doesn't involve rewriting my TikZ code.  And I'm squeamish about using the CVS bleeding edge code even if it were fixed, since I don't want to introduce other problems.  Ideally I'd like a simple patch that I can stick at the preamble, or just fix one file in the PGF distro.
113553
What I want:    This is what I have so far in terms of code:  \newcommand\gauss[2]{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}  % Gauss function, parameters mu and sigma  \begin{tikzpicture} \begin{axis}[every axis plot post/.append style={   mark=none,domain=-2:3,samples=50,smooth}, % All plots: from -2:2, 50 samples, smooth, no marks axis x line*=bottom, % no box around the plot, only x and y axis axis y line*=left, % the * suppresses the arrow tips enlargelimits=upper] % extend the axes a bit to the right and top \addplot {\gauss{0}{0.5}}; \addplot {\gauss{1}{0.75}}; \end{axis} \end{tikzpicture}
105905
After reading a question on "",  I have a code like this that refers to the inequalities    \documentclass{article} \usepackage{mathtools} \usepackage{amssymb} \usepackage{MnSymbol} \usepackage{tikz} \usepackage{pgfplots} \usetikzlibrary{intersections} \usetikzlibrary{patterns}  \makeatletter \newcommand{\pgfplotsdrawaxis}{\pgfplots@draw@axis} \makeatother \pgfplotsset{only axis on top/.style={axis on top=false, after end axis/.code={              \pgfplotsset{axis line style=opaque, ticklabel style=opaque, tick style=opaque,                           grid=none}\pgfplotsdrawaxis}}}  \newcommand{\drawge}{-- (rel axis cs:1,0) -- (rel axis cs:1,1) -- (rel axis cs:0,1) \closedcycle} \newcommand{\drawle}{-- (rel axis cs:1,1) -- (rel axis cs:1,0) -- (rel axis cs:0,0) \closedcycle}  \begin{document} \begin{figure}[ht] \centering \begin{tikzpicture} \begin{axis}[axis line style=thin, axis x line=center, axis y line=center, ymin=-7, ymax=7, xmin=-7, xmax=7, xlabel=\(x\), ylabel=\(y\), grid=minor] \addplot[name path global=line1, pattern=north west lines, color=blue!50, thick, domain=-7:7]{3*x-5}; \addplot[name path global=line2, pattern=north west lines, color=blue!50, thick, domain=-7:7]{6-2*x}; \addplot [draw=none, pattern=northeast lines, pattern color=blue!40, domain=-7:7]{3*x-5} \drawle; \addplot [draw=none, pattern=northeast lines, pattern color=blue!40, domain=-7:7]{6-2*x} \drawge; \end{axis} \end{tikzpicture} \end{figure}   \end{document}   which looks like    I want it to look like   , where the graph is filled only where all the inequalities hold true. NOTE the two graphs are entirely different problems. I only want the style, not the question.  However, the code for the latter image uses intersections:  \begin{figure}[ht] \centering \begin{tikzpicture}     \begin{axis}[axis line style=thin,     axis x line=center,     axis y line=center,     ymin=-6, ymax=7, xmin=-6, xmax=11, xlabel=\(x\), ylabel=\(y\), grid=minor]     \addplot[name path global=line1, color=blue!50, thick, domain=-5:10]{5/3-x/3};     \addplot[name path global=line2, color=blue!50, thick, domain=-5:10]{x/5-10/7};     \addplot[name path global=line3, color=blue!50, thick, domain=-5:10]{6*x+10};     \fill[name intersections={of=line1 and line2,by=point1}, name intersections={of=line1 and line3,by=point2}, name intersections={of=line2 and line3,by=point3}][very thick, pattern=northeast lines, draw=blue!60, pattern color=blue!30!cyan](point1)--(point2)--(point3)--(point1);     \end{axis} \end{tikzpicture} \end{figure}   The first image has only one intersecting point, hence I cannot use this method. I also don't want other areas shaded- only the final areas where the lines intersect. Is there a way around it without to find the points in which the lines intersect the border of the grid, meaning I have to manually compute the points?  EDIT: added the inequalities for the graph.
59834
I've just started to play with pgfplot. I'm trying to prepare a plot like to following   \begin{figure}[h] \centering \begin{tikzpicture} \begin{axis}[minor tick num=1,  axis x line=middle, axis y line=middle, xlabel=$k$, ylabel=$\omega$, ymin=0,xmin=-2,ymax=60] \addplot[blue,domain=0:5, line width=1.5pt] {x^2+25}; \addplot[orange,domain=0:5,line width=1pt]{3*x+22.75}; \addplot[cyan,domain=0:1.5, line width=1pt,dashed]{18.166*x}; \node[coordinate,pin=right:{$v_{\phi}=\frac{\omega}{k}$}]     at (axis cs:1,17) {}; \node[coordinate,pin=right:{$v_{g}=\frac{d\omega}{dk}$}]     at (axis cs:2.5,30) {}; \node[coordinate,pin=left:{dispersion relation}]     at (axis cs:4.5,47) {}; \end{axis} \end{tikzpicture} \caption{Wave dispersion relation with phase and group velocity} \label{fig:2} \end{figure}   What I would like to do is dropping the x-y tick labels so that we just maintaing the x-y title. How can I obtain it?
81189
Assuming I have the graph of a function $f(x)$ is there function $f_1(f(x))$ that will give me a rotated version of the graph of that function?  For example if I plot $\sin(x)$ I will get a sine wave which straddles the $x$-axis, can I apply a function to $\sin(x)$ to yield a wave that straddles the line that would result from $y = 2x$?
122806
I am trying to plot the function 1/x^2 but the result is obviously wrong, here is how it looks like    here is the code  \begin{center}      \begin{tikzpicture}      \begin{axis}[      %xlabel=$x$,     %ylabel={$f(x) = x^2 - x +4$}   ]      \addplot[blue] {1/(x^2)};     \end{axis}     \end{tikzpicture} \end{center}   Any suggestions on how to fix this?
22759
I once already asked a very similar question; . But this is some what different.  I have the following code;  \documentclass{standalone} \usepackage{graphics} \usepackage{tikz,pgfplots} \pgfplotsset{compat=1.6} \begin{document} \begin{tikzpicture}  \begin{axis}[% width=3cm, height=3cm, scale only axis, every x tick label/.append style={font=\scriptsize\color{gray!80!black}}, xmin=0, xmax=20000, xlabel={$t$}, xmajorgrids, xminorgrids, every y tick label/.append style={font=\scriptsize\color{gray!80!black}}, ymin=0.0004, ymax=0.0012, ylabel={$\phi_{\mathrm{i}}(t)$}, ymajorgrids, yminorgrids, name=plot1]  \end{axis}  \begin{axis}[% width=3cm, height=3cm, scale only axis, every x tick label/.append style={font=\scriptsize\color{gray!80!black}}, xmin=0, xmax=20000, xlabel={$t$}, xmajorgrids, xminorgrids, every y tick label/.append style={font=\scriptsize\color{gray!80!black}}, ymin=0.2, ymax=1.2, ylabel={$h(t)$}, ymajorgrids, yminorgrids, name=plot2, at=(plot1.right of north east), anchor=left of north west]  \end{axis}  \begin{axis}[% width=3cm, height=3cm, scale only axis, every x tick label/.append style={font=\scriptsize\color{gray!80!black}}, xmin=0, xmax=20000, xlabel={$t$}, xmajorgrids, xminorgrids, every y tick label/.append style={font=\scriptsize\color{gray!80!black}}, ymin=0.0004, ymax=0.0012, ylabel={$\phi_{\mathrm{o}}(t)$}, ymajorgrids, yminorgrids, name=plot4, at=(plot1.below south west), anchor=above north west]  \end{axis}  \begin{axis}[% width=3cm, height=3cm, scale only axis, every x tick label/.append style={font=\scriptsize\color{gray!80!black}}, xmin=0, xmax=20000, xlabel={$t$}, xmajorgrids, xminorgrids, every y tick label/.append style={font=\scriptsize\color{gray!80!black}}, ymin=2000, ymax=12000, ylabel={$p_{\mathrm{i}}(t)$}, ymajorgrids, yminorgrids, name=plot5, at=(plot4.right of north east), anchor=left of north west]  \end{axis}  \end{tikzpicture} \end{document}   This creates the following plot:    I think there is to few vertical/horizontal spacing between the plots. I want to increase this. Currently I use x- yshift, this gives the following result:  \documentclass{standalone} \usepackage{graphics} \usepackage{tikz,pgfplots} \pgfplotsset{compat=1.6} \begin{document} \begin{tikzpicture}  \begin{axis}[% width=3cm, height=3cm, scale only axis, every x tick label/.append style={font=\scriptsize\color{gray!80!black}}, xmin=0, xmax=20000, xlabel={$t$}, xmajorgrids, xminorgrids, every y tick label/.append style={font=\scriptsize\color{gray!80!black}}, ymin=0.0004, ymax=0.0012, ylabel={$\phi_{\mathrm{i}}(t)$}, ymajorgrids, yminorgrids, name=plot1]  \end{axis}  \begin{axis}[% xshift=1cm, width=3cm, height=3cm, scale only axis, every x tick label/.append style={font=\scriptsize\color{gray!80!black}}, xmin=0, xmax=20000, xlabel={$t$}, xmajorgrids, xminorgrids, every y tick label/.append style={font=\scriptsize\color{gray!80!black}}, ymin=0.2, ymax=1.2, ylabel={$h(t)$}, ymajorgrids, yminorgrids, name=plot2, at=(plot1.right of north east), anchor=left of north west]  \end{axis}  \begin{axis}[% yshift=-1cm, width=3cm, height=3cm, scale only axis, every x tick label/.append style={font=\scriptsize\color{gray!80!black}}, xmin=0, xmax=20000, xlabel={$t$}, xmajorgrids, xminorgrids, every y tick label/.append style={font=\scriptsize\color{gray!80!black}}, ymin=0.0004, ymax=0.0012, ylabel={$\phi_{\mathrm{o}}(t)$}, ymajorgrids, yminorgrids, name=plot4, at=(plot1.below south west), anchor=above north west]  \end{axis}  \begin{axis}[% xshift=1cm, width=3cm, height=3cm, scale only axis, every x tick label/.append style={font=\scriptsize\color{gray!80!black}}, xmin=0, xmax=20000, xlabel={$t$}, xmajorgrids, xminorgrids, every y tick label/.append style={font=\scriptsize\color{gray!80!black}}, ymin=2000, ymax=12000, ylabel={$p_{\mathrm{i}}(t)$}, ymajorgrids, yminorgrids, name=plot5, at=(plot4.right of north east), anchor=left of north west]  \end{axis}  \end{tikzpicture} \end{document}     I want to know if there is a more consistent manner to do this.
63994
I am trying to locate the vertices of a rectangle and to color the rectangular region.  I specify the y-coordinate as a function value, like \sqrt{3}/2 or \sin(60).  I am getting an error.  \documentclass{amsart} \usepackage{tikz} \usetikzlibrary{calc}   \begin{document} \begin{tikzpicture}  \coordinate (A) at (-1,{-\sqrt{3}/2}); \coordinate (B) at (-1,{\sin(60)}); \coordinate (C) at (2,{\sin(60)); \coordinate (D) at (2,{-\sqrt{3}/2});  \path[fill=yellow] (A) -- (B) -- (C) -- (D) -- cycle;  \node[outer sep=0pt,circle, fill,inner sep=1.5pt,label={[fill=white]below left:$A$}] at (A) {}; \node[outer sep=0pt,circle, fill,inner sep=1.5pt,label={[fill=white]above left:$B$}] at (B) {}; \node[outer sep=0pt,circle, fill,inner sep=1.5pt,label={[fill=white]above right:$C$}] at (C) {}; \node[outer sep=0pt,circle, fill,inner sep=1.5pt,label={[fill=white]below right:$D$}] at (D) {}; \end{tikzpicture}
48015
I would like to plot these four equations :   $$y=\dfrac{3}{2x+1}, y=3x-2, x=2   y=0$$   and i don't know how to draw vertical line of equation x=2 and  shade a region like the picture below      \documentclass{article} \usepackage{pgfplots} \usepackage{pst-plot} \usepackage{pstricks}  \begin{document}  \begin{table}[h] \centering     \begin{tikzpicture}         \begin{axis}[              extra y ticks       = 2,       extra y tick labels = z,       extra y tick style  = { grid = major },              axis lines=middle,              grid=major,               xmin=-1,                 xmax=3,         ymin=-1,         ymax=3,         xlabel=$x$,         ylabel=$y$,                 xtick={-1,-0.5,0,...,3},         ytick={-1,-0.5,0,...,3},         legend style={at={(axis cs:-.5,0,1)}, anchor=north west,width=90cm, draw=none,opacity=.9, inner sep=2pt,fill=gray!10}]             %\addlegendentry{$f(x)=2^{x}$}             %\addlegendentry{$f(x)={\left(\dfrac{1}{2}\right)}^x$}             smooth,                 enlargelimits=false,         axis line style={latex-latex},  \addplot[thick, samples=100, domain=0:6,blue] {3/(2*x+1)}; %node[right] {$f(x)=2^{x}$}; \addplot[thick, samples=50, smooth,domain=0:6,olive] {3*x-2}; % node[right]{$f(x)={\dfrac{1}{2}}^x$};     \end{axis} \end{tikzpicture} \end{table}  \end{document}   which produces :
83045
Help me to plot the following plot using Hobby.   I have tried to plot it. My code is  \begin{tikzpicture}[use Hobby shortcut]  \draw (-.3 ,1).. (0, 0) .. ( 1.2 , 0 ) .. ( 0 , 0 ) .. (-.3 ,-1);  \draw (.45, 0) .. ( .9 , 0 ) .. ( .6 , 0 ) .. ( .7 , -0.01); \draw  (-.15, 1.2).. (-.01, .2) ..(.01, .22).. (.6, .1) .. ( 1.3 , 0 ) .. ( 0 , -.1 ) .. (-.3 ,-1.2); \node[inner sep=1pt,circle,fill=black] at  ( .7 , -0.01) {}; \end{tikzpicture}   Please correct my code to get the desired fig. Also I want to write HL adjacent to the Fig.
107917
The following code I got from:     \documentclass{article}   \usepackage{pgfplots}  \usetikzlibrary{patterns}  \makeatletter \newcommand{\pgfplotsdrawaxis}{\pgfplots@draw@axis} \makeatother \pgfplotsset{only axis on top/.style={axis on top=false, after end axis/.code={              \pgfplotsset{axis line style=opaque, ticklabel style=opaque, tick style=opaque,                           grid=none}\pgfplotsdrawaxis}}}  \newcommand{\drawge}{-- (rel axis cs:1,0) -- (rel axis cs:1,1) -- (rel axis cs:0,1) \closedcycle} \newcommand{\drawle}{-- (rel axis cs:1,1) -- (rel axis cs:1,0) -- (rel axis cs:0,0) \closedcycle}  \begin{document}    \begin{figure}[htpb]      \centering      \label{fig:p3:c1}      \begin{tikzpicture}        \begin{axis}[only axis on top,         axis line style=very thick,          axis x line=middle,          axis y line=middle,           ymin=-1,ymax=5.99,xmin=-1,xmax=5.99,           xlabel=$x$, ylabel=$y$,grid=major        ]          \addplot [draw=none, pattern=north west lines, pattern color=blue!40, domain=-10:12]                  {3-3/2*x} \drawge;         \addplot[very thick, domain=-1:2.5,&lt;-&gt;] {3-3/2*x};        \end{axis}      \end{tikzpicture}      \caption{Problem 4, Part A}    \end{figure}   \end{document}   The question here is how can I get it to work with a setting like the following:    \documentclass[dvipsnames]{article} \usepackage{amsmath,pgfplots,tikz} \usetikzlibrary{arrows,calc} \begin{document}      \begin{tikzpicture}[transform shape,scale=0.6]     \draw[step=1cm,gray,very thin] (-4,-3) grid (4,5);     \draw [-latex,thick](-4,0) -- (4,0) node[right] {$x$} coordinate(x axis);     \foreach \x in {-3,-2,-1,1,2,3}              \draw (\x,0.1) -- (\x,-0.1) node [fill=white,below] {$\x$};     \foreach \y in {-2,-1,1,2,3,4}              \draw (0.1,\y) -- (-0.1,\y) node [fill=white,left] {$\y$};     \draw [-latex,thick](0,-3) -- (0,5) node[above] {$y$} coordinate(y axis);     \node at (-0.25,-0.3375) {0};     \draw[color=Cerulean,latex-latex,domain=-1.3:4] plot (\x,-3/2*\x+3);     \filldraw[OrangeRed] (0,3) circle (1.5pt) node[inner sep=2pt,right,fill=white,shift={(0.25,0)}] {$(0,3)$};     \filldraw[OrangeRed] (2,0) circle (1.5pt) node[inner sep=2pt,right,fill=white,shift={(0.25,0.35)}] {$(2,0)$};     \end{tikzpicture} \end{document}   That is, I would like to represent the solution set of the inequality in a similar manner as is done using pgfplots in my last example above. Is this possible?
113979
How to achieve this kind of axis with pgfplot ? Image taken from Szymon Beczkowski's awesome PhD thesis design ()    I may provide you with some data to play with.  \documentclass{standalone} \usepackage{pgfplots}  \begin{document} \begin{tikzpicture} \begin{axis}[xlabel={$L$ [H]},ylabel={$\hat{I}_{DM}$ [A]},axis lines*=left,grid,xtick=data]   \addplot coordinates {(948e-6,1.61981) (1.5e-3,1.02377) (2e-3,0.769047) (2.5e-3,0.614994) (3e-3,0.503511)}; \end{axis} \end{tikzpicture} \end{document}
95916
I am trying to plot the elliptic curve secp256k1 y^2=x^3+7 in my latex-document.  \begin{center} \begin{tikzpicture}[domain=-4:4, samples at ={-1.769292354238631, -1.76, -1.74, ..., 2.26, 2.35, 2.7, 2.9}]     \draw[-&gt;] (-2.2,0) -- (3.2,0) node[right] {$x$};     \draw[-&gt;] (0,-2.2) -- (0,4.2) node[above] {$y$};     \draw[-&gt;, color=red] plot (\x,{sqrt(\x^3+7)}) node[right] {$y^2=x^3-2x+2$};     \draw[-&gt;, color=red] plot (\x,{-sqrt(\x^3+7)}) node[right] {} \end{tikzpicture} \end{center}   but this gives me a curve that is interrupted at the left. And to be honest, I don't really know what all of these comments mean.  I would be happy if someone could help me, or has a good tutorial that explains how the plotting in Latex works!  Thanks in advance! And all the best.
21350
When I found that a simple x^(1.0/3.0) does not yield a graph in PGFplots for negative values of x, I attempted to define my own function for CubeRoot using pgfmathdeclarefunction as below. But, am not able to get them to work.    These are based on , and .   This compiles as is, but has a problem if I set \DomainMin to a negative value. The CubeRootB function does not even compile, and I do not see what the problem with it is.  \documentclass{article} \usepackage{tikz}  \newcommand*{\DomainMin}{0.1} %\newcommand*{\DomainMin}{-2.0} % CubeRootA gives and error if DomainMin &lt; 0  \tikzstyle{MyPlotStyle}=[domain=\DomainMin:2,samples=100,smooth]  \pgfmathdeclarefunction{gauss}{3}{% From links mentioned in the question     \pgfmathparse{1/(#3*sqrt(2*pi))*exp(-((#1-#2)^2)/(2*#3^2))}% }  \pgfmathdeclarefunction{CubeRootA}{1}{%     \pgfmathparse{%         ifthenelse(equal(#1,abs(#1)),%             (#1)^(1.0/3.0),%            #1 &gt;= 0             -1.0*((abs(#1))^(1.0/3.0))% #1 is negative         )%     }% }  \pgfmathdeclarefunction{CubeRootB}{1}{%     \pgfmathparse{%         \pgfmathifthenelse             {\pgfmathequal{#1}{\pgfmathabs{#1}}}%             {exp(ln(#1)/3.0)}%            #1 &gt;= 0             {-1.0*(exp(ln(abs(#1))/3.0))}% #1 is negative     }%      }  % Modified version of CubeRootB per Caramdir's suggestion \pgfmathdeclarefunction{CubeRootC}{1}{%         \pgfmathparse{%             ifthenelse(                 equal(#1,abs(#1)),%                 exp(ln(#1)/3.0),%            #1 &gt;= 0                 -1.0*(exp(ln(abs(#1))/3.0))% #1 is negative             )         }%     }      \begin{document} \begin{tikzpicture} \draw [help lines] (-2,-2) grid [step=0.5] (2,2); \draw plot [MyPlotStyle] (\x,{gauss(\x,0,0.5)}); % \draw plot [MyPlotStyle] (\x,{    CubeRootA(\x)});% Error if DomainMin &lt; 0 %\draw plot [MyPlotStyle] (\x,{1.0+CubeRootB(\x)});% Does not compile \draw plot [MyPlotStyle] (\x,{    CubeRootC(\x)});% Error if DomainMin &lt; 0 \end{tikzpicture} \end{document}