Can't make parabola without including the tip

Easiest solution is to draw two parabolas, one upside down, and clip them both to just show the parts above your line:

\documentclass[border=3.14,tikz]{standalone}

\begin{document}
\begin{tikzpicture}
    \draw (-5,0)--(5,0);
    \begin{scope}
      \clip (-5,0) rectangle (5,6);
      \draw (-4,6) parabola bend (0,-2) (4,6);
      \draw (-4,-6) parabola bend (0,2) (4,-6);
    \end{scope}
\end{tikzpicture}
\end{document}

enter image description here


Another simple solution is use the plot function and define parabola accordingly:

\documentclass[tikz,border=3mm]{standalone}

\begin{document}
    \begin{tikzpicture}
\draw (-5,0)--(5,0);
\draw[semithick, red] plot [domain=-2:2] (2*\x,{abs(\x*\x-1)});
    \end{tikzpicture}
\end{document}

enter image description here

Edit: Or with declaring function in tikzpicture option and use 200 samples instead of default number (30, if I remember correctly):

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
    \begin{tikzpicture}[
declare function = {f(\x)={abs(\x*\x-1)};}
                        ]
\draw (-5,0) -- (5,0);
\draw[semithick, red] plot [domain=-2:2, samples=200] (2*\x,{f(\x)});
    \end{tikzpicture}
\end{document}

enter image description here


This is really just for fun. You can make TikZ reflect the parabola (or anything you draw) at the x axis (say) automatically. This can be done by installing a nonlinear transformation, which is in this case particularly simple.

\documentclass[tikz,border=3mm]{standalone}
\usepgfmodule{nonlineartransformations}
\makeatletter
\def\yreflect{%
    \pgfmathsetmacro{\myy}{abs(\pgf@y)}%
    \pgf@y=\myy pt}
\begin{document}
\begin{tikzpicture}
 \begin{scope}[transform shape nonlinear=true]
  \pgftransformnonlinear{\yreflect}
  \draw (-5,0)--(5,0);
  \draw (-4,6) parabola bend (0,-2) (4,6);
 \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

As one can see, there are small gaps, so the solution is not as perfect as Skillmon's solution.

Tags:

Tikz Pgf