Learn to love the struggle — if you can’t enjoy the pains of programming, you’re going to face all the more difficulties when you advance to complex problems.

— Joe Previte on learning to program. His statement is true for most other difficult human activities as well.

Figure 1: Wyoming Dominates US Coal Production.

I have been listening to politicians discussing US energy policy the last few days. Very few facts were presented during these discussions, but one politician did casually mentioned that Wyoming produces more coal than the next six states combined. I did not know that Wyoming was such a dominating coal producer, and I began to look at how to fact check this statement. Fortunately, the US Energy Information Administration (EIA) has all the data readily available from this web page.

I downloaded the US coal production data from the EIA web page, processed it using Power Query, and created Table 1. I was able to confirm that Wyoming's coal production exceeds the total output of the next six largest coal coal producing states. For those who are interested, here is my Excel workbook.

Having proper motivation and honesty are the keys to overcoming fear or anxiety. Fearless and honest self-appraisal can be a powerful weapon against self-doubt or low self-confidence.

— Dalai Lama

Introduction

Figure 1: Resistance Variation with Temperature of a Real "Linear" Temperature Coefficient Resistor.

Our products contain many analog circuits, and these circuits often require temperature compensation in order to meet their requirements across the product's entire temperature range. To perform this compensation, we often use resistors with a specified Temperature Coefficients of Resistance (TCR). A vendor recently stopped manufacturing one of the resistors we use for temperature compensation, and we needed to find a substitute. While searching for a substitute resistor, I needed to understand just how linear the approved resistor's temperature variation is so I can find an appropriate substitute.

Unfortunately, the original designer (gone for over ten years) used a TCR for which the vendor supported but had not published resistance versus temperature curves. The vendor did provide resistance curves for three similar temperature coefficients, which allows me to use interpolation to estimate the curves for the value we are using. Of course, I am requesting that the vendor send me the correct curve. In the meantime, I am just going to interpolate between the specified curves for a preliminary result.

Figure 1 shows my plot of:

resistance versus temperature curves for two different TCRs (3900 ppm/°C and 1500 ppm/°C)

my interpolated resistance versus temperature curve for a TCR of 3300 ppm/°C.

You can see that there is a small error between the linear ideal and reality. I need to find a substitute part with a similar level of nonlinearity. This post is about viewing the nonlinearity – selecting the substitute part is another matter.

Background

Model for Resistance Variation with Temperature

Equation 1 shows the formula for the variation in resistance for a linear temperature coefficient (i.e. constant TCR) resistor.

Eq. 1

where

R(T) is the resistor's resistance at a temperature of T.

R_{ref} is the resistor's resistance at a temperature of T_{ref}.

T_{ref} is temperature at which the resistor's nominal resistance is specified.

α is the resistor's TCR.

In Figure 1, I used Equation 1 as my ideal temperature function.

Approach

My analysis approach is simple:

Digitize the vendor's three resistance plots (TCRs = 1550, 2700, and 3900 ppm/°C) using Dagra.

Perform a two-dimensional interpolation to estimate the response for a TCR = 3300 ppm/°C.

Plot both the ideal and the interpolated responses for a visual comparison of the level of nonlinearity.

Analysis

The analysis was performed in Mathcad and is best viewed either in the Mathcad source or viewing the PDF, both of which are included here.

Conclusion

I am surprised at the typical level of nonlinearity that I am seeing for these resistors. I have always thought that the temperature coefficient for these devices would be a constant, but there is a significant nonlinear component.

Good programmers comment their code. Great programmers tell you why a particular implementation was chosen. Master programmers tell you why other implementations were not chosen.

— I saw this rule of thumb for commenting code on Stack Overflow. This statement made me think hard about how I comment my code. I see so many comments that tell me what the code is doing and not why – I never seem to have enough why information.

Figure 1: Edward Teller, Father of the American H-Bomb. (Source}

I have been reading the book Building the H Bomb: A Personal History by Ken Ford. A major character in the book is Edward Teller, a very famous physicist who is best known as the father of the American H-bomb. I had to smile as I read about Edward Teller. When I worked at Hewlett-Packard, an electrical engineer named Russ Price talked about interviewing for a job at Lawrence Livermore National Laboratory, where he walked into a room and faced Edward Teller as his interviewer. He and Dr. Teller then proceeded to have a very technical interview.

Russ was not familiar with Teller's background, which was probably a good thing. Russ said the interview was pretty tough, but he had nothing but nice things to say about Dr. Teller. He did mention being asked to work a problem about modeling the behavior of a pencil standing on its tip, which he did not know how to solve. Russ also commented that Dr. Teller was very quick and very smart. Unfortunately, Russ did not get the job.

I think I would have turned into a babbling idiot upon seeing him – good thing Russ did not know who Dr. Teller was until after the interview was over.

You have not yet begun to consider what sorts of people are these Athenians whom you may have to fight.

— Thucydides, describing a statement by an ambassador from Corinth who was speaking to the Spartan Assembly. The Spartans were bent on war. This quote is similar to Yamamoto's often cited (but unconfirmed) warning to the Japanese government about going to war with the United States.

I have been reading about the US Air Force's battle to retire the A-10 Warthog (Figure 1). The USAF has never cared for the A-10 and has made a number of attempts to replace it with either the F-16 or the F-35. During my reading, I saw the following statement about the recoil of its 30 mm Gatling gun, and the impact of this recoil on the A-10's speed.

The average recoil force of the GAU-8/A is 10,000 pounds-force (45 kN), which is slightly more than the output of one of the A-10's two TF34 engines (9,065 lbf / 40.3 kN each). While this recoil force is significant, in practice a cannon fire burst only slows the aircraft a few miles per hour in level flight.

In this post, I will examine these two statements mathematically to determine if I understand them.

Background

Key Performance Parameters

Figure 2 shows the GAU-8 data as stated on the General Dynamics web page.

Figure 3: Three Types of 30 mm GAU-8 Rounds. (Source)

Figure 3 shows the GAU-8's 30 mm projectile. For this exercise, I will assume the projectile has the following characteristics:

Projectile velocity: v_{Muzzle} = 3400 feet per second (fps)

Projectile mass: m_{GAU8} = 395 grams

Rate of fire: r = 6000 round per minute

The GAU-8 can be programmed for different rates of fire. I will assume a 6000 rounds per minute for the maximum rate of fire, which will generate the maximum recoil. I will also assume that the gun is fired in burst of 100 rounds, a number that I am guessing based on the ammunition capacity of 511 rounds. Effectively, I am assuming that the gun only has five bursts available.

To estimate the impact of firing the GAU-8 on the speed of the A-10, I will assume that the A-10 weighs 51,000 pounds, which is its listed maximum takeoff weight.

Analysis

Shortcomings of this Analysis

No explosion-driven device is 100% efficient at converting chemical energy into projectile energy. In the case of gun, it is common to assume that as much as 20% of available powder energy goes into the gases that escape from the end of the barrel. I do not know the impact of this gas discharge on the overall recoil for a GAU-8, but it is significant. I will ignore this escaping gas in my analysis below, which means that my calculations provide a lower bound on the recoil of this weapon.

In reality, recoil can only be accurately estimated with detailed knowledge of the gas discharge characteristics.

Recoil Analysis

Figure 4 shows how to estimate the amount of recoil by assume that recoil is do to the change in momentum caused by the opposing momentum of the fired projectiles. Note that this estimate ignores the momentum of the expelled gases.

Figure 4: Recoil Calculation.

We see that the recoil must be greater than 9,200 pounds, which means that the stated recoil force of 10,000 pounds is reasonable.

Impact on A-10 Speed

Figure 5 shows how you can estimate the reduction in the aircraft's speed caused by the firing of the GAU-8. I calculate that the impact of the GAU-8 on the A-10's speed is ~4 miles per hours, which roughly agrees with the statement quoted in this post's introduction, i.e. a few miles per hour.

Figure 5: Impact of GAU-8 Firing on A-10 Velocity.

Conclusion

The fact that the GAU-8 has ~5 tons of recoil force is amazing. It is hard to believe a weapon like that can be mounted on an aircraft.

As I worked on this problem, I recalled a Woody Woodpecker cartoon within the movie Destination Moon that illustrated how a firing a rifle can generate thrust.

Figure 6: Woody Woodpecker Explains Newton's Third Law.

If physics was about proofs, von Neumann would be a pretty good physicist.

— Wolfgang Pauli, after reading a rigorous mathematical proof about some aspect of quantum mechanics by John von Neumann.

Figure 1: Chart of Eagle Lake Level Relative to Sea Level. The Ordinary High-Water Mark (OHWM) is the level used by the State of Minnesota for determining how far away buildings must be placed from the water.

My wife and I are building a vacation home on the shores of Eagle Lake in Itasca County, Minnesota. We also are active members of the local lake association, which is a group of homeowners who work on projects to keep our lake healthy. One task I perform on a yearly basis for the lake association is to draw a graph of how our lake level is varying over time (Figure 1). The lake level is important to homeowners because it affects the amount of beach that is exposed and the length of their docks.

Figure 1 shows how our lake level has varied since 2001. The peaks correspond to recent heavy rains. The low points tend to corresponds to times when a beaver dam at the lake outflow fails, releasing water, and causing a quick reduction in lake level. In general, the beavers perform excellent maintenance on their dams, but trappers occasionally remove the beavers, and then the beaver dams fall into disrepair until a new beaver pair arrives. No lake level measurements are taken during the winter because the lake is frozen and covered in snow. I indicate winter in Figure 1 with a snowflake symbol.

I attach my spreadsheet here for those who are interested in how this chart is obtain the lake level information. Power Query is used to grab the data from the State of Minnesota and clean the data up for graphing. I use standard Excel commands for plotting the data.

The Hemingway we are talking about did not choose his death.

— Orson Welles, talking about Ernest Hemingway and how he suffered near the end of his life. Hemingway was not the same man at the end of his life that Welles had known earlier.

Introduction

Figure 1: Histogram of Sugar-to-Flour Mass Ratios in 62 Cake Recipes.

I have been working at becoming a better baker. Specifically, I have been trying to understand how recipes are developed. Many baker's begin developing their recipe's based on ratios of ingredients. The classic rule ratio of thumb for cake recipes is to use equal masses of flour, sugar, butter, and eggs – with the ingredient ratios expressed as 1:1:1:1.

I recently noticed that many of the recipes that I have been using do not follow this rule of thumb. I was most curious about how the ratio of sugar-to-flour varied between recipes. I found a text database of cake recipes and decide to create a histogram that shows how the sugar-to-flour mass ratio varies.

Background

Flour and Sugar Densities

Recipes in the US tend to use volume measures like cups rather than mass measures. To convert these volume measures to masses, I needed to determine the densities of flour and sugar in terms of cups (Figure 2).

Figure 2: Computing the Density Ratio of Sugar-to-Flour.

Confounding Issues

Cake recipes frequently contain ingredients that affect the amount of flour or sugar required. Example of these confounding ingredients include:

Also, the recipes sometimes call out sifted flour, which has a lower density than unsifted flour. For my analysis here, I am ignoring confounding ingredients and just looking at the ingredients labeled sugar and flour (granulated or brown) and taking their mass ratios.

Analysis

My analysis was performed using Excel and Power Query. I have included my analysis and data here. I did not use every recipe in the text database because many recipes had obvious confounding sources of sugar. For example, some recipes had large amounts of sugar added in the form of juices and fruits. I flagged the recipes I used by prefixing their names and their flour and sugar ingredients with "@" symbols. This made it simple to extract the information that I needed.

Once I had extracted the ingredients, I then determined the volume ratios and converted the volume ratios to mass ratios using the densities of flour and sugar.

Conclusion

The 1:1 mass ratio between flour and sugar appears to be violated frequently. In fact, the 1:1 volume ratio between flour and sugar is more common than the 1:1 mass ratio.

First forget inspiration. Habit is more dependable. Habit will sustain you whether you’re inspired or not.

— Octavia Butler. It is very important to cultivate habits that promote excellence. Jack London used to say that "You can't wait for inspiration, you have to go after it with a club." I believe that as well. I often find that inspiration comes in the quiet times that occur after I have laid siege to a problem for a while.

Introduction

Figure 1: Illustration of the Manufacturing Situation.

I recently was asked to provide a recommendation on how to schedule the operating time for three different machines that were producing three different products. This is not a made up problem, but reflects a real production situation. My solution uses Excel's Solver and its linear programming-based optimization routine to find an optimal machine scheduling plan. The solution I provided has proven to be useful to the folks who asked for it, and I thought it was worth sharing my solution here.

I should mention that the model I am showing here is only the first-round of my modeling effort. I am continuing to work with the group that is responsible for this manufacturing effort to create a more detailed model of their manufacturing process. The effort has been very interesting and has provided much insight into their manufacturing process.

For privacy reasons, I have normalized all product costs and have changed all the default values from their true values.

Problem Description

Figure 1 shows a high-level illustration of the manufacturing situation. The following list defines the problem and its constraints:

There are three machines called 1, 2, and 3.

There are three products being manufactured called A, B, and C.

Each product has a different unit market value.

We will be be optimizing the total product value produced by these three machines each month.

Machine 1 can only produce product A.

Machine 2 can only produce product A.

Machine 3 can produce either product B or C.

Machine's 1 and 3 share the same electrical supply and only one of these machines can be run at a time. I should mention that these machines are enormous, in a remote location, and take a considerable amount of power. Upgrading the electrical service is prohibitively expensive.

Machine 3 requires time to switch from producing B to C and vice-versa. I will not be modeling this loss of production – I will include switch-over time in a later model. I needed to get an initial solution out immediately.

There are production contracts that mandate that a minimum number of A, B, and C products must be manufactured each month.

The machines have a certain amount of downtime that is related to their hours of operation. I have modeled these maintenance operations as a loss of efficiency.

Analysis

I am not going to go through the details of the spreadsheet here in text – I recommend you just look at the spreadsheet itself. Here are its critical features:

The spreadsheet uses simple VBA macros to select canned scenarios and run the solver.

I have defined four scenarios that you can select using radio buttons.

You can change the inputs to whatever you want and click the solve button to generate a custom solution.

Every boy in the streets of Göttingen knows more about 4-dimensional geometry than Einstein.

— David Hilbert, a first-class mathematician in competition with Einstein for developing general relativity. The boys in Göttingen sound pretty impressive to me.

Figure 1: Salt Boats Being Used to Carry Tourists. (Wikipedia)

I just came back from a business trip to Aveiro, Portugal. What a beautiful place! It is a very vibrant university town that lies about 6 km from the ocean. It is known as the "Venice of Portugal" because of its system of canals, which is a legacy of the old days when Aveiro was a major source of sea salt for the region (Figure 1). The climate is warm, with a very substantial breeze that blows out toward the Atlantic ocean. I liked my visit so much that I plan on bringing my wife on a future trip.

I was in Portugal visiting the University of Aveiro, which is an exciting place with much engineering activity. Portugal is working hard to develop a high-tech industrial base. They have some excellent electronics and optics design capability at the university and are performing some very high tech manufacturing at local commercial firms. These manufacturing firms also have a significant capability for servicing electronic products that are returned by customers. As you might expect, these manufacturers are located near the university – you see the same symbiotic relationship between schools and industry throughout the US. I was quite impressed.

As an amateur builder, I always look closely at how construction practices differ around the world. One novel aspect of Portuguese construction is Portuguese pavement, a type of stone pavement into which decorative patterns or symbols are inlaid (Figure 2). Most of patterns I saw were very artistic, e.g. wave patterns or stain glass-like figures, but one inlay in Aveiro of an NPN transistor symbol shows that not all patterns are artistic (Figure 3). I spent a few minutes watching some workers repair a damaged inlay – the work required a tremendous amount of labor and artistic talent. We do not have that kind of patience in the US.

Figure 4: Movie Poster for The Miracle of Our Lady of Fatima. (Wikipedia)

While driving to Aveiro from Lisbon, I passed the city of Fatima. As a lapsed Catholic, this name is very familiar to me. I vividly recall from my youth watching the movie The Miracle of Our Lady of Fatima (Figure 4). I found the story very compelling as a child, and I was not going to pass up an opportunity to visit the site.

I must admit that I was stunned when I arrived at the Sanctuary of Fatima – it was huge. The place was a beehive of activity because Pope Francis was going to visit the site for the 100^{th} anniversary of the miracle (13-May-2017). This was making visiting the shrine expensive for the pilgrims coming to the site. I was told that during the Pope's visit, cots were renting for 1000 € per night – that is a huge sum for anyone and especially for Portugal. I really enjoyed my visit there, and I highly recommend it for anyone who happens to be in the area.

Figure 5 shows a panoramic view of the Sanctuary of Fatima. The scale of the site was incredible.

This is not a peace. It is an armistice for twenty years.

— Ferdinand Foch on WW1's Treaty of Versailles in 1919. He proved to be prophetic, with WW2 starting almost twenty years to the day after he made this statement.

Introduction

Figure 1: My Proposed Differential Termination Network. It is drawn in LTSpice. In a later post, I will discuss how to use LTSpice to solve this problem.

An engineer asked me for assistance on determining the termination circuit for a Xilinx uG476 series 7 FPGA. The circuit works is slightly different manner than those termination circuits I have developed before (here and here) because there is not termination voltage, so I thought I should document my work here in detail. I will be using Mathcad 15 to determining the optimal resistor values for (1) terminating the circuit in printed circuit board's characteristic impedance (Z_{0}), and (2) ensuring that I preserve as much of the transmit signal level as possible without exceeding the input circuit's maximum voltage level.

This is a classic optimization problem that engineers must solve on a regular basis. I have been working on many of these problems lately, including a factory optimization problem that I will be documenting in a future post.

For those who are interested, my Mathcad source is here.

Background

Definitions

Common-Mode Voltage (V_{A} and V_{B})

This is the DC level of the differential signal. In the circuit of Figure 1, there are two common-mode voltage requirements that must be met: (1) the open-circuit output voltage for the transmitter (V_{A}), and (2) the open-circuit voltage for the receiver (V_{B}).

Characteristic Impedance (Z_{0})

For the low-loss case we have here, the characteristic impedance is the resistive value that represents the effective resistance of an infinitely long transmission line.

Gain (G)

Really, this is an attenuation factor between the differential signal (represented by V_{3} and V_{4} in Figure 1, and the signal across the termination resistors, R_{5} and R_{6}. Xilinx refers to this parameter as "Gain," and I will use their nomenclature.

Requirements

The requirements are simple:

V_{A}= 1.3 V (specified by Xilinx)

V_{B} = 0.8 V (specified by Xilinx)

R_{5}, R_{6} = 50 Ω (inside the FPGA and specified by Xilinx)

Figure 2 shows how I derived the formulas for the resistor values required to meet the Z_{0} and common-mode voltage values, which are met exactly by these formulas.

Figure 2: Derivation of Resistance Formulas.

Solution for Resistance Values

Figure 3 shows how I used Mathcad's maximize routine to determine the optimal resistor values. I chose the resistor values to find the largest gain consistent with the gain range limits.

Figure 3: Determine the Optimum Solution.

This solution shows that R_{2} is large relative to the other resistors and can be replaced by an open circuit.

Solution for Resistance Values

Figure 4 shows how I converted the computed resistor values to standard resistor values. I also verified that my solution is still valid using standard resistor values (see Appendix B).

Figure 4: Compute Standard Resistance Values and Double Check the Solution Still Works.

As mentioned above, R_{2} is so large relative to the other resistances that it can be replaced by an open circuit. All requirements are met by the computed resistance values.

Conclusion

I was able to derive the required resistor values to meet the requirements that Xilinx imposed on the termination. This circuit will be used for terminating electronics within a high-speed fiber optic product.

P.S.

I have been working in Aveiro, Portugal for the last week. The circuit was tested in my absence and worked.

Appendix A: Gain Requirements.

Figure 5 shows how Xilinx derived the gain requirements here.

Figure 5: Derivation of Gain Margin Min and Max

Appendix B: Determining Closest Standard Resistor Value.

Figure 6 shows my routine for determining the closest standard resistor value to the computed resistor value.

Figure 6: Determining Closest Standard Resistor Value.

The best of ideas is hurt by uncritical acceptance and thrives on critical examination.

— George Polya, mathematician

Figure 1: Locations of 2-Person Naked and Afraid Episodes.

I have been receiving quite a few questions about my database of Naked and Afraid information. I only track the shows with 2-person teams – I am not a big fan of the XL episodes. There recently has been a number of shows where women have been particularly strong leaders and finishers, and some big, tough-looking men struggled right from the start and failed to complete the challenge. In response to some of the recent shows, a number of people have asked "Who taps out more – men or women?" So I have updated my Excel Workbook with the data from recent episodes and went to work. I have also updated Figure 1, which shows where the episodes were filmed.

I filtered my database for episodes where a woman finished and a man did not, or vice versa. This process generated a list of solo finishers and the number of days they were solo (Figure 2). Seventeen people finished the challenge alone, 9 men and 8 women.

Figure 2: List of Solo Finishers and the Number of Days Solo.

Figure 3 shows the summary statistics for the solo finishers. While there have been some strong female solo finishers lately, overall men and women have had similar solo performances, at least with respect to the average days solo and the number of solo finishers.

Figure 3: Summary Statistics of Solo Finishers.

I am seeing a pattern in how men tap out that I do want to explore, but I am not certain how to obtain the data to prove it. It seems that the big, muscular men do not do as well as the smaller, wiry men. I do not have data on the size of the men, so I cannot perform this analysis right now – I am thinking about how to gather that data.

All content provided on the mathscinotes.com blog is for informational purposes only. The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site.
The owner of mathscinotes.com will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of this information.