# Pgf plot square not positive

I am using pgfplot to draw a node and a cusp but it seems to be that the squares \x^2 are returning negative numbers to the coordinates. This is strange. I was using the same code before and getting the right pictures. Now I moved to Windows 8 and MikTeX 2.9 and the problem appeared. The result is that the cusp is looking smooth like a cubic parabola and the node doesn't self-intersect.

The code is

 \documentclass{beamer}
\usepackage{amsmath,amssymb,stmaryrd}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{pgfpages}
\usepackage[ansinew]{inputenc}
\usepackage{lmodern}
\usepackage{mathtools}
\usepackage{pgfplots}
\usepackage{textcomp}
\usepackage{microtype}

\begin{document}
\begin{frame}{Definition of Simple Normal Crossings}
\begin{center}
\begin{tikzpicture}
\draw[thick,domain= -1.2:1.2] plot (\x^2,\x^3);
\draw[thick,domain=-1.4:1.4] plot (\x^2+4,\x^3-\x);
\end{tikzpicture}
\end{center}
\end{frame}

\end{document}


There is a solution using the code

\documentclass{beamer}
\usepackage{amsmath,amssymb,stmaryrd}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{pgfpages}
\usepackage[ansinew]{inputenc}
\usepackage{lmodern}
\usepackage{mathtools}
\usepackage{pgfplots}
\usepackage{textcomp}
\usepackage{microtype}

\begin{document}
\begin{frame}{Definition of Simple Normal Crossings}
\begin{center}
\begin{tikzpicture}
\draw[thick,domain=0:1.2] plot (\x^2,\x^3);
\draw[thick,domain=0:1.2] plot (\x^2,-\x^3);
\draw[thick,domain=0:1.4] plot (\x^2+4,\x^3-\x);
\draw[thick,domain=0:1.4] plot (\x^2+4,-\x^3+\x);
\end{tikzpicture}
\end{center}
\end{frame}

\end{document}


This give the right image.

But there should be an explanation of what is wrong in the first.

-

I don't know if this is what you are looking for, but seems that the system doesn't understand \x^2. If you write (\x)^2 instead it works (at least for me). The code will be

\begin{frame}{Definition of Simple Normal Crossings}
\begin{center}
\begin{tikzpicture}
\draw[thick, domain = -1.2:1.2] plot ({(\x)^2},{\x^3});
\draw[thick, domain = -1.4:1.4] plot ({(\x)^2 + 4},{\x^3 - \x});
\end{tikzpicture}
\end{center}
\end{frame}


Remember you have to put { and } because if not it gives you errors. I hope it helps.

A basic explanation is that it's different i.e. \x^2 =! -1^2 = -1 (because the system substitutes the \x by an -1) than (\x)^2 =! (-1)^2 = 1. I think that's the reason.

-
That was the problem. Maybe some changes from MikTex 2.8 to 2.9 made that happen. Before I was not having that problem. I tried the brackets but forgot about the braces thing. Thanks. – Mlazhinka Shung Gronzalez LeWy Nov 11 '12 at 15:39
There was a bug in pgf which lead to -2^2 = 4 (which is clearly wrong, although it allowed to write \x^2). That bug has been fixed, but the plot expression input has not been improved since. – Christian Feuersänger Nov 11 '12 at 18:59