Sunday, February 26, 2023

The Egg Sandwich Problem, Part II: The Proof

So, we've got an egg sandwich that we're trying to split up into four equal pieces, and the pesky yolk is off-center. We've already figured out how to make the first cut, right along the line that connects the centers of the circles, and the third cut, which is just going to be the same as the second cut - assuming we can find one. The sandwich is definitely cold by now, but let's forge ahead and figure out the second cut. 

My intuition says that there's a way to make one straight diagonal cut through the semicircle of sandwich that will divide both the sandwich and the yolk in two. My reasoning is a bit involved, but let's walk through it in three steps.

Step 1: Forget the yolk, and imagine some ways we could cut the half sandwich in half. We could cut it straight down the middle, and make two quarter-circles. We could cut it lengthwise - that's a bit trickier, because it's hard to tell where exactly to cut it without doing some measuring, but it is possible to get two equal pieces that way. Or, we could cut it at any random angle.




Side Note: It's not super obvious, but it is actually possible to cut any two-dimensional shape in half... at any given angle. I best visualize this when thinking of waving a knife over a piece of cake. Close your eyes and keep your hand steady and maintain the same angle as you pass over the cake. When you've just started, there's more cake on one side of the knife than the other. When you're almost done, it's reversed - the other side has more cake on it. So, at some point during that wave, the amount of cake on both sides of the knife were equal. It's not always easy to find where to stop and cut, but this thought experiment proves that there always is a place to stop.

This key mathematical concept definitely has a name, but I'm going to call it "The Fair Halves Principle". I reserve the right to change that name to something more catchy / appropriate if I think of something better. Okay, so ignoring the yolk, we can divide the sandwich in half in many ways with many angles of cutting!

Now, Step 2: Add the yolk back in, and apply the Fair Halves Principle on the turning knife.

Here's an animation illustrating this. Each of these cuts divides the sandwich in half, and the angle's changing smoothly. (They all hit the centroid of the semicircle, but that's a story for another time.) 




Looking closely, you can see that at the beginning of the animation, there's more yolk on the right/bottom side of the line. At the end, there's more yolk on the left/top side. Because it's a continuous change, we know that at some point, the side that has the most yolk changes from right to left... and exactly at that point, the yolk on both sides must be equal. So, we've proven that there is some cut we can make that will divide both the sandwich and the yolk equally.

But wait a minute, you might be saying. That rotating line only applies when we throw out the yolk! Step 1 relies on the simplicity of the semicircle without having to worry about the yolk. And that's true, so the rotating line above isn't valid for the sandwich + yolk. But here's where Step 3 comes in!

Step 3: at that point we determined in Step 2, where there must exist a line where the yolk is evenly divided, we know two things about that split. One, the yolk on both sides is the same - this is the result of the Fair Halves Principle and Step 2. Two, the halves of the semicircle on both sides is the same - this is the result of the Fair Halves Principle and Step 1. Put them together, and we see that the purple areas (with sandwich and no egg yolk) also must be the same! If the "total sandwich area" and the "yolk area" is the same on both sides of the line, then "the total sandwich area minus the yolk area" must also be the same!

Therefore, we've proven that there exists a line that will work - a cut that will equally divide the yolk and the sandwich. The interesting theoretical work is done; now, we have to actually do the calculations and find the answer so we can eat breakfast!

Saturday, January 14, 2023

The Egg Sandwich Problem, I

Sometimes, a problem is so interesting that I can’t help but drop everything to think about it. That was what happened at breakfast a few days ago, when my family and I were trying to making egg sandwiches, consisting of a fried over easy egg, a piece of cheese, and a Panera bagel. There’s four of us, and due to a kind Panera employee, there was an extra bagel. (Yes, I in particular made the judgement call that a Panera bagel was worth it, but it was better to make the sandwich part at home rather than paying the premium.)

So, we made the extra sandwich, and went to divide it equally. It’s pretty easy to split a round sandwich – just cut it in half along a diameter, and then in half again with the perpendicular diameter.

But there was a problem: the yolk on the fried egg was off-center, like yolks always are. Splitting the sandwich in the usual way would result in an unfair split of the yolk.

And it was at this point that I abandoned the idea of eating breakfast and went to find some paper.

So, here’s the problem. Given an egg sandwich, with the yolk off-center, is it possible to divide the sandwich into four equal pieces so that everyone gets the same amount of sandwich and the same amount of yolk?

Let’s start with some assumptions.

Bagels are round, so we can approximate the sandwich itself as a perfect circle. The bagel we were working with didn’t have a hole in the center (thank Panera’s Asiago bagel design for that simplification), so we don’t have to worry about that, either. 

Fried eggs aren’t usually round, but the pan we used to fry them in is tiny and made specifically for frying a single egg at a time, so we can approximate the egg as a perfect circle. 

The fried egg is about the same size as the bagel, so we can assume that they are perfectly aligned and the same shape and size. 

The yolk of an egg is more or less a perfect sphere, and in a fried over easy egg, we can disregard the dome shape of the cooked yolk and approximate it as a circle. Notably, this circle is smaller than the circle of cooked egg white, and it’s also fully contained within the circle. 

There’s a subtler assumption here about the size of the yolk compared to the egg, but I don’t know how to formalize it yet. 

The yolk of a fried egg is not necessarily in the center of the egg. If it were, this problem would be trivial. 

The cheese we used was a square of sharp cheddar, and I’m going to disregard it completely – we’re only optimizing for equal amounts of egg, bagel, and yolk.

 

Now, we move to intuition. My intuition says that to divide this into four pieces, the case with which I found this presented, it’ll be easier to divide the sandwich into two equal pieces and subdivide the equal pieces. We can exploit the symmetry of the diagram for this – if a circle is contained inside another circle, and they’re not necessarily concentric, you can draw a line between their centers to find an axis of symmetry for the combined shape. In this way, if we’re cutting this up for four people, we get a “free” first cut – no matter where the yolk is, we’re guaranteed to be able to make this cut.

And now that we have two identical pieces, and one cut already made, you can see that the third cut is also made for us. If we find a way to divide one of the pieces equally, we can just repeat that cut on the other piece, and we’ll have four equal pieces!

Now, the second cut is the hard part. How can we make a cut that divides both the sandwich and yolk equally? Is such a cut possible for any possible position that the yolk can be in? We’ll have to delve into that next time, because there’s a fancy animation I’m trying to make that is taking forever. Hopefully it ends up working and you can see it next time!

Tuesday, July 26, 2022

Birthday Puzzle 2022!

It's time for another birthday puzzle! This year, my birthday puzzle was CLASSIFIED. I've never done anything like that before, so it had a lot of puzzle ideas that had been building up in me for a while!

But, I couldn't resist also making something smaller in scope but wider in audience for a birthday puzzle. It's definitely simpler than many of its predecessors, but I enjoyed creating it all the same. I hope you enjoy solving it!




Sunday, May 1, 2022

Sequence Differences (Diffsy Qs I)

 Years and years ago, back in my old Math League days, I came up with a trick to finding out the formulas of sequences. The problem type I'm talking about would give me a list of Xs and Ys in a table like this:

Wait, I need HTML for tables? Wow, okay.

X 1 2 3 4 5
Y 4 8 14 22 32

Oh my god, I thought I hated tables when I only knew of how awful they were in the context of word processors. HTML tables are so much worse.

Anyways, the problems would have a table like the one above and ask for the equation that generated those values, usually in the form of y = f(x). There aren't any convenient algorithms for this, so usually the student is expected to graph it, determine if it's a line or parabola, and use the appropriate equations. 

This problem is actually one of the few interesting math problems that a student might see in school. I categorize a lot of math taught in schools as a three step process: 

1. Remember the formula or algorithm that applies to this problem.

2. Apply the formula or algorithm and follow the steps.

3. Write down the result.

This problem gets an additional step; an analysis of the results, as simple as it may be. 

1. Remember the formula or algorithm that applies to this problem (Hm, when the problem looks like this, I have to graph the points on a Cartesian plane)

2. Apply the formula or algorithm and follow the steps. (Actually graph each point)

3. Analyze the results. (Check if the graphed points follow a line or a parabola)

4. Remember the formula or algorithm that applies to this problem (Remember the appropriate formulas for your graph)

5. Apply the formula or algorithm and follow the steps. (Use the appropriate formulas / plug 'n chug)

6. Write down the result (The formulas spit out this number for the slope and this number for the y-intercept, so I can put them in place of the m and the b and write down the equation)

Yeah, that additional analysis step is very simple, but it's one of two examples that come to mind in the math I learned as a kid that weren't completely algorithmic. (The other is triangle congruence, which was always a favorite of mine!) 

This analysis step is something I loved back then, because I could get around it with some thinking. Why bother graphing out all those points when you can just intuitively figure out whether the points will make a line or a parabola? (Well, because the teacher's going to take points away for not showing your work, that's why.)

So, how do you figure out whether it's a line or a parabola without graphing it? I came up with a method that I'm now going to retroactively call "Sequence Differences". I called them "subsequences" back then, but it turns out that that term is protected. I subtracted adjacent y values from each other to make a new sequence that had one fewer term. Let's see if I can get a table to illustrate that:

X 1 2 3 4 5
Y1 4 8 14 22 32
Y2 4 6 8 10

Eh, close enough. As you can see, the Y2 sequence comes from 8 - 4, 14 - 8, 22 - 14, and 32 - 22. Upon seeing this, I thought "these numbers are all different, and lines have a constant slope, so it must be a parabola!" and went on to the next part of the problem. But isn't it interesting that the numbers are increasing in an arithmetic sequence? If I were to do another round of sequence differences here, 

X 1 2 3 4 5
Y1 4 8 14 22 32
Y2 4 6 8 10
Y3 2 2 2

we can see that the sequence is constant. Somehow, every time I performed a sequence difference, I decremented the degree of the source equation. The first equation was y = x2 + x +2; the second can be solved to be y = 2x + 2, and the last is just y = 2. Looks... a bit familiar, doesn't it? The constant isn't the same, but it looks almost like we're taking the derivative to find the equations that describe our new sequences. There's a mystery there!

But, that's probably plenty for one day; it's definitely enough HTML tables for one day. All that remains is a name, and I think I've got a good one. Differential Equations are often abbreviated to Diff Eq, pronounced "Diffy Q", and this problem is about Differences (of) Sequences, so let's go with the almost cringeworthy Diffsy Q. Next time, a deep dive into the mechanics of Diffsy Qs!