[Tex/LaTex] Graphing y=x^2 and y=x

graphs

I want to draw the region bounded by y=x^2 and y=x. Any ideas? I was hoping this would be somewhat simple. I've tried used a similar, with \begin{axis}..\end{axis}, but it doesn't like that. Did I not declare a package or something?

Also, if I wanted to show the solid this region creates by rotating it about the x-axis, is there a way to did this in latex? (If you had cal 2, think volume of a solid rotated about …).

Best Answer

Like I said in the comments, plotting a function in 2D is relatively easy in pgfplots, and with the version 1.10 filling between is even easier.

Output

enter image description here

Code

\documentclass{article}
\usepackage{pgfplots}

\pgfplotsset{compat=1.10}
\usepgfplotslibrary{fillbetween}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    xmin=0, xmax=10,
    ymin=0, ymax=10
    ]

    \addplot [name path=plot1, ultra thin, domain=-10:10, samples=150]{x^2};
    \addplot [name path=plot2, ultra thin, domain=-8:8]{x};

    \addplot[red] fill between[of=plot1 and plot2, soft clip={domain=0:1}];

\end{axis}
\end{tikzpicture}
\end{document}