0

I'm presenting some basic functions to my students, one of them being square root. When using TikZ to represent it, I always see an annoying "break" between 0 and 1, on what should be a very smooth curve, despite using "smooth".

Here is my MWE, how can I have a proper rendering of the square root function?

Thanks!

Note: square and cube are perfectly smooth. At this stage, square root and cubic root are the 2 showing such an annoying "break".

\documentclass{report}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  \draw[->] (0,0) -- (10,0) node[right] {$x$};
  \draw[->] (0,0) -- (0,4) node[above] {$y$};
  \draw[domain=0:10, smooth, variable=\x, blue, line width=0.8pt] plot (\x,{sqrt(\x)});
\end{tikzpicture}

\end{document}

Red rectangle shows the problematic "break" on the curve

3
  • Can you add a screenshot? Don’t use smooth, increase the number of samples instaed.
    – MS-SPO
    Commented Jul 25 at 6:58
  • 1
    You will have graphical representation problems with any curve admitting a tangent parallel to the ordinate axis which cannot have an equation like y=...
    – gigiair
    Commented Jul 25 at 7:09
  • 1
    Consider using PGFPlots (it is build on top of TikZ) - there are a lot of examples on this site and in the manual. Commented Jul 25 at 7:56

1 Answer 1

2
\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[->] (0,0) -- (10,0) node[right] {$x$};
\draw[->] (0,0) -- (0,4) node[above] {$y$};
\draw[blue, line width=0.8pt] plot[domain=0:1, samples=100, smooth] (\x,{sqrt(\x)}) -- plot[domain=1:10, samples=50, smooth] (\x,{sqrt(\x)});
\end{tikzpicture}
\end{document}

Graph with parabola

Not the answer you're looking for? Browse other questions tagged .