-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathenvelope.html
367 lines (342 loc) · 17.3 KB
/
envelope.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
<!DOCTYPE html>
<html>
<head>
<link rel="canonical" href="https://hardmath123.github.io/envelope.html"/>
<link rel="stylesheet" type="text/css" href="/static/base.css"/>
<title>Caustics and Casinos on the I-5 - Comfortably Numbered</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="alternate" type="application/rss+xml" title="Comfortably Numbered" href="/feed.xml" />
<!--
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>
MathJax.Hub.Config({
tex2jax: {inlineMath: [['$','$']]}
});
</script>
-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-YNHdsYkH6gMx9y3mRkmcJ2mFUjTd0qNQQvY9VYZgQd7DcN7env35GzlmFaZ23JGp" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-vZTG03m+2yp6N6BNi5iM4rW4oIwk5DfcNdFfxkk9ZWpDriOkXX8voJBFrAO7MpVl" crossorigin="anonymous"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
renderMathInElement(document.body, {
// customised options
// • auto-render specific keys, e.g.:
delimiters: [
{left: '$$', right: '$$', display: true},
{left: '$', right: '$', display: false},
{left: '\\begin{align}', right: '\\end{align}', display: true},
{left: '\\(', right: '\\)', display: false},
{left: '\\[', right: '\\]', display: true}
],
// • rendering keys, e.g.:
throwOnError : false
});
});
</script>
</head>
<body>
<header id="header">
<script src="static/main.js"></script>
<div>
<a href="/"><span class="left-word">Comfortably</span> <span class="right-word">Numbered</span></a>
</div>
</header>
<article id="postcontent" class="centered">
<section>
<h1>Caustics and Casinos on the I-5</h1>
<center><em><p>An analytical analysis of an anomalous advertisement</p>
</em></center>
<h4>Friday, January 4, 2019 · 7 min read</h4>
<p>I was in Los Angeles over winter break, and on the long drive back home I began
thinking about a billboard I saw just at the edge of the city advertising the
<strong>“closest casino to anywhere in LA.”</strong></p>
<p>This is a fascinating claim. Let me rephrase it, at least the way I interpret
it: the claim is that <em>wherever</em> you are in LA, the closest casino is the one
advertised on the billboard. (This is confusingly distinct from the claim that
the casino is closest to <em>anywhere</em> in LA, in the sense that the placement of
the casino minimizes the distance to the nearest bit of LA soil. Of course,
practically speaking this latter claim is useless because any casino <em>within</em>
LA trivially has the minimal distance of zero to “anywhere in LA.”)</p>
<p>The question is this: what region does the billboard’s claim imply is devoid of
casinos?</p>
<p>Let’s start with a simple case to get some intuition. Suppose LA is a
15-mile-radius disk, and the casino is at the center of the disk. Then,
according to the billboard, there must be <em>no</em> other casinos within LA’s
15-mile radius (otherwise, if you were in LA, you <em>might</em> be closer to that
other casino!). But actually, the claim is quite a bit stronger: there cannot
be any casinos within <em>thirty</em> miles of the center. Why? Well, suppose there
was a casino 20 miles from the center of LA. Then, someone just within the city
borders would be 5 miles away from that <em>other</em> casino, but 15 miles from the
city-center casino.</p>
<p>One more simple case: suppose LA is a line segment of length 15 miles, and the
casino is located at one endpoint. Can you imagine what the region in question
must be? It is a disk of radius 15 miles, centered at the <em>other</em> endpoint!
This is not entirely obvious, and you might need to draw a picture to convince
yourself that this is true.</p>
<p>Now let’s consider a much trickier case: suppose LA is a circle again, but the
casino is located along the <em>circumference</em>. Suddenly, it’s <em>much</em> harder to
picture what’s going on — sitting in a car without pencil or paper, I had no
idea what the region might look like. My instinct was “circle centered at the
diametrically-opposite point on the circumference,” but it turns out that this
is <em>wrong!</em></p>
<p>In the rest of this post, we’ll build up some mathematical machinery to answer
this question correctly. If you don’t want to work through the math, however,
then feel free to just scroll to the red-bordered squares and enjoy the
interactive demos.</p>
<hr>
<p><strong>Definition.</strong> Given some region $ R \subset \mathbb{R}^2 $, the <em>casino
closure</em> with respect to some point $ p \in \mathbb{R}^2 $ is defined as</p>
<p>\[
R^p = \left\{
c \in \mathbb{R}^2 ~\middle|~
\exists z \in R, || p - z || > || c - z ||
\right\}
\]</p>
<p>Or, informally: the casino closure is the set of <em>possible casino locations</em> $
c $ such that there exists a person $ z $ in the region $ R $ who is
closer to $ c $ than to $ p $.</p>
<p>From here on out, I’m only going to worry about “nice” regions, i.e. closed,
connected regions with smooth boundaries. I’m also going to use $ x, p, z, c
$ to range over points in $ \mathbb{R}^2 $, but really most math that
follows is equally applicable in $ \mathbb{R}^n $. It’s just harder to
visualize.</p>
<p><strong>Lemma.</strong> Let the disk $ D(z, r) $ be the set of all points in $
\mathbb{R}^2 $ within $ r $ of point $ z $. Then,
\[
R^p = \bigcup_{z~\in~R} D(z, ||p - z||)
\]</p>
<p>That is, we can construct $ R^p $ by combining all the disks at all the
points in $ R $ that have $ p $ on their circumference.</p>
<p><strong>Proof sketch.</strong> This should make sense “by construction.” If point $ c $ is
in this constructed $ R^p $, then it lies in some disk $ d $, and thus the
point $ z \in R $ that created disk $ d $ fulfills the existence criterion
of our definition.</p>
<p><strong>Lemma.</strong> If region $ R $ has a boundary $ B \subset R $, then $
B^p = R^p $.</p>
<p><strong>Proof sketch.</strong> Clearly, $ B^p \subset R^p $ if you believe the first lemma
— adding more points to $ B $ should only increase the union of disks.</p>
<p>The harder direction to show is $ R^p \subset B^p $. Consider some point $ z
\in R$. Extend the ray $ \overrightarrow{pz} $ until it intersects with $ B
$ at point $ z^\prime $. Then, we can relate the disks created by $ z $
and $ z^\prime $: $ D(z, ||p-z||) \subset D(z^\prime, ||p-z^\prime||) $.
Why? Because the disk from $ z $ is smaller and internally tangent to the
disk from $ z^\prime $.</p>
<p>Mapping this argument over the entire union, it makes sense that $ R^p \subset
B^p $.</p>
<p>Okay, time for some empirical verification of all this theory. Try drawing the
boundary of a region (in black) here! The disks will show up in red. Notice how
filling in your region with black dots doesn’t change the red blob at all.
(Click to clear.)</p>
<canvas id="world-freestyle" width=300 height=300 style="border: 1px solid red;"></canvas>
<hr>
<p>The boundary-circle lemma gives us a nicer characterization of $ R^p $: it is
the region bounded by the curve that is tangent to all of the disks created by
the points on $ B $. It turns out that there is a very nice mathematical
theory of “the curve that is tangent to all curves in a given family of
curves,” and that is the theory of <em>envelopes</em>. The account below is
paraphrased from <a href="https://www.jstor.org/stable/3617131?seq=1#metadata_info_tab_contents">“What is an
Envelope?”</a>,
a lovely 1981 paper.</p>
<p>Let the function $ F(x, t) : \mathbb{R}^2 \times \mathbb{R} \rightarrow
\mathbb{R} $ define a family of curves parameterized by $ t $, in the sense
that $ F(x, 0) = 0 $ defines a curve and $ F(x, 1) = 0 $ defines another
curve, and so on. Then, we seek to characterize the envelope curve which is
tangent to every curve in $ F $.</p>
<p><strong>Lemma.</strong> If the boundary of $ R $ can be (periodically) parameterized as $
B(t), t \in \mathbb{R} $ then the boundary of $ R^p $ is the <em>envelope</em> with
respect to $ t $ of
\[
F(x, t) = || x - B(t) ||^2 - || p - B(t) ||^2
\]</p>
<p><strong>Proof sketch.</strong> Again, this should make sense “by construction”: $ F $ is
chosen to correspond to circles centered at $ B(t) $ passing through $ p $.</p>
<hr>
<p>Ah, but how do we find the envelope? Here we need a tiny bit of multivariable
calculus.</p>
<p>Let $ X(t) $ be the parameterization of the envelope of $ F $. Then for all
$ t $, we have that $ F(X(t), t) = 0 $ because the envelope must lie on the
respective curve in the family (“tangent” means “touch”!). We also have that
the curve $ X(t) $ must be parallel to the member of family $ F $ at $ t
$. We can then express this condition by saying that the gradient (with
respect to $ X $ of $ F $ at $ t $ is perpendicular to the derivative of
$ X $ at $ t $. Or:</p>
<p>\[
d X(t) / dt \cdot \nabla_X F(X(t), t) = 0
\]</p>
<p>In two dimensions, with $ X(t) = (x(t), y(t)) $, this equation manifests
itself as $ x^\prime(t)\partial F(x, y, t) / \partial x + y^\prime(t)\partial
F(x, y, t) / \partial y $.</p>
<p>The left hand side is oddly reminiscent of the multivariable chain rule.
Indeed, if we took the partial derivative of our equation $ F(X(t), t) = 0 $
with respect to $ t $, we would get:</p>
<p>\[
dF(X, t)/dt = dX/dt\cdot\nabla_X F(X, t) + dt/dt\cdot \partial F(X, t)/\partial t = 0
\]</p>
<p>So we must have $ \partial F(X, t) / \partial t = 0$.</p>
<p>There is a simpler but less rigorous derivation if you believe that the
envelope is exactly the points of intersection of infinitesimally close curves
in the family $ F $. Then we want every point $ X $ on the envelope to
satisfy both $ F(X, t) $ and $ F(X, t + \delta) $ for some $ t $ and some
infinitesimal $ \delta $. Taking the limit as $ \delta $ approaches zero
gives the same condition that $ \partial F(X, t) / \partial t = 0 $. The
paper above discusses how this notion is subtly different in some strange
cases, but it suffices to say that for all “nice” $ R $, we’re fine.</p>
<p><strong>Almost-a-theorem.</strong> The boundary of $ R^p $ is given by the parameterized
vectors $ X $ that satisfy $ F(X, t) = 0 $ and $ \partial F (X, t) /
\partial t = 0 $ for the $ F $ defined above.</p>
<p><strong>Almost-a-proof-sketch.</strong> Almost! In general, the solution for $ X $ might
self-intersect, so we want to take only the “outermost” part of $ X $. But
this is easy to work out on a case-by-case basis.</p>
<p><strong>Example.</strong> Suppose $ R $ is the unit disk centered at $ (a, 0) $, and $
p $ is located at the origin. Then $ B(t) = (\cos t + a, \sin t) $ and $ p
= (0, 0) $. We have</p>
<p>\[
F((x, y), t) =
((x - (\cos t + a))^2 + (y - \sin t)^2) - ((\cos t + a)^2 + \sin^2 t)
\]</p>
<p>\[
F((x, y), t) = -2ax + x^2 - 2x\cos t + y^2 - 2y \sin t = 0
\]</p>
<p>We also have</p>
<p>\[
\partial F((x, y), t) / \partial t = 2x\sin t - 2y\cos t = 0
\]</p>
<p>Solving these by eliminating $ t $ is a simple exercise in polar coordinates.
Discover from the second equation that $ t = \theta $, then recall that $
r^2 = x^2 + y^2 $. The resulting boundary of $ R^p $ is (almost!) the curve
$ r = 2(1 + a\cos\theta) $. In other words, it’s (almost!) a limaçon! As $ a
$ varies, the character of the limaçon varies, and at the critical points $ a
= \pm 1 $, we get a cardioid with a cusp. Beyond those critical points, the
curve has an inner loop that we have to ignore; hence, “almost!”</p>
<p>Okay, time for more empiricism. Move your mouse around in the square below to
see how the relative placement of LA and the casino affects the envelope.
Notice also the inner loop predicted by the envelope, which we should of course
ignore for the purposes of bounding $ R^p $.</p>
<canvas id="world-cardioid" width=300 height=300 style="border: 1px solid red;"></canvas>
<p>An amazing fact is that a cardioid is the same shape you get on the surface of
your coffee mug when you put it under a light! Well, not quite — it depends
subtly on where the light source is. Read more about caustics at
<a href="http://chalkdustmagazine.com/features/cardioids-coffee-cups/">Chalkdust</a>, from
whom I also borrowed the image below:</p>
<p><img src="https://i0.wp.com/chalkdustmagazine.com/wp-content/uploads/2017/10/photo-1.jpg?resize=768%2C576" alt="coffee
cardioid"></p>
<hr>
<p>Further reading: Wikipedia has <a href="https://en.wikipedia.org/wiki/Cardioid#Cardioid_as_envelope_of_a_pencil_of_circles">great
diagrams</a>
to accompany. Dan Kalman’s article <a href="http://dankalman.net/AUhome/pdffiles/ladder_paper_MM.pdf">“Solving the Ladder Problem on the Back of
an Envelope.”</a>
includes a nice pedagogically-oriented discussion of envelope subtleties. It
cites Courant’s <a href="https://archive.org/details/DifferentialIntegralCalculusVol2/page/n183">Differential and Integral Calculus (vol
2)</a>,
which is freely available on Archive.org.</p>
<script>
var worldFreestyle = document.getElementById('world-freestyle');
var worldCardioid = document.getElementById('world-cardioid');
function mark(world, ctx, X, Y) {
var originX = world.width / 2;
var originY = world.height / 2;
ctx.strokeStyle = 'rgba(255, 0, 0, 0.3)'
ctx.beginPath();
ctx.arc(
X, Y,
Math.sqrt(
(X - originX) * (X - originX) +
(Y - originY) * (Y - originY)),
0, Math.PI * 2
);
ctx.stroke();
ctx.fillRect(X, Y, 2, 2);
}
function clear(world, ctx) {
var originX = world.width / 2;
var originY = world.height / 2;
// Clear
world.height = world.height;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
// Casino
ctx.strokeRect(originX - 2, originY - 2, 4, 4);
ctx.fillText("Casino", originX, originY - 12);
}
worldFreestyle.addEventListener('click', function(event) {
var ctx = this.getContext('2d');
clear(this, ctx);
}, false);
clear(worldFreestyle, worldFreestyle.getContext('2d'));
worldFreestyle.addEventListener('mousemove', function(event) {
var ctx = this.getContext('2d');
var X = event.clientX - this.offsetLeft + window.scrollX;
var Y = event.clientY - this.offsetTop + window.scrollY;
mark(this, ctx, X, Y);
}, false);
worldCardioid.addEventListener('mousemove', function(event) {
var ctx = this.getContext('2d');
var X = event.clientX - this.offsetLeft + window.scrollX;
var Y = event.clientY - this.offsetTop + window.scrollY;
var originX = this.width / 2;
var originY = this.height / 2;
clear(this, ctx);
// Region
var R = this.width / 6;
var N = 18;
for (var i = 0; i < N; i++) {
mark(
this, ctx,
X + Math.sin(i / N * Math.PI * 2) * R,
Y + Math.cos(i / N * Math.PI * 2) * R
);
}
// Circle
ctx.beginPath();
ctx.arc(X, Y, R, 0, Math.PI * 2);
ctx.stroke();
ctx.fillStyle = 'black';
ctx.fillText("Los Angeles", X, Y - 12);
// Limacon
ctx.save();
ctx.lineWidth = 10;
ctx.beginPath();
for (var theta = 0; theta < 2 * Math.PI; theta += 0.01) {
var phi = Math.atan2(originX - X, originY - Y);
var a = Math.sqrt(Math.pow(originX - X, 2) + Math.pow(originY - Y, 2)) / R;
var r = 2 * (1 + a * Math.cos(theta)) * R;
ctx.lineTo(
originX + r * Math.cos(theta - phi - Math.PI / 2),
originY + r * Math.sin(theta - phi - Math.PI / 2)
);
}
ctx.stroke();
ctx.restore();
}, false);
</script>
</section>
<div id="comment-breaker">◊ ◊ ◊</div>
</article>
<footer id="footer">
<div>
<ul>
<li><a href="https://github.com/kach">
Github</a></li>
<li><a href="feed.xml">
Subscribe (RSS feed)</a></li>
<li><a href="https://twitter.com/hardmath123">
Twitter</a></li>
<li><a href="https://creativecommons.org/licenses/by-nc/3.0/deed.en_US">
CC BY-NC 3.0</a></li>
</ul>
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-46120535-1', 'hardmath123.github.io');
ga('require', 'displayfeatures');
ga('send', 'pageview');
</script>
</footer>
</body>
</html>