<img src="https://d5nxst8fruw4z.cloudfront.net/atrk.gif?account=iA1Pi1a8Dy00ym" style="display:none" height="1" width="1" alt="" />
Skip Navigation

6.2: A Modeling Example: Counting Ping Pong Balls

Difficulty Level: At Grade Created by: CK-12

Suppose you have a cylinder of height \begin{align*}h\end{align*}h with base diameter \begin{align*}b\end{align*}b (perhaps an empty pretzel jar), and you wish to know how many ping-pong balls of diameter \begin{align*}d\end{align*}d have been placed inside the cylinder. How could you determine this? This problem, along with the strategy for computing the lower bound on the number of ping-pong balls, is adapted from Starfield (1994).

A lower bound for this problem is found as follows. Define the following variables:

  • \begin{align*}N_L-\end{align*}NLLower bound on the number of balls that fit into the cylinder.
  • \begin{align*}V_{cyl}-\end{align*}VcylThe volume of the cylinder.
  • \begin{align*}V_{cube}-\end{align*}VcubeThe volume of a cube that encloses a single ball.

\begin{align*}V_{cyl} & = h\pi(\tfrac{b}{2})^2 \\ V_{cube} & = d^3\end{align*}VcylVcube=hπ(b2)2=d3

The lower bound \begin{align*}N_L\end{align*}NL is found by dividing the volume of the cylinder by the volume of the cube enclosing a single ball:

\begin{align*}N_L = \tfrac{V_{cyl}}{V_{cube}}\end{align*}NL=VcylVcube

Exercise 11

You are given the following values:

  • \begin{align*}d = 1.54\;\mathrm{in}\end{align*}d=1.54in
  • \begin{align*}b = 8\;\mathrm{in}\end{align*}b=8in
  • \begin{align*}h = 14 \;\mathrm{in}\end{align*}h=14in

Type commands at the command line prompt to compute \begin{align*}N_L\end{align*}NL.

Exercise 12

Create an m-file to solve Exercise 11.

To complicate your problem, suppose that you have not been given values for \begin{align*}d\end{align*}d, \begin{align*}b\end{align*}b, and \begin{align*}h\end{align*}h. Instead you are required to estimate the number of ping pong balls for many different possible combinations of these variables (perhaps \begin{align*}50\end{align*}50 or more combinations). How can you automate this computation?

One way to automate the computation of \begin{align*}N_L\end{align*}NL for many different combinations of parameter values is to use a for loop. The following exercises ask you to develop several different ways that for loops can be used to automate these computations.

Exercise 13

Add a for loop to your m-file from Exercise 12 to compute \begin{align*}N_L\end{align*}NL for \begin{align*}b = 8 \;\mathrm{in}\end{align*}b=8in, \begin{align*}h = 14 \;\mathrm{in}\end{align*}h=14in, and values of \begin{align*}d\end{align*}d ranging from \begin{align*}1.0 \;\mathrm{in}\end{align*}1.0in to \begin{align*}2.0 \;\mathrm{in}\end{align*}2.0in.

Exercise 14

Modify your m-file from Exercise 13 to plot \begin{align*}N_L\end{align*}NL as a function of \begin{align*}d\end{align*}d for \begin{align*}b = 8 \;\mathrm{in}\end{align*}b=8in and \begin{align*}h = 14 \;\mathrm{in}\end{align*}h=14in.

Exercise 15

Modify your m-file from Exercise 13 to compute \begin{align*}N_L\end{align*}NL for \begin{align*}d = 1.54 \;\mathrm{in}\end{align*}d=1.54in and various values of \begin{align*}b\end{align*}b and \begin{align*}h\end{align*}h.

Image Attributions

Show Hide Details
Files can only be attached to the latest version of section
Help us create better content by rating and reviewing this modality.
Loading reviews...
Please wait...
Please wait...
Image Detail
Sizes: Medium | Original

Original text