# How does one draw a cylindrical shell in TikZ?

I am trying to illustrate the disk and shell methods for computing the volume of solids of revolution. I was able to use the following code to create a typical approximating disk when the revolution is about the x-axis. I am stuck on how to create a typical approximating shell when the same region is revolved about the y-axis. How might I achieve this?

\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=1,>=latex,x=1.5cm,y=0.8cm]
\fill[fill=green,opacity=0.5] (1,0) -- plot[domain=1:4] (\x,{sqrt(2*(\x)+1))}) -- (4,0);
\fill[fill=green,opacity=0.5] (1,0) -- plot[domain=1:4] (\x,{-sqrt(2*(\x)+1))}) -- (4,0);
\draw[-,thick,domain=-.2:4.5,samples=100] plot (\x,{sqrt(2*(\x)+1))}) node[right] {\footnotesize $y=f(x)$};
\draw[-,thick,domain=-.2:4.5,samples=100] plot (\x,{-sqrt(2*(\x)+1))});
\fill[red!40] (2.3,-2.449489743) rectangle (2.7,2.449489743);
\draw (2.3,2.449489743) -- (2.7,2.449489743);
\draw (2.3,-2.449489743) -- (2.7,-2.449489743);
\draw[<->] (2.3,-2.6) -- (2.7,-2.6) node[below, midway] {\footnotesize $\Delta x$};
\draw[<->] (2.9,0) -- (2.9,2.449489743) node[right, midway]  {\footnotesize $R$};
\draw[->,thick] (-1,0) -- (5,0) node[above] {\footnotesize $x$};
\draw[->,thick] (0,-5) -- (0,5) node[below right]{\footnotesize $y$};
\draw[-] (1,3pt) -- (1,-3pt) node[below] {\footnotesize $a$};
\draw[-] (4,3pt) -- (4,-3pt) node[below] {\footnotesize $b$};
\end{tikzpicture}
\end{document}

• I'm not an expert to understand how it should look like. It would be helpful, if you could add an example picture for Illustration. – Harald Lichtenstein Sep 8 '17 at 8:48
• This link shows examples:tutorial.math.lamar.edu/Classes/CalcI/VolumeWithCylinder.aspx – DJJerome Sep 9 '17 at 11:36
• The pgfplots manual on CTAN shows following example, which may be starting point for 3D graphics: % Preamble: \pgfplotsset{width=7cm,compat=1.15} 1 −0.5 0 0.5 \begin{tikzpicture} \begin{axis}[view={60}{30}] \addplot3 [ surf,shader=flat, samples=20, domain=-1:0,y domain=0:2*pi, z buffer=sort, ] ( {sqrt(1-x^2) * cos(deg(y))}, {sqrt(1-x^2) * sin(deg(y))}, x ); \end{axis} \end{tikzpicture} – Harald Lichtenstein Sep 9 '17 at 16:02
• @DJJerome So my answer was not what you were looking for? – Cragfelt Dec 17 '17 at 3:03
• @Cragfelt see figure 3 in this document: stewartcalculus.com/data/CALCULUS%20Concepts%20and%20Contexts/… – DJJerome Dec 28 '17 at 22:13

Practically you need to switch all the coordinates and domains, and make some other minor changes. Also obtaining the function in terms of x algebraically.

This is the output according to your code, where revolution is about the x-axis

and this is output after changes, regarding revolution around y-axis.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}

\begin{document}
\begin{tikzpicture}[%
scale=1,
>=latex,
x=0.8cm,
y=1.5cm,
]
\fill[fill=green, opacity=0.5] (-3,4) -- plot[domain=-3:3](\x,{0.5*(\x*\x-1)}) -- (3,4);
\fill[fill=white] (-1.732050808,1) -- plot[domain=-1.732050808:1.732050808] (\x,{0.5*(\x*\x-1)}) -- (1.732050808,1);

\draw[-,thick, domain=-3.2:3.2, samples=100] plot (\x,{0.5*(\x*\x-1)}) node[right] {\footnotesize $y=f(x)$};
\fill[red!60] (-2.449489743,2.3) rectangle (2.449489743,2.7);
\draw (2.449489743,2.3) -- (2.449489743,2.7);
\draw (-2.449489743,2.3) -- (-2.449489743,2.7);
\draw[<->] (-2.6,2.3) -- (-2.6,2.7) node[left, midway] {\footnotesize $\Delta x$};
\draw[<->] (0,2.9) -- (2.449489743,2.9) node[above, midway]  {\footnotesize $R$};
\draw[->, thick] (-5,0) -- (5,0) node[above] {\footnotesize $x$};
\draw[->, thick] (0,-1) -- (0,5) node[below right]{\footnotesize $y$};
\draw[-] (-3pt,1) -- (3pt,1) node[right] {\footnotesize $a$};
\draw[-] (-3pt,4) -- (3pt,4) node[right] {\footnotesize $b$};
\end{tikzpicture}
\end{document}


UPDATE

According to your feedback in comments, I could figured out how to replicate a shell as the document provided, and made respective changes to the original drawing. Maybe now it meets your specs.

This is the code

\documentclass[border=4mm,tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}

\begin{document}
\footnotesize

\begin{tikzpicture}[%
scale=1,
>=stealth,
x=0.8cm,
y=1.5cm,
]
\tikzset{cyl/.style = {thick,color=red!60}}
\tikzset{ellip/.style = {gray!80, shading=axis, top color=gray!80, right color=gray!20, thick}}

%\fill[fill=green, opacity=0.4] (-3,4) -- plot[domain=-3:3](\x,{0.5*(\x*\x-1)}) -- (3,4);
%\fill[fill=white] (-1.732050808,1) -- plot[domain=-1.732050808:1.732050808] (\x,{0.5*(\x*\x-1)}) -- (1.732050808,1);

% Parabola
\draw[-, blue, thick, domain=-3.2:3.2, samples=100] plot (\x,{0.5*(\x*\x-1)}) node[right] {$y=f(x)$};

% Ellipses & Cyllinder
\draw[dashed] (2.449489743,0) -- (2.449489743,2.7);
\draw[dashed] (2.25,0) -- (2.25,2.7);
\draw[cyl, opacity=0.7, dashed] (-2.25,2.3) -- (-2.25,2.7);
\draw[cyl] (2.449489743,2.3) -- (2.449489743,2.7);
\draw[cyl] (-2.449489743,2.3) -- (-2.449489743,2.7);

% Dimensions
\draw (-3pt,1) -- (3pt,1) node[right] {$a$};
\draw (-3pt,4) -- (3pt,4) node[right] {$b$};
\draw (-57.5pt,2.95) -- node[anchor=south] {$\overline{x}_i$} (-49pt,2.95);
\draw (-2.449489743,2.5) -- (-2.449489743,3);
\draw (-2.25,2.7) -- (-2.25,3);
\node at (2.25,0) [below right] {$x_i$};
\node at (2.449489743,0) [below left] {$x_{i-1}$};
\draw[<->, >=stealth] (-2.6,2.3) -- (-2.6,2.7) node[left, midway] {$\Delta y$};

% Axes
\draw[thick] (0,-1) -- (0,2.1);
\draw[thick, dashed] (0,2.1) -- (0,2.535);
\draw[->, thick] (0,2.535) -- (0,5) node[below right] {$y$};
\draw[->, thick] (-5,0) -- (5,0) node[above] {$x$};

\end{tikzpicture}
\end{document}