2

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} 
4
  • 4
    You need the syntax \addplot {x^2-7x+10}; for pgfplots. And you need a function not an equation.
    – percusse
    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
    – Sigur
    Feb 3, 2015 at 12:14
  • 4
    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

1 Answer 1

7

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,
]
\addplot {x^2-7*x+10} ;
\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: rr

Not the answer you're looking for? Browse other questions tagged or ask your own question.