<?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>BetterExplained &#187; Math</title>
	<atom:link href="http://betterexplained.com/articles/category/math/feed/" rel="self" type="application/rss+xml" />
	<link>http://betterexplained.com</link>
	<description>Learn Right, Not Rote.</description>
	<lastBuildDate>Wed, 01 Feb 2012 21:14:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Using Logarithms in the Real World</title>
		<link>http://betterexplained.com/articles/using-logs-in-the-real-world/</link>
		<comments>http://betterexplained.com/articles/using-logs-in-the-real-world/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 14:00:41 +0000</pubDate>
		<dc:creator>kalid</dc:creator>
				<category><![CDATA[Math]]></category>

		<guid isPermaLink="false">http://betterexplained.com/?p=1782</guid>
		<description><![CDATA[Logarithms are everywhere. Ever use any of the following phrases?

<ul>
<li>6 figures</li>
<li>Double digits</li>
<li>Order of magnitude</li>
</ul>

You&#8217;re describing numbers in terms of their powers of 10 &#8212; a logarithm. Ever mention an interest rate or rate of&#8230; <a href="http://betterexplained.com/articles/using-logs-in-the-real-world/" class="read_more">Read article</a>]]></description>
			<content:encoded><![CDATA[<p>Logarithms are everywhere. Ever use any of the following phrases?</p>

<ul>
<li>6 figures</li>
<li>Double digits</li>
<li>Order of magnitude</li>
</ul>

<p>You&#8217;re describing numbers in terms of their powers of 10 &#8212; a logarithm. Ever mention an interest rate or rate of return? It&#8217;s the logarithm of your growth.</p>

<p>Surprised that logarithms are so common? Me too. Many attempts at Math In the Real World are attempts to point out logarithms in some arcane formula or pretending we&#8217;re geologists fascinated by the Richter Scale. &#8220;Scientists care about logs, and you should too. Also, can you imagine a <a href="http://www.snpp.com/episodes/8F16.html">world without zinc</a>?&#8221;</p>

<p>No, no, no, no no, no no! (Mama mia!)</p>

<p>Math expresses concepts with notation like &#8220;ln&#8221; or &#8220;log&#8221;. Finding &#8220;math in the real world&#8221; means encountering ideas in life and seeing how they <em>could</em> be written with notation. Don&#8217;t look for the literal symbols! When was the last time you wrote a division sign? When was the last time you chopped up some food?</p>

<h2>Ok, ok, we get it: what are logarithms about?</h2>

<p><strong>Logarithms find the cause for an effect, i.e the input for some output</strong></p>

<p>A common &#8220;effect&#8221; is seeing something grow, like going from $100 to $150 in 5 years. How did this happen? We&#8217;re not sure, but the logarithm finds a possible cause: A continuous return of ln(150/100) / 5 = 8.1% would account for that change. It might not be the actual cause (did all the growth happen in the final year?), but it&#8217;s a smooth average we can compare to other changes.</p>

<p>By the way, the notion of &#8220;cause and effect&#8221; is nuanced. Why is 1000 bigger than 100?</p>

<ul>
<li>100 is 10 which grew by itself for 2 time periods (10 * 10)</li>
<li>1000 is 10 which grew by itself for 3 time periods (10 * 10 * 10)</li>
</ul>

<p>We can think of numbers as outputs (1000 is &#8220;1000 outputs&#8221;) and inputs (&#8220;How many times does 10 need to grow to make those outputs?&#8221;). So,</p>

<p>1000 outputs > 100 outputs</p>

<p>because</p>

<p>3 inputs > 2 inputs [i.e., because log(1000) > log(100)]</p>

<p>Why is this useful?</p>

<p><strong>Logarithms put numbers on a human-friendly scale.</strong></p>

<p>Large numbers break our brains. Millions and trillions are &#8220;really big&#8221; even though a million seconds is 12 days, a trillion seconds is 30,000 years. I.e., the difference between an American vacation year and the entirety of human civilization.</p>

<p>The trick to overcoming &#8220;huge number blindness&#8221; is to write numbers in terms of &#8220;inputs&#8221; (i.e. their power base 10). This smaller scale (0 to 100) is much easier to grasp:</p>

<ul>
<li>power of 0 = 10^0 = 1 (single item)</li>
<li>power of 1 = 10^1 = 10</li>
<li>power of 3 = 10^3 = thousand</li>
<li>power of 6 = 10^6 = million</li>
<li>power of 9 = 10^9 = billion</li>
<li>power of 12 = 10^12 = trillion</li>
<li>power of 23 = 10^23 = number of molecules in a dozen grams of carbon</li>
<li>power of 80 = 10^80 = number of molecules in the universe</li>
</ul>

<p>A 0 to 80 scale took us from a single item to the number of things in the universe. Not too shabby.</p>

<p><strong>Logarithms count multiplication as steps</strong></p>

<p>Logarithms describe changes in terms of multiplication: in the examples above, each step is 10x bigger. With the natural log, each step is &#8220;e&#8221; (2.71828&#8230;) times more.</p>

<p>When dealing with a series of multiplications, logarithms help &#8220;count&#8221; them, just like addition counts for us when effects are added.</p>

<h2>Show me the math</h2>

<p>Time for the meat: let&#8217;s see where logarithms show up!</p>

<p><strong>Six-figure salary or 2-digit expense</strong></p>

<p>We&#8217;re describing numbers in terms of their digits, i.e. how many powers of 10 they have (are they in the tens, hundreds, thousands, ten-thousands, etc.). Adding a digit means &#8220;multiplying by 10&#8243;, i.e.</p>

<p>1 [1 digit] * 10 * 10 * 10 * 10 * 10 [5 more digits] = 10^5 = 100,000</p>

<p>Logarithms count the number of multiplications <em>added on</em>, so starting with 1 (a single digit) we add 5 more digits (10^5) and 100,000 get a 6-figure result. Talking about &#8220;6&#8243; instead of &#8220;One hundred thousand&#8221; is the essence of logarithms. It gives a rough sense of scale without jumping into details.</p>

<p>Bonus question: How would you describe 500,000? Saying &#8220;6 figure&#8221; is misleading because 6-figures often implies something closer to 100,000. Would &#8220;6.5 figure&#8221; work?</p>

<p>Not really. In our heads, 6.5 means &#8220;halfway&#8221; between 6 and 7 figures, but that&#8217;s an adder&#8217;s mindset. With logarithms a &#8220;.5&#8243; means halfway in terms of multiplication, i.e the square root (9^.5 means the square root of 9 &#8212; 3 is halfway in terms of multiplication because it&#8217;s 1 to 3 and 3 to 9).</p>

<p>Taking log(500,000) we get 5.7, add 1 for the extra digit, and we can say &#8220;500,000 is a 6.7 figure number&#8221;. Try it out here:</p>

<iframe src="http://new.instacalc.com/895/embed" frameborder="0" marginwidth="0" marginheight="0" width="450" height="250"></iframe>

<p><strong>Order of magnitude</strong></p>

<p>We geeks love this phrase. It means roughly &#8220;10x difference&#8221; but just sounds cooler than &#8220;1 digit larger&#8221;.</p>

<p>In computers, where everything is counted with bits (1 or 0), each bit has a doubling effect (not 10x). So going from 8 to 16 bits is &#8220;8 orders of magnitude&#8221; or 2^8 = 256 times larger. (These bit sizes refers to the amount of memory available, not the processor speed). Going from 16 to 32 bits means 16 orders of magnitude, or 2^16 ~ 65,536 times larger.</p>

<p>Isn&#8217;t &#8220;16 extra bits of memory&#8221; better than &#8220;65,536 times more memory?&#8221;.</p>

<p><strong>Interest Rates</strong></p>

<p>How do we figure out growth rates? A country doesn&#8217;t intend to grow at 8.56% per year. You look at the GDP one year and the GDP the next, and take the logarithm to find the <em>implicit</em> growth rate.</p>

<p>My two favorite interpretations of the natural logarithm (ln(x)), i.e. the natural log of 1.5:</p>

<ul>
<li>Assuming 100% growth, how long do you need to grow to get to 1.5? (.405, less than half the time period)</li>
<li>Assuming 1 unit of time, how fast do you need to grow to get to 1.5? (40.5% per year, continuously compounded)</li>
</ul>

<p>Logarithms are how we figure out how fast we&#8217;re growing.</p>

<p><strong>Measurement Scale: Google PageRank</strong></p>

<p>Google gives every page on the web a score (PageRank) which is a rough measure of authority / importance. This is a logarithmic scale, which in my head means &#8220;PageRank counts the number of digits in your score&#8221;.</p>

<p>So, a site with pagerank 2 (&#8220;2 digits&#8221;) is 10x more popular than a PageRank 1 site. My site is PageRank 5 and CNN has PageRank 9, so there&#8217;s a difference of 4 orders of magnitude (10^4 = 10,000).</p>

<p>Roughly speaking, I get about 7000 visits / day. Using my envelope math, I can guess CNN gets about 7000 * 10,000 = 70 million visits / day. (How&#8217;d I do that? In my head, I think 7k * 10k = 70 * k * k = 70 * M). They might have a few times more than that (100M, 200M) but probably not up to 700M.</p>

<p>Google conveys a lot of information with a very rough scale (1-10).</p>

<p><strong>Measurement Scale: Richter, Decibel, etc.</strong></p>

<p>Sigh. We&#8217;re at the typical &#8220;logarithms in the real world&#8221; example: Richter scale and Decibel. The idea is to put events which can vary drastically (earthquakes) on a single 1 &#8211; 10 scale. Just like PageRank, each 1-point increase is a 10x improvement in power.</p>

<p>Decibels are similar, though it can be negative. Sounds can go from intensely quiet (pindrop) to extremely loud (airplane) and our brains can process it all. In reality, the sound of an airplane&#8217;s engine is millions (billions, trillions) of times more powerful than a pindrop, and it&#8217;s inconvenient to have a scale that goes from 1 to a gazillion. Logs keep everything on a reasonable scale.</p>

<p><strong>Logarithmic Graphs</strong></p>

<p>You&#8217;ll often see items plotted on a &#8220;log scale&#8221;. In my head, this means one side is counting &#8220;number of digits&#8221; or &#8220;number of multiplications&#8221;, not the value itself. Again, this helps show wildly varying events on a single scale (going from 1 to 10, not 1 to billions).</p>

<p>Moore&#8217;s law is a great example: we double the number of transistors every 18 months (image courtesy <a href="http://en.wikipedia.org/wiki/File:Transistor_Count_and_Moore%27s_Law_-_2011.svg">Wikipedia</a>).</p>

<p><img src="http://betterexplained.com/wp-content/uploads/logs/moores_law.png" alt="Moore's Law" /></p>

<p>The neat thing about log-scale graphs is exponential changes (processor speed) appear as a straight line. Growing 10x per year means you&#8217;re steadily marching up the &#8220;digits&#8221; scale.</p>

<h2>Onward and upward</h2>

<p>If a concept is well-known but not well-loved, it means we need to build our intuition. Find the analogies that work, and don&#8217;t settle for the slop a textbook will trot out. In my head:</p>

<ul>
<li>Logarithms find the root cause for an effect (see growth, find interest rate)</li>
<li>They help count multiplications or digits, with the bonus of partial counts (500k is a 6.7 digit number)</li>
</ul>

<p>Happy math.</p>
]]></content:encoded>
			<wfw:commentRss>http://betterexplained.com/articles/using-logs-in-the-real-world/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Understanding Pythagorean Distance and the Gradient</title>
		<link>http://betterexplained.com/articles/understanding-pythagorean-distance-and-the-gradient/</link>
		<comments>http://betterexplained.com/articles/understanding-pythagorean-distance-and-the-gradient/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 16:24:48 +0000</pubDate>
		<dc:creator>kalid</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Vector Calculus]]></category>

		<guid isPermaLink="false">http://betterexplained.com/?p=1460</guid>
		<description><![CDATA[The <a href="http://betterexplained.com/articles/measure-any-distance-with-the-pythagorean-theorem/">Pythagorean Theorem</a> shows how strange our concept of distance is. Using the rule a<sup>2</sup> + b<sup>2</sup> = c<sup>2</sup>, we can trade some &#8220;a&#8221; to get more &#8220;b&#8221;.

Starting with



means &#8220;A 13-inch pizza equals a 13-inch pizza&#8221;. Sure.&#8230; <a href="http://betterexplained.com/articles/understanding-pythagorean-distance-and-the-gradient/" class="read_more">Read article</a>]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://betterexplained.com/articles/measure-any-distance-with-the-pythagorean-theorem/">Pythagorean Theorem</a> shows how strange our concept of distance is. Using the rule <span class="tex-inline" alt="a^2 + b^2 = c^2">a<sup>2</sup> + b<sup>2</sup> = c<sup>2</sup></span>, we can trade some &#8220;a&#8221; to get more &#8220;b&#8221;.</p>

<p>Starting with</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/4fe780744f65a3a106be7088db2d4cc4.png' title='\displaystyle{13^2 + 0^2 = 13^2}' alt='\displaystyle{13^2 + 0^2 = 13^2}' align=absmiddle class='tex'></p>

<p>means &#8220;A 13-inch pizza equals a 13-inch pizza&#8221;. Sure. But we can trade an inch and get:</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/87c51dc809eaac5cee3f2bd3954af2fa.png' title='\displaystyle{12^2 + 5^2 = 13^2}' alt='\displaystyle{12^2 + 5^2 = 13^2}' align=absmiddle class='tex'></p>

<p>Huh? A 12-inch pizza and a 5-inch pizza equal a 13-inch pizza?</p>

<p>The math works (144 + 25 = 169) but, but&#8230; we gave up an inch and got a five-inch pizza!</p>

<p>Let&#8217;s understand why the tradeoff happens, and how to use it.</p>

<h2>Explanation 1: Shaving the Square</h2>

<p>A key insight: <strong>Bigger numbers are harder to square</strong>.</p>

<p><img src="http://betterexplained.com/wp-content/uploads/pythagdistance/shavingthesquare.png" alt="Shaving the Square" /></p>

<p>Imagine laying tiles on a porch &#8212; as your porch grows, the outer layer needs more tiles. Trimming a 13&#215;13 porch to 12&#215;12 frees up 25 tiles, which is enough to make a new 5&#215;5 porch!</p>

<p>I call this &#8220;shaving the square&#8221;. Trimming 1 unit from the outside of a large square has more &#8220;shavings&#8221; which can contribute to a smaller one (trimming an inch from a giant fro can make a sweater for an infant). As we continue to trim, the benefit diminishes because our starting point is smaller and smaller.</p>

<h2>Explanation 2: Sliding the Chopstick</h2>

<p>A second insight: <strong>Slide a little, pivot a lot</strong>.</p>

<p>Imagine a chopstick wedged in a corner: the length is fixed, and the ends of the chopstick must touch a wall. What&#8217;re the options?</p>

<p>Well, laying on a single wall means 100% for one side (like saying <span class="tex-inline" alt="13^2 + 0^2 = 13^2">13<sup>2</sup> + 0<sup>2</sup> = 13<sup>2</sup></span>). Not that interesting.</p>

<p>By sliding the chopstick (from 13 to 12) we can swing it <em>out</em> by 5 on the other wall!</p>

<p><img src="http://betterexplained.com/wp-content/uploads/pythagdistance/slideandpivot.png" alt="Shaving the Square" /></p>

<p>You need to try it &#8212; a small slide gives a giant pivot. As we keep sliding, the tradeoff (How much pivot do we get?) changes.</p>

<h2>So What&#8217;s the Tradeoff?</h2>

<p>Time to see how the a/b tradeoff works. First, let&#8217;s use grid coordinates: x &#038; y (horizontal and vertical). Given a fixed distance (13 units, let&#8217;s say), our options lay on the circle where <span class="tex-inline" alt="x^2 + y^2 = 13^2">x<sup>2</sup> + y<sup>2</sup> = 13<sup>2</sup></span>:</p>

<p>A few points:</p>

<ul>
<li>Each possibility is the same distance, but has a different ratio of x to y (100% x, 100% y, or a mix like (12,5))</li>
<li>We can only move to neighboring points on the circle (options at the same distance)</li>
<li>The tradeoff we face is how much &#8220;x&#8221; we get for &#8220;y&#8221; when moving to a neighbor. If we&#8217;re at (0, 13) we could move to (5, 12). This trades 1 y for 5 x&#8217;s.</li>
</ul>

<p>This is the &#8220;chunky&#8221; tradeoff where we&#8217;re using an entire unit at a time. What about .5 units? .01?</p>

<p>Enter the tangent! The <strong>tangent line</strong> shows the trajectory of our current path, the direction to our neighbor. We follow the tangent for a tiny, microscopic amount to get our next neighbor. The tangent is an approximation &#8212; it&#8217;s not pointing exactly at our nearest neighbor, but it&#8217;s pretty close.</p>

<p><strong>The tangent shows the tradeoff you are about to make.</strong></p>

<p>What&#8217;s the actual amount? Any point (x,y) has a slope of y/x, and a tangent line with slope -x/y, so the tradeoff is&#8230;getting confused yet?</p>

<p>Less mindless algebra, more intuition:</p>

<ul>
<li>Circles have a tangent line perpendicular to the current point</li>
<li>If you&#8217;re at (5,12) then tangent slope is some ratio of 5 and 12</li>
<li>Remember &#8220;shaving the square&#8221;: you get a better deal in the direction of the smaller coordinate (increasing a large square is tough).</li>
<li>So, at (5, 12) you&#8217;re &#8220;heavy on the y&#8221; and the trade will favor improving your x: it should be &#8220;trade 5 y&#8217;s for 12 x&#8217;s&#8221;. And why not the other way? It doesn&#8217;t make sense that the more y you have, the <em>easier</em> it is to get y! That&#8217;d spiral off into exponential growth, not a circle.</li>
<li>Lastly, we can&#8217;t trade an entire chunk of 5 y&#8217;s! The tangent is about our nearest neighbor. We have a trade of 12/5 or 2.4 to 1. Our next, tiny movement will be at this ratio (and then we&#8217;ll be at a new point, with a new tangent).</li>
</ul>

<p>General principle: Our neighbors are on a circle, which encourages balance. You get a better deal in the direction of the smaller coordinate: at (x,y) the tradeoff is y:x.</p>

<h2>Optimizing The Tradeoff</h2>

<p>Now we know the tradeoff for any point (x,y) &#8212; let&#8217;s optimize!</p>

<p>In a boring scenario, we get paid based on pure distance, so every point (or direction to move) is the same.</p>

<p>The exciting scenario: our (x,y) position is an <em>input</em> into some other function which gives us a return! Now we want to maximize that function.</p>

<p>Here&#8217;s a scenario: Popeye throws cars for cash. He lines up spectators on fences running North and East. The spectators must look straight ahead (they&#8217;re in neck braces, due to earlier events) but will pay Popeye if they see a car pass in front of them.</p>

<p><img src="http://betterexplained.com/wp-content/uploads/pythagdistance/popeyeshow.png" alt="Popeye's show" /></p>

<h2>Maximizing Even Payouts</h2>

<p>Suppose each spectator offers $1 if they see the car (Payout (x,y) = x + y). Where to throw?</p>

<p>First, assume Popeye has finite energy &#8212; he can throw the car 13 meters. Now let&#8217;s start somewhere: throwing the car pure North (0, 13):</p>

<p>P(0,13) = 0 + 13 = $13</p>

<p>Ok. What if he threw it slightly East? To (5, 12) let&#8217;s say?</p>

<p>P(5,12) = 5 + 12 = $17</p>

<p>Clearly better. This should make sense: at (0,13) the tradeoff is <em>great</em> to get more East. We can give up 1 North and get a whopping 5 East, a &#8220;profit&#8221; of $4 if we do the trade. We should keep trading as long as it&#8217;s profitable &#8212; as long as we&#8217;re out of balance, the circle will reward us for boosting the smaller side. Following a 45 degree angle for 13 units is the ideal:</p>

<p>P(13 * 1/sqrt(2), 13 * 1/sqrt(2)) = P(13 * .707, 13 * .707) = 9.2 + 9.2 = $18.4</p>

<p>Neat. A 45-degree throw hits 70.7% of the possible spectators for each side.</p>

<p>Psst. Confused about how we got .707? No problem. Taking sides of 1 and 1 means the hypotenuse is 2:</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/528ca43e1d8dc4fd0d1486fe586b3366.png' title='\displaystyle{1^2 + 1^2 = 2}' alt='\displaystyle{1^2 + 1^2 = 2}' align=absmiddle class='tex'></p>

<p>But we want a trajectory of length 1, so we can scale it up easily (multiply by 13). So we divide both sides by 2:</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/33ca50402c348f07ad8e9d4fb44f4957.png' title='\displaystyle{\frac{1^2}{2} + \frac{1^2}{2} = \frac{2}{2} = 1}' alt='\displaystyle{\frac{1^2}{2} + \frac{1^2}{2} = \frac{2}{2} = 1}' align=absmiddle class='tex'></p>

<p>To get the new &#8220;a&#8221; and &#8220;b&#8221; back out, convert 2 into &#8220;sqrt(2)^2&#8243;:</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/e05e6103ff367469f368e872ccd97e6c.png' title='\displaystyle{\frac{1^2}{(\sqrt 2)^2} + \frac{1^2}{(\sqrt 2)^2} = \left( \frac{1}{\sqrt 2} \right)^2 + \left( \frac{1}{\sqrt 2} \right) ^2 = a^2 + b^2 = 1}' alt='\displaystyle{\frac{1^2}{(\sqrt 2)^2} + \frac{1^2}{(\sqrt 2)^2} = \left( \frac{1}{\sqrt 2} \right)^2 + \left( \frac{1}{\sqrt 2} \right) ^2 = a^2 + b^2 = 1}' align=absmiddle class='tex'></p>

<h2>General Technique: Finding the Best Direction</h2>

<p>We stumbled upon the way to find the best return:</p>

<ul>
<li>Pick any starting point / direction</li>
<li>Tweak it: if our return improves, keep the new choice (it&#8217;s profitable)</li>
<li>Keep tweaking until our return is no longer profitable</li>
</ul>

<p>In math slang, this is &#8220;finding the local maximum&#8221;. In economics slang, it&#8217;s finding the point of &#8220;zero marginal returns&#8221;. Popeye calls it Squeezing the Spinach.</p>

<h2>Maximizing Uneven Returns</h2>

<p>Now suppose the Northern spectators offer $2 (Eastern stay at $1), so P(x,y) = x + 2*y. Should we throw it 100% North?</p>

<p>P(0, 13) = 0 + 2*13 = $26</p>

<p>Not bad. But what about 45 degrees again?</p>

<p>P(9.2, 9.2) = 9.2 + 2*9.2 = $27.6</p>

<p>Interesting &#8212; 45 degrees is still better! But&#8230; I think we went too far! Shouldn&#8217;t we favor North since it pays more?</p>

<p>Yep. Let&#8217;s remember how to Squeeze the Spinach (maximize our returns): start with North and change until it&#8217;s not profitable:</p>

<ul>
<li>The payout function means 1 North = 2 Easts (North pays $2, so 1 unit North = 2 units East)</li>
<li>Trades are profitable if we can beat 1 North for 2 Easts (1 North for 3 Easts, for example, would profit $1)</li>
</ul>

<p>So&#8230; where are trades <em>better</em> than 1 North for 2 Easts? In the Northern section, where the circle rewards us by throwing Easts at us (&#8220;Please, please go East&#8230; I&#8217;ll give you a bunch if you give up a little North&#8221;).</p>

<p>Remember how circles are about x/y, x &#038; y, x:y, etc.? Well, we have the numbers 1 and 2. (2,1) is in the East section. We want (1,2). Why? At (1,2) we have reached the perfect 1 North = 2 East tradeoff.</p>

<p>Following the direction (1,2) for 13 units is:</p>

<p>P(13 * 1/sqrt(5), 13 * 2/sqrt(5)) = P(5.81, 11.62) = 5.81 + 2*11.62 = $29.05</p>

<p>Tada! Over 29 smackeroos because we maximized our return.</p>

<h2>The Gradient Principle</h2>

<p>We can supercharge this result:</p>

<p><strong>To maximize return, go in each direction proportional to its payoff.</strong></p>

<p>If North pays 2:1 compared to East, your trajectory should favor North by 2:1. In mathier terms:</p>

<ul>
<li>Payoff(x,y) = a<em>x + b</em>y</li>
<li>Best trajectory = (a, b)  [in our case, (East, North) => (1, 2)]</li>
</ul>

<p>And this works in multiple dimensions! Given 3 dimensions, go in a direction (Payoff(x), Payoff(y), Payoff(z)). Vector calculus fans, this is why the <a href="http://betterexplained.com/articles/vector-calculus-understanding-the-gradient/">gradient</a> is in the direction of greatest increase.</p>

<p>The gradient for <span class="tex-inline" alt="F(x,y,z)">F(x,y,z)</span> is</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/13c8856e02bc4cf4cea67c6916bf34f9.png' title='\displaystyle{(\frac{dF}{dx},\frac{dF}{dy},\frac{dF}{dz})}' alt='\displaystyle{(\frac{dF}{dx},\frac{dF}{dy},\frac{dF}{dz})}' align=absmiddle class='tex'></p>

<p>And each partial derivative (dF/dx) is the payoff for moving in that direction.</p>

<p>But does it all balance? Suppose x pays 3, y pays 4, and z pays 5 (at the current position). The 2-dimensional tradeoff trajectories are:</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/2b214d4d423707d97da9b5c7dcdd34dd.png' title='\displaystyle{ (x, y) = (3,4) }' alt='\displaystyle{ (x, y) = (3,4) }' align=absmiddle class='tex'>
<img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/a4ca4bb583d2542ab0eeb05f2faba973.png' title='\displaystyle{ (y, z) = (4, 5) }' alt='\displaystyle{ (y, z) = (4, 5) }' align=absmiddle class='tex'>
<img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/43a3f96057809346b877f071453c6e82.png' title='\displaystyle{ (x, z) = (3, 5) }' alt='\displaystyle{ (x, z) = (3, 5) }' align=absmiddle class='tex'></p>

<p>Now for the magic: the combined trajectory</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/e171550b05778387a538d7d3be4bc823.png' title='\displaystyle{(x,y,z) = (3,4,5)}' alt='\displaystyle{(x,y,z) = (3,4,5)}' align=absmiddle class='tex'></p>

<p>satisfies all 3 requirements! On the x-z plane, x doesn&#8217;t care about y &#8212; as long as the ratio to z is (3 , ?, 5) you&#8217;re getting the best tradeoff from the x-z perspective. The pairs are:</p>

<ul>
<li>(3, ?, 5)</li>
<li>(?, 4, 5)</li>
<li>(3, 4, ?)</li>
</ul>

<p>You don&#8217;t need a sudoku master to see (3, 4, 5) satisfies all those proportions.</p>

<p>Still not convinced? Imagine the payoff for y was zero. We don&#8217;t want to waste energy in our trajectory (3, ?, 5) in a useless direction. But that can&#8217;t happen, because the y-z tradeoff will be (?, 0, 5) and the x-y tradeoff will be (3, 0, ?). The x-z tradeoff lets y-z and x-y &#8220;figure out&#8221; what y should be, which is 0.</p>

<h2>Questions I Had That You Might Have Too</h2>

<p><strong>Q: I still don&#8217;t get why this works at all. Somehow 50% in x and 50% in y leads to .7 + .7 = 1.4?</strong></p>

<p>It&#8217;s a deep question about <em>why</em> space behaves like this. I was going crazy staring at chopsticks on a wall.</p>

<p>Here&#8217;s my answer: distance is distance. 13 units is 13 units. But in some situations we are &#8220;measuring our coordinates&#8221; (what are the values of x &#038; y) and <em>not</em> the distance itself.</p>

<p>Coordinates with perpendicular axes are very inefficient, especially for diagonal motion (i.e., you are measuring the sides of the triangle, not the hypotenuse). When .707^2 + .707^2 = 1, it&#8217;s a measure how how &#8220;inefficient&#8221; our x &#038; y coordinates are being. We used 70% of each coordinate to represent an object that could have been 100% on one (i.e, if we used polar coordinates).</p>

<p><strong>Q: I have an offshore investment with 200% return, and an onshore one with 5% return. I have $1000 to spend &#8212; should I split my money?</strong></p>

<p>Heavens, no! Remember, this principle is about <em>distance measurements on a grid</em> with the idea that 50% in x and 50% in y covers &#8220;more ground&#8221; than 100% in x. In investing 1) money is not on a grid and 2) there&#8217;s no distance bonus. Putting half your money in each is plain old 0.5 + 0.5 = 1.0. Giving up $1 of the offshore investment gives you $1 for the onshore one.</p>

<p>Put all your money in the best investment.</p>

<p><strong>Q: So all this stuff is useless?</strong></p>

<p>Heavens, no! Ask yourself: am I measuring distance on a coordinate system?</p>

<p>Many things are measured in terms of x-y coordinates (physical phenomena, etc.) and <em>do</em> have the Pythagorean distance tradeoff.</p>

<p><a href="http://betterexplained.com/articles/types-of-graphs/">But not every graph is the same</a>. Graphs that aren&#8217;t about distance (like &#8220;Money vs. Time&#8221;) do <em>not</em> get any boost from the Pythagorean theorem. This confused me for a long time: the Pythagorean Theorem works for coordinate distance!</p>

<h2>Final Thoughts</h2>

<p>The Pythagorean Theorem is so versatile &#8212; it&#8217;s not about triangles, it covers the nature of distance. I seem to find some new realization when I study it. Really grokking it will help you everywhere, from geometry to vector calculus.</p>

<p>Happy math.</p>
]]></content:encoded>
			<wfw:commentRss>http://betterexplained.com/articles/understanding-pythagorean-distance-and-the-gradient/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Understanding Why Complex Multiplication Works</title>
		<link>http://betterexplained.com/articles/understanding-why-complex-multiplication-works/</link>
		<comments>http://betterexplained.com/articles/understanding-why-complex-multiplication-works/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 14:00:24 +0000</pubDate>
		<dc:creator>kalid</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[complex numbers]]></category>

		<guid isPermaLink="false">http://betterexplained.com/?p=1289</guid>
		<description><![CDATA[Seeing <a href="http://betterexplained.com/articles/a-visual-intuitive-guide-to-imaginary-numbers/">imaginary numbers as rotations</a> was one of my favorite aha moments:



i, the square root of -1, is a number in a different dimension! Once that clicks, we can use multiplication to &#8220;combine&#8221; rotations of two complex numbers:&#8230; <a href="http://betterexplained.com/articles/understanding-why-complex-multiplication-works/" class="read_more">Read article</a>]]></description>
			<content:encoded><![CDATA[<p>Seeing <a href="http://betterexplained.com/articles/a-visual-intuitive-guide-to-imaginary-numbers/">imaginary numbers as rotations</a> was one of my favorite aha moments:</p>

<p><img src="http://betterexplained.com/wp-content/uploads/complex/imaginary_rotation.png" alt="" width="350px" /></p>

<p>i, the square root of -1, is a number in a different dimension! Once that clicks, we can use multiplication to &#8220;combine&#8221; rotations of two complex numbers:</p>

<p><img src="http://betterexplained.com/wp-content/uploads/complex/imaginary_example2.png" alt="" width="350px" /></p>

<p>Yowza, did that ever blow my mind: add angles without sine or cosine! Unfortunately, I didn&#8217;t have an intuitive grasp of <em>why</em> this worked. Let&#8217;s fix that!</p>

<h2>The Boring Explanation: How?</h2>

<p>Here&#8217;s the common explanation of why complex multiplication adds the angles. First, write the complex numbers as polar coordinates (radius &amp; angle):</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/5f48a29ef8d7a23d06d2027757b86203.png' title='\displaystyle{ r1(cos(a) + isin(a)) \cdot r2 (cos(b) + isin(b)) }' alt='\displaystyle{ r1(cos(a) + isin(a)) \cdot r2 (cos(b) + isin(b)) }' align=absmiddle class='tex'></p>

<p>Next, take the product, group by real/imaginary parts:</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/33c1f27455489c9d47dc9afdc8d0c0f2.png' title='\displaystyle{ = (r1 \cos(a) \cdot r2 \cos(b) - r1 \sin(a) \cdot r2 \sin(b))}' alt='\displaystyle{ = (r1 \cos(a) \cdot r2 \cos(b) - r1 \sin(a) \cdot r2 \sin(b))}' align=absmiddle class='tex'>
<img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/e76ca0be70247dbd6ea663816575cf39.png' title='\displaystyle{ + i (r1 \cos(a) \cdot r2 \sin(b) + r2 \cos(b) \cdot r1 \sin(a)) }' alt='\displaystyle{ + i (r1 \cos(a) \cdot r2 \sin(b) + r2 \cos(b) \cdot r1 \sin(a)) }' align=absmiddle class='tex'></p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/1833841cc6e303d42f68c0ec4f088f37.png' title='\displaystyle{ = r1 \cdot r2[(\cos(a) \cdot \cos(b) - \sin(a) \cdot \sin(b))}' alt='\displaystyle{ = r1 \cdot r2[(\cos(a) \cdot \cos(b) - \sin(a) \cdot \sin(b))}' align=absmiddle class='tex'>
<img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/1f49822216f2349b077286821a1ccc11.png' title='\displaystyle{ + i (\cos(a) \cdot \sin(b) + \cos(b) \cdot \sin(a))] }' alt='\displaystyle{ + i (\cos(a) \cdot \sin(b) + \cos(b) \cdot \sin(a))] }' align=absmiddle class='tex'></p>

<p>Lastly, notice how this matches the sine and cosine angle addition formulas:</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/28ca5485e8de75139cb07825b340fe15.png' title='\displaystyle{ cos(a+b)= \cos(a) \cdot \cos(b) - \sin(a) \cdot \sin(b) }' alt='\displaystyle{ cos(a+b)= \cos(a) \cdot \cos(b) - \sin(a) \cdot \sin(b) }' align=absmiddle class='tex'>
<img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/b63160647336f5ff7453872df534b25f.png' title='\displaystyle{ sin(a+b) =\cos(a) \cdot \sin(b) + \cos(b) \cdot \sin(a) }' alt='\displaystyle{ sin(a+b) =\cos(a) \cdot \sin(b) + \cos(b) \cdot \sin(a) }' align=absmiddle class='tex'></p>

<p>And there you have it! What&#8217;s that? You don&#8217;t intuitively think in terms of sine and cosine expansions? Too bad, the math checks out!</p>

<p>&#8230;</p>

<p>Still here? Good. The problem is we&#8217;ve lost the magic: it&#8217;s like saying two poems are similar because we analyzed the distribution of letters. Accurate but unsatisfying!</p>

<p>I like sine as much as anyone, but the details come <em>after</em> seeing the relationship click.</p>

<h2>The Fun Explanation: Why!</h2>

<p>What&#8217;s our goal again? Oh yes &#8212; to see <em>why</em> we can multiply two complex numbers and add the angles.</p>

<p>First, let&#8217;s figure out what multiplication does:</p>

<p><img src="http://betterexplained.com/wp-content/uploads/complex_multiplication/complex-table-rules.png" alt="" /></p>

<ul>
<li><strong>Regular multiplication</strong> (&#8220;times 2&#8243;) scales up a number (makes it larger or smaller)</li>
<li><strong>Imaginary multiplication</strong> (&#8220;times i&#8221;) rotates you by 90 degrees</li>
</ul>

<p>And what if we combine the effects in a complex number? Multiplying by (2 + i) means &#8220;double your number &#8212; oh, add in a perpendicular rotation&#8221;.</p>

<p>Quick example: <span class="tex-inline" alt="4 \cdot (3+i) = 4 \cdot 3 + 4 \cdot i = 12 + 4i">4 &middot; (3+i) = 4 &middot; 3 + 4 &middot; i = 12 + 4i</span></p>

<p>That is, take our original (4), make it 3 times larger (4 * 3) and <em>then</em> add the effect of rotation (+4i). Again, if we wanted only rotation, we&#8217;d multiply by &#8220;i&#8221;. If we wanted only scaling we&#8217;d multiply by plain old 3. A complex number (a + bi) has both effects.</p>

<h2>Visualizing Complex Multiplication</h2>

<p>That was easy &#8212; a real number (4) times a complex (3+i). What about two complex numbers (&#8220;triangles&#8221;), like <span class="tex-inline" alt="(3 + 4i) \cdot (2 + 3i)">(3 + 4i) &middot; (2 + 3i)</span>?</p>

<p><img src="http://betterexplained.com/wp-content/uploads/complex_multiplication/complex-multiplication-1.png" alt="" /></p>

<p>Now we&#8217;re talking! I see this as &#8220;Make a scaled version of our original triangle (times 2) and add a scaled/rotated triangle (times 3i)&#8221;. The final endpoint is the new complex number.</p>

<p>But&#8230; I love alternate explanations! Here&#8217;s another:</p>

<p><img src="http://betterexplained.com/wp-content/uploads/complex_multiplication/complex-FOIL.png" alt="" /></p>

<p>Instead of grouping the multiplication by triangle, we analyze each part of the FOIL (first, outside, inside, last). Adding each component takes us along a <em>path</em> and ends in the same spot!</p>

<h2>But What About the Angles?</h2>

<p>Ah yes, the angles. It looks like we&#8217;re adding the angles, but can we be sure?</p>

<p><img src="http://betterexplained.com/wp-content/uploads/complex_multiplication/complex-angles.png" alt="" /></p>

<p>Captain Geometry to the rescue! Oh, how I&#8217;ve missed you from 9th grade. Is the result (dotted blue line) at the same angle as plopping the triangles on each other?</p>

<p>In the normal case, we start with a triangle (3 + 4i) and plop on the other (2 + 3i) to get the combined angle.</p>

<p>After the multiplication, we start with a scaled triangle (2x) and plop on another scaled triangle (times 3i). Even though it&#8217;s larger, <a href="http://betterexplained.com/articles/understanding-why-similarity-works/">similar triangles</a> have the same angles &#8212; they&#8217;re just bigger (but don&#8217;t ask about its size, ok?).</p>

<p>We scaled up the original triangle (no change in angle) and &#8220;plopped on&#8221; another scaled triangle (no change in angle), so the result is the same! I love seeing this come together &#8212; we scale up, rotate out, and boom &#8212; we&#8217;re at the combined angle. This isn&#8217;t about &#8220;imaginary numbers&#8221; &#8212; it&#8217;s a way to combine triangles without trigonometry!</p>

<h2>Side Effects May Include Scaling</h2>

<p>Notice how we&#8217;re making larger copies of our original triangle and adding them together. What&#8217;s the change in size compared to our starting blue triangle?</p>

<p>Well, let&#8217;s call our original length &#8220;x&#8221;. Whatever it is, we end up getting a new triangle layered on top, with a size of 2x + 3x (a + bi in general). And from Pythagoras (I love that gentleman) the &#8220;real&#8221; distance is</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/e2274f9d87c667223dc3b53b13ea9fe8.png' title='\displaystyle{\sqrt{(ax)^2 + (bx)^2} = \sqrt{x^2(a^2 + b^2)} = x \cdot \sqrt{a^2 + b^2}}' alt='\displaystyle{\sqrt{(ax)^2 + (bx)^2} = \sqrt{x^2(a^2 + b^2)} = x \cdot \sqrt{a^2 + b^2}}' align=absmiddle class='tex'></p>

<p>That is, we take our original distance (x) and scale it by the <em>size</em> of the new triangle (size of a + bi).</p>

<p>If the new triangle is size 1 (<span class="tex-inline" alt="a^2 + b^2 = 1">a<sup>2</sup> + b<sup>2</sup> = 1</span>) then the distance won&#8217;t change!</p>

<h2>A Few Thoughts</h2>

<p>I don&#8217;t hate rigorous proofs &#8212; I hate pretending they&#8217;re helpful when they&#8217;re not. Proofs have two goals:</p>

<ul>
<li>Show <em>that</em> a result is true. This is for mathematicians presenting results &#8212; students rarely question the validity of facts in math class.</li>
<li>Show <em>why</em> a result is true.</li>
</ul>

<p>Real, satisfying insight comes from playing with analogies and examples &#8212; not reading distilled, minimalist proofs (especially those which appeal to the sine/cosine addition formulas!).</p>

<p>Poyla said it well: “When you have satisfied yourself that the theorem is true, you start proving it.&#8221;</p>

<p>Happy math.</p>
]]></content:encoded>
			<wfw:commentRss>http://betterexplained.com/articles/understanding-why-complex-multiplication-works/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Intuitive Understanding of Sine Waves</title>
		<link>http://betterexplained.com/articles/intuitive-understanding-of-sine-waves/</link>
		<comments>http://betterexplained.com/articles/intuitive-understanding-of-sine-waves/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 14:00:25 +0000</pubDate>
		<dc:creator>kalid</dc:creator>
				<category><![CDATA[Calculus]]></category>
		<category><![CDATA[Math]]></category>

		<guid isPermaLink="false">http://betterexplained.com/?p=1183</guid>
		<description><![CDATA[Sine waves confused me. Yes, I can mumble "SOH CAH TOA" and draw lines within triangles. <strong>But what does it mean</strong>?

I was stuck thinking sine had to be extracted from other shapes. A quick analogy:

<blockquote>
You: Geometry is</blockquote>&#8230; <a href="http://betterexplained.com/articles/intuitive-understanding-of-sine-waves/" class="read_more">Read article</a>]]></description>
			<content:encoded><![CDATA[<p>Sine waves confused me. Yes, I can mumble "SOH <span class="caps">CAH TOA</span>" and draw lines within triangles. <strong>But what does it mean</strong>?</p>

<p>I was stuck thinking sine had to be extracted from other shapes. A quick analogy:</p>

<blockquote>
You: Geometry is about shapes, lines, and so on...

<p>Alien: Oh? Can you show me a line?</p>

<p>You (looking around): Uh... see that brick, there? A line is one edge of that brick.</p>

<p>Alien: So lines are part of a shape?</p>

<p>You: Sort of. Yes, most shapes have lines in them. But a line is a basic concept on its own: a beam of light, a direct route on a map, or even a vector in many dimensions. You see--</p>

Alien: Lines come from bricks. Bricks bricks bricks.<br />
</blockquote>

<p>The frustration! Because sine is introduced with angles and circles, my brain thinks "Sine comes from circles. Circles circles circles."</p>

<p>No more. In a sentence:</p>

<p><strong>Sine a natural sway, the epitome of smoothness: it makes circles "circular" in the same way lines make squares "square".</strong></p>

<p>Let's build our intuition by seeing sine as its own shape, and <em>then</em> understand how it fits into circles and the like. Onward!</p>

<h2>Sine vs Lines</h2>

<p>Remember to separate an <em>idea</em> from an <em>example</em>: squares are <em>examples</em> of lines. Sine clicked when it became its own idea, not "part of a circle."</p>

<p>Let's observe sine in a simulator (Email readers, you may need to open the article directly):</p>

<p><iframe style="width: 500px; height: 300px" src="http://jsfiddle.net/nfeZF/64/embedded/result/"></iframe></p>

<p>Hubert will give the tour:</p>


<ul>
<li><strong>Click start</strong>. Go, Hubert go! Notice that smooth back and forth motion? That's Hubert, but more importantly (sorry Hubert), that's sine! It's natural, the way springs bounce, pendulums swing, strings vibrate... and many things move.</li>
<li><strong>Change "vertical" to "linear"</strong>. Big difference -- see how the motion gets constant and robotic, like a game of pong?</li>
</ul>



<p>Let's explore the differences <a href="http://www.youtube.com/watch?v=WAyTK6jF5o8">with video</a>:</p>

<p><iframe title="YouTube video player" width="480" height="390" src="http://www.youtube.com/embed/WAyTK6jF5o8" frameborder="0" allowfullscreen></iframe></p>


<ul>
<li><strong>Linear motion</strong> is constant: we go a set speed and turn around instantly. It's the unnatural motion in the robot dance (notice the linear bounce with no slowdown at 0:07, the strobing effect at :38).</li>
</ul>




<ul>
<li><strong>Sine</strong> changes its speed: it starts fast, slows down, stops, and speeds up again. It's the enchanting smoothness in liquid dancing (human sine wave at 0:12 and 0:23, natural bounce at :47).</li>
</ul>



<p>Unfortunately, textbooks don't show sine with animations or dancing. No, they prefer to introduce sine with a timeline (try setting "horizontal" to "timeline"):</p>

<p><img src="http://betterexplained.com/wp-content/uploads/sine/sine-plot.gif" width="500" />
(<a href="http://en.wikipedia.org/wiki/File:Sine.svg">source</a>)</p>

<p>Egads. This is the schematic diagram we've always been shown. Does it give you the feeling of sine? Not any more than a skeleton portrays the agility of a cat. Let's watch sine move and <em>then</em> chart its course.</p>

<h2>The Unavoidable Circle</h2>

<p>Circles have sine. Yes. But seeing the sine inside a circle is like getting the eggs back out of the omelette. It's all mixed together!</p>

<p>Let's take it slow. In the simulation, set Hubert to vertical:none and horizontal: sine*. See him wiggle sideways? That's the motion of sine. There's a small tweak: normally sine starts the cycle at the neutral midpoint and races to the max. This time, we start at the max and fall towards the midpoint. Sine that "starts at the max" is called cosine, and it's just a version of sine (like a horizontal line is a version of a vertical line).</p>

<p>Ok. Time for both sine waves: put vertical as "sine" and horizontal as "sine*". And... we have a circle!</p>

<p>A horizontal and vertical "spring" combine to give circular motion. Most textbooks draw the circle and try to extract the sine, but I prefer to build up: start with pure horizontal or vertical motion and add in the other.</p>

<h2>Quick Q &#038; A</h2>

<p>A few insights I missed when first learning sine:</p>

<p><strong>Sine really is 1-dimensional</strong></p>

<p>Sine wiggles in one dimension. Really. We often graph sine over time (so we don't write over ourselves) and sometimes the "thing" doing sine is also moving, but this is optional! A spring in one dimension is a perfectly happy sine wave.</p>

<p><img src="http://betterexplained.com/wp-content/uploads/sine/sine-1d.gif" /></p>

<p><strong>Circles are an <em>example</em> of two sine waves</strong></p>

<p>Circles and square are a combination of basic components (sines and lines). But circles aren't the "origin" of sines any more than squares are the root cause of lines.</p>

<p><strong>What do the values of sine mean?</strong></p>

<p>Sine cycles between -1 and 1. It starts at 0, grows to 1.0 (max), dives to -1.0 (min) and returns to neutral. I also see sine like a percentage, from 100% (full steam ahead) to -100% (full retreat).</p>

<p><strong>What's is the input 'x' in sin(x)?</strong></p>

<p>Tricky question. Sine is a cycle and x, the input, is <strong>how far along we are in the cycle</strong>.</p>

<p>Let's look at lines:</p>


<ul>
<li>You're traveling on a square. Each side takes 10 seconds.</li>
<li>After 1 second, you are 10% complete on that side</li>
<li>After 5 seconds, you are 50% complete</li>
<li>After 10 seconds, you finished the side</li>
</ul>



<p>Linear motion has few surprises. Now for sine (focusing on the "0 to max" cycle):</p>

<p><img src="http://betterexplained.com/wp-content/uploads/sine/sine-growth.png" /></p>


<ul>
<li>We're traveling on a sine wave, from 0 (neutral) to 1.0 (max). This portion takes 10 seconds.</li>
<li>After 5 seconds we are... 70% complete! Sine rockets out of the gate and slows down. Most of the gains are in the first 5 seconds</li>
<li>It takes 5 more seconds to get from 70% to 100%. And going from 98% to 100% takes almost a full second!</li>
</ul>



<p>Despite our initial speed, sine slows so we gently kiss the max value before turning around. This smoothness makes sine, sine.</p>

<p>For the geeks: Press "show stats" in the simulation. You'll see the percent complete of the total cycle, mini-cycle (0 to 1.0), and the value attained so far. Stop, step through, and switch between linear and sine motion to see the values.</p>

<p>Quick quiz: What's higher, 10% of a linear cycle, or 10% of a sine cycle? Sine. Remember, it barrels out of the gate at max speed. The average speed is indeed hit at 50% of the cycle time, but in the beginning we're going faster than average.</p>

<p><strong>So x is the 'amount of your cycle'. What's the cycle?</strong></p>

<p>It depends on the context.</p>


<ul>
<li>Basic trig: 'x' is degrees, and a full cycle is 360 degrees</li>
<li>Advanced trig: 'x' is radians (<a href="http://betterexplained.com/articles/intuitive-guide-to-angles-degrees-and-radians/">they are more natural!</a>), and a full cycle is going around the unit circle (2*pi radians)</li>
</ul>



<p>Play with values of x here:</p>

<p><iframe width="425" height="320" frameborder="0" marginwidth="0" marginheight="0" src="http://tinyurl.com/3nrecr8"></iframe></p>

<p>But again, cycles depend on circles! Can we escape their tyranny?</p>

<h2>Pi without Pictures</h2>

<p>Imagine a sightless alien who only notices shades of light and dark. Could you describe pi to him? It's hard to flicker the idea of a circle's circumference, right?</p>

<p>Let's step back a bit. Sine is a repeating pattern, which means it must... repeat! It goes from 0, to 1, to 0, to -1, to 0, and so on.</p>

<p><strong>Let's define pi as the time sine takes from 0 to 1 and back to 0.</strong> Whoa! Now we're using pi without a circle too! Pi is a concept that <em>just happens</em> to show up in circles:</p>


<ul>
<li>Sine is a gentle back and forth rocking</li>
<li>Pi is the time from neutral to max and back to neutral</li>
<li>n*Pi (0*Pi, 1*pi, 2*pi, and so on) are the times you are at neutral</li>
<li>2*Pi, 4*pi, 6*pi, etc. are full cycles</li>
</ul>



<p>Aha! That is why pi appears in so many formulas! Pi doesn't "belong" to circles any more than 0 and 1 do -- <strong>pi is about sine returning to center</strong>! A circle is an <em>example</em> of a shape that repeats and returns to center every 2*pi units. But springs, vibrations, etc. return to center after pi too!</p>

<p><strong>Question: If pi is half of a natural cycle, why does it go on forever (i.e., irrational)?</strong></p>

<p>Can I answer a question with a question? Why does the diagonal of a "unit square" have length sqrt(2), which also goes on forever?</p>

<p>But yes, I realize it's <a href="http://en.wikipedia.org/wiki/Hippasus">philosophically inconvenient</a> when nature behaves randomly. I don't have a good intuition.</p>

<h2>How fast is sine?</h2>

<p>I've been tricky. Previously, I said "imagine it takes sine 10 seconds from 0 to max". And now it's pi seconds from 0 to max back to 0? What gives?</p>


<ul>
<li>sin(x) is the <em>default</em>, off-the-shelf sine wave, that indeed takes pi units of time from 0 to max to 0 (or 2*pi for a complete cycle)</li>
<li>sin(2x) is a wave that moves twice as fast</li>
<li>sin(x/2) is a wave that moves twice as slow</li>
</ul>



<p>So, we use sin(n*x) to get a sine wave cycling as fast as we need. Often, the phrase "sine wave" is referencing the general shape and not a specific speed.</p>

<p><img src="http://betterexplained.com/wp-content/uploads/sine/sine-variations.png" /></p>

<h2>Part 2: Understanding the definitions of sine</h2>

<p>That's a brainful -- take a break if you need it. Hopefully, sine is emerging as its own pattern. Now let's <a href="http://betterexplained.com/articles/developing-your-intuition-for-math/">develop our intuition</a> by seeing how common definitions of sine connect.</p>

<h2>Definition 1: The height of a triangle / circle!</h2>

<p>Sine was first found in triangles. You may remember "SOH <span class="caps">CAH TOA</span>" as a mnemonic</p>

<p><img src="http://betterexplained.com/wp-content/uploads/sine/SOH.png" /></p>


<ul>
<li><span class="caps">SOH</span>: Sine is Opposite / Hypotenuse</li>
<li><span class="caps">CAH</span>: Cosine is Adjacent / Hypotenuse</li>
<li><span class="caps">TOA</span>: Tangent is Opposite / Adjacent</li>
</ul>



<p>For a right triangle with angle x, sin(x) is the length of the opposite side divided by the hypotenuse. If we make the hypotenuse 1, we can simplify to:</p>


<ul>
<li>Sine = Opposite</li>
<li>Cosine = Adjacent</li>
</ul>



<p>And with more cleverness, we can draw our triangles with hypotenuse 1 in a circle with radius 1:</p>

<p><img src="http://betterexplained.com/wp-content/uploads/sine/sine-unit-circle.png" /></p>

<p>Voila! A circle containing all possible right triangles (since they can be scaled up using similarity). For example:</p>


<ul>
<li>sin(45) = .707</li>
<li>Lay down a 10-foot pole and raise it 45 degrees. It is 10 * sin(45) = 7.07 feet off the ground</li>
<li>An 8-foot pole would be 8 * sin(45) = 5.65 feet</li>
</ul>



<p>These direct manipulations are great for construction (the <a href="http://en.wikipedia.org/wiki/History_of_trigonometry">pyramids</a> won't calculate themselves). Unfortunately, after thousands of years we start thinking the <em>meaning</em> of sine is the height of a triangle. No no, it's a shape that <em>shows up</em> in circles (and triangles).</p>

<p>Realistically, for many problems we go into "geometry mode" and start thinking "sine = height" to speed through things. That's fine -- just don't get stuck there.</p>

<h2>Definition 2: The infinite series</h2>

<p>I've avoided the elephant in the room: <strong>how in blazes do we actually calculate sine!?</strong> Is my calculator drawing a circle and measuring it?</p>

<p>Glad to rile you up. Here's the circle-less secret of sine:</p>

<p><strong>Sine is acceleration opposite to your current position</strong></p>

<p>Using our bank account metaphor: Imagine a perverse boss who gives you a raise the exact <em>opposite</em> of your current bank account! If you have $50 in the bank, then your raise next week is -$50. Of course, your income might be $75/week, so you'll still be earning some money ($75 - $50 for that week), but eventually your balance will decrease as the "raises" overpower your income.</p>

<p>But never fear! Once your account hits negative (say you're at -$50), then your boss gives a legit $50/week raise. Again, your income might be negative, but eventually the raises will overpower it.</p>

<p>This constant pull towards the center keeps the cycle going: when you rise up, the "pull" conspires to pull you in again. It also explains why neutral is the max speed for sine: If you are at the max, you begin falling and accumulating more and more "negative raises" as you plummet. As you pass through then neutral point you are feeling all the negative raises possible (once you cross, you'll start getting positive raises and slowing down).</p>

<p>By the way: since sine is acceleration opposite to your current position, and a circle is made up of a horizontal and vertical sine... you got it! Circular motion can be described as "a constant pull opposite your current position, towards your horizontal and vertical center".</p>

<h2>Geeking Out With Calculus</h2>

<p>Let's describe sine with calculus. Like e, we can break sine into smaller effects:</p>


<ul>
<li>Start at 0 and grow at unit speed</li>
<li>At every instant, get pulled back by negative acceleration</li>
</ul>



<p>How should we think about this? See how each effect above changes our distance from center:</p>


<ul>
<li>Our initial kick increases distance linearly: y (distance from center) = x (time taken)</li>
<li>At any moment, we feel a restoring force of -x. We integrate twice to turn negative acceleration into distance:</li>
</ul>



<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/9628e9f099a8387f4c62d72bd2af9f6b.png' title='\displaystyle{ \iint -x = -x^3/3! }' alt='\displaystyle{ \iint -x = -x^3/3! }' align=absmiddle class='tex' /></p>

<p>Seeing how acceleration impacts distance is like seeing how a raise hits your bank account. The "raise" must change your income, and your income changes your bank account (two integrals "up the chain").</p>

<p>So, after "x" seconds we might guess that sine is "x" (initial impulse) minus x^3/3! (effect of the acceleration):</p>

<p><img src="http://betterexplained.com/wp-content/uploads/sine/sine-model-1.png" /></p>

<p>Something's wrong -- sine doesn't nosedive! With e, we saw that "interest earns interest" and sine is similar. The "restoring force" changes our distance by -x^3/3!, which creates <em>another</em> restoring force to consider. Consider a spring: the pull that yanks you down goes too far, which shoots you downward and creates <em>another</em> pull to bring you up (which again goes too far). Springs are crazy!</p>

<p>We need to consider every restoring force:</p>


<ul>
<li>y = x is our initial motion, which creates a restoring force of impact:</li>
<li>y = -x^3/3!, which creates a restoring force of impact:</li>
<li>y = x^5/5!, which creates a restoring force of impact:</li>
<li>y = -x^7/7! which creates a restoring force of impact...</li>
</ul>



<p><img src="http://betterexplained.com/wp-content/uploads/sine/sine-better-models.png" /></p>

<p>Just like e, sine can be described with an infinite equation:</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/ca6adf601c50e7f1d55c8804bb458968.png' title='\displaystyle{sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ... }' alt='\displaystyle{sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ... }' align=absmiddle class='tex' /></p>

<p>I saw this formula a lot, but it only clicked when I saw sine as a <em>combination of an initial impulse and restoring forces</em>. The initial push (y = x, going positive) is eventually overcome by a restoring force (which pulls us negative), which is overpowered by its own restoring force (which pulls us positive), and so on.</p>

<p>A few fun notes:</p>


<ul>
<li>Consider the "restoring force" like "positive or negative interest". This makes the sine/e connection in <a href="http://betterexplained.com/articles/intuitive-understanding-of-eulers-formula/">Euler's formula</a> easier to understand. Sine is like e, except sometimes it earns negative interest. There's more to learn here <img src='http://betterexplained.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</li>
<li>For small amounts, "y = x" is a good guess for sine. We just take the initial impulse and ignore any restoring forces.</li>
</ul>



<h2>The Calculus of Cosine</h2>

<p>Cosine is just a shifted sine, and is fun (yes!) now that we understand sine:</p>


<ul>
<li>Sine: Start at 0, initial impulse of y = x (100%)</li>
<li>Cosine: Start at 1, no initial impulse</li>
</ul>



<p>So cosine just starts off... sitting there at 1. We let the restoring force do the work:</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/447ceef8f15d28bd997f3d7a8b441318.png' title='\displaystyle{y = 1 - x^2/2!}' alt='\displaystyle{y = 1 - x^2/2!}' align=absmiddle class='tex' /></p>

<p>Again, we integrate -1 twice to get -x^2/2!. But this kicks off another restoring force, and before you know it:</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/7952197434837dbc9cbd6bc3a2bc15c9.png' title='\displaystyle{cos(x) = 1 - x^2/2! + x^4/4!}' alt='\displaystyle{cos(x) = 1 - x^2/2! + x^4/4!}' align=absmiddle class='tex' /></p>

<h2>Definition 3: The differential equation</h2>

<p>We've described sine's behavior with specific equations. A more succinct way (<a href="http://www.wolframalpha.com/input/?i=y%27%27+%3D+-y">equation</a>):</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/d3ea12e48b8e6159c66818c9baa5a633.png' title='\displaystyle{y&amp;#039;&amp;#039; = -y}' alt='\displaystyle{y&amp;#039;&amp;#039; = -y}' align=absmiddle class='tex' /></p>

<p>This beauty says:</p>


<ul>
<li>Our current position is y</li>
<li>Our acceleration (2nd derivative, or y'') is the opposite of our current position (-y)</li>
</ul>



<p>Both sine and cosine make this true. I first hated this definition; it's so divorced from a visualization. I didn't realize it described the essence of sine, "acceleration opposite your position".</p>

<p>And remember how sine and e are connected? Well, e^x can be be described by (<a href="http://www.wolframalpha.com/input/?i=y%27%27+%3D+y">equation</a>):</p>

<p><img src='http://74.50.62.72/wp-content/plugins/wp-latexrender/pictures/5c5da41edfd48a9b9af233292a32e6f8.png' title='\displaystyle{y&amp;#039;&amp;#039; = y}' alt='\displaystyle{y&amp;#039;&amp;#039; = y}' align=absmiddle class='tex' /></p>

<p>The same equation with a positive sign ("acceleration equal to your position")! When sine is "the height of a circle" it's really hard to make the connection to e.</p>

<p>One of my great mathematical regrets is not learning differential equations. But I want to, and I suspect having an intuition for sine and e will be crucial.</p>

<h2>Summing it up</h2>

<p>The goal is to move sine from some mathematical trivia ("part of a circle") to its own shape:</p>


<ul>
<li>Sine is a smooth, swaying motion between min (-1) and max (1). Mathematically, you're accelerating opposite your position. This "negative interest" keeps sine rocking forever.</li>
<li>Sine <em>happens to appear</em> in circles and triangles (and springs, pendulums, vibrations, sound...)</li>
<li><strong>Pi</strong> is the time from neutral to neutral in sin(x). It doesn't "belong" to circles any more than 0 and 1 do.</li>
</ul>



<p>Let sine enter your mental toolbox (<i>Hrm, I need a formula to make smooth changes...</i>). Eventually, we'll understand the foundations intuitively (<a href="http://betterexplained.com/articles/an-intuitive-guide-to-exponential-functions-e/">e</a>, <a href="http://betterexplained.com/articles/prehistoric-calculus-discovering-pi/">pi</a>, <a href="http://betterexplained.com/articles/intuitive-guide-to-angles-degrees-and-radians/">radians</a>, <a href="http://betterexplained.com/articles/a-visual-intuitive-guide-to-imaginary-numbers/">imaginaries</a>, sine...) and they can be mixed into a scrumptious math salad. Enjoy!</p>]]></content:encoded>
			<wfw:commentRss>http://betterexplained.com/articles/intuitive-understanding-of-sine-waves/feed/</wfw:commentRss>
		<slash:comments>51</slash:comments>
		</item>
	</channel>
</rss>

