# 6.2: A Modeling Example: Counting Ping Pong Balls

**At Grade**Created by: CK-12

Suppose you have a cylinder of height with base diameter (perhaps an empty pretzel jar), and you wish to know how many ping-pong balls of diameter 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:

- Lower bound on the number of balls that fit into the cylinder.
- The volume of the cylinder.
- The volume of a cube that encloses a single ball.

The lower bound is found by dividing the volume of the cylinder by the volume of the cube enclosing a single ball:

**Exercise 11**

You are given the following values:

Type commands at the command line prompt to compute .

**Exercise 12**

Create an m-file to solve Exercise 11.

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

One way to automate the computation of 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 for , , and values of ranging from to .

**Exercise 14**

Modify your m-file from Exercise 13 to plot as a function of for and .

**Exercise 15**

Modify your m-file from Exercise 13 to compute for and various values of and .

### Notes/Highlights Having trouble? Report an issue.

Color | Highlighted Text | Notes | |
---|---|---|---|

Please Sign In to create your own Highlights / Notes | |||

Show More |

### Image Attributions

**Save or share your relevant files like activites, homework and worksheet.**

To add resources, you must be the owner of the section. Click Customize to make your own copy.