<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Popular &#8211; BetterExplained</title>
	<atom:link href="https://betterexplained.com/articles/category/popular/feed/" rel="self" type="application/rss+xml" />
	<link>https://betterexplained.com</link>
	<description>Math lessons that click</description>
	<lastBuildDate>Mon, 08 Dec 2025 22:27:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>How To Learn Trigonometry Intuitively</title>
		<link>https://betterexplained.com/articles/intuitive-trigonometry/</link>
					<comments>https://betterexplained.com/articles/intuitive-trigonometry/#disqus_thread</comments>
		
		<dc:creator><![CDATA[kalid]]></dc:creator>
		<pubDate>Mon, 24 Feb 2014 16:30:11 +0000</pubDate>
				<category><![CDATA[Guides]]></category>
				<category><![CDATA[Math]]></category>
				<category><![CDATA[Popular]]></category>
				<category><![CDATA[Sine (Geometric Definition)]]></category>
				<category><![CDATA[Sine (Unit Circle)]]></category>
		<guid isPermaLink="false">http://betterexplained.com/?p=3844</guid>

					<description><![CDATA[Trig mnemonics like SOH-CAH-TOA focus on computations, not concepts: TOA explains the tangent about as well as describes a circle. Sure, if you&#8217;re a math robot, an equation is enough. The rest of us, with organic brains half-dedicated to vision processing, seem to enjoy imagery. And &#8220;TOA&#8221; evokes the stunning beauty of an abstract ratio. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Trig mnemonics like <a href="http://mathworld.wolfram.com/SOHCAHTOA.html">SOH-CAH-TOA</a> focus on computations, not concepts:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/sohcahtoa-bleh.png" alt="body proportions" class="webpexpress-processed"></p>

<p>TOA explains the tangent about as well as <img src="https://betterexplained.com/latex/50a871a13a934d1e2fd0.png" alt="$x^2 + y^2 = r^2$" width="98" height="19" style="vertical-align:-3.71px" class="bex-math"></img> describes a circle. Sure, if you&#8217;re a math robot, an equation is enough. The rest of us, with organic brains half-dedicated to vision processing, seem to enjoy imagery. And &#8220;TOA&#8221; evokes the stunning beauty of an abstract ratio.</p>

<p>I think you deserve better, and here&#8217;s what made trig click for me.</p>

<ul>
<li>Visualize a dome, a wall, and a ceiling</li>
<li>Trig functions are <em>percentages</em> to the three shapes</li>
</ul>

<iframe width="640" height="360" src="https://www.youtube.com/embed/rDE1GBUjTUM?wmode=transparent" frameborder="0" allowfullscreen="" wmode="Opaque"></iframe>

<h2>Motivation: Trig Is Anatomy</h2>

<p>Imagine Bob The Alien visits Earth to study our species.</p>

<p>Without new words, humans are hard to describe: &#8220;There&#8217;s a sphere at the top, which gets scratched occasionally&#8221; or &#8220;Two elongated cylinders appear to provide locomotion&#8221;.</p>

<p>After creating specific terms for anatomy, Bob might jot down typical <a href="https://en.wikipedia.org/wiki/Body_proportions">body proportions</a>:</p>

<ul>
<li>The armspan (fingertip to fingertip) is approximately the height</li>
<li>A head is 5 eye-widths wide</li>
<li>Adults are 8 head-heights tall</li>
</ul>

<p><a href="https://en.wikipedia.org/wiki/Vitruvian_Man">
<img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/vitruvian-man.jpg" alt="body proportions trig analogy" class="webpexpress-processed">
</a></p>

<p>How is this helpful?</p>

<p>Well, when Bob finds a jacket, he can pick it up, stretch out the arms, and estimate the owner&#8217;s height. And head size. And eye width. One fact is linked to a variety of conclusions.</p>

<p>Even better, human biology explains human thinking. Tables have legs, organizations have heads, crime bosses have muscle. Our biology offers ready-made analogies that appear in man-made creations.</p>

<p>Now the plot twist: <em>you</em> are Bob the alien, studying creatures in math-land!</p>

<p>Generic words like &#8220;triangle&#8221; aren&#8217;t overly useful. But labeling sine, cosine, and hypotenuse helps us notice deeper connections. And scholars might study haversine, exsecant and <a href="https://www.theonion.com/articles/nations-math-teachers-introduce-27-new-trig-functi,33804/">gamsin</a>, like biologists who find a link between your tibia and clavicle.</p>

<p>And because triangles show up in circles&#8230;</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/vitruvian-triangle.png" alt="circular path" class="webpexpress-processed"></p>

<p>&#8230;and circles appear in cycles, our triangle terminology helps describe repeating patterns!</p>

<p>Trig is the anatomy book for &#8220;math-made&#8221; objects. If we can find a metaphorical triangle, we&#8217;ll get an armada of conclusions for free.</p>

<h2>Sine/Cosine: The Dome</h2>

<p>Instead of staring at triangles by themselves, like a caveman frozen in ice, imagine them in a scenario, hunting that mammoth.</p>

<p>Pretend you&#8217;re in the middle of your dome, about to hang up a movie screen. You point to some angle &#8220;x&#8221;, and that&#8217;s where the screen will hang.</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/trig-dome.png" alt="Trig dome analogy" class="webpexpress-processed"></p>

<p>The angle you point at determines:</p>

<ul>
<li>sine(x) = sin(x) = height of the screen, hanging like a sign</li>
<li>cosine(x) = cos(x) = distance to the screen along the ground [&#8220;cos&#8221; ~ how &#8220;close&#8221;]</li>
<li>the hypotenuse, the distance to the top of the screen, is always the same</li>
</ul>

<p>Want the biggest screen possible? Point straight up. It&#8217;s at the center, on top of your head, but it&#8217;s <em>big</em> dagnabbit.</p>

<p>Want the screen the furthest away? Sure. Point straight across, 0 degrees. The screen has &#8220;0 height&#8221; at this position, and it&#8217;s far away, like you asked.</p>

<p>The height and distance move in opposite directions: bring the screen closer, and it gets taller.</p>

<h2>Tip: Trig Values Are Percentages</h2>

<p>Nobody ever told me in my years of schooling: <strong>sine and cosine are percentages</strong>. They vary from +100% to 0 to -100%, or max positive to nothing to max negative.</p>

<p>Let&#8217;s say I paid \$14 in tax. You have no idea if that&#8217;s expensive. But if I say I paid 95% in tax, you know I&#8217;m getting ripped off.</p>

<p>An absolute height isn&#8217;t helpful, but if your sine value is .95, I know you&#8217;re almost at the top of your dome. Pretty soon you&#8217;ll hit the max, then start coming down again.</p>

<p>How do we compute the percentage? Simple: divide the current value by the maximum possible (the radius of the dome, aka the hypotenuse).</p>

<p><em>That&#8217;s</em> why we&#8217;re told &#8220;Sine = Opposite / Hypotenuse&#8221;. It&#8217;s to get a percentage! A better wording is &#8220;Sine is your height, as a percentage of the hypotenuse&#8221;. (Sine becomes negative if your angle points &#8220;underground&#8221;. Cosine becomes negative when your angle points backwards.)</p>

<p>Let&#8217;s simplify the calculation by assuming we&#8217;re on the unit circle (radius 1). Now we can skip the division by 1 and just say sine = height.</p>

<p>Every circle is really the unit circle, scaled up or down to a different size. So work out the connections on the unit circle and apply the results to your particular scenario.</p>

<p>Try it out: plug in an angle and see what percent of the height and width it reaches:</p>

<iframe src="https://instacalc.com/20361/embed" height="170" width="450" frameborder="0" marginwidth="0" marginheight="0"></iframe>

<p>The growth pattern of sine isn&#8217;t an even line. The first 45 degrees cover 70% of the height, and the final 10 degrees (from 80 to 90) only cover 2%.</p>

<p>This should make sense: at 0 degrees, you&#8217;re moving nearly vertical, but as you get to the top of the dome, your height changes level off.</p>

<h2>Tangent/Secant: The Wall</h2>

<p>One day your neighbor puts up a wall <em>right next</em> to your dome. Ack, your view! Your resale value!</p>

<p>But can we make the best of a bad situation?</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/trig-wall.png" alt="trig wall analogy" class="webpexpress-processed"></p>

<p>Sure. What if we hang our movie screen on the wall? You point at an angle (x) and figure out:</p>

<ul>
<li>tangent(x) = tan(x) = height of screen on the wall</li>
<li>distance to screen: 1 (the screen is always the same distance along the ground, right?)</li>
<li>secant(x) = sec(x) = the &#8220;ladder distance&#8221; to the screen</li>
</ul>

<p>We have some fancy new vocab terms. Imagine seeing the Vitruvian &#8220;TAN GENTleman&#8221; projected on the wall. You climb the ladder, making sure you can &#8220;SEE, CAN&#8217;T you?&#8221;. (Yeah, he&#8217;s naked&#8230; won&#8217;t forget the analogy now, will you?)</p>

<p>Let&#8217;s notice a few things about tangent, the height of the screen.</p>

<ul>
<li><p>It starts at 0, and goes infinitely high. You can keep pointing higher and higher on the wall, to get an infinitely large screen! (That&#8217;ll cost ya.)</p></li>
<li><p>Tangent is just a bigger version of sine! It&#8217;s never smaller, and while sine &#8220;tops off&#8221; as the dome curves in, tangent keeps growing.</p></li>
</ul>

<p>How about secant, the ladder distance?</p>

<ul>
<li>Secant starts at 1 (ladder on the floor to the wall) and grows from there</li>
<li>Secant is always longer than tangent. The leaning ladder used to put up the screen must be longer than the screen itself, right? (At enormous sizes, when the ladder is nearly vertical, they&#8217;re close. But secant is always a smidge longer.)</li>
</ul>

<p>Remember, the values are <em>percentages</em>. If you&#8217;re pointing at a 50-degree angle, tan(50) = 1.19. Your screen is 19% larger than the distance to the wall (the radius of the dome).</p>

<iframe src="https://instacalc.com/51565/embed" height="170" width="450" frameborder="0" marginwidth="0" marginheight="0"></iframe>

<p>(Plug in x=0 and check your intuition that tan(0) = 0, and sec(0) = 1.)</p>

<h2>Cotangent/Cosecant: The Ceiling</h2>

<p>Amazingly enough, your neighbor now decides to build a ceiling on top of your dome, far into the horizon. (<em>What&#8217;s with this guy? Oh, the naked-man-on-my-wall incident&#8230;</em>)</p>

<p>Well, time to build a ramp to the ceiling, and have a little chit chat. You pick an angle to build and work out:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/trig-ceiling.png" alt="trig ceiling" class="webpexpress-processed"></p>

<ul>
<li>cotangent(x) = cot(x) = how far the ceiling extends before we connect</li>
<li>cosecant(x) = csc(x) = how long we walk on the ramp</li>
<li>the vertical distance traversed is always 1</li>
</ul>

<p>Tangent/secant describe the wall, and COtangent and COsecant describe the ceiling.</p>

<p>Our intuitive facts are similar:</p>

<ul>
<li>If you pick an angle of 0, your ramp is flat (infinite) and never reaches the ceiling. Bummer.</li>
<li>The shortest &#8220;ramp&#8221; is when you point 90-degrees straight up. The cotangent is 0 (we didn&#8217;t move along the ceiling) and the cosecant is 1 (the &#8220;ramp length&#8221; is at the minimum).</li>
</ul>

<h2>Visualize The Connections</h2>

<p>A short time ago I had <em>zero</em> &#8220;intuitive conclusions&#8221; about the cosecant. But with the dome/wall/ceiling metaphor, here&#8217;s what we see:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/trig-overall.png" alt="Trig all functions in a single diagram" class="webpexpress-processed"></p>

<p>Whoa, it&#8217;s the same triangle, just scaled to reach the wall and ceiling. We have vertical parts (sine, tangent), horizontal parts (cosine, cotangent), and &#8220;hypotenuses&#8221; (secant, cosecant). (Note: the labels show where each item &#8220;goes up to&#8221;. Cosecant is the full distance from you to the ceiling.)</p>

<p>Now the magic. The triangles have similar facts:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/trig-identities.png" alt="Trig identities from similar triangles and pythagorean theorem" class="webpexpress-processed"></p>

<p>From the <a href="https://betterexplained.com/articles/surprising-uses-of-the-pythagorean-theorem/">Pythagorean Theorem</a> (<img src="https://betterexplained.com/latex/34b5a306bb294561834a.png" alt="$a^2 + b^2 = c^2$" width="96" height="17" style="vertical-align:-1.49px" class="bex-math"></img>) we see how the sides of each triangle are linked.</p>

<p>And from <a href="https://betterexplained.com/articles/understanding-why-similarity-works/">similarity</a>, ratios like &#8220;height to width&#8221; must be the same for these triangles. (Intuition: step away from a big triangle. Now it looks smaller in your field of view, but the internal ratios couldn&#8217;t have changed.)</p>

<p>This is how we find out &#8220;sine/cosine = tangent/1&#8221;.</p>

<p>I&#8217;d always tried to memorize these facts, when they just jump out at us when visualized. SOH-CAH-TOA is a nice shortcut, but get a real understanding first!</p>

<h2>Gotcha: Remember Other Angles</h2>

<p><em>Psst</em>&#8230; don&#8217;t over-focus on a single diagram, thinking tangent is always smaller than 1. If we increase the angle, we reach the ceiling before the wall:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/trig-overall-alt.png" alt="Trig alternative" class="webpexpress-processed"></p>

<p>The Pythagorean/similarity connections are always true, but the relative sizes can vary.</p>

<p>(But, you might notice that sine and cosine are always smallest, or tied, since they&#8217;re trapped inside the dome. Nice!)</p>

<h2>Summary: What Should We Remember?</h2>

<p>For most of us, I&#8217;d say this is enough:</p>

<ul>
<li>Trig explains the anatomy of &#8220;math-made&#8221; objects, such as circles and repeating cycles</li>
<li>The dome/wall/ceiling analogy shows the connections between the trig functions</li>
<li>Trig functions return percentages, that we apply to our specific scenario</li>
</ul>

<p>You don&#8217;t need to memorize <img src="https://betterexplained.com/latex/3d108451e346f1679e5f.png" alt="$1^2 + \cot^2 = \csc^2$" width="127" height="17" style="vertical-align:-1.49px" class="bex-math"></img>, except for silly tests that mistake trivia for understanding. In that case, take a minute to draw the dome/wall/ceiling diagram, fill in the labels (a tan gentleman you can see, can&#8217;t you?), and create a <a href="http://www.mathwords.com/t/trig_identities.htm">cheatsheet</a> for yourself.</p>

<p>In a follow-up, we&#8217;ll learn about graphing, complements, and using <a href="https://betterexplained.com/articles/intuitive-understanding-of-eulers-formula/">Euler&#8217;s Formula</a> to find even more connections.</p>

<h2>Appendix: The Original Definition Of Tangent</h2>

<p>You may see tangent defined as the length of the tangent line from the circle to the x-axis (geometry buffs can work this out).</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/tangent.png" alt="Tangent" class="webpexpress-processed"></p>

<p>As expected, at the top of the circle (x=90) the tangent line can never reach the x-axis and is infinitely long.</p>

<p>I like this intuition because it helps us remember the name &#8220;tangent&#8221;, and here&#8217;s a nice <a href="http://web.archive.org/web/20150511220229/http://www.touchmathematics.org:80/topics/trigonometry">interactive trig guide</a> to explore:</p>

<p><a href="http://web.archive.org/web/20150511220229/http://www.touchmathematics.org:80/topics/trigonometry"><img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/trig-interactive.png" alt="Trig interactive" class="webpexpress-processed"></a></p>

<p>Still, it&#8217;s critical to put the tangent vertical and recognize it&#8217;s just sine projected on the back wall (along with the other triangle connections).</p>

<h2>Appendix: Inverse Functions</h2>

<p>Trig functions take an angle and return a percentage. <img src="https://betterexplained.com/latex/cdd68ea93ba8b7a4410a.png" alt="$\sin(30) = .5$" width="93" height="19" style="vertical-align:-4.53px" class="bex-math"></img> means a 30-degree angle is 50% of the max height.</p>

<p>The inverse trig functions let us work backwards, and are written <img src="https://betterexplained.com/latex/63cc7d892ff2e54e32d1.png" alt="$\sin^{-1}$" width="41" height="16" style="vertical-align:-0.2px" class="bex-math"></img> or <img src="https://betterexplained.com/latex/eb38ac535f8f56ce8007.png" alt="$\arcsin$" width="47" height="13" style="vertical-align:-0.2px" class="bex-math"></img> (&#8220;arcsine&#8221;), and often written <code>asin</code> in various programming languages.</p>

<p>If our height is 25% of the dome, what&#8217;s our angle?</p>

<iframe src="https://instacalc.com/20385/embed" height="170" width="450" frameborder="0" marginwidth="0" marginheight="0"></iframe>

<p>Plugging asin(.25) into a calculator gives an angle of 14.5 degrees.</p>

<p>Now what about something exotic, like inverse secant? Often times it&#8217;s not available as a calculator function (even the one I built, sigh).</p>

<p>Looking at our trig cheatsheet, we find an easy ratio where we can compare secant to 1. For example, secant to 1 (hypotenuse to horizontal) is the same as 1 to cosine:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/1c6b27dcf917ff034bed2aa595eba81a.png' width='76' height='38' alt='\displaystyle{\frac{\sec}{1} = \frac{1}{\cos}}' class='tex'></p>

<p>Suppose our secant is 3.5, i.e. 350% of the radius of the unit circle. What&#8217;s the angle to the wall?</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/a29970d0f195066e76005026f22178b1.png' width='189' height='124' alt='&#10;\begin{aligned}&#10;\frac{\sec}{1} &amp;= \frac{1}{\cos} = 3.5 \\&#10;\cos &amp;= \frac{1}{3.5} \\&#10;\arccos(\frac{1}{3.5}) &amp;= 73.4&#10;\end{aligned}&#10;' class='tex'></p>

<h2>Appendix: A Few Examples</h2>

<p><strong>Example: Find the sine of angle x.</strong></p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/example-sine.png?t=1" alt="Sine Example" /></p>

<p>Ack, what a boring question. Instead of &#8220;find the sine&#8221; think, &#8220;What&#8217;s the height as a percentage of the max (the hypotenuse)?&#8221;.</p>

<p>First, notice the triangle is &#8220;backwards&#8221;. That&#8217;s ok. It still has a height, in green.</p>

<p>What&#8217;s the max height? By the Pythagorean theorem, we know</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/48bebf9436a39d73cfcc9c2240e2f48c.png' width='176' height='78' alt='&#10;\begin{aligned}&#10;3^2 + 4^2 &amp;= \text{hypotenuse}^2 \\&#10;25 &amp;= \text{hypotenuse}^2 \\&#10;5 &amp;= \text{hypotenuse}&#10;\end{aligned}&#10;' class='tex'></p>

<p>Ok! The sine is the height as a percentage of the max, which is 3/5 or .60.</p>

<p><strong>Follow-up: Find the angle.</strong></p>

<p>Of course. We have a few ways. Now that we know sine = .60, we can just do:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/91ccb174c2db0946bd9857a5a6bd15d0.png' width='139' height='18' alt='\displaystyle{\arcsin(.60) = 36.9}' class='tex'></p>

<p>Here&#8217;s another approach. Instead of using sine, notice the triangle is &#8220;up against the wall&#8221;, so tangent is an option. The height is 3, the distance to the wall is 4, so the tangent height is 3/4 or 75%. We can use arctangent to turn the percentage back into an angle:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/1beb7a7bbecad3ad24eef007aeea4f3a.png' width='110' height='37' alt='\displaystyle{\tan = \frac{3}{4} = .75 }' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/775e788c6261426fcb1392018ed6a9c5.png' width='143' height='18' alt='\displaystyle{\arctan(.75) = 36.9}' class='tex'></p>

<p><strong>Example: Can you make it to shore?</strong></p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/example-boat.png" alt="Boat Example" class="webpexpress-processed"></p>

<p>You&#8217;re on a boat with enough fuel to sail 2 miles. You&#8217;re currently .25 miles from shore. What&#8217;s the largest angle you could use and still reach land? Also, the only reference available is <em>Hubert&#8217;s Compendium of Arccosines, 3rd Ed</em>. (Truly, a hellish voyage.)</p>

<p>Ok. Here, we can visualize the beach as the &#8220;wall&#8221; and the &#8220;ladder distance&#8221; to the wall is the secant.</p>

<p>First, we need to normalize everything in terms of percentages. We have 2 / .25 = 8 &#8220;hypotenuse units&#8221; worth of fuel. So, the largest secant we could allow is 8 times the distance to the wall.</p>

<p>We&#8217;d <em>like</em> to ask &#8220;What angle has a secant of 8?&#8221;. But we can&#8217;t, since we only have a book of arccosines.</p>

<p>We use our cheatsheet diagram to relate secant to cosine: Ah, I see that &#8220;sec/1 = 1/cos&#8221;, so</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/788083022b6e0f305a4c5b63f7a95a4f.png' width='161' height='124' alt='&#10;\begin{aligned}&#10;\sec &amp;= \frac{1}{\cos} = 8 \\&#10;\cos &amp;= \frac{1}{8} \\&#10;\arccos(\frac{1}{8}) &amp;= 82.8&#10;\end{aligned}&#10;' class='tex'></p>

<p>A secant of 8 implies a cosine of 1/8. The angle with a cosine of 1/8 is arccos(1/8) = 82.8 degrees, the largest we can afford.</p>

<p>Not too bad, right? Before the dome/wall/ceiling analogy, I&#8217;d be drowning in a mess of computations. Visualizing the scenario makes it simple, even fun, to see which trig buddy can help us out.</p>

<p>In your problem, think: am I interested in the dome (sin/cos), the wall (tan/sec), or the ceiling (cot/csc)?</p>

<p>Happy math.</p>

<p><strong>Update:</strong> The owner of <a href="https://gmmentalgym.blogspot.com/">Grey Matters</a> put together interactive diagrams for the analogies (drag the slider on the left to change the angle):</p>

<ul>
<li><a href="https://www.desmos.com/calculator/0uyr4ywrvt">Sine/Cosine: The Dome</a></li>
<li><a href="https://www.desmos.com/calculator/2ehsvswurj">Tangent/Secant: The Wall</a></li>
<li><a href="https://www.desmos.com/calculator/1bswcagm9k">Cotangent/Cosecant: The Ceiling</a></li>
<li><a href="https://www.desmos.com/calculator/az45nwnmis">Combined visualization</a></li>
</ul>

<p><a href="https://www.desmos.com/calculator/az45nwnmis"><img decoding="async" src="https://betterexplained.com/wp-content/uploads/2014/02/interactive-2.png" alt="interactive-2" width="400" height="382" class="webpexpress-processed"></a></p>

<p>Thanks!</p>

]]></content:encoded>
					
					<wfw:commentRss>https://betterexplained.com/articles/intuitive-trigonometry/feed/</wfw:commentRss>
			<slash:comments>172</slash:comments>
		

			</item>
	<item>
		<title>An Interactive Guide To The Fourier Transform</title>
		<link>https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/</link>
					<comments>https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/#disqus_thread</comments>
		
		<dc:creator><![CDATA[kalid]]></dc:creator>
		<pubDate>Thu, 20 Dec 2012 03:30:10 +0000</pubDate>
				<category><![CDATA[Math]]></category>
				<category><![CDATA[Popular]]></category>
				<category><![CDATA[Fourier Transform]]></category>
		<guid isPermaLink="false">http://betterexplained.com/?p=2851</guid>

					<description><![CDATA[The Fourier Transform is one of the deepest insights ever made. Unfortunately, the meaning is buried within dense equations: Yikes. Rather than jumping into the symbols, let's experience the key idea firsthand. Here's a plain-English metaphor: What does the Fourier Transform do? Given a smoothie, it finds the recipe. How? Run the smoothie through filters [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>The Fourier Transform is one of the deepest insights ever made. Unfortunately, the meaning is buried within dense equations:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/45c088dbb767150fc0bacfeb49dd49e5.png' width='189' height='54' alt='\displaystyle{X_k = \sum_{n=0}^{N-1} x_n \cdot e^{-i 2 \pi k n / N}}' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/faeb9c5bf2e60add63ae4a70b293c7b4.png' width='202' height='54' alt='\displaystyle{x_n = \frac{1}{N} \sum_{k=0}^{N-1} X_k \cdot e^{i 2 \pi k n / N}}' class='tex'></p>

<p>Yikes. Rather than jumping into the symbols, let's experience the key idea firsthand. Here's a plain-English metaphor:</p>

<ul>
<li><strong>What does the Fourier Transform do?</strong> Given a smoothie, it finds the recipe.</li>
<li><strong>How?</strong> Run the smoothie through filters to extract each ingredient.</li>
<li><strong>Why?</strong> Recipes are easier to analyze, compare, and modify than the smoothie itself.</li>
<li><strong>How do we get the smoothie back?</strong> Blend the ingredients.</li>
</ul>

<p>Here's the "math English" version of the above:</p>

<ul>
<li>The Fourier Transform takes a time-based pattern, measures every possible cycle, and returns the overall "cycle recipe" (the amplitude, offset, &amp; rotation speed for every cycle that was found).</li>
</ul>

<p>Time for the equations? No! Let's get our hands dirty and <em>experience</em> how any pattern can be built with cycles, with live simulations.</p>

<p>If all goes well, we'll have an aha! moment and intuitively realize why the Fourier Transform is possible. We'll save the detailed math analysis for the follow-up.</p>

<p>This isn't a force-march through the equations, it's the casual stroll I wish I had. Onward!</p>

<div style="position:relative;height:0;padding-bottom:56.25%"><iframe src="https://www.youtube.com/embed/iN0VG9N2q0U?ecver=2" width="640" height="360" frameborder="0" style="position:absolute;width:100%;height:100%;left:0" allowfullscreen></iframe></div>

<h2>From Smoothie to Recipe</h2>

<p>A math transformation is a change of perspective. We change our notion of quantity from "single items" (lines in the sand, tally system) to "groups of 10" (decimal) depending on what we're counting. Scoring a game? Tally it up. Multiplying? Decimals, please.</p>

<p>The Fourier Transform changes our perspective from consumer to producer, turning <em>What do I have?</em> into <em>How was it made?</em></p>

<p>In other words: given a smoothie, let's find the recipe.</p>

<p>Why? Well, recipes are great descriptions of drinks. You wouldn't share a drop-by-drop analysis, you'd say "I had an orange/banana smoothie". A recipe is more easily categorized, compared, and modified than the object itself.</p>

<p>So... given a smoothie, how do we find the recipe?</p>

<p><img decoding="async" alt="fourier transform analogy smoothie to recipe" src="https://betterexplained.com/wp-content/uploads/images/smoothie-to-recipe-20121030-223058.png" height="300" class="webpexpress-processed"></p>

<p>Well, imagine you had a few filters lying around:</p>

<ul>
<li>Pour through the "banana" filter. 1 oz of bananas are extracted.</li>
<li>Pour through the "orange" filter. 2 oz of oranges.</li>
<li>Pour through the "milk" filter. 3 oz of milk.</li>
<li>Pour through the "water" filter. 3 oz of water.</li>
</ul>

<p>We can reverse-engineer the recipe by filtering each ingredient. The catch?</p>

<ul>
<li><p><strong>Filters must be independent</strong>. The banana filter needs to capture bananas, and nothing else. Adding more oranges should never affect the banana reading.</p></li>
<li><p><strong>Filters must be complete</strong>. We won't get the real recipe if we leave out a filter ("There were mangoes too!"). Our collection of filters must catch every possible ingredient.</p></li>
<li><p><strong>Ingredients must be combine-able</strong>. Smoothies can be separated and re-combined without issue (A cookie? Not so much. Who wants crumbs?). The ingredients, when separated and combined in any order, must make the same result.</p></li>
</ul>

<h2>See The World As Cycles</h2>

<p>The Fourier Transform takes a specific viewpoint: <strong>What if any signal could be filtered into a bunch of circular paths?</strong></p>

<p>Whoa. This concept is mind-blowing, and poor Joseph Fourier had his idea rejected at first. (<em>Really Joe, even a staircase pattern can be made from circles?</em>)</p>

<p>And despite <a href="http://wiki.answers.com/Q/What_is_the_history_of_fourier_series">decades of debate</a> in the math community, we expect students to internalize the idea without issue. Ugh. Let's walk through the intuition.</p>

<p>The Fourier Transform finds the recipe for a signal, like our smoothie process:</p>

<ul>
<li>Start with a time-based signal</li>
<li>Apply filters to measure each possible "circular ingredient"</li>
<li>Collect the full recipe, listing the amount of each "circular ingredient"</li>
</ul>

<p>Stop. Here's where most tutorials excitedly throw engineering applications at your face. Don't get scared; think of the examples as "Wow, we're finally seeing the source code (DNA) behind previously confusing ideas".</p>

<ul>
<li><p>If earthquake vibrations can be separated into "ingredients" (vibrations of different speeds &amp; amplitudes), buildings can be designed to avoid interacting with the strongest ones.</p></li>
<li><p>If sound waves can be separated into ingredients (bass and treble frequencies), we can boost the parts we care about, and hide the ones we don't. The crackle of random noise can be removed. Maybe similar "sound recipes" can be compared (music recognition services compare recipes, not the raw audio clips).</p></li>
<li><p>If computer data can be represented with oscillating patterns, perhaps the least-important ones can be ignored. This "lossy compression" can drastically shrink file sizes (and why JPEG and MP3 files are much smaller than raw .bmp or .wav files).</p></li>
<li><p>If a radio wave is our signal, we can use filters to listen to a particular channel. In the smoothie world, imagine each person paid attention to a different ingredient: Adam looks for apples, Bob looks for bananas, and Charlie gets cauliflower (sorry bud).</p></li>
</ul>

<p>The Fourier Transform is useful in engineering, sure, but it's a metaphor about finding the root causes behind an observed effect.</p>

<h2>Think With Circles, Not Just Sinusoids</h2>

<p>One of my giant confusions was separating the definitions of "sinusoid" and "circle".</p>

<ul>
<li>A "sinusoid" is a specific back-and-forth pattern (a <a href="https://betterexplained.com/articles/intuitive-understanding-of-sine-waves/">sine</a> or cosine wave), and 99% of the time, it refers to motion in one dimension.</li>
<li>A "circle" is a round, 2d pattern you probably know. If you enjoy using 10-dollar words to describe 10-cent ideas, you might call a circular path a "complex sinusoid".</li>
</ul>

<p>Labeling a circular path as a "complex sinusoid" is like describing a word as a "multi-letter". You zoomed into the wrong level of detail. Words are about concepts, not the letters they can be split into!</p>

<p>The Fourier Transform is about circular paths (not 1-d sinusoids) and <a href="https://betterexplained.com/articles/intuitive-understanding-of-eulers-formula/">Euler's formula</a> is a clever way to generate one:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/euler/equal_paths.png" alt="euler path" class="webpexpress-processed"></p>

<p>Must we use imaginary exponents to move in a circle? Nope. But it's convenient and compact. And sure, we can describe our path as coordinated motion in two dimensions (real and imaginary), but don't forget the big picture: we're just moving in a circle.</p>

<h2>Following Circular Paths</h2>

<p>Let's say we're chatting on the phone and, like usual, I want us to draw the same circle simultaneously. (<em>You promised!</em>) What should I say?</p>

<ul>
<li>How big is the circle? (Amplitude, i.e. size of radius)</li>
<li>How fast do we draw it? (Frequency. 1 circle/second is a frequency of 1 Hertz (Hz) or 2*pi radians/sec)</li>
<li>Where do we start? (Phase angle, where 0 degrees is the x-axis)</li>
</ul>

<p>I could say "2-inch radius, start at 45 degrees, 1 circle per second, go!". After half a second, we should each be pointing to: starting point + amount traveled = 45 + 180 = 225 degrees (on a 2-inch circle).</p>

<p><img decoding="async" alt="circular path with parameters" src="https://betterexplained.com/wp-content/uploads/images/circular-path-parameters-20121201-203317.png" width="500" class="webpexpress-processed"></p>

<p>Every circular path needs a size, speed, and starting angle (amplitude/frequency/phase). We can even combine paths: imagine tiny motorcars, driving in circles at different speeds.</p>

<p>The combined position of <em>all the cycles</em> is our signal, just like the combined flavor of <em>all the ingredients</em> is our smoothie.</p>

<p>Here's a simulation of a basic circular path:</p>

<iframe src="https://betterexplained.com/examples/fourier/?cycles=0,1" width="550px" height="280px" frameborder="0"></iframe>

<p>(Based on <a href="https://web.archive.org/web/20140320040804/http://treeblurb.com/dev_math/sin_canv00.html">this animation</a>, here's <a href="https://gist.github.com/kazad/8bb682da198db597558c">the source code</a>. Modern browser required. Click the graph to pause/unpause.)</p>

<p>The magnitude of each cycle is listed in order, starting at 0Hz. Cycles <code>[0 1]</code> means</p>

<ul>
<li>0 amplitude for the 0Hz cycle (0Hz = a constant cycle, stuck on the x-axis at zero degrees)</li>
<li>1 amplitude for the 1Hz cycle (completes 1 cycle per time interval)</li>
</ul>

<p>Now the tricky part:</p>

<ul>
<li><strong>The blue graph measures the <em>real part</em> of the cycle</strong>. Another lovely math confusion: the real axis of the circle, which is usually horizontal, has its magnitude shown on the vertical axis. You can mentally rotate the circle 90 degrees if you like.</li>
<li><strong>The time points are spaced at the fastest frequency</strong>. A 1Hz signal needs 2 time points for a start and stop (a single data point doesn't have a frequency). The time values <code>[1 -1]</code> shows the amplitude at these equally-spaced intervals.</li>
</ul>

<p>With me? <code>[0 1]</code> is a pure 1Hz cycle.</p>

<p>Now let's add a 2Hz cycle to the mix. <code>[0 1 1]</code> means "Nothing at 0Hz, 1Hz of amplitude 1, 2Hz of amplitude 1":</p>

<iframe src="https://betterexplained.com/examples/fourier/?cycles=0,1,1" width="550px" height="280px" frameborder="0"></iframe>

<p>Whoa. The little motorcars are getting wild: the green lines are the 1Hz and 2Hz cycles, and the blue line is the combined result. Try toggling the green checkbox to see the final result clearly. The combined "flavor" is a sway that starts at the max and dips low for the rest of the interval.</p>

<p>The yellow dots are when we actually measure the signal. With 3 cycles defined (0Hz, 1Hz, 2Hz), each dot is 1/3 of the way through the signal. In this case, cycles <code>[0 1 1]</code> generate the time values <code>[2 -1 -1]</code>, which starts at the max (2) and dips low (-1).</p>

<p>Oh! We can't forget phase, the starting angle! Use <code>magnitude:angle</code> to set the phase. So <code>[0 1:45]</code> is a 1Hz cycle that starts at 45 degrees:</p>

<iframe src="https://betterexplained.com/examples/fourier/?cycles=0,1:45" width="550px" height="280px" frameborder="0"></iframe>

<p>This is a shifted version of <code>[0 1]</code>. On the time side we get <code>[.7 -.7]</code> instead of <code>[1 -1]</code>, because our cycle isn't exactly lined up with our measuring intervals, which are still at the halfway point (this could be desired!).</p>

<p><strong>The Fourier Transform finds the set of cycle speeds, amplitudes and phases to match any time signal.</strong></p>

<p>Our signal becomes an abstract notion that we consider as "observations in the time domain" or "ingredients in the frequency domain".</p>

<p>Enough talk: try it out! In the simulator, type any time or cycle pattern you'd like to see. If it's time points, you'll get a collection of cycles (that combine into a "wave") that matches your desired points.</p>

<p><a href="https://betterexplained.com/wp-content/uploads/images/time-patterns-20121205-164541.png" target="_blank" rel="noopener">
<img decoding="async" alt="fourier transform examples" src="https://betterexplained.com/wp-content/uploads/images/time-patterns-20121205-164541.png" width="550px" class="webpexpress-processed"></a></p>

<p>But… doesn't the combined wave have strange values between the yellow time intervals? Sure. But who's to say whether a signal travels in straight lines, or curves, or zips into other dimensions when we aren't measuring it? It behaves exactly as we need at the equally-spaced moments we asked for.</p>

<h2>Making A Spike In Time</h2>

<p>Can we make a spike in time, like <code>(4 0 0 0)</code>, using cycles? I'll use parentheses <code>()</code> for a sequence of time points, and brackets <code>[]</code> for a sequence of cycles.</p>

<p>Although the spike seems boring to us time-dwellers (<em>one data point, that's it?</em>), think about the complexity in the cycle world. Our cycle ingredients must start aligned (at the max value, 4) and then "explode outwards", each cycle with partners that cancel it in the future. Every remaining point is zero, which is a tricky balance with multiple cycles running around (we can't just "turn them off").</p>

<p>Let's walk through each time point:</p>

<ul>
<li><p>At time 0, the first instant, every cycle ingredient is at its max. Ignoring the other time points, <code>(4 ? ? ?)</code> can be made from 4 cycles (0Hz 1Hz 2Hz 3Hz), each with a magnitude of 1 and phase of 0 (i.e., 1 + 1 + 1 + 1 = 4).</p></li>
<li><p>At every future point (t = 1, 2, 3), the sum of all cycles must cancel.</p></li>
</ul>

<p>Here's the trick: when two cycles are on opposites sides of the circle (North &amp; South, East &amp; West, etc.) their combined position is zero (3 cycles can cancel if they're spread evenly at 0, 120, and 240 degrees).</p>

<p>Imagine a constellation of points moving around the circle. Here's the position of each cycle at every instant:</p>

<pre>Time 0 1 2 3 
------------
0Hz: 0 0 0 0 
1Hz: 0 1 2 3
2Hz: 0 2 0 2
3Hz: 0 3 2 1
</pre>

<p>Notice how the 3Hz cycle starts at 0, gets to position 3, then position "6" (with only 4 positions, 6 <a href="https://betterexplained.com/articles/fun-with-modular-arithmetic/">modulo</a> 4 = 2), then position "9" (9 modulo 4 = 1).</p>

<p>When our cycle is 4 units long, cycle speeds a half-cycle apart (2 units) will either be lined up (difference of 0, 4, 8…) or on opposite sides (difference of 2, 6, 10…).</p>

<p>OK. Let's drill into each time point:</p>

<ul>
<li>Time 0: All cycles at their max (total of 4)</li>
<li>Time 1: 1Hz and 3Hz cancel (positions 1 &amp; 3 are opposites), 0Hz and 2Hz cancel as well. The net is 0.</li>
<li>Time 2: 0Hz and 2Hz line up at position 0, while 1Hz and 3Hz line up at position 2 (the opposite side). The total is still 0.</li>
<li>Time 3: 0Hz and 2Hz cancel. 1Hz and 3Hz cancel.</li>
<li>Time 4 (repeat of t=0): All cycles line up.</li>
</ul>

<p>The trick is having individual speeds cancel (0Hz vs 2Hz, 1Hz vs 3Hz), or having the lined-up pairs cancel (0Hz + 2Hz vs 1Hz + 3Hz).</p>

<p>When every cycle has equal power and 0 phase, we start aligned and cancel afterwards. (I don't have a nice proof yet -- any takers? -- but you can see it yourself. Try <code>[1 1]</code>, <code>[1 1 1]</code>, <code>[1 1 1 1]</code> and notice the signals we generate: <code>(2 0)</code>, <code>(3 0 0)</code>, <code>(4 0 0 0)</code>).</p>

<p>In my head, I label these signals as "time spikes": they have a value for a single instant, and are zero otherwise (the fancy name is a <a href="https://en.wikipedia.org/wiki/Dirac_delta_function">delta function</a>.)</p>

<p>Here's how I visualize the initial alignment, followed by a net cancellation:</p>

<p><img decoding="async" alt="fourier transform constructive and destructive interference" src="https://betterexplained.com/wp-content/uploads/images/fourier-interference-20121211-171719.png" width="400px" class="webpexpress-processed"></p>

<h2>Moving The Time Spike</h2>

<p>Not everything happens at t=0. Can we change our spike to <code>(0 4 0 0)</code>?</p>

<p>It seems the cycle ingredients should be similar to <code>(4 0 0 0)</code>, but the cycles must align at t=1 (one second in the future). Here's where phase comes in.</p>

<p>Imagine a race with 4 runners. Normal races have everyone lined up at the starting line, the <code>(4 0 0 0)</code> time pattern. Boring.</p>

<p>What if we want everyone to <em>finish</em> at the same time? Easy. Just move people forward or backwards by the appropriate distance. Maybe granny can start 2 feet in front of the finish line, Usain Bolt can start 100m back, and they can cross the tape holding hands.</p>

<p>Phase shifts, the starting angle, are delays in the cycle universe. Here's how we adjust the starting position to delay every cycle 1 second:</p>

<ul>
<li>A 0Hz cycle doesn't move, so it's already aligned</li>
<li>A 1Hz cycle goes 1 revolution in the entire 4 seconds, so a 1-second delay is a quarter-turn. Phase shift it 90 degrees backwards (-90) and it gets to phase=0, the max value, at t=1.</li>
<li>A 2Hz cycle is twice as fast, so give it twice the angle to cover (-180 or 180 phase shift -- it's across the circle, either way).</li>
<li>A 3Hz cycle is 3x as fast, so give it 3x the distance to move (-270 or +90 phase shift)</li>
</ul>

<p>If time points <code>(4 0 0 0)</code> are made from cycles <code>[1 1 1 1]</code>, then time points <code>(0 4 0 0)</code> are made from <code>[1 1:-90 1:180 1:90]</code>. (Note: I'm using "1Hz", but I mean "1 cycle over the entire time period").</p>

<p>Whoa -- we're working out the cycles in our head!</p>

<p>The interference visualization is similar, except the alignment is at t=1.</p>

<p><img decoding="async" alt="fourier transform time spike" src="https://betterexplained.com/wp-content/uploads/images/delayed-spike-20121214-162623.png" width="400px" class="webpexpress-processed"></p>

<p>Test your intuition: Can you make <code>(0 0 4 0)</code>, i.e. a 2-second delay? 0Hz has no phase. 1Hz has 180 degrees, 2Hz has 360 (aka 0), and 3Hz has 540 (aka 180), so it's <code>[1 1:180 1 1:180]</code>.</p>

<h2>Discovering The Full Transform</h2>

<p>The big insight: our signal is just a bunch of time spikes! If we merge the recipes for each time spike, we should get the recipe for the full signal.</p>

<p>The Fourier Transform builds the recipe frequency-by-frequency:</p>

<ul>
<li>Separate the full signal (a b c d) into "time spikes": (a 0 0 0) (0 b 0 0) (0 0 c 0) (0 0 0 d)</li>
<li>For any frequency (like 2Hz), the <em>tentative</em> recipe is "a/4 + b/4 + c/4 + d/4" (the amplitude of each spike is split among all frequencies)</li>
<li>Wait! We need to offset each spike with a phase delay (the angle for a "1 second delay" depends on the frequency).</li>
<li>Actual recipe for a frequency = a/4 (no offset) + b/4 (1 second offset) + c/4 (2 second offset) + d/4 (3 second offset).</li>
</ul>

<p>We can then loop through every frequency to get the full transform.</p>

<p>Here's the conversion from "math English" to full math:</p>

<p><img decoding="async" alt="fourier transform plain english" src="https://betterexplained.com/wp-content/uploads/images/fourier-explained-20121219-224649.png" width="500px" class="webpexpress-processed"></p>

<p>A few notes:</p>

<ul>
<li>N = number of time samples we have</li>
<li>n = current sample we're considering (0 .. N-1)</li>
<li>x<sub>n</sub> = value of the signal at time n</li>
<li>k = current frequency we're considering (0 Hertz up to N-1 Hertz)</li>
<li>X<sub>k</sub> = amount of frequency k in the signal (amplitude and phase, a complex number)</li>
<li>The 1/N factor is usually moved to the <em>reverse transform</em> (going from frequencies back to time). This <a href="http://math.stackexchange.com/questions/58163/dft-why-are-the-definitions-for-inverse-and-forward-commonly-switched">is allowed</a>, though I prefer 1/N in the forward transform since it gives the <em>actual</em> sizes for the time spikes. You can get wild and even use <img src="https://betterexplained.com/latex/7c865975e451d5e3eebe.png" alt="$1/\sqrt{N}$" width="50" height="23" style="vertical-align:-4.53px" class="bex-math"></img> on both transforms (going forward and back creates the 1/N factor).</li>
<li>n/N is the percent of the time we've gone through. 2 * pi * k is our speed in radians / sec. e^-ix is our backwards-moving circular path. The combination is how far we've moved, for this speed and time.</li>
<li>The raw equations for the Fourier Transform just say "add the complex numbers". Many programming languages cannot handle complex numbers directly, so you convert everything to rectangular coordinates and add those.</li>
</ul>

<h2>Onward</h2>

<p>This was my most challenging article yet. The Fourier Transform has several flavors (discrete/continuous/finite/infinite), covers deep math (Dirac delta functions), and it's easy to get lost in details. I was constantly bumping into the edge of my knowledge.</p>

<p>But there's always simple analogies out there -- I refuse to think otherwise. Whether it's a smoothie or Usain Bolt &amp; Granny crossing the finish line, take a simple understanding and refine it. The analogy is flawed, and that's ok: it's a raft to use, and leave behind once we cross the river.</p>

<p>I realized how feeble my own understanding was when I couldn't work out the transform of <code>(1 0 0 0)</code> in my head. For me, it was like saying I knew addition but, gee whiz, I'm not sure what "1 + 1 + 1 + 1" would be. Why not? Shouldn't we have an intuition for the simplest of operations?</p>

<p>That discomfort led me around the web to build my intuition. In addition to the references in the article, I'd like to thank:</p>

<ul>
<li><a href="http://www.scotthyoung.com/blog/">Scott Young</a>, for the initial impetus for this post</li>
<li><a href="http://shaheengandhi.com">Shaheen Gandhi</a>, Roger Cheng, and <a href="http://britcruise.com/">Brit Cruise</a> for kicking around ideas &amp; refining the analogy</li>
<li><a href="http://cns-alumni.bu.edu/~slehar/fourier/fourier.html">Steve Lehar</a> for great examples of the Fourier Transform on images</li>
<li><a href="http://www.complextoreal.com/chapters/fft1.pdf">Charan Langton</a> for her detailed walkthrough</li>
<li><a href="https://ccrma.stanford.edu/~jos/log/">Julius Smith</a> for a fantastic walkthrough of the Discrete Fourier Transform (what we covered today)</li>
<li><a href="http://worrydream.com/#!/LearnableProgramming">Bret Victor</a> for his techniques on visualizing learning</li>
</ul>

<p>Today's goal was to <em>experience</em> the Fourier Transform. We'll save the advanced analysis for next time.</p>

<p>Happy math.</p>

<h2>Appendix: Projecting Onto Cycles</h2>

<p>Stuart Riffle has a <a href="https://web.archive.org/web/20120418231513/http://www.altdevblogaday.com/2011/05/17/understanding-the-fourier-transform/">great interpretation</a> of the Fourier Transform:</p>

<p><img decoding="async" alt="fourier transform colorized" src="https://betterexplained.com/wp-content/uploads/images/DerivedDFT.png" class="webpexpress-processed"></p>

<p>Imagine spinning your signal in a centrifuge and checking for a bias. I have a correction: we must spin <em>backwards</em> (the exponent in the equation above should be <img src="https://betterexplained.com/latex/838f64d5cea6b214b1e0.png" alt="$e^{-i 2 \pi...}$" width="49" height="16" style="vertical-align:-0.2px" class="bex-math"></img>). You already know why: we need a phase <em>delay</em> so spikes appear in the <em>future</em>.</p>

<h2>Appendix: Another Awesome Visualization</h2>

<p><a href="http://toxicdump.org/blog/">Lucas Vieira</a>, author of excellent <a href="https://en.wikipedia.org/wiki/User:Kieff/Gallery">Wikipedia animations</a>, was <a href="http://blog.matthen.com/post/42112703604/the-smooth-motion-of-rotating-circles-can-be-used">inspired</a> to make this interactive animation:</p>

<p><a href="https://web.archive.org/web/20170201145911/http://toxicdump.org/stuff/FourierToy.swf">Fourier Toy - Click to download, requires flash</a></p>

<p><a href="http://toxicdump.org/stuff/FourierToy.swf"><img decoding="async" class="alignnone size-medium wp-image-5267" src="https://betterexplained.com/wp-content/uploads/2012/12/Fourier_Toy-300x126.png" alt="Fourier_Toy" width="300" height="126" srcset="https://betterexplained.com/wp-content/uploads/2012/12/Fourier_Toy-300x126.png 300w, https://betterexplained.com/wp-content/uploads/2012/12/Fourier_Toy-768x323.png 768w, https://betterexplained.com/wp-content/uploads/2012/12/Fourier_Toy-1024x431.png 1024w, https://betterexplained.com/wp-content/uploads/2012/12/Fourier_Toy-320x135.png 320w, https://betterexplained.com/wp-content/uploads/2012/12/Fourier_Toy-200x84.png 200w, https://betterexplained.com/wp-content/uploads/2012/12/Fourier_Toy-400x168.png 400w, https://betterexplained.com/wp-content/uploads/2012/12/Fourier_Toy.png 1438w" sizes="(max-width: 300px) 100vw, 300px"></a></p>
<!--



<iframe src="https://toxicdump.org/stuff/FourierToy.swf" width="500" height="212" style="border:none;"></iframe>


-->

<p>(<a href="http://www.reddit.com/r/math/comments/17v8cv/visualized_fourier/c89c3pa">Detailed list</a> of control options)</p>

<p>The Fourier Transform is about cycles added to cycles added to cycles. Try making a "time spike" by setting a amplitude of 1 for every component (press Enter after inputting each number). Fun fact: with enough terms, you can draw any shape, even <a href="https://www.youtube.com/watch?v=QVuU2YCwHjw&amp;feature=youtu.be">Homer Simpson</a>.</p>

<iframe src="https://www.youtube.com/embed/QVuU2YCwHjw" width="420" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe>

<p>Check out <a href="http://www.jezzamon.com/fourier/">http://www.jezzamon.com/fourier/</a> for a great tool to draw any shape using epicycles.</p>

<p><a href="http://www.jezzamon.com/fourier/"><img alt="An Interactive Guide To The Fourier Transform" decoding="async" src="https://betterexplained.com/wp-content/uploads/2019/01/Fourier-Transforms-2019-01-12-15-11-48.png" width="500" class="webpexpress-processed">
</a></p>

<h2>Appendix: Article with R code samples</h2>

<p>João Neto made a great writeup, with technical (R) code samples here:</p>

<p><a href="http://www.di.fc.ul.pt/~jpn/r/fourier/fourier.html">http://www.di.fc.ul.pt/~jpn/r/fourier/fourier.html</a></p>

<h2>Appendix: Using the code</h2>

<p>All the code and examples are open source (MIT licensed, do what you like).</p>

<ul>
<li><a href="https://betterexplained.com/examples/fourier/">Interactive example</a> (view source)</li>
<li><a href="https://gist.github.com/129d477ddb1c8025c9ac">Github gist</a></li>
<li><a href="http://www.reddit.com/r/programming/comments/156a9i/an_interactive_guide_to_the_fourier_transform/c7k9b1t?context=3">Reddit discussion</a> on details of the computation, I'm pb_zeppelin</li>
</ul>

]]></content:encoded>
					
					<wfw:commentRss>https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/feed/</wfw:commentRss>
			<slash:comments>478</slash:comments>
		

			</item>
	<item>
		<title>An Intuitive Guide to Linear Algebra</title>
		<link>https://betterexplained.com/articles/linear-algebra-guide/</link>
					<comments>https://betterexplained.com/articles/linear-algebra-guide/#disqus_thread</comments>
		
		<dc:creator><![CDATA[kalid]]></dc:creator>
		<pubDate>Tue, 09 Oct 2012 14:36:36 +0000</pubDate>
				<category><![CDATA[Math]]></category>
				<category><![CDATA[Popular]]></category>
		<guid isPermaLink="false">http://betterexplained.com/?p=2763</guid>

					<description><![CDATA[Despite two linear algebra classes, my knowledge consisted of &#8220;Matrices, determinants, eigen something something&#8221;. Why? Well, let&#8217;s try this course format: Name the course Linear Algebra but focus on things called matrices and vectors Teach concepts like Row/Column order with mnemonics instead of explaining the reasoning Favor abstract examples (2d vectors! 3d vectors!) and avoid [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Despite two linear algebra classes, my knowledge consisted of &#8220;Matrices, determinants, eigen something something&#8221;.</p>

<p>Why? Well, let&#8217;s try this course format:</p>

<ul>
<li>Name the course <em>Linear Algebra</em> but focus on things called matrices and vectors</li>
<li>Teach concepts like Row/Column order with mnemonics instead of explaining the reasoning</li>
<li>Favor abstract examples (2d vectors! 3d vectors!) and avoid real-world topics until the final week</li>
</ul>

<p>The survivors are physicists, graphics programmers and other masochists. We missed the key insight:</p>

<p><strong>Linear algebra gives you mini-spreadsheets for your math equations.</strong></p>

<p>We can take a table of data (a matrix) and create updated tables from the original. It&#8217;s the power of a spreadsheet written as an equation.</p>

<p>Here&#8217;s the linear algebra introduction I wish I had, with a real-world stock market example.</p>

<h2>What&#8217;s in a name?</h2>

<p>&#8220;Algebra&#8221; means, roughly, &#8220;relationships&#8221;. Grade-school algebra explores the relationship between unknown numbers. Without knowing x and y, we can still work out that <img src="https://betterexplained.com/latex/d1107633510ad1c731ba.png" alt="$(x + y)^2 = x^2 + 2xy + y^2$" width="196" height="20" style="vertical-align:-4.53px" class="bex-math"></img>.</p>

<p>&#8220;Linear Algebra&#8221; means, roughly, &#8220;line-like relationships&#8221;. Let&#8217;s clarify a bit.</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/linear-algebra/linear-vs-nonlinear.png" alt="An Intuitive Guide to Linear Algebra" class="webpexpress-processed"></p>

<p>Straight lines are predictable. Imagine a rooftop: move forward 3 horizontal feet (relative to the ground) and you might rise 1 foot in elevation (The slope! Rise/run = 1/3). Move forward 6 feet, and you&#8217;d expect a rise of 2 feet. Contrast this with climbing a dome: each horizontal foot forward raises you a different amount.</p>

<p>Lines are nice and predictable:</p>

<ul>
<li>If 3 feet forward has a 1-foot rise, then going 10x as far should give a 10x rise (30 feet forward is a 10-foot rise)</li>
<li>If 3 feet forward has a 1-foot rise, and 6 feet has a 2-foot rise, then (3 + 6) feet should have a (1 + 2) foot rise</li>
</ul>

<p>In math terms, an operation F is linear if scaling inputs scales the output, and adding inputs adds the outputs:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/09fa24ebc98dc2d051aa341bdf3af939.png' width='192' height='46' alt='&#10;\begin{aligned}&#10;F(ax) &amp;= a \cdot F(x) \\&#10;F(x + y) &amp;= F(x) + F(y)&#10;\end{aligned}&#10;' class='tex'></p>

<p>In our example, <img src="https://betterexplained.com/latex/bac3d1987cb18f3c53f0.png" alt="$F(x)$" width="38" height="19" style="vertical-align:-4.53px" class="bex-math"></img> calculates the rise when moving forward x feet, and the properties hold:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/5daca54e0e1b24f95be0e19730c347ef.png' width='203' height='18' alt='\displaystyle{F(10 \cdot 3) = 10 \cdot F(3) = 10}' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/aa091456dff3c4fca20a57b14c3de208.png' width='222' height='18' alt='\displaystyle{F(3+6) = F(3) + F(6) = 3}' class='tex'></p>

<h2>Linear Operations</h2>

<p>An operation is a calculation based on some inputs. Which operations are linear and predictable? Multiplication, it seems.</p>

<p>Exponents (<img src="https://betterexplained.com/latex/5ca4e3f1fd7ef5a274d9.png" alt="$F(x) = x^2$" width="81" height="20" style="vertical-align:-4.53px" class="bex-math"></img>) aren&#8217;t predictable: <img src="https://betterexplained.com/latex/adb6d1846be4e808a14f.png" alt="$10^2$" width="26" height="17" style="vertical-align:-0.4px" class="bex-math"></img> is 100, but <img src="https://betterexplained.com/latex/9e70e6b99871deada50d.png" alt="$20^2$" width="26" height="17" style="vertical-align:-0.4px" class="bex-math"></img> is 400. We doubled the input but quadrupled the output.</p>

<p>Surprisingly, regular addition isn&#8217;t linear either. Consider the &#8220;add three&#8221; function <img src="https://betterexplained.com/latex/923027e9688b535005a4.png" alt="$F(x) = x + 3$" width="104" height="19" style="vertical-align:-4.53px" class="bex-math"></img>:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/44f95c15b7b9d5b5f155692a1458f7f5.png' width='88' height='46' alt='&#10;\begin{aligned}&#10;F(10) &amp;= 13 \\&#10;F(20) &amp;= 23&#10;\end{aligned}&#10;' class='tex'></p>

<p>We doubled the input and did not double the output. (Yes, <img src="https://betterexplained.com/latex/923027e9688b535005a4.png" alt="$F(x) = x + 3$" width="104" height="19" style="vertical-align:-4.53px" class="bex-math"></img> happens to be the equation for an <em>offset</em> line, but it&#8217;s still not &#8220;linear&#8221; because <img src="https://betterexplained.com/latex/54fd88423f89232faf75.png" alt="$F(10) \neq 10 \cdot F(1)$" width="138" height="19" style="vertical-align:-4.53px" class="bex-math"></img>. Fun.)</p>

<p>So, what types of functions are <em>actually</em> linear? Plain-old scaling by a constant, or functions that look like: <img src="https://betterexplained.com/latex/679ad8240b6f03f813eb.png" alt="$F(x) = ax$" width="83" height="19" style="vertical-align:-4.53px" class="bex-math"></img>. In our roof example, <img src="https://betterexplained.com/latex/c61d565ce21d09095f1a.png" alt="$a = 1/3$" width="61" height="19" style="vertical-align:-4.53px" class="bex-math"></img>.</p>

<p>But life isn&#8217;t <em>too</em> boring. We can still combine multiple linear functions (<img src="https://betterexplained.com/latex/3c958c4fce00ba4b9b3f.png" alt="$A(x) = ax, B(x) = bx, C(x)=cx$" width="260" height="19" style="vertical-align:-4.53px" class="bex-math"></img>) into a larger one, <img src="https://betterexplained.com/latex/27a583627eb8303e3ea1.png" alt="$G$" width="15" height="14" style="vertical-align:-0.4px" class="bex-math"></img>:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/9ae605d8349f11e71a75b0c9cb849bc6.png' width='379' height='19' alt='\displaystyle{G(x,y,z) = A(x) + B(y) + C(z) = ax + by + cz }' class='tex'></p>

<p><img src="https://betterexplained.com/latex/27a583627eb8303e3ea1.png" alt="$G$" width="15" height="14" style="vertical-align:-0.4px" class="bex-math"></img> is still linear, since doubling the input continues to double the output:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/495b6ea1b9badbcb0db15ceb21899159.png' width='558' height='19' alt='\displaystyle{G(2x, 2y, 2z) = a(2x) + b(2y) + c(2z) = 2(ax + by + cz) = 2 \cdot G(x, y, z)}' class='tex'></p>

<p>We have “mini arithmetic”: multiply inputs by a constant, and add the results. It’s actually useful because we can split inputs apart, analyze them individually, and combine the results:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/aaa2d86705d06b750e305ccacd68ce74.png' width='357' height='18' alt='\displaystyle{G(x,y,z) = G(x,0,0) + G(0,y,0) + G(0,0,z)}' class='tex'></p>

<p>If we allowed non-linear operations (like <img src="https://betterexplained.com/latex/f342230dc501347db21f.png" alt="$x^2$" width="19" height="16" style="vertical-align:-0.2px" class="bex-math"></img>) we couldn&#8217;t split our work and combine the results, since <img src="https://betterexplained.com/latex/83150d20c8621996f0ff.png" alt="$(a+b)^2 \neq a^2 + b^2$" width="141" height="20" style="vertical-align:-4.53px" class="bex-math"></img>. Limiting ourselves to linear operations has its advantages.</p>

<h2>Organizing Inputs and Operations</h2>

<p>Most courses hit you in the face with the details of a matrix. &#8220;Ok kids, let&#8217;s learn to speak. Select a subject, verb and object. Next, conjugate the verb. Then, add the prepositions&#8230;&#8221;</p>

<p><strong>No!</strong> Grammar is not the focus. What&#8217;s the key idea?</p>

<ul>
<li>We have a bunch of inputs to track</li>
<li>We have predictable, linear operations to perform (our &#8220;mini-arithmetic&#8221;)</li>
<li>We generate a result, perhaps transforming it again</li>
</ul>

<p>Ok. First, how should we track a bunch of inputs? How about a list:</p>

<pre><code>x
y
z
</code></pre>

<p>Not bad. We could write it (x, y, z) too &#8212; hang onto that thought.</p>

<p>Next, how should we track our operations? Remember, we only have &#8220;mini arithmetic&#8221;: multiplications by a constant, with a final addition. If our operation <img src="https://betterexplained.com/latex/4f57ad0bbe6f740c74fa.png" alt="$F$" width="14" height="13" style="vertical-align:0px" class="bex-math"></img> behaves like this:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/0e14e1462e4d71e33254bca3034f93f6.png' width='198' height='18' alt='\displaystyle{F(x, y, z) = 3x + 4y + 5z}' class='tex'></p>

<p>We could abbreviate the entire function as (3, 4, 5). We know to multiply the first input by the first value, the second input by the second value, the third input by the third value, and add the results.</p>

<p>Only need the first input?</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/7df6fe52f03a79f5d43aa7c581e741a4.png' width='278' height='18' alt='\displaystyle{G(x, y, z) = 3x + 0y + 0z = (3, 0, 0)}' class='tex'></p>

<p>Let&#8217;s spice it up: how should we handle multiple sets of inputs? Let&#8217;s say we want to run operation F on both (a, b, c) and (x, y, z). We could try this:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/366129689a962a39d13fc8bba305e1b4.png' width='150' height='18' alt='\displaystyle{F(a, b, c, x, y, z) = ?}' class='tex'></p>

<p>But it won&#8217;t work: F expects 3 inputs, not 6. We should separate the inputs into groups:</p>

<pre><code>1st Input  2nd Input
--------------------
a          x
b          y
c          z
</code></pre>

<p>Much neater.</p>

<p>And how could we run the same input through several operations? Have a row for each operation:</p>

<pre><code>F: 3 4 5
G: 3 0 0
</code></pre>

<p>Neat. We&#8217;re getting organized: inputs in vertical columns, operations in horizontal rows.</p>

<h2>Visualizing The Matrix</h2>

<p>Words aren&#8217;t enough. Here&#8217;s how I visualize inputs, operations, and outputs:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/images//linear-algebra-visualize-20121002-221620.png" alt="linear algebra reference" class="webpexpress-processed"></p>

<p>Imagine &#8220;pouring&#8221; each input through each operation:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/images//linear-algebra-pour-20121002-220550.png" alt="linear algebra pour in" class="webpexpress-processed"></p>

<p>As an input passes an operation, it creates an output item. In our example, the input (a, b, c) goes against operation F and outputs 3a + 4b + 5c. It goes against operation G and outputs 3a + 0 + 0.</p>

<p>Time for the red pill. A matrix is a shorthand for our diagrams:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/3aa4f8c19764f6aed0969bee9b27bd57.png' width='334' height='66' alt='\text{I}\text{nputs} = A = \begin{bmatrix} \text{i}\text{nput1}&amp;\text{i}\text{nput2}\end{bmatrix} = \begin{bmatrix}a &amp; x\\b &amp; y\\c &amp; z\end{bmatrix}' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/b6326fd70b2a885f537f6d96a1802b9d.png' width='361' height='44' alt='\text{Operations} = M = \begin{bmatrix}\text{operation1}\\ \text{operation2}\end{bmatrix} = \begin{bmatrix}3 &amp; 4 &amp; 5\\3 &amp; 0 &amp; 0\end{bmatrix}' class='tex'></p>

<p>A matrix is a single variable representing a spreadsheet of inputs or operations.</p>

<p><strong>Trickiness #1: The reading order</strong></p>

<p>Instead of an input => matrix => output flow, we use function notation, like y = f(x) or f(x) = y. We usually write a matrix with a capital letter (F), and a single input column with lowercase (x). Because we have several inputs (A) and outputs (B), they&#8217;re considered matrices too:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/175ec48c2ca59b2f32e22b646e2cb1c7.png' width='71' height='13' alt='\displaystyle{MA = B}' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/b5d8ab037ca1679d48340a1b33940131.png' width='398' height='66' alt='&#10;\begin{bmatrix}3 &amp; 4 &amp; 5\\3 &amp; 0 &amp; 0\end{bmatrix} \begin{bmatrix}a &amp; x\\b &amp; y\\c &amp; z\end{bmatrix}&#10;= \begin{bmatrix}3a + 4b + 5c &amp; 3x + 4y + 5z\\ 3a &amp; 3x\end{bmatrix}&#10;' class='tex'></p>

<p><strong>Trickiness #2: The numbering</strong></p>

<p>Matrix size is measured as RxC: row count, then column count, and abbreviated &#8220;m x n&#8221; (I hear ya, &#8220;r x c&#8221; would be easier to remember). Items in the matrix are referenced the same way: a<sub>ij</sub> is the ith row and jth column (I hear ya, &#8220;i&#8221; and &#8220;j&#8221; are easily confused on a chalkboard). Mnemonics are ok <em>with context</em>, and here&#8217;s what I use:</p>

<ul>
<li>RC, like Roman Centurion or RC Cola</li>
<li>Use an &#8220;L&#8221; shape. Count down the L, then across</li>
</ul>

<p>Why does RC ordering make sense? Our operations matrix is 2&#215;3 and our input matrix is 3&#215;2. Writing them together:</p>

<pre><code>[Operation Matrix] [Input Matrix]
[operation count x operation size] [input size x input count]
[m x n] [p x q] = [m x q]
[2 x 3] [3 x 2] = [2 x 2]
</code></pre>

<p>Notice the matrices touch at the &#8220;size of operation&#8221; and &#8220;size of input&#8221; (n = p). They should match! If our inputs have 3 components, our operations should expect 3 items. In fact, we can <em>only</em> multiply matrices when n = p.</p>

<p>The output matrix has m operation rows for each input, and q inputs, giving a &#8220;m x q&#8221; matrix.</p>

<h2>Fancier Operations</h2>

<p>Let&#8217;s get comfortable with operations. Assuming 3 inputs, we can whip up a few 1-operation matrices:</p>

<ul>
<li>Adder: [1 1 1]</li>
<li>Averager: [1/3 1/3 1/3]</li>
</ul>

<p>The &#8220;Adder&#8221; is just a + b + c. The &#8220;Averager&#8221; is similar: (a + b + c)/3 = a/3 + b/3 + c/3.</p>

<p>Try these 1-liners:</p>

<ul>
<li>First-input only: [1 0 0]</li>
<li>Second-input only: [0 1 0]</li>
<li>Third-input only: [0 0 1]</li>
</ul>

<p>And if we merge them into a single matrix:</p>

<pre><code>[1 0 0]
[0 1 0]
[0 0 1]
</code></pre>

<p>Whoa &#8212; it&#8217;s the &#8220;identity matrix&#8221;, which copies 3 inputs to 3 outputs, unchanged. How about this guy?</p>

<pre><code>[1 0 0]
[0 0 1]
[0 1 0]
</code></pre>

<p>He reorders the inputs: (x, y, z) becomes (x, z, y).</p>

<p>And this one?</p>

<pre><code>[2 0 0]
[0 2 0]
[0 0 2]
</code></pre>

<p>He&#8217;s an input doubler. We could rewrite him to <code>2*I</code> (the identity matrix) if we were so inclined.</p>

<p>And yes, when we decide to treat inputs as vector coordinates, the operations matrix will transform our vectors. Here&#8217;s a <a href="http://blog.stata.com/2011/03/03/understanding-matrices-intuitively-part-1/">few examples</a>:</p>

<ul>
<li>Scale: make all inputs bigger/smaller</li>
<li>Skew: make certain inputs bigger/smaller</li>
<li>Flip: make inputs negative</li>
<li>Rotate: make new coordinates based on old ones (East becomes North, North becomes West, etc.)</li>
</ul>

<p>These are geometric interpretations of multiplication, and how to warp a vector space. Just remember that vectors are <em>examples</em> of data to modify.</p>

<h2>A Non-Vector Example: Stock Market Portfolios</h2>

<p>Let&#8217;s practice linear algebra in the real world:</p>

<ul>
<li>Input data: stock portfolios with dollars in Apple, Google and Microsoft stock</li>
<li>Operations: the changes in company values after a news event</li>
<li>Output: updated portfolios</li>
</ul>

<p>And a bonus output: let&#8217;s make a new portfolio listing the net profit/loss from the event.</p>

<p>Normally, we&#8217;d track this in a spreadsheet. Let&#8217;s learn to think with linear algebra:</p>

<ul>
<li><p>The input vector could be (\$Apple, \$Google, \$Microsoft), showing the dollars in each stock. (Oh! These dollar values could  come from <em>another</em> matrix that multiplied the number of shares by their price. Fancy that!)</p></li>
<li><p>The 4 output operations should be: Update Apple value, Update Google value, Update Microsoft value, Compute Profit</p></li>
</ul>

<p>Visualize the problem. Imagine running through each operation:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/images//linear-algebra-stock-20121002-230152.png" alt="linear algebra stock example" class="webpexpress-processed"></p>

<p>The key is understanding <em>why</em> we&#8217;re setting up the matrix like this, not blindly crunching numbers.</p>

<p>Got it? Let&#8217;s introduce the scenario.</p>

<p>Suppose a secret iDevice is launched: Apple jumps 20%, Google drops 5%, and Microsoft stays the same. We want to adjust each stock value, using something similar to the identity matrix:</p>

<pre><code>New Apple     [1.2  0      0]
New Google    [0    0.95   0]
New Microsoft [0    0      1]
</code></pre>

<p>The new Apple value is the original, increased by 20% (Google = 5% decrease, Microsoft = no change).</p>

<p>Oh wait! We need the overall profit:</p>

<p>Total change = (.20 * Apple) + (-.05 * Google) + (0 * Microsoft)</p>

<p>Our final operations matrix:</p>

<pre><code>New Apple       [1.2  0      0]
New Google      [0    0.95   0]
New Microsoft   [0    0      1]
Total Profit    [.20  -.05   0]
</code></pre>

<p>Making sense? Three inputs enter, four outputs leave. The first three operations are a &#8220;modified copy&#8221; and the last brings the changes together.</p>

<p>Now let&#8217;s feed in the portfolios for Alice  \$1000, \$1000, \$1000) and Bob  \$500, \$2000, \$500). We can crunch the numbers by hand, or use a Wolfram Alpha (<a href="http://www.wolframalpha.com/input/?i=++++%7B%7B1.2%2C0%2C0%7D%2C%7B0%2C0.95%2C0%7D%2C%7B0%2C0%2C1%7D%2C%7B.2%2C+-.05%2C+0%7D%7D+.+Transpose%28%5B%7B1000%2C+1000%2C+1000%7D%2C%7B500%2C2000%2C500%7D%5D%29">calculation</a>):</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/images//matrix-stock-computation-20121002-231618.png" alt="matrix stock computation" /></p>

<p>(Note: Inputs should be in columns, but it&#8217;s easier to type rows. The Transpose operation, indicated by t (tau), converts rows to columns.)</p>

<p>The final numbers: Alice has \$1200 in AAPL, \$950 in GOOG, \$1000 in MSFT, with a net profit of \$150. Bob has \$600 in AAPL, \$1900 in GOOG, and \$500 in MSFT, with a net profit of \$0.</p>

<p>What&#8217;s happening? <strong>We&#8217;re doing math with our own spreadsheet.</strong> Linear algebra emerged in the 1800s yet spreadsheets were invented in the 1980s. I blame the gap on poor linear algebra education.</p>

<h2>Historical Notes: Solving Simultaneous equations</h2>

<p>An <em>early</em> use of tables of numbers (not yet a &#8220;matrix&#8221;) was bookkeeping for linear systems:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/d233925e50828fb082c4d36fad63a306.png' width='162' height='71' alt='&#10;\begin{aligned}&#10;x + 2y + 3z &amp;= 3 \\&#10;2x + 3y + 1z &amp;= -10 \\&#10;5x + -y + 2z &amp;= 14&#10;\end{aligned}&#10;' class='tex'></p>

<p>becomes</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/68fcbe0e409c55cafce74984fbae2ed2.png' width='211' height='66' alt='&#10;\begin{bmatrix}1 &amp; 2 &amp; 3\\2 &amp; 3 &amp; 1\\5 &amp; -1 &amp; 2\end{bmatrix} \begin{bmatrix}x \\y \\ z \end{bmatrix}&#10;= \begin{bmatrix}3 \\ -10 \\ 14 \end{bmatrix}&#10;' class='tex'></p>

<p>We can avoid hand cramps by adding/subtracting rows in the matrix and output, vs. rewriting the full equations. As the matrix evolves into the identity matrix, the values of x, y and z are revealed on the output side.</p>

<p>This process, called Gauss-Jordan elimination, saves time. However, linear algebra is mainly about matrix transformations, not solving large sets of equations (it&#8217;d be like using Excel for your shopping list).</p>

<h2>Terminology, Determinants, and Eigenstuff</h2>

<p>Words have technical categories to describe their use (nouns, verbs, adjectives). Matrices can be similarly subdivided.</p>

<p>Descriptions like &#8220;upper-triangular&#8221;, &#8220;symmetric&#8221;, &#8220;diagonal&#8221; are the shape of the matrix, and influence their transformations.</p>

<p>The <strong>determinant</strong> is the &#8220;size&#8221; of the output transformation. If the input was a unit vector (representing area or volume of 1), the determinant is the size of the transformed area or volume. A determinant of 0 means matrix is &#8220;destructive&#8221; and cannot be reversed (similar to multiplying by zero: information was lost).</p>

<p>The <strong>eigenvector</strong> and <strong>eigenvalue</strong> represent the &#8220;axes&#8221; of the transformation.</p>

<p>Consider spinning a globe: every location faces a new direction, except the poles.</p>

<p>An &#8220;eigenvector&#8221; is an input that doesn&#8217;t change direction when it&#8217;s run through the matrix (it points &#8220;along the axis&#8221;). And although the direction doesn&#8217;t change, the size might. The eigenvalue is the amount the eigenvector is scaled up or down when going through the matrix.</p>

<p>(My intuition here is weak, and I&#8217;d like to explore more. Here&#8217;s a <a href="https://en.wikipedia.org/wiki/File:Eigenvectors.gif">nice diagram</a> and <a href="https://www.youtube.com/watch?v=wXCRcnbCsJA">video</a>.)</p>

<h2>Matrices As Inputs</h2>

<p>A funky thought: we can treat the operations matrix as inputs!</p>

<p>Think of a recipe as a list of commands (<em>Add 2 cups of sugar, 3 cups of flour…</em>).</p>

<p>What if we want the metric version? Take the instructions, treat them like text, and convert the units. The recipe is &#8220;input&#8221; to modify. When we&#8217;re done, we can follow the instructions again.</p>

<p>An operations matrix is similar: commands to modify. Applying one operations matrix to another gives a new operations matrix that applies <em>both</em> transformations, in order.</p>

<p>If N is &#8220;adjust for portfolio for news&#8221; and T is &#8220;adjust portfolio for taxes&#8221; then applying both:</p>

<p>TN = X</p>

<p>means &#8220;Create matrix X, which first adjusts for news, and then adjusts for taxes&#8221;. Whoa! We didn&#8217;t need an input portfolio, we applied one matrix directly to the other.</p>

<p>The beauty of linear algebra is representing an entire spreadsheet calculation with a single letter. Want to apply the same transformation a few times? Use <img src="https://betterexplained.com/latex/af1fd814a30234581abd.png" alt="$N^2$" width="25" height="16" style="vertical-align:0px" class="bex-math"></img> or <img src="https://betterexplained.com/latex/9410c13efe23349d401b.png" alt="$N^3$" width="25" height="16" style="vertical-align:0px" class="bex-math"></img>.</p>

<h2>Can We Use Regular Addition, Please?</h2>

<p>Yes, because you asked nicely. Our &#8220;mini arithmetic&#8221; seems limiting: multiplications, but no addition? Time to expand our brains.</p>

<p>Imagine adding a dummy entry of 1 to our input: (x, y, z) becomes (x, y, z, 1).</p>

<p>Now our operations matrix has an extra, known value to play with! If we want <code>x + 1</code> we can write:</p>

<pre><code>[1 0 0 1]
</code></pre>

<p>And <code>x + y - 3</code> would be:</p>

<pre><code>[1 1 0 -3]
</code></pre>

<p>Huzzah!</p>

<p>Want the geeky explanation? We&#8217;re pretending our input exists in a 1-higher dimension, and put a &#8220;1&#8221; in that dimension. We <em>skew</em> that higher dimension, which looks like a <em>slide</em> in the current one. For example: take input (x, y, z, 1) and run it through:</p>

<pre><code>[1 0 0 1]
[0 1 0 1]
[0 0 1 1]
[0 0 0 1]
</code></pre>

<p>The result is (x + 1, y + 1, z + 1, 1). Ignoring the 4th dimension, every input got a +1. We keep the dummy entry, and can do more slides later.</p>

<p>Mini-arithmetic isn&#8217;t so limited after all.</p>

<h2>Onward</h2>

<p>I&#8217;ve overlooked some linear algebra subtleties, and I&#8217;m not too concerned. Why?</p>

<p>These metaphors are helping me <em>think</em> with matrices, more than the classes I &#8220;aced&#8221;. I can finally respond to &#8220;Why is linear algebra useful?&#8221; with &#8220;Why are spreadsheets useful?&#8221;</p>

<p>They&#8217;re not, unless you want a tool used to attack nearly every real-world problem. Ask a businessman if they&#8217;d rather donate a kidney or be banned from Excel forever. That&#8217;s the impact of linear algebra we&#8217;ve overlooked: efficient notation to bring spreadsheets into our math equations.</p>

<p>Happy math.</p>

]]></content:encoded>
					
					<wfw:commentRss>https://betterexplained.com/articles/linear-algebra-guide/feed/</wfw:commentRss>
			<slash:comments>95</slash:comments>
		

			</item>
	<item>
		<title>Intuitive Understanding Of Euler&#8217;s Formula</title>
		<link>https://betterexplained.com/articles/intuitive-understanding-of-eulers-formula/</link>
					<comments>https://betterexplained.com/articles/intuitive-understanding-of-eulers-formula/#disqus_thread</comments>
		
		<dc:creator><![CDATA[kalid]]></dc:creator>
		<pubDate>Mon, 19 Jul 2010 17:55:21 +0000</pubDate>
				<category><![CDATA[Calculus]]></category>
				<category><![CDATA[Math]]></category>
				<category><![CDATA[Popular]]></category>
				<category><![CDATA[Euler's Formula]]></category>
				<category><![CDATA[Euler's Identity]]></category>
		<guid isPermaLink="false">http://betterexplained.com/?p=686</guid>

					<description><![CDATA[Euler's identity seems baffling: It emerges from a more general formula: Yowza -- we're relating an imaginary exponent to sine and cosine! And somehow plugging in pi gives -1? Could this ever be intuitive? Not according to 1800s mathematician Benjamin Peirce: It is absolutely paradoxical; we cannot understand it, and we don't know what it [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Euler's identity seems baffling:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/2acd58c7dcd28737fd97b42365ffb335.png' width='69' height='17' alt='\displaystyle{e^{i\pi} = -1}' class='tex'></p>

<p>It emerges from a more general formula:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/2fd89c7b7e57630dc0d9029015d17d45.png' width='171' height='21' alt='\displaystyle{ e^{ix} = \cos(x) + i \sin(x)}' class='tex'></p>

<p>Yowza -- we're relating an <em>imaginary exponent</em> to sine and cosine! And somehow plugging in pi gives -1? Could this ever be intuitive?</p>

<p>Not according to 1800s mathematician Benjamin Peirce:</p>

<blockquote>

<p>It is absolutely paradoxical; we cannot understand it, and we don't know what it means, but we have proved it, and therefore we know it must be the truth.</p>
</blockquote>

<p>Argh, this attitude makes my blood boil! Formulas are not magical spells to be memorized: we must, must, <strong>must</strong> find an insight. Here's mine:</p>

<p><strong>Euler's formula describes two equivalent ways to move in a circle.</strong></p>

<p>That's it? This stunning equation is about spinning around? Yes -- and we can understand it by building on a few analogies:</p>

<ul>
<li>Starting at the number 1, see multiplication as a <a href="https://betterexplained.com/articles/rethinking-arithmetic-a-visual-guide/">transformation</a> that changes the number: <img src="https://betterexplained.com/latex/4b7ca20a7bd1ea95387b.png" alt="$1 \cdot e^{i \pi}$" width="44" height="16" style="vertical-align:-0.2px" class="bex-math"></img></li>
<li>Regular <a href="https://betterexplained.com/articles/an-intuitive-guide-to-exponential-functions-e/">exponential growth</a> continuously <em>increases</em> 1 by some rate for some time period; <a href="https://betterexplained.com/articles/a-visual-intuitive-guide-to-imaginary-numbers/">imaginary</a> exponential growth continuously <em>rotates</em> 1 for some time period</li>
<li>Growing for "pi" units of time means going pi <a href="https://betterexplained.com/articles/intuitive-guide-to-angles-degrees-and-radians/">radians</a> around a circle</li>
<li>Therefore, <img src="https://betterexplained.com/latex/bc3515a42ed42e85d532.png" alt="$e^{i \pi}$" width="22" height="16" style="vertical-align:-0.2px" class="bex-math"></img> means starting at 1 and rotating pi (halfway around a circle) to get to -1</li>
</ul>

<p>That's the high-level view, let's dive into the details. By the way, if someone tries to impress you with <img src="https://betterexplained.com/latex/5b6ec705692e4a5b74d7.png" alt="$e^{i \pi} = -1$" width="69" height="17" style="vertical-align:-1.49px" class="bex-math"></img>, ask them about <em>i</em> to the <i>i</i>-th power. If they can't think it through, Euler's formula is still a magic spell to them.</p>

<p><strong>Update:</strong> While writing, I thought a video might help explain the ideas more clearly:</p>

<iframe width="640" height="360" src="https://www.youtube.com/embed/qpOj98VNJi4" frameborder="0" allowfullscreen></iframe>

<h2>Understanding cos(x) + i * sin(x)</h2>

<p>The equals sign is overloaded. Sometimes we mean "set one thing to another" (like x = 3) and others we mean "these two things describe the same concept" (like <img src="https://betterexplained.com/latex/5e21130dd3ad440221f7.png" alt="$\sqrt{-1} = i$" width="69" height="20" style="vertical-align:-2.54px" class="bex-math"></img>).</p>

<p>Euler's formula is the latter: it gives two formulas which explain how to move in a circle. If we examine circular motion using trig, and travel x radians:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/euler/circle_traverse.png" alt="imaginary numbers traversing a circle" class="webpexpress-processed"></p>

<ul>
<li>cos(x) is the x-coordinate (horizontal distance)</li>
<li>sin(x) is the y-coordinate (vertical distance)</li>
</ul>

<p>The statement</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/a013ee5eebae51d59c248434c7aa0116.png' width='125' height='18' alt='\displaystyle{\cos(x) + i \sin(x)}' class='tex'></p>

<p>is a clever way to smush the x and y coordinates into a single number. The analogy "complex numbers are 2-dimensional" helps us interpret a single complex number as a position on a circle.</p>

<p>When we set x to <img src="https://betterexplained.com/latex/6cbee51e8365518a121a.png" alt="$\pi$" width="11" height="8" style="vertical-align:-0.2px" class="bex-math"></img>, we're traveling <img src="https://betterexplained.com/latex/6cbee51e8365518a121a.png" alt="$\pi$" width="11" height="8" style="vertical-align:-0.2px" class="bex-math"></img> units along the outside of the unit circle. Because the total circumference is <img src="https://betterexplained.com/latex/8d3b93b989885b7167af.png" alt="$2\pi$" width="20" height="13" style="vertical-align:-0.2px" class="bex-math"></img>, plain old <img src="https://betterexplained.com/latex/6cbee51e8365518a121a.png" alt="$\pi$" width="11" height="8" style="vertical-align:-0.2px" class="bex-math"></img> is halfway around, putting us at -1.</p>

<p>Neato: The right side of Euler's formula (<img src="https://betterexplained.com/latex/654bed89b342825c41c6.png" alt="$\cos(x) + i \sin(x)$" width="127" height="19" style="vertical-align:-4.53px" class="bex-math"></img>) describes circular motion with imaginary numbers. Now let's figure out how the <em>e</em> side of the equation accomplishes it.</p>

<h2>What is Imaginary Growth?</h2>

<p>Combining x- and y- coordinates into a complex number is tricky, but manageable. But what does an imaginary <em>exponent</em> mean?</p>

<p>Let's step back a bit. When I see <img src="https://betterexplained.com/latex/7aa1a645fe3a23a173cb.png" alt="$3^4$" width="17" height="16" style="vertical-align:-0.4px" class="bex-math"></img>, I think of it like this:</p>

<ul>
<li>3 is the <em>end result</em> of growing instantly (using e) at a rate of ln(3). In other words: <img src="https://betterexplained.com/latex/b720d5f44d721bb5e3bd.png" alt="$3 = e^{\ln(3)}$" width="71" height="18" style="vertical-align:-1.49px" class="bex-math"></img></li>
<li><img src="https://betterexplained.com/latex/7aa1a645fe3a23a173cb.png" alt="$3^4$" width="17" height="16" style="vertical-align:-0.4px" class="bex-math"></img> is the same as growing to 3, but then growing for 4x as long. So <img src="https://betterexplained.com/latex/5c3d428819d09077c0b9.png" alt="$3^4 = e^{\ln(3) \cdot 4} = 81$" width="131" height="18" style="vertical-align:-1.49px" class="bex-math"></img></li>
</ul>

<p>Instead of seeing numbers on their own, you can think of them as something e had to "grow to". Real numbers, like 3, give an interest rate of ln(3) = 1.1, and that's what e "collects" as it's going along, growing continuously.</p>

<p>Regular growth is simple: it keeps "pushing" a number in the same, real direction it was going. 3 × 3 pushes in the original direction, making it 3 times larger (9).</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/euler/imaginary_growth.png" alt="imaginary growth" class="webpexpress-processed"></p>

<p>Imaginary growth is different: the "interest" we earn is in a different direction! It's like a jet engine that was strapped on sideways -- instead of going forward, we start pushing at 90 degrees.</p>

<p>The neat thing about a constant orthogonal (perpendicular) push is that it doesn't speed you up or slow you down -- it rotates you! Taking any number and multiplying by <em>i</em> will not change its magnitude, just the direction it points.</p>

<p>Intuitively, here's how I see <strong>continuous imaginary growth rate</strong>: "When I grow, don't push me forward or back in the direction I'm already going. Rotate me instead."</p>

<h2>But Shouldn't We Spin Faster and Faster?</h2>

<p>I wondered that too. Regular growth compounds in our original direction, so we go 1, 2, 4, 8, 16, multiplying 2x each time and staying in the real numbers. We can consider this <img src="https://betterexplained.com/latex/5f21b775790c7873518d.png" alt="$e^{\ln(2)x}$" width="45" height="17" style="vertical-align:-0.2px" class="bex-math"></img>, which means grow instantly at a rate of ln(2) for "x" seconds.</p>

<p>And hey -- if our growth rate was twice as fast, 2ln(2) vs ln(2), it would look the same as growing for twice as long (2x vs x). The magic of e lets us swap rate and time; 2 seconds at ln(2) is the same growth as 1 second at 2ln(2).</p>

<p>Now, imagine we have some purely imaginary growth rate (Ri) that rotates us until we reach i, or 90 degrees upward. What happens if we double that rate to 2Ri, will we spin off the circle?</p>

<p>Nope! Having a rate of 2Ri means we just spin twice as fast, or alternatively, spin at a rate of R for twice as long, but we're staying on the circle. Rotating twice as long means we're now facing 180 degrees.</p>

<p>Once we realize that some exponential growth rate can take us from 1 to i, increasing that rate just spins us more. We'll never escape the circle.</p>

<p>However, if our growth rate is complex (a+bi vs Ri) then the real part (a) will grow us like normal, while the imaginary part (bi) rotates us. But let's not get fancy: Euler's formula, <img src="https://betterexplained.com/latex/f24af717b851ea6a5e39.png" alt="$e^{ix}$" width="22" height="16" style="vertical-align:-0.2px" class="bex-math"></img>, is about the <em>purely imaginary</em> growth that keeps us on the circle (more later).</p>

<h2>A Quick Sanity Check</h2>

<p>While writing, I had to clarify a few questions for myself:</p>

<p><strong>Why use <img src="https://betterexplained.com/latex/e7aded5a42342d4b3f23.png" alt="$e^x$" width="18" height="13" style="vertical-align:-0.2px" class="bex-math"></img>, aren't we rotating the number 1?</strong></p>

<p><em>e</em> represents the process of starting at 1 and growing continuously at 100% interest for 1 unit of time.</p>

<p>When we write <em>e</em> we're capturing that entire process in a single number -- e represents all the whole rigmarole of continuous growth. So really, <img src="https://betterexplained.com/latex/e7aded5a42342d4b3f23.png" alt="$e^x$" width="18" height="13" style="vertical-align:-0.2px" class="bex-math"></img> is saying "start at 1 and grow continuously at 100% for x seconds", and starts from 1 like we want.</p>

<p><strong>But what does i as an exponent do?</strong></p>

<p>For a regular exponent like <img src="https://betterexplained.com/latex/7aa1a645fe3a23a173cb.png" alt="$3^4$" width="17" height="16" style="vertical-align:-0.4px" class="bex-math"></img> we ask:</p>

<ul>
<li>What is the implicit growth rate? We're growing from 1 to 3 (the base of the exponent).</li>
<li>How do we <strong>change</strong> that growth rate? We scale it by 4x (the power of the exponent).</li>
</ul>

<p>We can convert our growth into "e" format: our instantaneous rate is ln(3), and we increase it to ln(3) * 4&#46; Again, the power of the exponent (4) just scaled our growth rate.</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/d59ce80107c165669d029d5832047403.png' width='175' height='22' alt='\displaystyle{3^4 = e^{\ln(3) \cdot 4} = (e^{\ln(3)})^4}' class='tex'></p>

<p>When the top exponent is i (as in <img src="https://betterexplained.com/latex/326464ac85eb1c08af69.png" alt="$3^i$" width="15" height="16" style="vertical-align:-0.4px" class="bex-math"></img>), we just multiply our implicit growth rate by i. So instead of growing at plain old ln(3), we're growing at ln(3) * i.</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/96718d451fc895d5fd4ec06bd32c1914.png' width='168' height='22' alt='\displaystyle{3^i = e^{\ln(3) \cdot i} = (e^{\ln(3)})^i}' class='tex'></p>

<p>The top part of the exponent <em>modifies</em> the implicit growth rate of the bottom part.</p>

<h2>The Nitty Gritty Details</h2>

<p>Let's take a closer look. Remember this definition of <em>e</em>:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/6d8f5c3f3e82bebc3c7cabdd1f754eb9.png' width='252' height='45' alt='\displaystyle{e = e^{100\%} = \lim_{n\to\infty} \left( 1 + \frac{100\%}{n} \right)^n}' class='tex'></p>

<p>That <img src="https://betterexplained.com/latex/21c70a10b1acbb7e1dc9.png" alt="$\frac{100\%}{n}$" width="38" height="24" style="vertical-align:-6.38px" class="bex-math"></img> represents the portion interest we earned in each microscopic period. We assumed the interest rate was 100% in the real dimension -- but what if it were 100% in the imaginary direction?</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/4dcb16d8ee877de1e4a3addf6a7fb513.png' width='247' height='45' alt='\displaystyle{e^{100\% \cdot i} = \lim_{n\to\infty} \left( 1 + \frac{100\%\cdot i}{n} \right)^n}' class='tex'></p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/euler/imaginary_interest.png" alt="cumulative imaginary interest" class="webpexpress-processed"></p>

<p>Now, our newly formed interest adds to us in the 90-degree direction. Surprisingly, this does not change our length -- this is a tricky concept, because it appears to make a triangle where the hypotenuse must be larger. We're dealing with a limit, and the extra distance is within the error margin we specify. This is something I want to tackle another day, but take my word: continuous perpendicular growth will rotate you. This is the heart of sine and cosine, where your change is perpendicular to your current position, and you move in a circle.</p>

<p>We apply <em>i</em> units of growth in infinitely small increments, each pushing us at a 90-degree angle. There is no "faster and faster" rotation - instead, we crawl along the perimeter a distance of |i| = 1 (magnitude of i).</p>

<p>And hey -- the distance crawled around a circle is an angle in radians! We've found another way to describe circular motion!</p>

<p><strong>To get circular motion:</strong> Change continuously by rotating at 90-degree angle (aka imaginary growth rate).</p>

<p>So, Euler's formula is saying "exponential, imaginary growth traces out a circle". And this path is the same as moving in a circle using sine and cosine in the imaginary plane.</p>

<p>In this case, the word "exponential" is confusing because we travel around the circle at a constant rate. In most discussions, exponential growth is assumed to have a cumulative, compounding effect.</p>

<h2>Some Examples</h2>

<p>You don't really believe me, do you? Here's a few examples, and how to think about them intuitively.</p>

<p><strong>Example: <img src="https://betterexplained.com/latex/90518c2f71e8c9ccd0e1.png" alt="$e^i$" width="15" height="16" style="vertical-align:-0.2px" class="bex-math"></img></strong></p>

<p>Where's the x? Ah, it's just 1&#46; Intuitively, without breaking out a calculator, we know that this means "travel 1 radian along the unit circle". In my head, I see "e" <em>trying</em> to grow 1 at 100% all in the same direction, but i keeps moving the ball and forces "1" to grow along the edge of a circle:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/4a318109513e9c72f9ca35d23ea4f053.png' width='307' height='21' alt='\displaystyle{e^i = \cos(1) + i \cdot \sin(1) = .5403 + .8415i}' class='tex'></p>

<p>Not the prettiest number, but there it is. Remember to put your calculator in radian mode when punching this in.</p>

<p><strong>Example: <img src="https://betterexplained.com/latex/326464ac85eb1c08af69.png" alt="$3^i$" width="15" height="16" style="vertical-align:-0.4px" class="bex-math"></img></strong></p>

<p>This is tricky -- it's not in our standard format. But remember, <img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/c088b0aa18cca5739cf517b549fbb15a.png' width='74' height='17' alt='\displaystyle{3^i = 1 \cdot 3^i}' class='tex'></p>

<p>We want an initial growth of 3x at the end of the period, or an instantaneous rate of ln(3). But, the <em>i</em> comes along and changes that rate of ln(3) to "i * ln(3)":</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/0babf08ce7b7ce3757baf483f33e88e2.png' width='168' height='22' alt='\displaystyle{3^i = (e^{\ln(3)})^i = e^{\ln(3)\cdot i}}' class='tex'></p>

<p>We <em>thought</em> we were going to transform at a regular rate of ln(3), a little faster than 100% continuous growth since e is about 2.718. But oh no, <em>i</em> spun us around: now we're transforming at an imaginary rate which means we're just rotating about. If <em>i</em> was a regular number like 4, it would have made us grow 4x faster. Now we're growing at a speed of ln(3), but sideways.</p>

<p>We should expect a complex number on the unit circle -- there's nothing in the growth rate to increase our size. Solving the equation:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/206ad9accfcec3d0a57dacf47855d8af.png' width='438' height='22' alt='\displaystyle{3^i = e^{\ln(3) \cdot i} = \cos(\ln(3)) + i \cdot \sin(\ln(3)) = .4548 + .8906i}' class='tex'></p>

<p>So, rather than ending up "1" unit around the circle (like <img src="https://betterexplained.com/latex/90518c2f71e8c9ccd0e1.png" alt="$e^i$" width="15" height="16" style="vertical-align:-0.2px" class="bex-math"></img>) we end up ln(3) units around.</p>

<p><strong>Example: <img src="https://betterexplained.com/latex/9f1c809a8b33cf962b99.png" alt="$i^i$" width="13" height="16" style="vertical-align:-0.2px" class="bex-math"></img></strong></p>

<p>A few months ago, this would have had me tears. Not today! Let's break down the transformations:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/a48a992232a8911b7cce8cf3c7b0381d.png' width='69' height='17' alt='\displaystyle{i^i = 1 \cdot i^i}' class='tex'></p>

<p>We start with 1 and want to change it. Like solving <img src="https://betterexplained.com/latex/326464ac85eb1c08af69.png" alt="$3^i$" width="15" height="16" style="vertical-align:-0.4px" class="bex-math"></img>, what's the instantaneous growth rate represented by <em>i</em> as a base?</p>

<p>Hrm. Normally we'd do ln(x) to get the growth rate needed to reach x at the end of 1 unit of time. But for an imaginary rate? We need to noodle this over.</p>

<p>In order to start with 1 and grow to <em>i</em> we need to start rotating at the outset. How fast? Well, we need to get 90 degrees (pi/2 radians) in 1 unit of time. So our rate is <img src="https://betterexplained.com/latex/6e6eeb2a896a7ddafc6c.png" alt="$i \frac{\pi}{2}$" width="22" height="19" style="vertical-align:-6.25px" class="bex-math"></img>. Remember our rate must be imaginary since we're rotating, not growing! Plain old <img src="https://betterexplained.com/latex/a4ac86f49bf2e11c00fa.png" alt="$\frac{\pi}{2}$" width="16" height="19" style="vertical-align:-6.25px" class="bex-math"></img> is about 1.57 and results in regular growth.</p>

<p>This should make sense: to turn 1.0 to <em>i</em> at the end of 1 unit, we should rotate <img src="https://betterexplained.com/latex/a4ac86f49bf2e11c00fa.png" alt="$\frac{\pi}{2}$" width="16" height="19" style="vertical-align:-6.25px" class="bex-math"></img> radians (90 degrees) in that amount of time. So, to get "i" we can use <img src="https://betterexplained.com/latex/46ec6cb116cc3976033d.png" alt="$e^{i \frac{\pi}{2}}$" width="26" height="16" style="vertical-align:-0.2px" class="bex-math"></img>.</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/1eaa177a737ea966a723552d8aa73a94.png' width='53' height='18' alt='\displaystyle{i = e^{i \frac{\pi}{2}}}' class='tex'></p>

<p>Phew. That describes i as the base. How about the exponent?</p>

<p>Well, the <em>other</em> i tells us to change our rate -- yes, that rate we spent so long figuring out! So rather than rotating at a speed of <img src="https://betterexplained.com/latex/6e6eeb2a896a7ddafc6c.png" alt="$i \frac{\pi}{2}$" width="22" height="19" style="vertical-align:-6.25px" class="bex-math"></img>, which is what a base of <em>i</em> means, we transform the rate to:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/337b4a4acc58dc5f3db90b14ac789602.png' width='166' height='33' alt='\displaystyle{\frac{\pi}{2}i \cdot i = \frac{\pi}{2} \cdot -1 = -\frac{\pi}{2}}' class='tex'></p>

<p>The i's cancel and make the growth rate real again! We rotated our rate and pushed ourselves into the negative numbers. And a negative growth rate means we're shrinking -- we should expect <img src="https://betterexplained.com/latex/9f1c809a8b33cf962b99.png" alt="$i^i$" width="13" height="16" style="vertical-align:-0.2px" class="bex-math"></img> to make things smaller. And it does:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/ae77d7310bad7af54c5996ca77234c74.png' width='106' height='18' alt='\displaystyle{i^i = e^{- \frac{\pi}{2}} \sim .2}' class='tex'></p>

<p>Tada! (Search "i^i" on Google to use its calculator)</p>

<p>Take a breather: You can intuitively figure out how imaginary bases and imaginary exponents should behave. Whoa.</p>

<p>And as a bonus, you figured out ln(i) -- to make <img src="https://betterexplained.com/latex/e7aded5a42342d4b3f23.png" alt="$e^x$" width="18" height="13" style="vertical-align:-0.2px" class="bex-math"></img> become i, make e rotate <img src="https://betterexplained.com/latex/a4ac86f49bf2e11c00fa.png" alt="$\frac{\pi}{2}$" width="16" height="19" style="vertical-align:-6.25px" class="bex-math"></img> radians.</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/ecba84581a86447fd8afe974b5b0082d.png' width='92' height='33' alt='\displaystyle{\ln(i) = i \cdot \frac{\pi}{2}}' class='tex'></p>

<p><strong>Example: (i^i)^i</strong></p>

<p>A double imaginary exponent? If you insist. First off, we know what our growth rate will be inside the parenthesis:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/75dec4aa2a2bdd2a18b963ec3198d2f4.png' width='135' height='22' alt='\displaystyle{i^i = (e^{\frac{\pi}{2}i})^i = e^{-\frac{\pi}{2}}}' class='tex'></p>

<p>We get a negative (shrinking) growth rate of -pi/2&#46; And now we modify that rate <em>again</em> by <em>i</em>:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/4fff11fd7fb2df19043fec759bda0f5c.png' width='166' height='22' alt='\displaystyle{(i^i)^i = (e^{-\frac{\pi}{2}})^i = e^{-\frac{\pi}{2}i}}' class='tex'></p>

<p>And now we have a negative rotation! We're going around the circle a rate of <img src="https://betterexplained.com/latex/c637e6071432217f7cff.png" alt="$-\frac{\pi}{2}$" width="30" height="19" style="vertical-align:-6.25px" class="bex-math"></img> per unit time. How long do we go for? Well, there's an implicit "1" unit of time at the very top of this exponent chain; the implied default is to go for 1 time unit (just like <img src="https://betterexplained.com/latex/a625c986adfdcdba2f11.png" alt="$e = e^1$" width="49" height="17" style="vertical-align:-1.49px" class="bex-math"></img>). 1 time unit gives us a rotation of <img src="https://betterexplained.com/latex/c637e6071432217f7cff.png" alt="$-\frac{\pi}{2}$" width="30" height="19" style="vertical-align:-6.25px" class="bex-math"></img> radians (-90 degrees) or -i!</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/c864006c97d5ba579b712416b0c5abf9.png' width='74' height='21' alt='\displaystyle{(i^i)^i = -i}' class='tex'></p>

<p>And, just for kicks, if we squared that crazy result:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/881c41a6765c5f40b6a2c8f75982c4c9.png' width='99' height='21' alt='\displaystyle{((i^i)^i)^2 = -1}' class='tex'></p>

<p>It's "just" twice the rotation: 2 is a regular number so doubles our rotation rate to a full -180 degrees in a unit of time. Or, you can look at it as applying -90 degree rotation twice in a row.</p>

<p>At first blush, these are really strange exponents. But with our analogies we can take them in stride.</p>

<h2>Complex Growth</h2>

<p>We can have real and imaginary growth at the same time: the real portion scales us up, and the imaginary part rotates us around:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/euler/complex_growth.png" alt="real and imaginary growth" class="webpexpress-processed"></p>

<p>A complex growth rate like (a + bi) is a mix of real and imaginary growth. The real part a, means "grow at 100% for <em>a</em> seconds" and the imaginary part b means "rotate for <em>b</em> seconds". Remember, rotations don't get the benefit of compounding since you keep 'pushing' in a different direction -- rotation adds up linearly.</p>

<p>With this in mind, we can represent any point on any sized circle using (a+bi)! The radius is <img src="https://betterexplained.com/latex/19fdf852e50d0ef46731.png" alt="$e^a$" width="17" height="13" style="vertical-align:-0.2px" class="bex-math"></img> and the angle is determined by <img src="https://betterexplained.com/latex/31d8db4d979f24d96b6b.png" alt="$e^{bi}$" width="20" height="16" style="vertical-align:-0.2px" class="bex-math"></img>. It's like putting the number in the expand-o-tron for two cycles: once to grow it to the right size (a seconds), another time to rotate it to the right angle (b seconds). Or, you could rotate it first and then grow!</p>

<p>Let's say we want to know the growth amount to get to 6 + 8i. This is really asking for the natural log of an imaginary number: how do we grow e to get (6 + 8i)?</p>

<ul>
<li>Radius: How big of a circle do we need? Well, the magnitude is <img src="https://betterexplained.com/latex/abd6820cc580fd85e8e1.png" alt="$\sqrt{6^2 + 8^2} = \sqrt{100} = 10$" width="181" height="20" style="vertical-align:-2px" class="bex-math"></img>. Which means we need to grow for ln(10) = 2.3 seconds to reach that amount.</li>
<li>Amount to rotate: What's the angle of that point? We can use arctan to figure it out: atan(8/6) = 53 degrees = .93 radian.</li>
<li>Combine the result: ln(6+8i) = 2.3 + .93i</li>
</ul>

<p>That is, we can reach the random point (6 + 8i) if we use <img src="https://betterexplained.com/latex/56c04a98acc93dc2b53b.png" alt="$e^{2.3 + .93i}$" width="58" height="16" style="vertical-align:-0.2px" class="bex-math"></img>.</p>

<h2>Why Is This Useful?</h2>

<p>Euler's formula gives us another way to describe motion in a circle. But we could already do that with sine and cosine -- what's so special?</p>

<p>It's all about perspective. Sine and cosine describe motion in terms of a <em>grid</em>, plotting out horizontal and vertical coordinates.</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/euler/equal_paths.png" alt="euler's formula two paths" class="webpexpress-processed"></p>

<p>Euler's formula uses polar coordinates -- what's your angle and distance? Again, it's two ways to describe motion:</p>

<ul>
<li>Grid system: Go 3 units east and 4 units north</li>
<li>Polar coordinates: Go 5 units at an angle of 53.13 degrees</li>
</ul>

<p>Depending on the problem, polar or rectangular coordinates are more useful. Euler's formula lets us convert between the two to use the best tool for the job. Also, because <img src="https://betterexplained.com/latex/f24af717b851ea6a5e39.png" alt="$e^{ix}$" width="22" height="16" style="vertical-align:-0.2px" class="bex-math"></img> can be converted to sine and cosine, we can rewrite formulas in trig as variations on e, which comes in very handy (no need to memorize sin(a+b), you can derive it -- more another day). And it's beautiful that every number, real or complex, is a variation of e.</p>

<p>But utility, schmutility: the most important result is the realization that baffling equations can become intuitive with the right analogies. Don't let beautiful equations like Euler's formula remain a magic spell -- <a href="https://betterexplained.com/articles/developing-your-intuition-for-math/">build on the analogies</a> you know to see the insights inside the equation.</p>

<p>Happy math.</p>

<h2>Appendix</h2>

<p>The screencast was fun, and feedback is definitely welcome. I think it helps the ideas pop, and walking through the article helped me find gaps in my intuition.</p>

<p>References:</p>

<ul>
<li>Brian Slesinsky has a neat <a href="http://slesinsky.org/brian/misc/eulers_identity.html">presentation on Euler's formula</a></li>
<li>Visual Complex Analysis has a great discussion on Euler's formula -- see p. 10 in the <a href="https://books.google.com/books?id=ogz5FjmiqlQC&amp;%23038;dq=visual+complex+analysis&amp;%23038;printsec=frontcover&amp;%23038;source=bn&amp;%23038;hl=en&amp;%23038;ei=4zBCTN3hIIfUtQPS4IHLDA&amp;%23038;sa=X&amp;%23038;oi=book_result&amp;%23038;ct=result&amp;%23038;resnum=6&amp;%23038;ved=0CDwQ6AEwBQ%23v=onepage&amp;%23038;q&amp;%23038;f=false">Google Book Preview</a></li>
<li>I did a talk on <a href="https://betterexplained.com/articles/math-and-analogies/">Math and Analogies</a> which explains Euler's Identity more visually:</li>
</ul>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/math-analogies/math-analogies-jpg.022.jpeg" alt="Intuitive Understanding Of Euler's Formula" class="webpexpress-processed"></p>

]]></content:encoded>
					
					<wfw:commentRss>https://betterexplained.com/articles/intuitive-understanding-of-eulers-formula/feed/</wfw:commentRss>
			<slash:comments>337</slash:comments>
		

			</item>
	</channel>
</rss>
