Jekyll2019-04-12T15:42:17+00:00http://mitchgordon.me/feed.xmlMitchell A. GordonIntelligence, math, zen, and practical fatalismKoan of Will2019-04-02T00:00:00+00:002019-04-02T00:00:00+00:00http://mitchgordon.me/zen/2019/04/02/koan-of-will<p>The student saw a monk sitting in the courtyard. He did not move.</p>
<p>For forty nights and days, the student returned to the courtyard to watch the monk, who still did not move.</p>
<p>On the fortieth day, the monk died and still did not move.</p>
<p>The student asked the master, “why has he done this?”</p>
<p>“To demonstrate his free will,” the master replied.</p>
<p>“Why?”</p>
<p>“Someone told him he did not have any,” the master replied.</p>
<p>“Were they right?”</p>
<p>“It does not matter. He is dead now.”</p>
<p>- 金道</p>The student saw a monk sitting in the courtyard. He did not move.Koan of Music2019-03-28T00:00:00+00:002019-03-28T00:00:00+00:00http://mitchgordon.me/zen/2019/03/28/koan-of-music<p>The student sought enlightenment.</p>
<p>“Master, what is best?”</p>
<p>The master answered, “play me the best music, and I will tell you the best way to live.”</p>
<p>So the student purchased a lute from a local merchant and played the master a song.</p>
<p>“That is not best,” the master said.</p>
<p>So the student traveled to the city and sought out the most famous lute players. She spent a year there, mastering seven genres.</p>
<p>She returned to the master and played her best seven songs.</p>
<p>“That is not best,” the master said.</p>
<p>In a fury, the student smashed the lute on the ground repeatedly, making a great cacophony.</p>
<p>“Ah, finally! You have played the best music… for me.”</p>
<p>The student was enlightened.</p>
<p>- 金道</p>The student sought enlightenment.Multiplying Complex Numbers2019-03-18T00:00:00+00:002019-03-18T00:00:00+00:00http://mitchgordon.me/math/2019/03/18/multiplying-complex-numbers<!-- Load the Paper.js library -->
<script src="/assets/js/acorn.js"></script>
<script type="text/javascript" src="/assets/js/paper-full.min.js"></script>
<!-- Define inlined PaperScript associate it with myCanvas -->
<script type="text/paperscript" canvas="myCanvas">
ORIGIN = new Point(300, 150)
SCALE = 10
// (a + bi)(c + di)
// = (a + bi)c + (a + bi)di
var yaxis = new Path([ORIGIN.x, 0], [ORIGIN.x, ORIGIN.y * 2]);
var xaxis = new Path([0, ORIGIN.y], [ORIGIN.x * 2, ORIGIN.y]);
yaxis.strokeColor = 'black'
xaxis.strokeColor = 'black'
yaxis.dashArray = [4, 4]
xaxis.dashArray = [4, 4]
function convertVec(vec){
// Convert a linear algebra vector into a Paper vector
return new Point(vec.x, -vec.y) * SCALE
}
function convertPaperPos(pos) {
// Convert a paper pos to a linear algebra vector
var paperVec = pos - ORIGIN;
return new Point(paperVec.x, -paperVec.y) / SCALE
}
function showText(content, pos, color='black') {
var text = new PointText(pos);
text.justification = 'left';
text.fillColor = color;
text.content = content;
text.fontFamily = 'CMSY10'
return text;
}
function showVec(vec, {name=null, start=new Point(0,0), color='black'} = {}) {
vec = convertVec(vec);
start = ORIGIN + convertVec(start);
end = vec+start;
if (name != null) {
namePos = start + (vec / 2) + vec.normalize(15).rotate(90)
var nameText = showText(name, namePos)
}
vectorItem = new Group([
new Path([start, end]),
new Path([end, end-vec.normalize(10).rotate(30)]),
new Path([end, end-vec.normalize(10).rotate(-30)]),
nameText
]);
vectorItem.strokeColor = color;
return vectorItem
}
var mouseVec;
var a = 10; var b = 2; var c = 2; var d = 1;
var x = new Point(a, b);
var drawGroup;
function onFrame(event) {
if (drawGroup) drawGroup.remove();
y = new Point(c,d);
rightAngle = new Path();
rightAngle.moveTo(ORIGIN + convertVec((x*d).rotate(90)) + convertVec(x).rotate(90).normalize(10))
rightAngle.lineTo(ORIGIN + convertVec((x*d).rotate(90)) + convertVec(x).rotate(90).normalize(10) + convertVec(x).normalize(10))
rightAngle.lineTo(ORIGIN + convertVec((x*d).rotate(90)) + convertVec(x).normalize(10))
rightAngle.strokeColor = 'black'
drawGroup = new Group([
rightAngle,
showVec(x, {name: 'a+bi', color: 'red'}),
// showVec(x * c),
showVec((x * d).rotate(90), {name:"(a+bi)*di", color:"blue"}),
showVec(x * c, {start:(x * d).rotate(90), name: "(a+bi)*c", color: 'green'}),
showVec((x * d).rotate(90) + (x * c), {name: "(a+bi)(c+di)"}),
showText("θ", ORIGIN + convertVec((x * d).rotate(90) + (x * c)).normalize(20).rotate(20), color='purple'),
showText(`a = ${a.toFixed(2)}, b = ${b.toFixed(2)}, |a + bi| = ${x.length.toFixed(2)}`, ORIGIN + new Point(50, 50), color='red'),
showText(`c = ${c.toFixed(2)}, `, ORIGIN + new Point(50, 70), color='green'),
showText(`d = ${d.toFixed(2)}`, ORIGIN + new Point(100, 70), color='blue'),
showText(`θ = 90 - arctan(c/d) = arctan(d/c) = ${(Math.atan(d/c) / 2 / Math.PI * 360).toFixed(2)}`, ORIGIN + new Point(50, 90), color='purple'),
showText(`|(a+bi)(c+di)| = ${x.length.toFixed(2)} * ${y.length.toFixed(2)} = ${(x.length * y.length).toFixed(2)}`, ORIGIN + new Point(50, 110)),
]);
}
function onMouseMove(event) {
mouseVec = convertPaperPos(event.point)
c = mouseVec.project(x).length / x.length
d = mouseVec.project(x.rotate(90)).length / x.length
}
</script>
<p>I’ve been interested in complex numbers lately<sup id="fnref:1"><a href="#fn:1" class="footnote">1</a></sup>, but something bothered me
about complex multiplication: <strong>why is multiplying two numbers the same as adding
their angles and multiplying their lengths</strong>? Luckily, I’m
starting to figure out that <a href="https://betterexplained.com/articles/math-and-analogies/">analogies are what make math
beautiful</a>, and that
doing good math often feels like playing around.</p>
<p>So, what analogies can we use? First, complex numbers can be vectors on a plane.
Second, doing arithmetic (multiplying, adding, etc.) can be <a href="https://betterexplained.com/articles/rethinking-arithmetic-a-visual-guide/">a geometric
transformation</a>.</p>
<p>So instead of asking, “what does <script type="math/tex">(a+bi)(c+di)</script> mean?” We can ask “what
geometric transformation is the same as multiplying by <script type="math/tex">(c+di)</script>?”</p>
<p>To start, we can apply the distributive rule:</p>
<script type="math/tex; mode=display">(a+bi)(c+di) = \textcolor{green}{(a+bi)c} + \textcolor{blue}{(a+bi)di}</script>
<p>So now, instead of one transformation, we have three simpler transformations:</p>
<p><span style="color: green">1. Scale your original complex number by c.</span></p>
<p><span style="color: blue">2. Scale your original complex number by d, then
rotate it by 90 degrees.</span> <br />
(Multiplying by i is the same as rotating by 90).</p>
<p><span>3. Add those together.</span></p>
<p>When you add two vectors together, it’s the same as putting the tail of one at
the end of the other, and then drawing a vector to the result. If we plot some
examples, we can see the geometry of these transformations<sup id="fnref:2"><a href="#fn:2" class="footnote">2</a></sup>: (it should move if
you mouse over it)</p>
<div style="text-align: center">
<canvas id="myCanvas" height="300" width="600"></canvas>
</div>
<p>This trick is what
<a href="https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw">3blue1brown</a> uses in
all his videos: create visual / geometric analogues for abstract concepts to
gain an intuitive and deeper understanding that connects with existing
experience. This is just one type of useful analogy, but it’s super useful, so I
want to keep practicing it.</p>
<p>Anyway, we’re interested in the black transformed vector: <script type="math/tex">(a+bi)(c+di)</script>.</p>
<p>What is the angle <script type="math/tex">\color{purple}\theta</script> between our original number and the
transformed one? From the geometry, we can see <script type="math/tex">\color{purple}\theta</script> is 90
degrees minus the angle formed by the right triangle. Luckily, we know the
length of the sides of that triangle is the same as our original complex number,
scaled by some scalars c and d:</p>
<script type="math/tex; mode=display">\textcolor{purple}{\theta} = 90 - \arctan(\frac{\textcolor{green}{c \|a+bi\|}}{\textcolor{blue}{d \|a+bi\|}}) = 90 - \arctan(\textcolor{green}{c}/\textcolor{blue}{d}) = \arctan(\textcolor{blue}{d} /\textcolor{green}{c})</script>
<p>Where <script type="math/tex">\color{red}\|a+bi\|</script> just means the length of <script type="math/tex">\color{red}(a+bi)</script>.
Notice that <script type="math/tex">\arctan(\textcolor{blue}{d} /\textcolor{green}{c})</script> is the same
as the angle of our multiplier, <script type="math/tex">(c+di)</script>. <strong>So multiplying by <script type="math/tex">(c+di)</script>
effectively rotates a complex number by the angle of <script type="math/tex">(c+di)</script>!</strong></p>
<p>If you play with the sketch above, you can see that when <script type="math/tex">d=0</script>, there’s no
rotation, when <script type="math/tex">c=0</script>, there’s a 90 degree rotation, and when <script type="math/tex">c=d</script>, the
rotation is exactly 45 degrees.</p>
<p>What about the length? Again, we can use the sides of our right triangle:</p>
<script type="math/tex; mode=display">\|(a+bi)(c+di)\| = \sqrt{\textcolor{green}{(c\|a+bi\|)^2} + \textcolor{blue}{(d\|a+bi\|)^2}} \\
= \sqrt{(c^2+d^2)\|a+bi\|^2} \\
= \sqrt{\|c+di\|^2\|a+bi\|^2} \\
= \|c+di\|\|a+bi\|</script>
<p><strong>So multiplying by <script type="math/tex">(c+di)</script> scales a number by the length of <script type="math/tex">(c+di)</script>.</strong></p>
<p>Now, we could have always figured this stuff out by applying definitions and
doing a bunch of algebra. But thinking about the geometry just makes it
feel… obvious. Note that we ignored some very important cases (what about
negative numbers?), but we can figure that out later.</p>
<p>What’s nice about having the intution is that extensions come just as naturally.
For example: finding the multiplicative inverse of a complex number. In other
words, what number undoes the transformation of multiplying by <script type="math/tex">(c+di)</script>?
Obviously it would need to rotate by the opposite angle, and then scale by the
inverse scale. More
<a href="https://betterexplained.com/articles/intuitive-arithmetic-with-complex-numbers/">here</a>.</p>
<p>So yeah, complex numbers are cool. Not sure why I never used them before, but it
seems like they would be cool <a href="https://medium.com/intuitionmachine/should-deep-learning-use-complex-numbers-edbd3aac3fb8">to use in machine
learning.</a>
What’s even cooler is that all of this complex business naturally derives from a
simple question: “how can we solve a polynomial with no real solutions?” When
you answer it, you get all this crazy geometry that’s closely related to
oscillations and trigonometry. Wild.</p>
<p>- Mitchell</p>
<div class="footnotes">
<ol>
<li id="fn:1">
<p>If you’re also interested, I highly recommend checking out BetterExplained’s <a href="https://betterexplained.com/articles/a-visual-intuitive-guide-to-imaginary-numbers/">visual intuitive guide to complex numbers</a>. If you’re really interested, check out the whole series! They go over the details of complex arithmetic, as well as euler’s formula and the Fourier Transform. Finally, you can check out 3blue1brown’s video on <a href="https://www.youtube.com/watch?v=mvmuCPvRoWQ">euler’s formula with introductory group theory</a> and <a href="https://www.youtube.com/watch?v=spUNpyF58BY">the Fourier Transform</a> for some of that and more (god I love Grant). <a href="#fnref:1" class="reversefootnote">↩</a></p>
</li>
<li id="fn:2">
<p>Multiplication is associative, so the picture we drew could also (c+di) as the original number and (a+bi) as the transformation. That would create a symmetric picture around our black product vector. Neat. <a href="#fnref:2" class="reversefootnote">↩</a></p>
</li>
</ol>
</div>Koan of Truth2019-03-13T00:00:00+00:002019-03-13T00:00:00+00:00http://mitchgordon.me/zen/2019/03/13/koan-of-truth<p>The student asked the master, “what is truth?”</p>
<p>The master grabbed his pet dog from the floor and presented it to the student.</p>
<p>“This is Truth.”</p>
<p>“That is not what I meant,” said the student.</p>
<p>“But that is what you asked,” said the master.</p>
<p>- 金道</p>The student asked the master, “what is truth?”Koan of Rock2019-03-10T00:00:00+00:002019-03-10T00:00:00+00:00http://mitchgordon.me/zen/2019/03/10/koan-of-rock<p>The master took his student to a field, where there stood a giant rock.</p>
<p>“Move this rock,” he said.</p>
<p>The student took a step to the left.</p>
<p>The master was pleased.</p>
<p>- 金道</p>The master took his student to a field, where there stood a giant rock.Koan of Names2019-03-06T00:00:00+00:002019-03-06T00:00:00+00:00http://mitchgordon.me/zen/2019/03/06/koan-of-names<p>The master asked her student, “what is a ball?”</p>
<p>“It is round. It rolls, and sometimes bounces,” the student replied.</p>
<p>The master reached into her robe, revealing a perfect sphere. “What is this?” she asked.</p>
<p>The student replied that it was a ball.</p>
<p>“Then it will roll?”</p>
<p>“On even ground,” the student replied.</p>
<p>The master placed the sphere on the ground and kicked it. It split into two perfect halves and did not roll.</p>
<p>The student objected to the trick. It was not a ball after all; it was two halves of a ball stuck together.</p>
<p>The master replied, “I did not name it. The ball did not name itself. You called it a ball because you expected it to roll. So it is with all things.”</p>
<p>The master then chopped the ball into many pieces, until it became dust and dissolved into the wind.</p>
<p>“Names are useful, but they are not truth. The names you create are your ignorance of the world.”</p>
<p>- 金道</p>The master asked her student, “what is a ball?”The MU Puzzle2018-05-01T00:00:00+00:002018-05-01T00:00:00+00:00http://mitchgordon.me/math/2018/05/01/MU-puzzle<p>In the 1920’s, an American logician named Emil Post invented a formal system commonly called a <a href="https://en.wikipedia.org/wiki/Post_canonical_system">Post production system</a>. A Post production system has three parts: an alphabet (like the English alphabet), an initial set of words that are assumed to exist, and a set of production rules. To use the system, you start with the intial words and apply the production rules to make new words out of the ones you already have, ad infinitum. Given these three parts the formal system is defined, and all the words that you could possibly create with this system are implicitly determined (but not necessarily known).</p>
<p>I bring up Emil’s system because I’ve been reading <a href="https://en.wikipedia.org/wiki/G%C3%B6del,_Escher,_Bach">Gödel, Escher, Bach</a> by Douglas Hofstadter, and he uses it to propose a fun puzzle. Well, he really uses it as a simple example of a formal system, with which he demonstrates fundamental concepts (like decision processes and incompleteness). I really only care about the puzzle, however, which will be the subject of today’s post. By the way, GEB is an amazing book (as far as I can tell having read the first two chapters), and I highly recommend it.</p>
<p>In Hofstadter’s specific instance of a Post production system, the alphabet has three letters: <em>M</em>, <em>I</em>, and <em>U</em>. So any word that exists in our system will be composed of <em>M</em>, <em>I</em>, or <em>U</em>. Some examples: <em>MUM</em>, <em>IUIU</em>, <em>UUUUUIIII</em>, etc.</p>
<p>There are four rules in Hofstadter’s system for changing existing words into new words.</p>
<p><strong>Rule 1.</strong><br />
If a word ends in <em>I</em>, you can add <em>U</em> to the end. For example, <em>MI</em> may become <em>MIU</em>. <em>MUUUMUUI</em> may become <em>MUUUMUUIU</em>.</p>
<p><strong>Rule 2.</strong><br />
If a word is of the form <em>Mx</em>, you may add <em>Mxx</em> to your list of existing words. Notice that “x” is not in our alphabet, it’s a variable representing some collection of letters. Some examples:<br />
<em>MUM</em> may become <em>MUMUM</em><br />
<em>MIU</em> may become <em>MIUIU</em><br />
<em>MU</em> may become <em>MUU</em></p>
<p><strong>Rule 3.</strong><br />
If <em>III</em> occurs in a word, you may make a new word with <em>U</em> in place of <em>III</em>. Examples:<br />
<em>UMIIIMU</em> could become <em>UMUMU</em><br />
<em>MIIII</em> could become <em>MIU</em> or <em>MUI</em><br />
<em>IIMII</em> can’t become anything using this rule, since three <em>I</em>’s are not connected<br />
<em>MIII</em> could become <em>MU</em></p>
<p><strong>Rule 4.</strong><br />
If <em>UU</em> occurs in a word, you may get rid of it. Examples:<br />
From <em>UUU</em>, get <em>U</em><br />
From <em>MUUUIII</em> get <em>MUIII</em></p>
<p>Notice that multiple rules may apply to a word at the same time. It is up to you to decide which rules to use and when.</p>
<p>And now that we have the system, finally we can state the puzzle: <strong>starting with <em>MI</em>, can you get <em>MU</em>?</strong></p>
<p>Note that the puzzle <em>does not</em> ask “how do you get to <em>MU</em> from <em>MI</em>” but rather “is it possible to get to <em>MU</em> from <em>MI</em>?” If it is possible, how do you do it? If it’s not possible, can you prove that it’s not?</p>
<p>If you’re trying this at home, have fun with it. Start with <em>MI</em> and write down some new words using the rules. See if you can identify some patterns.</p>
<p>For the solution, I’ll be writing a post soon about how I went about solving it. If you’re impatient, the solution is all over the internet.</p>
<p>- Mitchell</p>In the 1920’s, an American logician named Emil Post invented a formal system commonly called a Post production system. A Post production system has three parts: an alphabet (like the English alphabet), an initial set of words that are assumed to exist, and a set of production rules. To use the system, you start with the intial words and apply the production rules to make new words out of the ones you already have, ad infinitum. Given these three parts the formal system is defined, and all the words that you could possibly create with this system are implicitly determined (but not necessarily known).