The Mathematics of Dieting – Part 1 (BMI)

The Problem

This is a story with a very happy ending. I have been overweight for most of my 50+ years. I have tried to diet unsuccessfully many, many times. It can be hard especially if you don't face the issue at hand and look in the mirror and say "I can't stop eating" so you can finally address what you need to do. Two years ago, I started a weight loss plan that resulted in me losing 103 pounds over a period of 9 months and achieving my weight loss goal. Moreover, I have been able to maintain a stable weight in the 14 months since I went off my weight loss plan and starting maintenance. I will use several blog posts to discuss what I did to lose this weight. There was no magic, but it was interesting.

What was different this time from all the other times? This time, I turned weight loss into a math problem.

Motivations

Ultimately, the key to long-term weight loss is behavior modification. The key to behavior modification is motivation. Three things happened that provided me the motivation that I needed to diet seriously.

  • My youngest son was looking at some old pictures of me and commented that he had never seen me as thin as I was in some of the pictures. He did not say this in a mean manner, but it caused me to think about the example that I had set for him. I distinctly remember saying to myself that I can change this situation.
  • Years before I had bought a life insurance plan that increased in cost every year. Because of my weight, it was expensive. Basically, every month I received a bill for being overweight and I did not like how it was rising. I wondered many things, if should I stick with it, do I need Final expense insurance, or would a change to a fixed-rate policy save money? I realized if I wanted the latter I had to lose weight.
  • I hired a senior-level natural bodybuilder on to my engineering team. This gentleman literally changed my life. I have concluded that bodybuilders know a lot and that people should listen to what they say very carefully.

These are all good reasons, but the real reason came down to my family. When you get right down to it, most overweight people would like to lose weight, but simply doing something good for themselves is not sufficient motivation. You need to find a reason that is bigger than yourself. In my case, it was decided that I needed to do all that I could to ensure that I will be there when family needs me.

Timing

My doctor told me that I needed to have a baseline colonoscopy – one of the joys of turning 50. Since I was going to be empty anyway, I decided to turn my colonoscopy into a weight loss opportunity. My diet would begin the second week of November with my colonoscopy.

Since I am a person that always needs a date goal to strive for, I looked at the calendar and I could see a number of important dates in the near future.

  • My wife and I were going on a cruise in March.
  • My yearly physical was scheduled for May.
  • My son was going to be back home on the fourth of July.
  • My life insurance rate was scheduled to increase in August.

I chose July 4 as my date for hitting my goal weight because it was far enough in the future (9 months) that I would have a credible chance of losing 103 pounds. I would also be able to avoid my life insurance rate increase by qualifying for a cheaper policy. This meant that I needed to lose 11.4 lb/month. That sounded hard but doable. Anyone who has a life insurance policy like me will be aware of what you need to do to make sure you get a good deal. I know people who have shopped around for a while and checked out companies like Curo Financial to see what policies they can get so they are all set.

Life Insurance Math

I reviewed the life insurance policies of a number of companies: AAA, Prudential, Met Life, etc. All the policies had a common theme – they predicted your personal risk based on your Body Mass Index (BMI). They did not come right out and say BMI, but you could see that their tables were derived using the BMI equation.

BMI Basics

BMI is very simple formula that has major implications for the cost of your insurance.

BMI = \frac{m}{{{h^2}}}

where m is the body mass in kilograms and h is the body height in meters. This formula is used around the world to assess the body mass situation of groups of people.

The medical folks assign labels to different BMI ranges.

BMI Categories
BMI Range Category
‹ 16.5 Severly Underweight
16.5–18.4 Underweight
18.5–24.9 Normal
25.0–29.9 Overweight
30.0–34.9 Obese Class I
35.0–39.9 Obese Class II
› 40 Obese Class III

A person who is Obese Class III is often referred to as "morbidly obese." There are international variations on these thresholds.

BMI Trivia

Here are some commonly cited BMI values.

Example Calculation

Let's walk through an example calculation by using the typical American female supermodel as an example.

  • average height = 5' 10'' = 1.778 meters
  • average weight = 115 lb = 52.163 kg

The calculation is straightforward.

{\left. {BMI} \right|_{Supermodel}} = \frac{{52.163{\text{ kg}}}}{{{{\left( {1.778{\text{ m}}} \right)}^2}}} = 16.5{\text{ }}\frac{{{\text{kg}}}}{{{{\text{m}}^{\text{2}}}}}

Issues with BMI

I view BMI as a type of figure of merit. As a figure of merit, it definitely has some issues. For example, the units of BMI are kg/m2. Intuitively, this seems odd because the units look like a mass per unit area. If tall people were simply large versions large-versions of short people, it seems that the units should be kg/m3, which is the same as a density. Since muscle weighs more than fat, I can see where higher densities might be good and lower densities might be bad. While this makes intuitive sense, it is clear that tall people are not scaled up short people and that using a density form of measure would not work. Note that BMI is calculated the same for men and women, who definitely are constructed differently. So it seems that the use of height-squared is a compromise form of metric.

In fact, most medical experts say that while BMI has value with respect to populations, it has less value with respect to an individual. Individuals vary greatly with respect to muscle mass and skeletal frame. For example, the bodybuilder on my work team has a BMI of 33. This puts him in the Obese Class I category, but he has a body fat percentage that is less than 12% (when competing it is around 7%). I guarantee you that he is not obese by any definition other than BMI.

All this being said, since the insurance companies use BMI for medical underwriting, so we are stuck with it and have to use it. Its main advantage is that it is easy to compute.

My Personal BMI Situation

Alas, my personal BMI situation at the start of my diet was not good – it was 42.5. I was morbidly obese (the word "morbidly" makes me shudder). I had my work cut out for me. As it turned out, I hit my target weight on July 4 exactly.

Posted in Dieting, Health | Tagged , , , | 1 Comment

Book Review: Ratio by Michael Ruhlman

Introduction

I have always thought that there was something magical about baking. I especially like recipes that make things that rise. I think it is almost magical the ways breads and cakes grow into their final form. Because of my interest in baking, I have decided to learn to bake.

When I want to learn something, I use a "full court press" approach: classroom study, supplementary book reading, and good projects. I have been applying this approach to learning baking.

  • I am taking courses from "Cooks of Crocus Hills"
  • I have put together a small library of baking references from which I am making recipes
  • I am trying all sorts of bread recipes

The Book Review

One important book in my library is the book Ratio by Michael Ruhlman [1]. This book explains why recipes are built the way they are. For a mathematical person, it takes the mystery out of recipe construction. One issue that I have had with baking is that it has always seemed to contain mysterious procedures (recipes) with no rationale behind the procedures. I am always suspicious when I need to follow a procedure and I do not understand the rationale behind each and every item in the procedure. I have been working through the book (I am not quite done) and I have found it to be an excellent introduction to theory of recipe construction.

I first heard about the book when Ruhlman was interviewed on National Public Radio. The genesis of the book involved the author (Ruhlman) meeting a chef (Uwe Hestnar) who believes that that cooks do not need to have shelves full of recipe books — all they need is a list of 26 types of recipes and their ingredient ratios. Chef Hestnar has created 26 categories of fundamental cooking building blocks and the ratios of flour, eggs, sugar, liquids, and fats required to make all of them. Ruhlman has created a book that carefully walks the reader through these ratios and why the ratios are set the way they are.

I have really like having this book. It has taken the mystery out of recipes. I have compared Ruhlman's ratios with the ratios of many popular recipes. His ratios seem to hold with reasonable accuracy across all the recipes I have looked at. I now feel like I can walk into a kitchen without any recipes and produce some very good food with just a basic knowlege of the ratios behind the different food building-blocks. I also feel that I have the theoretical background I need to begin making my own recipes.

A Related Work

I recently heard software engineer Jeff Potter on the radio program Science Friday talk about his book Cooking for Geeks: Real Science, Great Hacks, and Good Food. I have not read this book (I am ordering it now). From the interview, it sounds like this book was written in a similar vein to Ratio. If you are interested in the science of cooking as discussed in Cooking for Geeks, you can read the transcript here.

References

1. M . Ruhlman, Ratio : the Simple Codes Behind the Craft of Everyday Cooking, Scribner, 2009. ISBN-10: 1416566112

2. J. Potter, Cooking for Geeks: Real Science, Great Hacks, and Good Food, O'Reilly, 2010. ISBN-13: 978-0596805883

Posted in Baking | Comments Off on Book Review: Ratio by Michael Ruhlman

The Case of the Mysterious Bit Errors

Introduction

I am the hardware director for a team of optical networking professionals. More often than I care to admit, we need to embark on a detective case in order to resolve a customer problem. This blog describes a situation that occurred recently where a little math shed some light on the problem.

The Problem

We recently had reports from the field of bit errors occurring in the mornings and evenings at a newly deployed site in Mexico. Our customers use bit error rate as a measure of the quality of service they are receiving. In this case, our bit error rate should have been zero. The bit errors were disturbingly like some reports we had received during the previous spring from a deployment in North Dakota. The bit errors in North Dakota vanished before we were unable to find their root cause. We have hundreds of sites that use our hardware without any bit errors occurring at all — What was common between two sites in Mexico and North Dakota that would cause bit errors in our system?

Clues

As we asked our field engineers questions, some clues emerged:

  • There are two types of fiber deployment: aerial and buried. Each of the problem sites involved aerial fiber deployments. In an aerial deployment, the fiber is hung from poles instead of being buried in the ground. We have large numbers of both types of deployments.
  • The North Dakota, the bit errors had only occurred in the spring, while the bit errors in Mexico were occurring in the summer.
  • In both cases, the errors occurred at sunrise and in late afternoon.
  • The fiber runs were long — 11 km or longer. While our system is certified to 60 km, over 80% of our deployments have ranges of 5 km or less.
  • The bit errors were not randomly placed. They occurred in specific areas at the end of long data sequences.

Formation of Hypotheses

Here is where problem-solving experience is useful. We start with some inferences based on our experience.

  • We know that the maximum temperature changes in an aerial deployment occur in the morning at first exposure to sunlight and late in the afternoon.
  • Our experience is that both North Dakota and Mexico experience fast changes in temperature. While their temperatures are different, both regions have similar rates of temperature change.
  • Our experience has been that bit errors at the end of long data sequences almost always meant that there was a timing problem.

Could we be experiencing a temperature-dependent timing problem? Our system depends on precise timing for reliable data transmission. We adjust for timing changes periodically, but between adjustments the system timing (i.e. arrival time of photons at a receiver) must remain constant within ±19.2 nsec for reliable data transmission.

Could rapid temperature changes be causing the transmission time of our signal be varying on the fiber enough to cause bit errors? We do periodically check the system timing to adjust for slow-moving timing changes. However, what if a change in timing occurs so quickly that our current approach cannot adjust fast enough? That could cause this problem.

Testing Our Hypothesis

We used a two-prong approach to test our hypothesis:

  • Insert a change into our programmable hardware (i.e. Field Programmable Gate Arrays [FPGA]) that would allow our system in Mexico to work with larger delay variation. If increasing our tolerance for delay variation reduced or eliminated the bit errors, we would know that timing was at the heart of the problem.
  • Begin a detailed look at the effect of temperature on the signal delay variation with temperature on fiber. This would tell us the amount of timing variation that the system must be designed to handle. During our early development, we had made assumptions about how fast the temperature could vary. Maybe the temperature was varying faster than we assumed?

When we made the change to our system in Mexico, the bit errors went away. This gave us empirical evidence that timing was the culprit. Now we needed to determine if the signal delay on the fiber was varying enough to cause a problem. Ideally, we would have many kilometers of fiber in our lab that we could use to make direct measurements of the signal delay variation with temperature. Unfortunately, we had neither the fiber nor the required temperature chambers to make these measurements. So we decided to try to alternative approaches: web searching for published fiber delay versus temperature data and mathematical modeling.

The web searching provided some data. Specifically, one reference from the power industry [1] stated that they had measured \left( {~80 \pm 20} \right)\frac{{{\text{ps}}}}{{{\text{km}} \cdot ^\circ {\text{C}}}} . However, they were using cables that were constructed very differently from hours. The power industry data was for massive cables that had large steel reinforcing members. My concern was that the fiber transmission speed is a function of the tension on the fiber and I am quite certain the tension on our cables is different than theirs.

Maybe some mathematical modeling could provide some insight into the critical variables? We proceeded as shown below.

How Does Signal Speed Vary on a Fiber with Temperature?

We begin by looking at what determines the signal transmission time on a fiber. The transmission time is simply distance divided by the speed of light on the cable.

\tau = \frac{L_{Fiber}}{c_{Fiber} }

Where \tau is the signal transmission time on the fiber, L_{Fiber} is the distance between the light transmitter (a laser) and the light receiver, and c_{Fiber} is the speed of light on the fiber.

The speed of light on the fiber is given by the following expression.

c_{Fiber} = \frac{c}{n}

Where c is the speed of light in a vacuum and n is the fiber's index of refraction. It turns out that n is a complicated term — it is a function of both temperature (T) and mechanical stress (S).

We can combine these expressions as follows.

\tau = \frac{L_{Fiber} \cdot n(T,S)}{c_{Fiber} }

Now we can apply a little calculus to determine how this delay varies with temperature. We can take the derivative of this expression with respect to temperature T and obtain the following result (note that c is a constant).

c_{Fiber} \cdot \frac{{d\tau }}{{dT}} = \frac{{d{L_{Fiber}}}}{{dT}} \cdot n + {L_{Fiber}} \cdot \left( {\frac{{\delta n}}{{\delta S}} \cdot \frac{{dS}}{{dT}} + \frac{{\delta n}}{{\delta T}}} \right)

We can rearrange this expression to make it a bit more useful for the discussions to follow. These expressions are formed to use readily available physical data for fiber.

d\tau  = \left( {\frac{{\frac{{\frac{{d{L_{Fiber}}}}{{dT}}}}{L} \cdot n}}{c} + \frac{{\frac{{\delta n}}{{\delta S}} \cdot \frac{{dS}}{{dT}}}}{c} + \frac{{\frac{{\frac{{\delta n}}{{\delta T}}}}{n} \cdot n}}{c}} \right) \cdot {L_{Fiber}} \cdot d\tau

Where k_T is the overall temperature coefficient of the fiber delay. A few definitions will simplify our look at each term of the temperature variation independently.

Components of Temperature-Induced Delay Variation
Delay Component Equation
Fiber Length-Related Change {k_L} \triangleq \frac{{\frac{{\frac{{dL}}{{dT}}}}{L} \cdot n}}{c}
Index of Refraction-Related Change with Temperature {k_I} \triangleq \frac{{\frac{{\frac{{\delta n}}{{\delta T}}}}{n} \cdot n}}{c}
Index of Refraction Changes with Temperature-Induced Stress {k_S} \triangleq \frac{{\frac{{\delta n}}{{\delta S}} \cdot \frac{{dS}}{{dT}}}}{c}

Using these definitions, we can now write a simple expression for the variation of signal delay on the fiber.

{k_T} = {k_L} + {k_I} + {k_S}

We can now discuss the overall delay variation in terms of the variation of each of the components.

d\tau  = \left( {{k_L} + {k_S} + {k_I}} \right) \cdot L \cdot d\tau

Temperature Variation of the Components of Signal Delay

Key Fiber Characteristics

Before we go too far, we need to list out some of the key physical characteristics of fiber optic cable. These characteristics vary a bit from manufacturer to manufacturer, but these values are representative.

Table of Important Fiber Physical Characteristics
Parameter Description Value Units
n Silica Index of Refraction 1.455 dimensionless
{\frac{{\frac{{\partial {L_{Fiber}}}}{{\partial T}}}}{{{L_{Fiber}}}}} Temperature Coefficient of Fiber Length 5.5E-7 1/°C
\frac{{\frac{{\partial n}}{{\partial T}}}}{n} Temperature Coefficient of Index of Refraction 9.76E-6 1/°C
p11 First Pockel's constant 0.113 dimensionless
p12 Second Pockel's constant 0.252 dimensionless
ν Poisson's Ratio 0.16 dimensionless

A Brief Look at the Photoelastic Effect

It turns out the effect of stress on the fiber is difficult to model. While there is a good theory for the fiber by itself, the fiber is bundled in other materials that have their own expansion coefficient. Thus, the overall stress on the fiber is a complex function of the constituent material properties. We can compute the photoelastic variation in the index of refraction for unsheathed fiber using the equation shown below.

{k_S} \triangleq \frac{{\frac{{\delta n}}{{\delta S}} \cdot \frac{{dS}}{{dT}}}}{c} = \frac{{{n^3}}}{2}\cdot\left[ {\left( {{p_{11}} + {p_{12}}} \right)\cdot\nu  - {p_{12}}} \right]\cdot\frac{\alpha }{c}

The analysis that follows will model the photoelastic variation of the fiber itself, but it will not attempt to model the total variation in the index of refraction due to stress — we simply do not have enough information. Similarly, while we have data for the temperature coefficient of expansion for silica, we do not have data on the specific cable being used in Mexico or North Dakota. So our modeling will be rough for two of the three terms. This means that we should treat our mathematical analysis as giving us an order of magnitude result that may not be exactly correct. It will tell us what are the most important terms.

Summary of Delay Coefficients

Calculation of Delay Variation Due to Length Change
Symbol Equation Value Unit
kL \frac{{\frac{{\frac{{\partial {L_{Fiber}}}}{{\partial T}}}}{{{L_{Fiber}}}}}}{c} \cdot n

2.67 \frac{{{\text{ps}}}}{{{\text{km}} \cdot {^{\circ}\text{C}}}}
kI \frac{{\frac{{\frac{{dn}}{{dT}}}}{n} \cdot n}}{c}

47.42 \frac{{{\text{ps}}}}{{{\text{km}} \cdot {^{\circ}\text{C}}}}
kS \frac{{\frac{{\partial {n_S}}}{{\partial T}}}}{{{n_S}}} -0.55 \frac{{{\text{ps}}}}{{{\text{km}} \cdot {^{\circ}\text{C}}}}
kT {k_L} + {k_I} + {k_S} 49.54 \frac{{{\text{ps}}}}{{{\text{km}} \cdot {^{\circ}\text{C}}}}

We see that the delay variation is dominated by the temperature coefficient of the index of refraction. So we should expect to see ~50 \frac{{{\text{ps}}}}{{{\text{km}} \cdot {^{\circ}\text{C}}}} for the fiber itself. However, Reference [1] reports larger values for the delay variation with temperature. My assumption is that this variation is due to the change in mechanical stresses with temperature, which I have not modeled. They are considered in [3], but that is way beyond my scope here. So 50 \frac{{{\text{ps}}}}{{{\text{km}} \cdot {^{\circ}\text{C}}}} should be looked upon as a lower bound. For the sake of further analysis, we will assume a delay temperature coefficient of \left( {~75 \pm 25} \right)\frac{{{\text{ps}}}}{{{\text{km}} \cdot ^\circ {\text{C}}}} .

Estimate of Total Delay Variation

If we assume a temperature variation of 30 °C, we can estimate the total delay variation using the following equation.

\tau  = {k_T} \cdot {L_{Fiber}} \cdot \Delta T

We can substitute the values from our Mexican deployment into this equation to obtain.

\tau = 75\frac{{{\text{ps}}}}{{{\text{km}} \cdot {^\circ \text{C}}}} \cdot 11{\text{ km}} \cdot \text{30 } ^\circ \text{K}  =  \text{25.750 ns}

This shows that the delay variation with temperature larger than our limit of 19.2 nsec and is sufficient to cause bit errors.

Comparison With Published Results

I was not able to find a large number of references on the variation in signal delay with temperature but there were two that were useful. One reference [1] stated that they had observed a fiber delay variation in the range of 60 to 100 \frac{{{\text{ps}}}}{{{\text{km}} \cdot {^\circ \text{C}}}} . This is consistent with what we were seeing. Another reference [2] states that the fiber delay variation is 43 \frac{{{\text{ps}}}}{{{\text{km}} \cdot {^\circ \text{C}}}} . This is less than my estimate, but still enough to cause a failure given a long fiber, large temperature variation, or both.

Conclusion

Here is how everything ended up:

  • We modified our system to meet a maximum fiber delay variation of 100 \frac{{{\text{ps}}}}{{{\text{km}} \cdot {^\circ \text{C}}}} .
  • Thanks to programmable hardware, we were able to download the change to our customers at no cost.
  • The problem has not reappeared. This is the best indication of all that we nailed the bug!

References

[1] Myoujin, Y.. "Transmission delay variations in OPGW and overhead fiber-optic cable links ." IEEE Transactions on Power Delivery 12, no. 4 (1997): 1415-1421.
[2] Nooren, G-J. "Influence of temperature and pressure on light propagation in fibres." June 6, /2000.http://www.nikhef.nl/~nooren/fibretest/ (accessed March 21, 2010).
[3] Kiesel, S et al. "Behaviour of intrinsic polymer optical fibre sensor for large-strain applications." Measurement Science and Technology 18 (2007) 3144–3154.

Posted in Fiber Optics | 1 Comment

Another Interview Question

Besides me, there is one other engineer in my group that used to work for Hewlett-Packard back in the old days. One day we decided to compare notes on the crazy interview questions that we were asked all those many years ago. During the discussion, I recalled one question that I have seen only once since my interview (~30 years ago). It is worth writing down here.

A young electrical engineer is handed two boxes, one labeled A and the other labeled B. It is known that one contains a Norton equivalent circuit and the other contains a Thevenin equivalent circuit (see figure below).

Norton and Thevenin Equivalent Circuits
Norton Equivalent Circuit Thevenin Equivalent Circuit
Norton Equivalent Circuit Thevenin Equivalent Circuits

The question for the young engineer is "What kind of circuit (Norton or Thevenin) is in box A and box B? How would you go about figuring out which box contains which equivalent circuit?"

The answer is there is no way using purely electrical test methods to determine what kind of equivalent circuit is in each box. So you need to look at other characteristics. Because the Norton circuit contains a current source, there is always a current flowing. This means that the box containing the Norton source will always be consuming power and generating a magnetic field. Most solutions are based on measuring power or magnetic field strength. The box containing the Thevenin circuit, with no load on its output, will neither consume power nor generate a magnetic field.

This is a nice problem in a number of ways. Correctly solving the problem demonstrates that the young engineer understands the important concept of equivalent circuits. It requires the young engineer to analyze a non-trivial problem while in a stressful situation. Also, it is convenient for an interviewer because it does not require any computation.

Posted in Interviewing, Problems | Tagged , , , , | 1 Comment

Fixing My Stairs Using Mathematics

The Problem

I am a VERY amateur carpenter, but I do love to build things out of wood. One particular specialty area of carpentry that I admire is stair building. I consider stair building (along with roof cutting) to be the brain surgery of carpentry. While occasionally stairs are works of art, they always must be safe and functional. Quite often, I see stairs where the height of either the bottom step or top step is not the same as the other stairs. This is nearly always because the flooring on the bottom or top floors has changed since the stairs were built. Unfortunately, I recently faced this same situation.

I live in a cold climate and my house has a basement. In order to make the basement livable in the winter, I hired a contractor to build an insulated floor, which is very thick compared with the original carpeting. Unfortunately, the additional lower floor height made the bottom step of my basement stairs very short. This created a safety issue and would be an issue if I were to try and sell the house. The city building inspector noticed the issue, but decided not to force the contractor to fix it. Given that option, the contractor left it short.

A few years after my basement floor was insulated, my wife and I decided to put a wood floor in the basement and re-carpet the stairs. Because the stair framework was exposed, this remodeling gave us an opportunity to equalize all the riser heights with minimal hassle. Unfortunately, we decided to equalize the riser heights the night before the carpet was due to go in. I contacted a carpenter for advice who said that I should just cut a new set of "stringers," which are the wooden supports that the treads sit on. This would not work, however, because the hour was late and I had neither the lumber nor the equipment to cut the stringers. After thinking about it a bit, the easiest solution was to use shims under each tread to set the unit rise for each tread. This is where a little bit of math came into play.

A Few Definitions

There are many special terms associated with the building of stairs. For this discussion, there are just a few terms that need to be defined. I have illustrated these terms in the following figure.

Illustration of a Few Stairway Terms

Illustration of a Few Stairway Terms

The situation that I faced was that my new insulated lower floor was now higher by 2.25 inches than when the stairs were originally built. The insulated floor was built using 2x4s (i.e. 1.5 inches thick) glued to my basement concrete surface to support a 0.75 inch thick floor surface made of plywood. Styrofoam insulation was placed between the plywood and the basement concrete surface. This was one of the best improvements I have made to my house, but it did raise my floor. The figure below illustrates the situation, along with some of the critical dimensions. Note that my actual stairs has many more treads than the four shown in this drawing but the drawing illustrates the problem just fine.

My Short Bottom Step Makes My Stairway Unsafe

The Fix

Let R be the unit rise before the floor height change, R' be the unit rise after the floor height change, T be the total rise before the floor height change, T' be the total rise after the floor height change, and N be the number of stairs. The unit rises before and after the floor height change are computed as follows.

{R} = \frac{T}{N}, {R'} = \frac{T'}{N}

Our objective here is to derive an expression for the thickness of each shim. In order to easily identify each individual shim height, we can assign a number to each stair tread — assign the bottom tread the number 1 and increment the number for each tread going up (top tread is actually the top finished floor and is assigned N). Each tread will be assigned a specific shim thickness. Let \tau_i be the shim thickness for the ith tread. For the sake of simplicity, we can define \tau_0 as the height increment of the newly finished lower floor height from the original floor height.

The following figure is useful in understanding the derivation of an expression for the shim thickness. It shows the relationship between the rise values before and after the shims.

Detail Drawing of An Individual Step

Using the figure above, we can see that the following relationship exists between R, R', \tau_{i} , and \tau _{i-1}.

R' + {\tau _{i - 1}} = R + \tau {}_i \Rightarrow R' = R + \left( {\tau {}_i - {\tau _{i - 1}}} \right)

Since each stair must be the same height and our overall stair height is shorter by \tau_0, the difference between the old and new stair heights must be {}^{{{\tau }_{0}}}\!\!\diagup\!\!{}_{N}\;. Given this difference, we can derive a relationship between the heights of the individual shims as follows.

R - R' = - \frac{{{\tau _0}}}{N} = \left( {\tau {}_i - {\tau _{i - 1}}} \right) \Rightarrow {\tau _i} = {\tau _{i - 1}} - \frac{{{\tau _0}}}{N}

This expression means that a shim's height is always \frac{\tau _0}{N} smaller than the shim on the next lower step.

Let's compute a few shim heights to illustrate the situation.

{\tau _1} = {\tau _0} - \frac{{{\tau _0}}}{N} = {\tau _0} \cdot \frac{{N - 1}}{N}

{\tau _2} = {\tau _1} - \frac{{{\tau _0}}}{N} = {\tau _0} \cdot \frac{{N - 2}}{N}

\vdots

{\tau _{N - 1}} = {\tau _0} - \frac{{\left( {N - 1} \right) \cdot {\tau _0}}}{N} = {\tau _0} \cdot \frac{1}{N}

{\tau _N} = {\tau _0} - \frac{{\left( N \right) \cdot {\tau _0}}}{N} = 0

There is a pattern here and the thickness of the ith shim is given by the following equation.

{\tau _i} = {\tau _0} \cdot \frac{{N - i}}{N}

We now have all the information we need to cut the shims and fix the stairs. Here is what the stairs looked like after the shimming was completed.

Shimming Equalizes All Unit Rises

My basement steps have been working without problems now for years. The unit rise of each step is exactly the same. All it ended up costing me was some scrap lumber, a little glue, and a little time to derive a solution. What more could I ask for?

Some Practical Issues

IRC Requirements

The main requirement of concern in this situation is the IRC constraint on the allowed variation in riser heights. To understand this requirement, consider the flight of stairs illustrated in the following figure.

Illustration of Riser Height Deviations

Illustration of Riser Height Deviations

The IRC requires that the following requirement be met.

\max \left( {{R_1},{R_2}, \cdots ,{R_{N}}} \right) - \min \left( {{R_1},{R_2}, \cdots ,{R_{N}}} \right)\; \leqslant \;\frac{3}{8}{\text{ inch}}

For more information on the IRC stairway requirement, see [1].

Dealing with Thin Shims

When I did my stairs, I worked too hard to make thin shims. If I had it to do over today, I would not have made any shims thinner than 1/8 inch. I would simply ensure that I met the IRC requirement that limits the maximum difference between riser heights to 3/8 inch. Making and installing thin strips is difficult because they are so fragile that they are not worth the effort.

A Reference with a Similar Approach

I did find one reference ([2]) that uses a similar method for fixing a flight of stairs, but the description is is not quite as detailed as presented here.

References

[1] "Visual Interpretation of the International Residential Code:2006 Stair Building Code", Stairway Manufacturers Association, 2006. Link
[2] B. Abernathy, "Q&A: Your Questions—Pro Answers: Fixing Rough Framed Stairs," Fine Homebuilding Magazine, Issue 168, pp. 106, Jan 2005. Link

Save

Save

Posted in Construction | 13 Comments

Why No More Bathyscaphes?

Introduction

Like many people, I have been watching BP try to cap the blown Deepwater Horizon oil well. While BP has had many issues, it has been very interesting watching the unmanned underwater vehicles (UUVs) do their job. When most people think of underwater vehicles they think of World War II submarines or one of the manned underwater vehicles that were used to explore Titanic. In today's world, most UUVs are busy quietly doing real work every day. Seeing these vehicles in action brought to mind some fond memories.

History

At one time in my career, I worked on UUVs and it was some of the most satisfying work of my career. I have always been fascinated by the history of undersea exploration. Most of this history has been about designing vehicles to take people to very inhospitable places. The topic of this article is the bathyscaphe, which is a manned vehicle that was designed to take people to the deepest depths. It is a vehicle of a time past.

My first and only direct contact with a bathyscaphe was on one of my business trips. While on a trip to Keyport, WA, I happened to stop by a wonderful museum, the Naval Undersea Museum. I highly recommend stopping by this museum if you have any interest in the sea. On this trip, I took particular note of their display of the bathyscaphe Trieste II. It is a heavily modified version of the Trieste I, the submarine that made the only manned trip to the deepest point in the ocean, Challenger Deep in the Marianas Trench. In fact, the Trieste II used the original pressure sphere from Trieste I, which is where the two-person crew resided while diving.

Bathyscaphe Trieste I

Wikipedia Photo of Trieste I

When I was a boy in the 1960s, I read about the bathyscaphe Trieste I and its brave crew, Jacques Piccard and Don Walsh. Their voyage had some scary moments, like when their glass viewing port cracked during the dive. If that port had let water in, there was no hope for their survival. However, they persevered and completed their mission. Their voyage also confirmed that life was present at the deepest point in the ocean. For those interested in more information on the mission, I recommend the Wikipedia’s exposition. There is also a very interesting web site that specializes in the Walsh/Piccard mission

How a Submarine Works

A typical submarine that works at relatively shallow depths usually has ballast tanks that can be filled with water. A submarine dives or surfaces by applying Archimedes' Principle, which states that an object sinks or floats based on its density relative to water. In the case of a submarine, as the ballast tanks fill with water, the submarine density of the submarine increases and it dives. To rise, compressed air is used to clear the tanks of water. As the water is removed, the density of the submarine decreases, and the submarine surfaces. The problem with this approach for an underwater vehicle is that the ballast tanks must be built sturdy enough to ensure that the pressure outside the tanks cannot crush them. This means big, heavy, and expensive tanks.

How a Bathyscaphe Works

A bathyscaphe works differently than a submarine. Because it works at extreme depth, the only air spaces on the vehicle are for the crew. From a buoyancy standpoint, a bathyscaphe is similar to a hot air balloon in that it uses contains a buoyant fluid (aviation fuel) in a lightweight enclosure to provide lift. The nice thing about aviation fuel is that it is incompressible and that means that it will resist the intense pressure. To sink, a bathyscaphe is filled with aviation fuel for buoyancy and iron shot for ballast. Enough iron shot is put on-board to ensure it can dive. When the bathyscaphe wants to surface, it releases the iron shot. To quote the Wikipedia, "Strictly speaking bathyscaphes are not submarines because they have minimal mobility and are built like a balloon, using a habitable spherical pressure vessel hung under a liquid hydrocarbon filled float drum." The following figures from Wikimedia Commons do a nice job illustrating how a bathyscaphe works.

Wikipedia Cutaway Drawing of the Trieste I

Wikimedia Commons Image of Bathyscaphe in Action

Why No More Bathyscaphes?

While bathyscaphes are interesting, no one builds them anymore. Why? I am an electrical engineer by training, but I was very curious about how these research vessels are designed. As part of my job, I worked with an excellent team of mechanical engineers that were designing the structures (pressure vessels, control surfaces, etc) for the underwater vehicles we were building. So I decided to ask the lead engineer of this very knowledgeable group "Why no more bathyscaphes?" He gave me a two-word answer ― "syntactic foam". A syntactic foam is basically a plastic material that is filled with a large number of tiny hollow spheres. The spheres can be made of various materials. In my case, they were glass. These spheres are very strong so that they can resist extreme pressures. They are also very light and easy to work with. They also provide a substantial amount of buoyancy. The polymer material binds all the spheres together; hence the term "syntactic," which means to "put together." The vehicles we were working on had a lot of foam. I noticed that all modern deep-diving submarines use syntactic foam (see Alvin for example). Now I understood why no one builds bathyscaphes anymore -- the foam is much cheaper and more convenient than aviation fuel when it comes to flotation. More importantly, it is also much safer because gasoline can leak from the tanks (see Bob Ballard story below).

Underwater Adventure

I have heard syntactic foam and bathyscaphes mentioned in the news.

Bathyscaphes in the News

Do not ever pass up an opportunity to hear Bob Ballard speak on science. He is absolutely the best. I was listening to him on the radio one day and he told a hair-raising story about a trip he took on a bathyscaphe. While down deep, a leak developed and the gasoline began to leak out. Now think about this ― the gasoline is like the hot air in a hot air balloon. If the hot air leaks out of a balloon you sink to the ground. If the gasoline leaks out of a bathyscaphe, you sink to the bottom of the ocean. Ballard related how they sweated out the long trip back to the surface hoping that they would have enough gasoline to get them to the surface. If they were to leak gasoline too quickly, they would end up on the bottom of the ocean — and no one else could dive deep enough to help recover them. Fortunately, everything worked out. But this illustrates how dangerous undersea exploration was in the early days. Here is a link to a PBS video where he relates the same story.

Syntactic Foam in the News

It may be hard to believe, but I actually heard a scientist on a documentary talking about syntactic foam. He was serving on the Alvin when it filmed vulcanism down at the mid-Atlantic ridge. The scientist was actually on the submarine and was reading the temperature of the water outside. As the temperature rose, an engineer mentioned to him that the outside temperature was hot enough to melt the syntactic foam and they should get to a cooler area. The scientist immediately agreed and they pulled out of that area.

On May 31, 2009, the robot submarine Nereus went to the bottom of Challenger deep. The craft they sent used a new kind of buoyancy system using ceramic spheres in place of syntactic foam.

Web References to the Dive

Posted in Underwater | Tagged , , | 3 Comments

Rule of 72 Redeux

I frequently have to work on “time value of money” problems. Good approximate solutions to these problems can often be obtained by using the “Rule of 72.” The Rule of 72 will tell you approximately how many interest payment intervals are required for an investment to double in value by evaluating the following formula.

N = \frac{{72}}{{r\left[ \%  \right]}}

Where N is the number of payment intervals and r is the interest rate in percentage. I just accepted this formula for years until I had a mathematician friend tell me that the Rule of 72 should really be the “Rule of 69.” He did not go into detail and I decided to think a bit more about the equation.

To determine the doubling interval of an investment, the basic equation that must be solved is the following.

{A_0} \cdot {\left( {1 + r} \right)^N} = 2 \cdot {A_0}

The exact solution is straightforward and can be derived as follows.

{A_0} \cdot {\left( {1 + r} \right)^N} = 2 \cdot {A_0}

\log \left( {{{\left( {1 + r} \right)}^N}} \right) = \log \left( 2 \right)

N \cdot \log \left( {1 + r} \right) = \log \left( 2 \right)

N = \frac{{\log \left( 2 \right)}}{{\log \left( {1 + r} \right)}} \doteq \frac{{69}}{r}

I now understand where my friend's comment came from. So I decided to graph the error in the Rule of 72 and Rule of 69 from the exact solution to see which is closer. The result surprised me.

Percentage Error Between Rule of 72 and Rule of 69 Versus Interest Rate

Percentage Error Between Rule of 72 and Rule of 69 Versus Interest Rate

Observe that the Rule of 72 has less error than the Rule of 69 for interest rates greater than 3.4%. These are common interest rates and I began to wonder if the Rule of 72 was written the way it is for a reason. Like always, I began to play with the equation. I soon saw that the Rule of 72 could be obtained by continuing the previous derivation with a slightly changed logarithm approximation.

N = \frac{{\log \left( 2 \right)}}{{\log \left( {1 + r} \right)}} \doteq \frac{{69}}{{r - \frac{{{r^2}}}{2}}} = \frac{{69}}{{r \cdot \left( {1 - \frac{r}{2}} \right)}} \doteq \frac{{69 \cdot \left( {1 + \frac{r}{2}} \right)}}{r}

We can make the error in this equation near zero for interest rates around 8% by substituting 8% in for r in numerator. The numerator function changes more slowly than the denominator function and an approximation is worthwhile there.

N \doteq \frac{{69 \cdot \left( {1 + \frac{{8\% }}{2}} \right)}}{r} = \frac{{72}}{r}

This gives us the Rule of 72 and explains why the error goes to zero for interest rates around 8%.

Posted in Financial, Management | 1 Comment

Estimating Product Cost Part 1

The Problem
I frequently am required to estimate product cost in the middle of some meeting with little or no preparation. As you gain more experience with building product, you soon are able to estimate a product's cost quickly for a production rate you are experienced with. The issue gets more complicated when you are asked to estimate product cost for production rates that you have no experience with. Unfortunately, this situation occurs far more than most engineers would care to admit. The answers are important — I have been working in start-ups where the question of product cost is critical to when you will hit profitability. You need to be able to estimate product cost at various production rates.

My Approach

I really had not thought about this question much until one day I was sitting in yet another vendor' s product cost presentation. During this seemingly endless presentation, there was a table that looked something like this.

Diplexer Cost
Component Cost Versus Volume
Annual Volume Cost
10K $100.00
20K $93.00
40K $86.49
80K $80.44
160K $74.81

This table was unusual because the price breaks occurred at points related by factors of 2. A quick check with my calculator verified that the our component costs would drop by 7% for each doubling of our annual component consumption. As I thought about it, this made sense. Doing a detailed, "bottoms-up" quote requires a lot of work. You must get quotes from all the vendors who make the parts that you must buy at the quantities that you must quote. Most of the time, customers do not end up buying at the rates they want you to estimate costs for. To make things easier, my vendors must be using a simple formula to estimatetheir product costs for the different production rates that customers were requesting. As it was for me, it is hard for them to constantly ask their vendors to quote on quantities that will never be ordered.

This prompted me to try the following cost model for all my components.

{C_N} = {C_R} \cdot {(1 - r)^{lo{g_2}\left( {\frac{N}{R}} \right)}}

Where CN is the component cost at a production rate of N, CR is the reference production rate R (say 10K per year), and r is the discount rate per doubling. In real life, price breaks occur at discrete points. However, a continuous model is useful for cost estimation purposes.

This model almost always worked for component consumption rates less 100K units per year. I found that the discounting rates varied from 5% to 10% per doubling of annual component consumption. I also applied the model to the overall product cost and found that my total unit product cost reduced in cost by an average of 7% for each doubling of annual production rates. I have used this model for the last 10 years with good agreement with reality.

This has proven to be a useful way to estimate how product cost varies with annual production rates. To illustrate how to apply this approach, let's work through an example.

Example

I often tell people that when it comes to manufacturing cost, the manufacturer with the highest production rates wins the game ("he with the most volume wins"). In a recent meeting, I was told that a competitor is reporting similar margins to ours, but his average selling price is 21 % lower than ours. His annual volume is 8x our annual volume (2^3 or 3 doublings). I responded that based on volume alone, our competitor has a 21% cost advantage over us. After discussing the situation for a while, everyone in the room agreed that a product cost advantage of ~20% would explain what we were seeing.

A Competing Model
Armed with my observation, I figured someone else has seen this relationship. I found only one article on the Internet that mentioned that PC costs were seen to drop by 10% for every doubling of volume. So this characteristic has been observed in other markets.

Further research showed me that there was another relationship that was also common. It used the following model.

{C_N} = {C_R}\cdot{\left( {\frac{N}{{{N_R}}}} \right)^q}

Where q is a parameter that varies for each product. This model matches mine in performance exactly. It turns out that we can show that both models are equivalent. I prefer my approach because I can estimate the discount rate by simply estimating the number of doubling over the reference rate and multiplying by 7%.

Equivalence Demonstration

I will begin with the form of the equation that I use and step-by-step get to the alternate form.

{C_N} = {C_1}\cdot{\left( {1 - r} \right)^{lo{g_2}\left( {\frac{N}{R}} \right)}}

{log_2}\left( {{C_N}} \right) = {log_2}\left( {{C_1}} \right) + {log_2}\left( {\frac{N}{R}} \right) \cdot {log_2}\left( {1 - r} \right)

{log_2}\left( {{C_N}} \right) = {log_2}\left( {{C_1}} \right) + \left( {{log_2}\left( N \right) - {log_2}\left( R \right)} \right)\cdot{log_2}\left( {1 - r} \right)

{log_2}\left( {{C_N}} \right) = {log_2}\left( {{C_1}} \right) - {log_2}\left( R \right) \cdot {log_2}\left( {1 - r} \right) + {log_2}\left( N \right)\cdot{log_2}\left( {1 - r} \right)

{C_N} = {\text{ }}\frac{{{C_R}}}{{{R^{{{\log }_2}\left( {1 - r} \right)}}}}\cdot{N^{lo{g_2}\left( {1 - r} \right)}} = {C_1}\cdot{N^q}

The derivation can be reversed to convert the alternate form to my form. Thus, the forms are equivalent.

Extending the Model

I mentioned that this model works for production volumes less than 100K. For higher annual production volumes, the rate of cost reduction reduces. For my products, I have seen the discount rate decrease from the 7% to 2% per doubling on production rates higher than 100K per year. The exact annual production rate and discount rate breakpoints vary by vendor.

Real Component Pricing Example
There is often some strategy used in the pricing of components. Here is a table product pricing table from a vendor that shows a bit of strategy being used. The vendor figured out that my total annual usage of this part was about 100K. He wanted all of our business, so he gave us a quote that was high for annual rates less than 100K but low for rates greater than 100K. Basically, he wanted to ensure that we would be tempted to make him the sole source on this part. Because of this strategy, my pricing function does not apply as well to this situation.

Optical Component Cost
Component Cost Versus Volume
Annual Volume Cost
1K $14.40
10K $13.34
50K $12.56
100K $11.38
250K $11.08
500K $10.68
1000K $10.29

You can see the discontinuity in the cost function on the following chart.
Plot of table data

Posted in Management | Comments Off on Estimating Product Cost Part 1

The Capacitor Puzzle That Got Me My First Job

In the spring of 1979, I was a soon-to-be-graduated electrical engineer that needed a job. As with other young engineers, I started to look for work during my last semester of school and I got a few nibbles. The most intriguing of the nibbles was from Hewlett-Packard, known by all engineers as "HP." At that time, HP was considered a class engineering act and getting a job there would be perfect for someone with plenty of energy but little experience.

The first interview was on campus and was pretty interesting. HP was known for having a tough on-campus interview. They asked tough questions. The questions weren't necessarily technical – most were puzzles. Fortunately, I like puzzles!

The interview went well and they sent me a plane ticket to Ft. Collins, Colorado for an interview. Soon I was out in Colorado. It was the first time I had flown (excluding one quick flight on a Piper Cub when I was 7). It was also the first time I had stayed at a motel without my parents. It was a trip filled with firsts for the kid from small-town USA!

The interview ended up being a grueling six-hour puzzle-solving session. Once I got over my initial jitters, I relaxed and actually enjoyed the experience. It must have gone well because I received a job offer before I left the building.

During my interview, there was one problem that kept coming up. It turned out the problem had been the subject of much discussion within HP. The Fort Collins facility was filled with engineers who loved math puzzles, which made sense when you think about their interview process. If you hire based on the ability of people to work puzzles, you probably end up hiring people who are good at them.

The problem begins with a young engineer being handed a 1 F (Farad) capacitor that is charged to 10 V.

You are handed a 1 F capacitor charged to 10 V and two boxes containing uncharged capacitors: one box contains an uncharged 1 F capacitor and the other contains 1 million 1 µF capacitors. You can connect the capacitors from one box, one at a time, across the charged capacitor. Your job is to determine which box will allow you to discharge the voltage on the charged capacitor the most?

Consider the first box. You can think of a 1 F capacitor as one million 1 µF capacitors in parallel. When this capacitor is connected across the charged capacitor, the final voltage will be 5 V and every capacitor will have the same voltage. The following figure illustrates the situation.

Now consider the box of one million capacitors. The first small capacitor you apply will be charged to nearly 10 V because the capacitor being connected is so small compared to 1 F.We can compute the voltage on the 1 F capacitor using the definition of capacitance. Let {C_1} = 1\;{\text{F}}. We can write the following equations.

{V_i} \cdot {C_1} = {V_{i + 1}} \cdot \left( {{C_1} + {C_2}} \right)

{V_{i + 1}} = {V_i} \cdot \frac{1}{{\frac{{{C_1} + {C_2}}}{{{C_1}}}}} = {V_i} \cdot \frac{1}{{1 + \frac{{{C_2}}}{{{C_1}}}}} = {V_i} \cdot {\left( {1 + \frac{{{C_2}}}{{{C_1}}}} \right)^{ - 1}}

This equation can now be applied one million times to determine the final voltage. Of course, applying this equation one million times means that we will be close to the limit of the following equation. So let's go find the limit.

{V_\infty } = \mathop {\lim }\limits_{\frac{{{C_2}}}{{{C_1}}} \to 0} \quad 10\;{\text{V}} \cdot {\left( {1 + \frac{{{C_2}}}{{{C_1}}}} \right)^{ - \frac{{{C_1}}}{{{C_2}}}}}

To simplify my notation, let n \triangleq \frac{{{C_2}}}{{{C_1}}}. We can then write

{V_\infty } = \mathop {\lim }\limits_{n \to 0} \quad 10\;{\text{V}} \cdot {\left( {1 + \frac{{{C_2}}}{{{C_1}}}} \right)^{ - \frac{1}{n}}}

When I looked at this equation, I realized that this was the equation for continuous compound interest. While in school, I had seen this limit and I was able to write down the answer directly.

{V_\infty } = 10 \cdot {e^{ - 1}} = {\text{3}}{\text{.678796}}

So the answer to the question of whether to choose box one or two was clear ─ choose box 2 with one million 1 µF capacitors. The capacitors will end up charged as shown below.

My interviewer looked stunned. He asked how I knew this and I told him that I had seen the limit before. He looked dismayed and said that he would prefer to see a method that did not require a "miracle" of observation. Our interview time was then over and I had another interviewer to face. Later that day I would receive a job offer and would return to live in Ft. Collins a few months later.

When I arrived in Ft. Collins to start my job, one of my interviewers came up to me and asked if I could come up with a more satisfying solution (i.e. one that did not require identifying the series by inspection).

As I looked at the equation, I told my interviewer that l'Hôpital's rule could probably be applied. My interviewer said that l'Hôpital's rule did not apply to equations of this form. Fortunately, I had recently seen a professor solve a similar problem by applying l'Hôpital's rule's to the logarithm of this equation. It turned out that l'Hôpital's rule could be applied to the logarithm of this equation.

\ln ({V_\infty }) = \ln (10) + \mathop {\lim }\limits_{n \to 0} \left( { - \frac{{\frac{d}{{dn}}\left( {\ln \left( {1 + n} \right)} \right)}}{{\frac{d}{{dn}}\left( n \right)}}} \right)

\ln ({V_\infty }) = \ln (10) + \mathop {\lim }\limits_{n \to 0} \left( { - \frac{{\frac{1}{{1 + n}}}}{1}} \right)= \ln (10)-1

{V_\infty } = 10 \cdot {e^{ - 1}} = {\text{3}}{\text{.678796}}

The interviewer looked at me with both happiness and dismay. He said that he had been working for months off and on trying to analytically come up with the limit. He also mentioned that my puzzle-solving ability was what motivated them to hire me.

Ever since then, I have fondly thought of this math puzzle. It is hard to believe that it got me my first real job!

Posted in Interviewing, Problems | Tagged , , , | 20 Comments