MATLAB Examples

TRY TO EMPTY A CUP OF WATER WITH A STRAW

As an inquisitive (and sometimes silly) college student, I would, at times, think of strange problems that have the potential for interesting solutions. On one such occasion, I was in the dining hall sipping on a beverage through a straw, and I began to wonder about the following situation:

If you dip a straw in a cup of water and hold your finger over the top, you can then pull the straw out and remove the amount* contained in the straw. How many times would you have to repeat this to empty the cup? It was immediately obvious that it is impossible to completely empty the cup, so I modified the question: How many times would you have to repeat this process to lower the water level to some smaller amount?

This file provides an analytical solution to this question as well as a simulated process that verifies the analytical equation.

* This model is currently in its simplest form because it makes the following assumptions: (1) The cup and straw are perfectly cylindrical. (2) The volume of the straw material is negligible (the straw does not displace any of the water in the cup during a dip). (3) The amount of water in the straw as it is pulled out of the cup is assumed to be exactly equal to the height of the water in the cup times its cross-sectional area (adhesive/cohesive properties of water that result in meniscus/surface tension effects are being ignored). (4) Finally, this model assumes that no water clings to the outside of the straw as it is drawn out of the cup.

AUTHOR: Joseph Kirk (c) 4/2006 EMAIL: jdkirk630 at gmail dot com

Contents

SPECIFY THE CUP AND STRAW DIMENSIONS

All values must be in the same units (i.e. centimeters) [Technically, the height units can be different than the radii units so long as H0 and Hn share units and Rc and Rs share units]

H0 = 10;    % Initial water level height
Hn = 1/2;   % Final water level height
Rc = 3;     % Cup radius
Rs = 1/2;   % Straw radius

ANALYTICAL SOLUTION

The derivation for this equation can be found at the bottom of this file

n = ceil(log(Hn/H0)/log((Rc*Rc-Rs*Rs)/(Rc*Rc)));
disp(['number of calculated dips = ' num2str(n)]);
number of calculated dips = 107

NUMERICAL SOLUTION (SIMULATED PROCESS)

  • Calculate volume in the cup
  • Insert the straw
  • Calculate volume in the straw
  • Remove the straw and the water in it
  • Calculate the new volume in the cup
  • Calculate the new height of the water
  • Record the dip
m = 0;
h = H0;
height = h;
while (h > Hn)
    Vcup = pi*Rc*Rc*h;      % Total volume in the cup
    Vstraw = pi*Rs*Rs*h;    % Volume in the straw
    Vnew = Vcup - Vstraw;   % Volume in the cup after the straw is removed
    h = Vnew/(pi*Rc*Rc);    % Calculate the new height of the water
    height = [height; h];
    m = m+1;                % Update the number of dips
end
disp(['number of actual dips = ' num2str(m)]);
number of actual dips = 107

PLOT DIPS VS. WATER LEVEL HEIGHT

figure;plot(height,'b.-');
title('Straw Dips vs. Water Level Height');
xlabel('Number of Dips');
ylabel('Height');
set(gcf,'color','white');
text(.6*n,.8*H0,['analytical: ' num2str(n) ' dips'],'color','k');
text(.6*n,.75*H0,['numerical: ' num2str(m) ' dips'],'color','k');

ANALYTICAL SOLUTION DERIVATION

Recall that the volume of a cylinder is

Let H0 be the initial water level, Hk be the water level after k dips, Vc be the volume of water in the cup, Vs be the volume of the water in the straw, Rc be the radius of the cup, and Rs be the radius of the straw, then the volume in the cup after the first dip of the straw is given by

Substituting the volume equation for cylinders results in

Solving for H1

Repeat this process for the next dip

But we already know what H1 is, so it can be substituted in

Now the pattern is obvious so we can conclude that

By definition, n is the number of dips it takes to reduce the water level to Hn, so we solve for it

Finally, the number of dips must be an integer, so