# Graphing sqrt function: not coming out properly

I have been looking at other posts and have modified my code accordingly, but I still can't get it to work. I think there is an issue that has not been addressed in any of the posts that I have found. However, I don't know what the issue is, so I can't make a specific inquiry.

  \begin{tikzpicture}
\begin{axis}[xmax = 4,ymax = 3,samples = 50]
\draw[black, smooth, variable=\x] plot (\x,{sqrt(1 - 4(x - \frac{1}{2})^2});
\end{axis}
\end{tikzpicture}

• Welcome to TeX.SE! If you go this way, the x must be a \x, i.e. \draw[black, smooth, variable=\x] plot (\x,{sqrt(1 - 4*(\x - 1/2)^2});, and you may want to add an appropriate domain. However, since you seem to use pgfplots, use \addplot {sqrt(1-4*(x-1/2)^2)};. – user121799 Nov 7 '18 at 18:28
• Thanks, marmot! Are you referring to the the x within the square root function? – Rafael Vergnaud Nov 7 '18 at 18:29
• I see. May you clarify what you mean by appropriate domain? – Rafael Vergnaud Nov 7 '18 at 18:30
• The build is saying the following: You can an axis with empty range (in the y direction) – Rafael Vergnaud Nov 7 '18 at 18:31
• I have to say, it doesn't come out very nicely. Would you help me make a graph (sorry to be pestering, haha)? – Rafael Vergnaud Nov 7 '18 at 18:33

OK, this is too long for a comment. There are several issues:

• You say variable=\x but one x does not have a backslash.
• You need to add multiplication signs.
• You cannot use \frac in an expression that is going to be parsed. \frac is used to typeset fractions.

Altogether, the expression should be (I guess) {sqrt(1 - 4*(x - 1/2)^2}. However, as you are using an axis environment, I think you are loading pgfplots, so I'd suggest

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmax = 4,ymax = 3,samples = 50]
\addplot[black, smooth,domain=0:1] {sqrt(1 - 4*(x - 1/2)^2};
\end{axis}
\end{tikzpicture}
\end{document} • Thank you very much marmot! I appreciate your help. :) – Rafael Vergnaud Nov 7 '18 at 18:40
• My very last question, which should be brief to answer, is how do I move the plot from the left margin of the pdf to the center of pdf? – Rafael Vergnaud Nov 7 '18 at 18:41
• @RafaelVergnaud This is due to xmax = 4,ymax = 3,. If you drop these, the plot is centered, and also if you make xmin and so on symmetric around the center. – user121799 Nov 7 '18 at 18:46
• Hey marmot! I mean on the pdf document. I did switch ymax to 4! Adding xmin did not center the plot of the pdf! It is still on the left hand margin of the pdf. If it's a hassle, I'll just leave it. It's no big deal! – Rafael Vergnaud Nov 7 '18 at 18:50
• @RafaelVergnaud The above document is standalone, so I thought you want to center the curve. If you want to center the plot in a figure in an article document, say, you could use \centering. – user121799 Nov 7 '18 at 19:06
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmax=10,ymax=10, samples=1000]

I would suggest to do something like this 