# How to plot a quadratic equation in TikZ? [closed]

I have the following quadratic formula: $x^2-7x+10=0$ and I am trying to plot the curve by using the following script without success:

\begin{tikzpicture}[baseline]
\begin{axis}[
axis y line=center,
axis x line=middle,
axis equal,
grid=both,
xmax=10,xmin=-10,
ymin=-10,ymax=10,
xlabel=$x$,ylabel=$y$,
xtick={-10,...,10},
ytick={-10,...,10},
width=15cm,
anchor=center,
]
\draw plot (x^2-7x+10=0) ;
\end{axis}
\end{tikzpicture}

• You need the syntax \addplot {x^2-7x+10}; for pgfplots. And you need a function not an equation. Feb 3, 2015 at 12:12
• Could you please have a look to TikZ/PGF: Simple function is not plotted. Where is the mistake? The problem looks similar. If that helps, we can consider to close this question as duplicate of the other. Feb 3, 2015 at 12:14
• @percusse 7*x. lol Feb 3, 2015 at 12:14
• I'm voting to close this question as off-topic because: You can not plot equations(only functions) - this is Math - not LaTeX. It is not relevant that the function is quadratic. Plotting with TikZ and PGFPlots has been covered in several other questions. Feb 12, 2015 at 21:34

Solution:

\documentclass{standalone}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}[baseline]
\begin{axis}[
axis y line=center,
axis x line=middle,
axis equal,
grid=both,
xmax=10,xmin=-10,
ymin=-10,ymax=10,
xlabel=$x$,ylabel=$y$,
xtick={-10,...,10},
ytick={-10,...,10},
width=15cm,
anchor=center,
]
\end{axis}
\end{tikzpicture}
\end{document}


NB:

• your equation x^2-7*x+10=0 corresponding to roots of the polynomial x^2-7*x+10 (two points in fact)
• I think you want to plot the polynomial x^2-7*x+10
• you must write any mathematical operators (^, *,...)
• use \addplot (using pgfplotspackage).
• use { and }.

Result: