I cannot found my error. I tried to draw a function, but Latex makes an error. Here the code:
\documentclass[a4paper,11pt]{article}
\usepackage{tikz, tkz-euclide}
\usetikzlibrary{calc,intersections,through,backgrounds,through, shapes, decorations}
\usetkzobj{all}
\usepackage{calc}
\begin{document}
\begin{tikzpicture}[xscale=1, yscale=1]
\fill[very thin, gray!40, domain=0:2, variable=\x] (0,0) -- (0,4.6667) -- plot (\x,{-1*\x + 4.6667}) -- (4.6667,0) -- cycle ;
\draw[very thick, black, domain=-2:5,smooth,samples=100,variable=\x] plot ( \x , {1/3*(\x^3) - 2*(\x^2) + 3*(\x) + 2}) ;
\draw[very thick, black, dashed, domain=-1:5.52,smooth,samples=100,variable=\x] plot ( \x , {-1*\x + 4.6667}) node[anchor=north] {$k$};
\draw[very thick,red] (-2,0) -- (5,0) node[anchor=west] {x};
\draw[very thick,red] (0,-1) -- (0,6) node[anchor=south] {y};
\end{tikzpicture}
\end{document}
This gives this picture:
But it should be:
What went wrong? (Not the extra line and the rectangle, but the extra curve on the negative side)



(\x)^3and(\x)^2. – esdd Jun 20 '17 at 17:57