Entry tags:
A holiday math puzzle
Well, OK, it's not particularly holiday-themed, but it came up two days before Thanksgiving, so...
Suppose (hypothetically) you were decommissioning a somewhat ragged queen-sized foam mattress topper, and it occurred to you that rather than throwing it all away, you could cut some pads out of it for your circular dog beds. You might spread it out on the kitchen floor (the largest unobstructed area of floor in the house), then put a dog bed on top of it to trace the right size and shape. Unfortunately, it's obvious that you won't get two circles the size of this dog bed from one mattress topper. So how much smaller do they need to be?

Since the circles are as symmetrical as a shape can be, and the two of them are to be congruent, and the rectangular mattress topper is pretty symmetrical too, it seems reasonable to assume that the cutting layout will be symmetrical too. Which means we can simplify the problem to "how large a circle can be inscribed in a given right triangle?" That should be straightforward.

No, wait: that's actually too restrictive. We might be able to get slightly larger circles if each one laps slightly over the rectangle's diagonal. In this diagram, I labelled the height (h) and width (w) of the rectangle, the radius (r) of each circle, the angle (θ) between the horizontal axis and the line between the circles' centers, and the angle (α) between the horizontal and the main diagonal of the rectangle.
Conveniently, θ = α, so this should be easy. Wait... why does θ have to be the same as α? Imagine a really tall rectangle, with h > 2w; then the largest circles you can fit are simply determined by the width, they don't even need to touch one another, and the line between their centers is vertical. Yet the main diagonal is most definitely not vertical. Furthermore, if h is slightly less than 2w, the line between the circles' centers will be almost vertical, while the main diagonal is quite far from vertical. So θ ≠ α in general. Oh, well, that would have been nice, but....
We're trying to find the θ that gives us the largest possible r. Sounds like a classic first-term-calculus problem: write r as a function of θ (treating h and w as constants), take a derivative with respect to θ, set it equal to zero, solve for θ, then plug into the original formula and get the resulting value of r.
The point where the two circles touch, by the symmetry of the whole problem, has to be the midpoint of the rectangle, h/2 away from top and bottom and w/2 away from left and right sides. So r + r*sin(θ) = h/2, while r + r*cos(θ) = w/2. We can easily isolate r on one side of each equation:
r = w/(2 * (1+cos(θ)))
r = h/(2 * (1+sin(θ)))
So we have not one, but two formulae for r in terms of θ. That's a little weird, but OK, let's differentiate them. Quotient rule... ho-d-hi minus hi-d-ho over ho-ho, right?
From the "horizontal" formula we get
dr/dθ = -2w(-sin(θ)) / 4(1+cos(θ))2 = w sin(θ) / 2(1+cos(θ))2
which is zero only when θ = 0, π, 2π, etc.
From the "vertical" formula we get
dr/dθ = -2w(cos(θ)) / 4(1+sin(θ))2 = - w sin(θ) / 2(1+sin(θ))2
which is zero only when θ = π/2, 3π/2, 5π/2, etc.
Umm... our two formulae contradict one another. Each one says it can maximize r at a place where the other says it can't. And it feels like they ought to be working together somehow, not at cross purposes.
Maybe I'm making this much too hard. Maybe we don't need calculus or trigonometry at all, just high school algebra.
The center of a circle is at coordinates (r, r) because it's distance r from both the bottom and a side (I don't really care whether it's the left or right side). The center of the rectangle is at coordinates (w/2, h/2). And if the two circles are touching, it'll be at the center of the rectangle, which means that point is distance r away from both centers. Which means
(r-w/2)2 + (r-h/2)2 = r2
r2 - rw + w2/4 + r2 - rh + h2/4 = r2
r2 - r(w+h) + (w2 + h2)/4 = 0
which we can solve with the quadratic formula:
r = ((w+h) ± sqrt((w+h)2 - w2 - h2))) / 2
r = ((w+h) ± sqrt(2wh)) / 2
r = (w+h)/2 ± sqrt(wh) / sqrt(2)
Does this make any sense? Let's plug in the simple, known case of h=2w, where r should come out exactly w/2.
The formula says r = (w+h)/2 ± sqrt(wh)/sqrt(2) = 3w/2 ± sqrt(2w2)/sqrt(2) = 3w/2 ± w
and indeed one of the values comes out w/2. (The other is 5w/2, which makes the circles much larger than the rectangle we started with, and the centers would both be outside the rectangle. Not sure whether this solution means anything at all.)
A more interesting special case is a square, in which we can't do the overlapping-the-diagonal thing: both circles do have to be entirely within their right-triangle half of the square. But the circles don't have to be entirely within a quadrant of the square; they can lap over a little in both vertical and horizontal dimensions, as long as they don't cross the diagonal. Since w = h, the formula says
r = w ± sqrt(w2)/sqrt(2) = w ± w/sqrt(2)
Again, the "plus" case of the ± is a spurious solution, going outside the rectangle, but what about w - w/sqrt(2)? Is that plausible?
Back when I was talking about θ, I wrote down that r + r*sin(θ) = w/2, and that should still be true. In this case θ = π/4, whose sine and cosine are both 1/sqrt(2). So let's plug in this solution.
r + r*sin(θ) = r * (1 + 1/sqrt(2)) = w * (1 - 1/sqrt(2)) * (1 + 1/sqrt(2)) = w * (1 - 1/2) = w/2
Hooray!
Now, what about a queen-sized mattress (topper)? The Intarwebz says a queen-sized mattress is 60" x 80", so let's plug that in.
r = (w+h)/2 ± sqrt(wh) / sqrt(2)
= 70 in ± sqrt(4800 in2)/sqrt(2)
= 70 in ± 48.99 in
Again, the "plus" solution is spurious; the "minus" solution gives us r = 21" (to the precision I can get with a Sharpie and a pair of scissors). And here's what that looks like on the actual mattress topper,

Truth in advertising: I didn't actually come up with the "high school algebra" solution until after I took the above photo. Since it was 40" from the rectangle midpoint to the bottom edge, I could tell that r=20" would certainly fit, but I thought I could probably do better, so I guessed at r=21", plotted where the center would be in that case, took some more measurements, and confirmed that it worked.
Suppose (hypothetically) you were decommissioning a somewhat ragged queen-sized foam mattress topper, and it occurred to you that rather than throwing it all away, you could cut some pads out of it for your circular dog beds. You might spread it out on the kitchen floor (the largest unobstructed area of floor in the house), then put a dog bed on top of it to trace the right size and shape. Unfortunately, it's obvious that you won't get two circles the size of this dog bed from one mattress topper. So how much smaller do they need to be?

Since the circles are as symmetrical as a shape can be, and the two of them are to be congruent, and the rectangular mattress topper is pretty symmetrical too, it seems reasonable to assume that the cutting layout will be symmetrical too. Which means we can simplify the problem to "how large a circle can be inscribed in a given right triangle?" That should be straightforward.

No, wait: that's actually too restrictive. We might be able to get slightly larger circles if each one laps slightly over the rectangle's diagonal. In this diagram, I labelled the height (h) and width (w) of the rectangle, the radius (r) of each circle, the angle (θ) between the horizontal axis and the line between the circles' centers, and the angle (α) between the horizontal and the main diagonal of the rectangle.
Conveniently, θ = α, so this should be easy. Wait... why does θ have to be the same as α? Imagine a really tall rectangle, with h > 2w; then the largest circles you can fit are simply determined by the width, they don't even need to touch one another, and the line between their centers is vertical. Yet the main diagonal is most definitely not vertical. Furthermore, if h is slightly less than 2w, the line between the circles' centers will be almost vertical, while the main diagonal is quite far from vertical. So θ ≠ α in general. Oh, well, that would have been nice, but....
We're trying to find the θ that gives us the largest possible r. Sounds like a classic first-term-calculus problem: write r as a function of θ (treating h and w as constants), take a derivative with respect to θ, set it equal to zero, solve for θ, then plug into the original formula and get the resulting value of r.
The point where the two circles touch, by the symmetry of the whole problem, has to be the midpoint of the rectangle, h/2 away from top and bottom and w/2 away from left and right sides. So r + r*sin(θ) = h/2, while r + r*cos(θ) = w/2. We can easily isolate r on one side of each equation:
r = w/(2 * (1+cos(θ)))
r = h/(2 * (1+sin(θ)))
So we have not one, but two formulae for r in terms of θ. That's a little weird, but OK, let's differentiate them. Quotient rule... ho-d-hi minus hi-d-ho over ho-ho, right?
From the "horizontal" formula we get
dr/dθ = -2w(-sin(θ)) / 4(1+cos(θ))2 = w sin(θ) / 2(1+cos(θ))2
which is zero only when θ = 0, π, 2π, etc.
From the "vertical" formula we get
dr/dθ = -2w(cos(θ)) / 4(1+sin(θ))2 = - w sin(θ) / 2(1+sin(θ))2
which is zero only when θ = π/2, 3π/2, 5π/2, etc.
Umm... our two formulae contradict one another. Each one says it can maximize r at a place where the other says it can't. And it feels like they ought to be working together somehow, not at cross purposes.
Maybe I'm making this much too hard. Maybe we don't need calculus or trigonometry at all, just high school algebra.
The center of a circle is at coordinates (r, r) because it's distance r from both the bottom and a side (I don't really care whether it's the left or right side). The center of the rectangle is at coordinates (w/2, h/2). And if the two circles are touching, it'll be at the center of the rectangle, which means that point is distance r away from both centers. Which means
(r-w/2)2 + (r-h/2)2 = r2
r2 - rw + w2/4 + r2 - rh + h2/4 = r2
r2 - r(w+h) + (w2 + h2)/4 = 0
which we can solve with the quadratic formula:
r = ((w+h) ± sqrt((w+h)2 - w2 - h2))) / 2
r = ((w+h) ± sqrt(2wh)) / 2
r = (w+h)/2 ± sqrt(wh) / sqrt(2)
Does this make any sense? Let's plug in the simple, known case of h=2w, where r should come out exactly w/2.
The formula says r = (w+h)/2 ± sqrt(wh)/sqrt(2) = 3w/2 ± sqrt(2w2)/sqrt(2) = 3w/2 ± w
and indeed one of the values comes out w/2. (The other is 5w/2, which makes the circles much larger than the rectangle we started with, and the centers would both be outside the rectangle. Not sure whether this solution means anything at all.)
A more interesting special case is a square, in which we can't do the overlapping-the-diagonal thing: both circles do have to be entirely within their right-triangle half of the square. But the circles don't have to be entirely within a quadrant of the square; they can lap over a little in both vertical and horizontal dimensions, as long as they don't cross the diagonal. Since w = h, the formula says
r = w ± sqrt(w2)/sqrt(2) = w ± w/sqrt(2)
Again, the "plus" case of the ± is a spurious solution, going outside the rectangle, but what about w - w/sqrt(2)? Is that plausible?
Back when I was talking about θ, I wrote down that r + r*sin(θ) = w/2, and that should still be true. In this case θ = π/4, whose sine and cosine are both 1/sqrt(2). So let's plug in this solution.
r + r*sin(θ) = r * (1 + 1/sqrt(2)) = w * (1 - 1/sqrt(2)) * (1 + 1/sqrt(2)) = w * (1 - 1/2) = w/2
Hooray!
Now, what about a queen-sized mattress (topper)? The Intarwebz says a queen-sized mattress is 60" x 80", so let's plug that in.
r = (w+h)/2 ± sqrt(wh) / sqrt(2)
= 70 in ± sqrt(4800 in2)/sqrt(2)
= 70 in ± 48.99 in
Again, the "plus" solution is spurious; the "minus" solution gives us r = 21" (to the precision I can get with a Sharpie and a pair of scissors). And here's what that looks like on the actual mattress topper,

Truth in advertising: I didn't actually come up with the "high school algebra" solution until after I took the above photo. Since it was 40" from the rectangle midpoint to the bottom edge, I could tell that r=20" would certainly fit, but I thought I could probably do better, so I guessed at r=21", plotted where the center would be in that case, took some more measurements, and confirmed that it worked.
