# Coordinate component calculation using tikz

I have the following defined in my latex file:

\begin{tikzpicture}[background rectangle/.style={fill=black}, show background rectangle]
\draw[step=1, transparent] (-1, -1) grid (3, 3);
\draw[ultra thick, ->] (-1, 0) -- (3, 0);
\draw[ultra thick, ->] (0, -1) -- (0, 3);

\draw[] (2.8, -0.2) node[below] {\textbf{$x$}};
\draw[] (-0.2, 2.8) node[left] {\textbf{$y$}};

\draw[scale=1, domain=-1:sqrt(3), smooth, variable=\x, thick] plot ({\x}, {\x*\x});

\fill[white] (1, 1) circle (2pt);
\end{tikzpicture}


I want to know how I can create a node on (3, sqrt(3)).

I have tried the following:

\node[] at (3, sqrt(3)) {A};


However, it does not seem to be working when compiling my code.

• Welcome to TeX.SX! You need to put calculated coordinates into curly brackets. Hence, \node at (3, {sqrt(3)}) {A}; should work. – Jasper Habicht Mar 2 at 17:49
• May be you are not seing the fact that the "reversed function" needs reversed variables too like \node at ({sqrt(3)},3) {A} – koleygr Mar 2 at 17:51
• @koleygr the function is not reversed or anything. I only wish to know how to compute the number inside the coordinates. – Octonions Mar 2 at 18:08
• @JasperHabicht thanks for the comment! I got it working by using {sqrt(3)}. My only concern is about why it works on domain=-1:sqrt(3) now. – Octonions Mar 2 at 18:12

As answered in comments, the correct way to write the coordinate is

(3, {sqrt(3)})


with braces. The reason is that when parsing coordinates TeX is looking for a comma and a closing parenthesis, so when it sees

(3, sqrt(3))


it gets confused by the parenthesis after 3 and it fails the parsing. You have to "hide" the parenthesis that is not part of the coordinate syntax in braces. (The same will happen for commas).

So you can have (1, 3+3) but not (1, add(3,3)) --- you need braces in the second case.

When you are parsing domain=-1:sqrt(3)  that doesn't happen — TikZ is looking for a number after the colon, delimited by a comma or the end of the list of options (]). If you need to put a comma or a ] into a parameter there, you'll need a set of braces.

• That is amazing! Thank you so much for the clean answer. I have marked yours as the solution. Thanks to @JasperHabicht as well! – Octonions Mar 2 at 20:43