<?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>Vector Calculus &#8211; BetterExplained</title>
	<atom:link href="https://betterexplained.com/articles/series/vector-calculus/feed/" rel="self" type="application/rss+xml" />
	<link>https://betterexplained.com</link>
	<description>Math lessons that click</description>
	<lastBuildDate>Thu, 22 Oct 2026 21:26:58 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Vector Calculus: Understanding the Cross Product</title>
		<link>https://betterexplained.com/articles/cross-product/</link>
					<comments>https://betterexplained.com/articles/cross-product/#disqus_thread</comments>
		
		<dc:creator><![CDATA[kalid]]></dc:creator>
		<pubDate>Wed, 15 Apr 2015 15:00:29 +0000</pubDate>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Vector Calculus]]></category>
		<guid isPermaLink="false">http://betterexplained.com/?p=5140</guid>

					<description><![CDATA[Taking two vectors, we can write every combination of components in a grid: This completed grid is the outer product, which can be separated into the: Dot product, the interactions between similar dimensions (x*x, y*y, z*z) Cross product, the interactions between different dimensions (x*y,y*z, z*x, etc.) The dot product ($\vec{a} \cdot \vec{b}$) measures similarity because [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Taking two vectors, we can write every combination of components in a grid:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/crossproduct/cross-product-grid.png" alt="cross product interaction grid" /></p>

<p>This completed grid is the <em>outer product</em>, which can be separated into the:</p>

<ul>
<li><p><strong>Dot product</strong>, the interactions between similar dimensions (<code>x*x</code>, <code>y*y</code>, <code>z*z</code>)</p></li>
<li><p><strong>Cross product</strong>, the interactions between different dimensions (<code>x*y</code>,<code>y*z</code>, <code>z*x</code>, etc.)</p></li>
</ul>

<p>The <a href="https://betterexplained.com/articles/vector-calculus-understanding-the-dot-product/">dot product</a>  ($\vec{a} \cdot \vec{b}$) measures similarity because it only accumulates interactions in matching dimensions. It&#8217;s a simple calculation with 3 components.</p>

<p>The cross product (written $\vec{a} \times \vec{b}$) has to measure a half-dozen &#8220;cross interactions&#8221;. The calculation looks complex but the concept is simple: accumulate 6 individual differences for the total difference.</p>

<p>Instead of thinking &#8220;When do I need the cross product?&#8221; think &#8220;When do I need interactions between different dimensions?&#8221;.</p>

<p>Area, for example, is formed by vectors pointing in different directions (the more orthogonal, the better). Indeed, the cross product measures the area spanned by two 3d vectors (<a href="http://en.wikipedia.org/wiki/Cross_product#/media/File:Cross_product_parallelogram.svg">source</a>):</p>

<p><img decoding="async" src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Cross_product_parallelogram.svg/220px-Cross_product_parallelogram.svg.png" alt="Vector Calculus: Understanding the Cross Product" /></p>

<p>(The &#8220;cross product&#8221; assumes 3d vectors, but <a href="http://math.stackexchange.com/questions/185991/is-the-vector-cross-product-only-defined-for-3d">the concept extends</a> to higher dimensions.)</p>

<p>Did the key intuition click? Let&#8217;s hop into the details.</p>

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

<h2>Defining the Cross Product</h2>

<p>The <a href="https://betterexplained.com/articles/vector-calculus-understanding-the-dot-product/">dot product</a> represents the similarity between vectors as a single number:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/20c93fc39256d5d72eb2deb37326baaf.png' width='592' height='23' alt='\displaystyle{\text{dot product} = (a_x, a_y, a_z) \cdot (b_x, b_y, b_z) = a_x b_x + a_y b_y + a_z b_z = \|\vec{a}\| \|\vec{b}\| \cos(\theta)}' class='tex'></p>

<p>For example, we can say that North and East are 0% similar since $(0, 1) \cdot (1, 0) = 0$. Or that North and Northeast are 70% similar ($\cos(45) = .707$, remember that <a href="https://betterexplained.com/articles/intuitive-trigonometry/">trig functions are percentages</a>.) The similarity shows the amount of one vector that &#8220;shows up&#8221; in the other.</p>

<p>Should the cross product, the difference between vectors, be a single number too?</p>

<p>Let&#8217;s try. Sine is the percentage difference, so we could write:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/7afba5a5fd4e49dc9e2a0ef7751ec769.png' width='501' height='23' alt='\displaystyle{\text{cross product candidate} = \text{amount of difference} = \|\vec{a}\| \|\vec{b}\| \sin(\theta)}' class='tex'></p>

<p>Unfortunately, we&#8217;re missing some details. Let&#8217;s say we&#8217;re looking down the x-axis: both y and z point 100% away from us. A number like &#8220;100%&#8221; tells us there&#8217;s a big difference, but we don&#8217;t know what it is! We need extra information to tell us &#8220;the difference between $\vec{x}$ and $\vec{y}$ is <em>this</em>&#8221; and &#8220;the difference between $\vec{x}$ and $\vec{z}$ is <em>that</em>&#8220;.</p>

<p>So, let&#8217;s express the cross product as a vector:</p>

<ul>
<li><p>The <em>size</em> of the cross product is the numeric &#8220;amount of difference&#8221; (with $\sin(\theta)$ as the percentage). By itself, this doesn&#8217;t distinguish $\vec{x} \times \vec{y}$ from $\vec{x} \times \vec{z}$.</p></li>
<li><p>The <em>direction</em> of the cross product is based on both inputs: it&#8217;s the direction orthogonal to both (i.e., favoring neither).</p></li>
</ul>

<p>Now $\vec{x} \times \vec{y}$ and $\vec{x} \times \vec{z}$ have different results, each with a magnitude indicating they are &#8220;100%&#8221; different from $\vec{x}$.</p>

<p>(Should the dot product be a vector result too? Well, we&#8217;re tracking the similarity between $\vec{a}$ and $\vec{b}$. The similarity measures the overlap between the original vector directions, which we already have.)</p>

<h2>Geometric Interpretation</h2>

<p>Two vectors determine a plane, and the cross product points in a direction different from both (<a href="http://en.wikipedia.org/wiki/Cross_product#/media/File:Cross_product_vector.svg">source</a>):</p>

<p><img decoding="async" src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Cross_product_vector.svg/220px-Cross_product_vector.svg.png" alt="cross product vector diagram" /></p>

<p>Here&#8217;s the problem: there&#8217;s two perpendicular directions. By convention, we assume a &#8220;right-handed system&#8221; (<a href="http://en.wikipedia.org/wiki/Cross_product#/media/File:Right_hand_rule_cross_product.svg">source</a>):</p>

<p><img decoding="async" src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Right_hand_rule_cross_product.svg/220px-Right_hand_rule_cross_product.svg.png" alt="cross product right hand rule" /></p>

<p>If you hold your first two fingers like the diagram shows, your thumb will point in the direction of the cross product. I make sure the orientation is correct by sweeping my first finger from $\vec{a}$ to $\vec{b}$. With the direction figured out, the magnitude of the cross product is $&#124;a&#124; &#124;b&#124; \sin(\theta)$, which is proportional to the magnitude of each vector and the &#8220;difference percentage&#8221; (sine).</p>

<h2>The Cross Product For Orthogonal Vectors</h2>

<p>To remember the right hand rule, write the <code>xyz</code> order twice:  <code>xyzxyz</code>. Next, find the pattern you&#8217;re looking for:</p>

<ul>
<li><code>xy =&gt; z</code> (<code>x</code> cross <code>y</code> is <code>z</code>)</li>
<li><code>yz =&gt; x</code> (<code>y</code> cross <code>z</code> is <code>x</code>; we looped around: <code>y</code> to <code>z</code> to <code>x</code>)</li>
<li><code>zx =&gt; y</code></li>
</ul>

<p>Now, <code>xy</code> and <code>yx</code> have opposite signs because they are forward and backward in our <code>xyzxyz</code> setup.</p>

<p>So, without a formula, you should be able to calculate:</p>

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

<p>Again, this is because <code>x</code> cross <code>y</code> is positive <code>z</code> in a right-handed coordinate system. I used unit vectors, but we could scale the terms:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/ed00ec69be624790ae200c5dbc27ee58.png' width='225' height='18' alt='\displaystyle{(3, 0, 0) \times (0, 4, 0) = (0, 0, 12)}' class='tex'></p>

<h2>Calculating The Cross Product</h2>

<p>A single vector can be decomposed into its 3 orthogonal parts:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/6fd5a295b21898e1c2a7c6b00508784f.png' width='384' height='19' alt='\displaystyle{ \vec{a} = (a_x, a_y, a_z) = (a_x, 0, 0)  + (0, a_y, 0) + (0, 0, a_z)}' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/1607d7525f7855c9e1472f24a31ed36a.png' width='371' height='23' alt='\displaystyle{ \vec{b} = (b_x, b_y, b_z) = (b_x, 0, 0)  + (0, b_y, 0) + (0, 0, b_z)}' class='tex'></p>

<p>When the vectors are crossed, each pair of orthogonal components (like $a_x \times b_y$) casts a vote for where the orthogonal vector should point. 6 components, 6 votes, and their total is the cross product. (Similar to the <a href="https://betterexplained.com/articles/understanding-pythagorean-distance-and-the-gradient/">gradient</a>, where each axis casts a vote for the direction of greatest increase.)</p>

<ul>
<li><code>xy =&gt; z</code> and <code>yx =&gt; -z</code> (assume $\vec{a}$ is first, so <code>xy</code> means $a_x b_y$)</li>
<li><code>yz =&gt; x</code> and <code>zy =&gt; -x</code></li>
<li><code>zx =&gt; y</code> and <code>xz =&gt; -y</code></li>
</ul>

<p><code>xy</code> and <code>yx</code> fight it out in the <code>z</code> direction. If those terms are equal, such as in $(2, 1, 0) \times (2, 1, 1)$, there is no cross product component in the <code>z</code> direction (2 &#8211; 2 = 0).</p>

<p>The final combination is:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/1607c12e141545e86dbbdd3391eef323.png' width='647' height='20' alt='\displaystyle{(a_x, a_y, a_z) \times (b_x, b_y, b_z) = (a_y b_z - a_z b_y, a_z b_x - a_x b_z, a_x b_y - a_y b_x) = \|a\| \|b\| \sin(\theta) \vec{n}}' class='tex'></p>

<p>where $\vec{n}$ is the unit vector normal to $\vec{a}$ and $\vec{b}$.</p>

<p>Don&#8217;t let this scare you:</p>

<ul>
<li>There&#8217;s 6 terms, 3 positive and 3 negative</li>
<li>Two dimensions vote on the third (so the <code>z</code> term must only have <code>y</code> and <code>x</code> components)</li>
<li>The positive/negative order is based on the <code>xyzxyz</code> pattern</li>
</ul>

<p>If you like, there is an <a href="https://web.archive.org/web/20180725212158/http://heaveninthebackyard.blogspot.com:80/2011/12/derivation-of-cross-product-formula.html">algebraic proof</a>, that the formula is both orthogonal and of size $&#124;a&#124; &#124;b&#124; \sin(\theta)$, but I like the &#8220;proportional voting&#8221; intuition.</p>

<h2>Example Time</h2>

<p>Again, we should do simple cross products in our head:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/b798c51f45e6efe6ab21aa4076d98f4f.png' width='216' height='18' alt='\displaystyle{(1, 0, 0) \times (0, 1, 0) = (0, 0, 1)}' class='tex'></p>

<p>Why? We crossed the <code>x</code> and <code>y</code> axes, giving us <code>z</code> (or $\vec{i} \times \vec{j} = \vec{k}$, using those unit vectors). Crossing the other way gives $-\vec{k}$.</p>

<p>Here&#8217;s how I walk through more complex examples:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/47bc80a57d8cd9913909e1778358c244.png' width='163' height='18' alt='\displaystyle{(1, 2, 3) \times (4, 5, 6) = ?}' class='tex'></p>

<ul>
<li>Let&#8217;s do the last term, the z-component. That&#8217;s (1)(5) minus (4)(2), or 5 &#8211; 8 = -3. I did <code>z</code> first because it uses <code>x</code> and <code>y</code>, the first two terms. Try seeing (1)(5) as &#8220;forward&#8221; as you scan from the first vector to the second, and (4)(2) as backwards as you move from the second vector to the first.</li>
<li>Now the <code>y</code> component: (3)(4) &#8211; (6)(1) = 12 &#8211; 6 = 6</li>
<li>Now the <code>x</code> component: (2)(6) &#8211; (5)(3) = 12 &#8211; 15 = -3</li>
</ul>

<p>So, the total is $(-3, 6, -3)$ which we can <a href="http://www.wolframalpha.com/input/?i=%281%2C+2%2C+3%29+cross+%284%2C+5%2C+6%29">verify</a> with Wolfram Alpha.</p>

<p><img loading="lazy" decoding="async" src="https://betterexplained.com/wp-content/uploads/2016/10/1__2__3__cross__4__5__6__-_Wolfram_Alpha.png" alt="(1, 2, 3) cross product (4, 5, 6) example" width="672" height="644" class="alignnone size-full wp-image-6468" srcset="https://betterexplained.com/wp-content/uploads/2016/10/1__2__3__cross__4__5__6__-_Wolfram_Alpha.png 672w, https://betterexplained.com/wp-content/uploads/2016/10/1__2__3__cross__4__5__6__-_Wolfram_Alpha-300x288.png 300w, https://betterexplained.com/wp-content/uploads/2016/10/1__2__3__cross__4__5__6__-_Wolfram_Alpha-211x202.png 211w, https://betterexplained.com/wp-content/uploads/2016/10/1__2__3__cross__4__5__6__-_Wolfram_Alpha-200x192.png 200w, https://betterexplained.com/wp-content/uploads/2016/10/1__2__3__cross__4__5__6__-_Wolfram_Alpha-400x383.png 400w" sizes="(max-width: 672px) 100vw, 672px" /></p>

<p>In short:</p>

<ul>
<li>The cross product tracks all the &#8220;cross interactions&#8221; between dimensions</li>
<li>There are 6 interactions (2 in each dimension), with signs based on the <code>xyzxyz</code> order</li>
</ul>

<h2>Appendix</h2>

<p><strong>Connection with the Determinant</strong></p>

<p>You can calculate the cross product using the determinant of this matrix:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/2b406f38eb038bc9b0838ebe118285de.png' width='156' height='67' alt='\mathbf{u\times v}=\begin{vmatrix}&#10;\mathbf{i} &amp; \mathbf{j} &amp; \mathbf{k}\\&#10;u_1 &amp; u_2 &amp; u_3\\&#10;v_1 &amp; v_2 &amp; v_3\\&#10;\end{vmatrix}&#10;' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/41829c3cf8f4bb6ed3461c47a8f122f1.png' width='331' height='45' alt=' \mathbf{u\times v}=&#10;\begin{vmatrix}&#10;u_2 &amp; u_3\\&#10;v_2 &amp; v_3&#10;\end{vmatrix}\mathbf{i}&#10;-\begin{vmatrix}&#10;u_1 &amp; u_3\\&#10;v_1 &amp; v_3&#10;\end{vmatrix}\mathbf{j}&#10;+\begin{vmatrix}&#10;u_1 &amp; u_2\\&#10;v_1 &amp; v_2&#10;\end{vmatrix}\mathbf{k} ' class='tex'></p>

<p>There&#8217;s a neat connection here, as the determinant (&#8220;signed area/volume&#8221;) tracks the contributions from orthogonal components.</p>

<p>There are <a href="http://math.stackexchange.com/questions/706011/why-is-cross-product-only-defined-in-3-and-7-dimensions">theoretical reasons</a> why the cross product (as an orthogonal vector) is only available in 0, 1, 3 or 7 dimensions. However, the cross product as a single number is essentially the determinant (a signed area, volume, or hypervolume as a scalar).</p>

<p><strong>Connection with Curl</strong></p>

<p><a href="https://betterexplained.com/articles/vector-calculus-understanding-circulation-and-curl/">Curl</a> measures the twisting force a vector field applies to a point, and is measured with a vector perpendicular to the surface. Whenever you hear &#8220;perpendicular vector&#8221; start thinking &#8220;cross product&#8221;.</p>

<p>We take the &#8220;determinant&#8221; of this matrix:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/3cf07fc4e0d5432b9df330c2b550627d.png' width='101' height='121' alt='\begin{vmatrix} \vec{i} &amp; \vec{j} &amp; \vec{k} \\  \\&#10;{\frac{\partial}{\partial x}} &amp; {\frac{\partial}{\partial y}} &amp; {\frac{\partial}{\partial z}} \\&#10; \\  F_x &amp; F_y &amp; F_z \end{vmatrix}' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/7fc9b26a31da12f328c030df0bc022be.png' width='510' height='44' alt='\displaystyle{\nabla \times \vec{F} = \left(\frac{\partial F_z}{\partial y}  - \frac{\partial F_y}{\partial z}\right) \vec{i} + \left(\frac{\partial F_x}{\partial z} - \frac{\partial F_z}{\partial x}\right) \vec{j} + \left(\frac{\partial F_y}{\partial x} - \frac{\partial F_x}{\partial y}\right) \vec{k}}' class='tex'></p>

<p>Instead of multiplication, the interaction is taking a partial derivative. As before, the $\vec{i}$ component of curl is based on the vectors and derivatives in the $\vec{j}$ and $\vec{k}$ directions.</p>

<p><strong>Relation to the Pythagorean Theorem</strong></p>

<p>The cross and dot product are like the orthogonal sides of a triangle:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/fc5cd9d68e5c4efe242c91e6a7382af5.png' width='94' height='18' alt='\displaystyle{a^2 + b^2 = c^2 }' class='tex'></p>

<p>For unit vectors, where $&#124;a&#124; = &#124;b&#124; = 1 $, we have:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/056ef00c642c430711c64ba5b7cb6c03.png' width='413' height='22' alt='\displaystyle{ \|\text{dot product}\|^2 + \|\text{cross product}\|^2 = \cos^2 + \sin^2 = 1}' class='tex'></p>

<p>I cheated a bit in the grid diagram, as we have to track the squared magnitudes (as done in the Pythagorean Theorem).</p>

<p><strong>Advanced Math</strong></p>

<p>The cross product &amp; friends get extended in <a href="https://slehar.wordpress.com/2014/03/18/clifford-algebra-a-visual-introduction/">Clifford Algebra</a> and <a href="http://en.wikipedia.org/wiki/Geometric_algebra">Geometric Algebra</a>. I&#8217;m still learning these.</p>

<p><strong>Cross Products of Cross Products</strong></p>

<p>Sometimes you&#8217;ll have a scenario like:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/3a5b3d2497a94ba63c0e2cd8fc0a7f89.png' width='96' height='18' alt='\displaystyle{\vec{a} \times \vec{b} \times \vec{c} = ? }' class='tex'></p>

<p>First, the cross product <a href="https://proofwiki.org/wiki/Cross_Product_is_not_Associative">isn&#8217;t associative</a>: order matters.</p>

<p>Next, remember what the cross product is doing: finding orthogonal vectors. If any two components are parallel ($\vec{a}$ parallel to $\vec{b}$) then there are no dimensions pushing on each other, and the cross product is zero (which carries through to $0 \times \vec{c}$).</p>

<p>But it&#8217;s ok for $\vec{a}$ and $\vec{c}$ to be parallel, since they are never directly involved in a cross product, for example:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/27ddc5802d3782444dacba87e4a900e3.png' width='163' height='21' alt='\displaystyle{\vec{i} \times \vec{j} \times \vec{i} = \vec{k} \times \vec{i} = \vec{j} }' class='tex'></p>

<p>Whoa! How&#8217;d we get back to $\vec{j}$? We asked for a direction perpendicular to both $\vec{i}$ and $\vec{j}$, and made that direction perpendicular to $\vec{i}$ again. Being &#8220;doubly perpendicular&#8221; means you&#8217;re back on the original axis.</p>

<p><strong>Dot Product of Cross Products</strong></p>

<p>Now if we take</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/db432439a1805e4f3f79668bea15e091.png' width='87' height='18' alt='\displaystyle{\vec{a} \times \vec{b} \cdot \vec{c} = ? }' class='tex'></p>

<p>what happens? We&#8217;re forced to do $\vec{a} \times \vec{b}$ first, because $\vec{b} \cdot \vec{c}$ returns a scalar (single number) which can&#8217;t be used in a cross product.</p>

<p>If $\vec{a}$ and $\vec{c}$ are parallel, what happens? Well, $\vec{a} \times \vec{b}$ is perpendicular to $\vec{a}$, which means it&#8217;s perpendicular to $\vec{c}$, so the dot product with $\vec{c}$ will be zero.</p>

<p>I never really memorized these rules, I have to think through the interactions.</p>

<p><strong>Other Coordinate Systems</strong></p>

<p>The Unity game engine is <a href="http://answers.unity3d.com/questions/38924/unity-is-a-left-handed-coordinate-system-why.html">left-handed</a>, OpenGL (and most math/physics tools) are right-handed. Why?</p>

<p>In a computer game, <code>x</code> goes horizontal, <code>y</code> goes vertical, and <code>z</code> goes &#8220;into the screen&#8221;. This results in a left-handed system. (Try it: using your right hand, you can see <code>x</code> cross <code>y</code> should point out of the screen).</p>

<p><strong>Applications of the Cross Product</strong></p>

<ul>
<li>Find the direction perpendicular to two given vectors.</li>
<li>Find the signed area spanned by two vectors.</li>
<li>Determine if two vectors are orthogonal (checking for a dot product of 0 is likely faster though).</li>
<li>&#8220;Multiply&#8221; two vectors when only perpendicular cross-terms make a contribution (such as finding torque).</li>
<li>With the quaternions (4d complex numbers), the cross product performs the work of rotating one vector around another (another article in the works!).</li>
</ul>

<p>Happy math.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://betterexplained.com/articles/cross-product/feed/</wfw:commentRss>
			<slash:comments>87</slash:comments>
		
		
			</item>
		<item>
		<title>Vector Calculus: Understanding the Dot Product</title>
		<link>https://betterexplained.com/articles/vector-calculus-understanding-the-dot-product/</link>
					<comments>https://betterexplained.com/articles/vector-calculus-understanding-the-dot-product/#disqus_thread</comments>
		
		<dc:creator><![CDATA[kalid]]></dc:creator>
		<pubDate>Wed, 22 Feb 2012 23:00:31 +0000</pubDate>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Vector Calculus]]></category>
		<guid isPermaLink="false">http://betterexplained.com/?p=1831</guid>

					<description><![CDATA[I think of the dot product as directional multiplication. Multiplication goes beyond repeated counting: it's applying the essence of one item to another. (For example, complex multiplication is rotation, not repeated counting.) When dealing with simple growth rates, multiplication scales one rate by another: "3 x 4" can mean "Take your 3x growth and make [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I think of the dot product as directional multiplication. Multiplication goes beyond <a href="https://betterexplained.com/articles/rethinking-arithmetic-a-visual-guide/">repeated counting</a>: it's applying the essence of one item to another. (For example, <a href="https://betterexplained.com/articles/understanding-why-complex-multiplication-works/">complex multiplication</a> is rotation, not repeated counting.)</p>

<p>When dealing with simple growth rates, multiplication scales one rate by another:</p>

<ul>
<li>"3 x 4" can mean "Take your 3x growth and make it 4x as large, to get 12x"</li>
</ul>

<p>When dealing with vectors ("directional growth"), there's a few operations we can do:</p>

<ul>
<li><strong>Add vectors:</strong> Accumulate the growth contained in several vectors.</li>
<li><strong>Multiply by a constant</strong>: Make an existing vector stronger (in the same direction).</li>
<li><strong>Dot product:</strong> Apply the directional growth of one vector to another. The result is how much stronger we've made the original vector (positive, negative, or zero).</li>
</ul>

<p>Today we'll build our intuition for how the dot product works.</p>

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

<h2>Getting the Formula Out of the Way</h2>

<p>You've seen the dot product equation everywhere:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/7093a2c642c17b4be8c2765fdc3d223f.png' width='283' height='23' alt='\displaystyle{\vec{a} \cdot \vec{b} = a_x \cdot b_x + a_y \cdot b_y = |\vec{a}||\vec{b}|\cos(\theta) }' class='tex'></p>

<p>And also the justification: "Well Billy, the <a href="https://betterexplained.com/articles/law-of-cosines/">Law of Cosines</a> (you remember that, don't you?) says the following calculations are the same, so they are." Not good enough -- it doesn't click! Beyond the computation, what does it mean?</p>

<p>The goal is to apply one vector to another. The equation above shows two ways to accomplish this:</p>

<ul>
<li>Rectangular perspective: combine x and y components</li>
<li>Polar perspective: combine magnitudes and angles</li>
</ul>

<p>The "this stuff = that stuff" equation just means "Here are two equivalent ways to 'directionally multiply' vectors".</p>

<h2>Seeing Numbers as Vectors</h2>

<p>Let's start simple, and treat 3 x 4 as a dot product:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/69d0b6157d3c64105256895647620f90.png' width='90' height='18' alt='\displaystyle{(3, 0) \cdot (4,0)}' class='tex'></p>

<p>The number 3 is "directional growth" in a single dimension (the x-axis, let's say), and 4 is "directional growth" in that same direction. 3 x 4 = 12 means we get 12x growth in a single dimension. Ok.</p>

<p>Now, suppose 3 and 4 refer to different dimensions. Let's say 3 means "triple your bananas" (x-axis) and 4 means "quadruple your oranges" (y-axis). Now they're not the same type of number: what happens when apply growth (use the dot product) in our "bananas, oranges" universe?</p>

<ul>
<li>(3,0) means "Triple your bananas, destroy your oranges"</li>
<li>(0,4) means "Destroy your bananas, quadruple your oranges"</li>
</ul>

<p>Applying (0,4) to (3,0) means "Destroy your banana growth, quadruple your orange growth". But (3, 0) had no orange growth to begin with, so the net result is 0 ("Destroy all your fruit, buddy").</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/d3c7038a36ee1fffede207579a40d786.png' width='125' height='18' alt='\displaystyle{(3, 0) \cdot (0, 4) = 0}' class='tex'></p>

<p>See how we're "applying" and not simply adding? With regular addition, we smush the vectors together: (3,0) + (0, 4) = (3, 4) [a vector which triples your oranges <em>and</em> quadruples your bananas].</p>

<p>"Application" is different. We're mutating the original vector based on the rules of the second. And the rules of (0, 4) are "Destroy your banana growth, and quadruple your orange growth." When applied to something with only bananas, like (3, 0), we're left with nothing.</p>

<p>The final result of the dot product process can be:</p>

<ul>
<li>Zero: we don't have any growth in the original direction</li>
<li>Positive number: we have some growth in the original direction</li>
<li>Negative number: we have negative (reverse) growth in the original direction</li>
</ul>

<h2>Understanding the Calculation</h2>

<p>"Applying vectors" is still a bit abstract. I think "How much energy/push is one vector giving to the other?". Here's how I visualize it:</p>

<p><strong>Rectangular Coordinates: Component-by-component overlap</strong></p>

<p>Like multiplying complex numbers, see how each x- and y-component interacts:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/dotproduct/dot_product_components.png" alt="Dot Product Components" /></p>

<p>We list out all four combinations (x with x, y with x, x with y, y with y). Since the x- and y-coordinates don't affect each other (like holding a bucket sideways under a waterfall -- nothing falls in), the total energy absorption is absorption(x) + absorption(y):</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/fba1cc0231e9178d6a8fc9db46f5fad5.png' width='171' height='23' alt='\displaystyle{\vec{a} \cdot \vec{b} = a_x \cdot b_x + a_y \cdot b_y}' class='tex'></p>

<p><strong>Polar coordinates: Projection</strong></p>

<p>The word "projection" is so sterile: I prefer "along the path". How much energy is actually going in our original direction?</p>

<p>Here's one way to see it:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/dotproduct/dot_product_rotation.png" alt="Dot Product Rotation" /></p>

<p>Take two vectors, a and b. Rotate our coordinates so b is horizontal: it becomes (|b|, 0), and everything is on this new x-axis. What's the dot product now? (It shouldn't change just because we tilted our head).</p>

<p>Well, vector a has new coordinates (a1, a2), and we get:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/54426ff2bcbd0c0c19cac25e8eb8b5a1.png' width='185' height='23' alt='\displaystyle{a1 \cdot |\vec{b}| + a2 \cdot 0 = a1 \cdot |\vec{b}|}' class='tex'></p>

<p>a1 is really "What is the x-coordinate of a, assuming b is the x-axis?". That is |a|cos(&#952;), aka the "projection":</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/589231b1e74b52bba5238e289552840c.png' width='141' height='23' alt='\displaystyle{\vec{a} \cdot \vec{b} = |\vec{a}|\cos(\theta)|\vec{b}|}' class='tex'></p>

<h2>Analogies for the Dot Product</h2>

<p>The common interpretation is "geometric projection", but it's so bland. Here's some analogies that click for me:</p>

<p><strong>Energy Absorption</strong></p>

<p>One vector are solar rays, the other is where the solar panel is pointing (yes, yes, the normal vector). Larger numbers mean stronger rays or a larger panel. How much energy is absorbed?</p>

<ul>
<li>Energy =  Overlap in direction * Strength of rays * Size of panel</li>
<li><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/5fa223cb296dcecc99b119406dcd7f47.png' width='190' height='19' alt='\displaystyle{\text{Energy} = \cos(\theta) \cdot |a| \cdot |b|}' class='tex'></li>
</ul>

<p>If you hold your panel sideways to the sun, no rays hit (cos(&#952;) = 0).</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/dotproduct/Solar_Panel.png" alt="Solar Panel Dot Product" />
<a href="http://www.flickr.com/photos/knowmybackyard/2394376192/">Photo credit</a></p>

<p>But... but... solar rays are leaving the sun, and the panel is facing the sun, and the dot product is negative when vectors are opposed! Take a deep breath, and remember the goal is to embrace the analogy (besides, physicists lose track of negative signs all the time).</p>

<p><strong>Mario-Kart Speed Boost</strong></p>

<p>In Mario Kart, there are "boost pads" on the ground that increase your speed (Never played? I'm sorry.)</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/dotproduct/mario_kart_vector.png" alt="Mario Kart Dot Product Example" />
<a href="http://www.mariokartwii.com/f72/official-mario-kart-wii-model-hacking-new-39114-409.html">Photo source</a></p>

<p>Imagine the red vector is your speed (x and y direction), and the blue vector is the orientation of the boost pad (x and y direction). Larger numbers are more power.</p>

<p>How much boost will you get? For the analogy, imagine the pad gives a speed bonus like this:</p>

<ul>
<li>If you come in going 0, you'll get nothing. (If you are dropped onto the pad, there's no boost.)</li>
<li>If you cross the pad perpendicularly, you'll get 0 benefit. (Just like the banana obliteration, there's 0x boost in the perpendicular direction.)</li>
<li>If our direction and pad are aligned, our x-speed contributes an x-boost, and our y-speed gives us a y-boost:</li>
</ul>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/56d854139d1de66dd8e8acd8afe32d3e.png' width='366' height='19' alt='\displaystyle{\text{boost effect} = speed_x \cdot boost_x + speed_y \cdot boost_y}' class='tex'></p>

<p>Neat, eh? Another way to see it: your incoming speed is $|a|$, and the max boost is $|b|$. The percentage of boost you actually get (based on how you're lined up) is $\cos(\theta)$, for an overall boost of $|a||b|\cos(\theta)$, which is the dot product.</p>

<iframe loading="lazy" src="https://instacalc.com/55618/embed" width="450" height="425" frameborder="0"></iframe>

<p><strong>Fruit Stand Analogy</strong></p>

<p>Let's say your store sells apples, bananas, and clementines. They cost \$1, \$2, and \$3 each, respectively.</p>

<p>A customer wants to buy 2 apples, 3 bananas, and 4 clementines. What does it cost?</p>

<pre><code>cost = (A quantity) * (A price) + (B quantity) * (B price) + (C quantity) * (C price) 
cost = 2*1 + 3*2 + 4*3 = 20 
</code></pre>

<p>This is the dot product between the "quantity" vector and the "price" vector! We're multiplying the matching entries and getting the total. We ignore entries that don't "make sense" to multiply (why should the banana quantity and clementine price impact each other?).</p>

<p><strong>Physics Physics Physics</strong></p>

<p>The dot product appears all over physics: some field (electric, gravitational) is pulling on some particle. We'd love to multiply, and we could if everything were lined up. But that's never the case, so we take the dot product to account for potential differences in direction.</p>

<p>It's all a useful generalization: Integrals are "multiplication, taking changes into account" and the dot product is "multiplication, taking direction into account".</p>

<p>And what if your direction is changing? Why, take the <a href="http://en.wikipedia.org/wiki/Line_integral">integral of the dot product</a>, of course!</p>

<h2>Onward and Upward</h2>

<p>Don't settle for "Dot product is the geometric projection, justified by the law of cosines". Find the analogies that click for you! Happy math.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://betterexplained.com/articles/vector-calculus-understanding-the-dot-product/feed/</wfw:commentRss>
			<slash:comments>130</slash:comments>
		
		
			</item>
		<item>
		<title>Understanding Pythagorean Distance and the Gradient</title>
		<link>https://betterexplained.com/articles/understanding-pythagorean-distance-and-the-gradient/</link>
					<comments>https://betterexplained.com/articles/understanding-pythagorean-distance-and-the-gradient/#disqus_thread</comments>
		
		<dc:creator><![CDATA[kalid]]></dc:creator>
		<pubDate>Fri, 04 Nov 2011 16:24:48 +0000</pubDate>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Vector Calculus]]></category>
		<category><![CDATA[Pythagorean Theorem]]></category>
		<guid isPermaLink="false">http://betterexplained.com/?p=1460</guid>

					<description><![CDATA[The Pythagorean Theorem shows how strange our concept of distance is. Using the rule $a^2 + b^2 = c^2$, we can trade some "a" to get more "b". Starting with means "A 13-inch pizza equals a 13-inch pizza". Sure. But we can trade an inch and get: Huh? A 12-inch pizza and a 5-inch pizza [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>The <a href="https://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^2 + b^2 = c^2$, we can trade some "a" to get more "b".</p>

<p>Starting with</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/4fe780744f65a3a106be7088db2d4cc4.png' width='113' height='18' alt='\displaystyle{13^2 + 0^2 = 13^2}' class='tex'></p>

<p>means "A 13-inch pizza equals a 13-inch pizza". Sure. But we can trade an inch and get:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/87c51dc809eaac5cee3f2bd3954af2fa.png' width='113' height='18' alt='\displaystyle{12^2 + 5^2 = 13^2}' 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... we gave up an inch and got a five-inch pizza!</p>

<p>Let'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 decoding="async" src="https://betterexplained.com/wp-content/uploads/pythagdistance/shavingthesquare.png" alt="Shaving the Square" /></p>

<p>Imagine laying tiles on a porch -- as your porch grows, the outer layer needs more tiles. Trimming a 13x13 porch to 12x12 frees up 25 tiles, which is enough to make a new 5x5 porch!</p>

<p>I call this "shaving the square". Trimming 1 unit from the outside of a large square has more "shavings" 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're the options?</p>

<p>Well, laying on a single wall means 100% for one side (like saying $13^2 + 0^2 = 13^2$). 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 decoding="async" src="https://betterexplained.com/wp-content/uploads/pythagdistance/slideandpivot.png" alt="pythagorean theorem slide sides" /></p>

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

<h2>So What's the Tradeoff?</h2>

<p>Time to see how the a/b tradeoff works. First, let's use grid coordinates: x &amp; y (horizontal and vertical). Given a fixed distance (13 units, let's say), our options lay on the circle where $x^2 + y^2 = 13^2$:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/pythagdistance/xytrade.png" alt="pythagorean theorem X-Y tradeoff" /></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 "x" we get for "y" when moving to a neighbor. If we're at (0, 13) we could move to (5, 12). This trades 1 y for 5 x's.</li>
</ul>

<p>This is the "chunky" tradeoff where we'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 -- it's not pointing exactly at our nearest neighbor, but it's pretty close.</p>

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

<p>What'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...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're at (5,12) then tangent slope is some ratio of 5 and 12</li>
<li>Remember "shaving the square": 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're "heavy on the y" and the trade will favor improving your x: it should be "trade 5 y's for 12 x's". And why not the other way? It doesn't make sense that the more y you have, the <em>easier</em> it is to get y! That'd spiral off into exponential growth, not a circle.</li>
<li>Lastly, we can't trade an entire chunk of 5 y'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'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) -- let'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'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'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 decoding="async" src="https://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 -- he can throw the car 13 meters. Now let's start somewhere: throwing the car pure North (0, 13):</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/be9333c28d7332adf440274cc021c15e.png' width='179' height='19' alt='\displaystyle{P(0,13) = 0 + 13 = 13}' class='tex'></p>

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

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/fbd3f9d7b6aed2e5e6d689a47532fc54.png' width='179' height='19' alt='\displaystyle{P(5,12) = 5 + 12 = 17}' class='tex'></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 "profit" of \$4 if we do the trade. We should keep trading as long as it's profitable -- as long as we'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><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/d0aa29750260bd8cccd756ea1c63d2fd.png' width='492' height='42' alt='\displaystyle{P(13 \cdot \frac{1}{\sqrt{2}}, 13 \cdot \frac{1}{\sqrt{2}}) = P(13 \cdot .707, 13 \cdot .707) = 9.2 + 9.2 = 18.4}' class='tex'></p>

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

<p>Psst. Confused about how a 45-degree through passes by 70.7% of the spectators on each side? No problem.</p>

<p>A 45-degree throw is along the diagonal of a square. A triangle with sides 1 and 1 has a hypotenuse of:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/3d35623cc16766ee742fef47d09744c4.png' width='187' height='22' alt='\displaystyle{\sqrt{1^2 + 1^2} = \sqrt{2} = 1.414}' class='tex'></p>

<p>And has sides $(1, 1, 1.414)$.</p>

<p>A hypotenuse of $\sqrt{2}$ isn't convenient: it's hard to know what fraction a side is of the whole. We divide the triangle by the length of the hypotenuse ($\sqrt{2}$), making the hypotenuse 1 and the other sides a percentage:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/5a84b2056a3d701e3a5a08023044262f.png' width='415' height='45' alt='\displaystyle{\text{Triangle with sides} = (\frac{1}{\sqrt{2}}, \frac{1}{\sqrt{2}}, \frac{\sqrt{2}}{\sqrt{2}}) = (.707, .707, 1)}' class='tex'></p>

<p>Now we've discovered that a 45-degree throw, with sides $(1, 1, \sqrt{2})$, has the ratio $.707, .707, 1$. 70.7% of the distance along the hypotenuse shows up on each side.</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's profitable)</li>
<li>Keep tweaking until our return is no longer profitable</li>
</ul>

<p>In math slang, this is "finding the local maximum". In economics slang, it's finding the point of "zero marginal returns". 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><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/cc0d3491c564298422664b79683bfd1a.png' width='201' height='19' alt='\displaystyle{ P(0, 13) = 0 + 2 \cdot 13 = 26 }' class='tex'></p>

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

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/9df17e3c0aac0a9df7805ed034aa21b3.png' width='253' height='19' alt='\displaystyle{P(9.2, 9.2) = 9.2 + 2 \cdot 9.2 = 27.6 }' class='tex'></p>

<p>Interesting -- 45 degrees is still better! But... I think we went too far! Shouldn't we favor North since it pays more?</p>

<p>Yep. Let's remember how to Squeeze the Spinach (maximize our returns): start with North and change until it'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... 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 ("Please, please go East... I'll give you a bunch if you give up a little North").</p>

<p>Remember how circles are about x/y, x &amp; 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><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/d681c8ca2885425258491c7b7d7f942f.png' width='497' height='42' alt='\displaystyle{P(13 \cdot \frac{1}{\sqrt{5}}, 13 \cdot \frac{2}{\sqrt{5}}) = P(5.81, 11.62) = 5.81 + 2 \cdot 11.62 = 29.05 }' class='tex'></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="https://betterexplained.com/articles/vector-calculus-understanding-the-gradient/">gradient</a> is in the direction of greatest increase.</p>

<p>The gradient for $F(x,y,z)$ is</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/13c8856e02bc4cf4cea67c6916bf34f9.png' width='110' height='41' alt='\displaystyle{(\frac{dF}{dx},\frac{dF}{dy},\frac{dF}{dz})}' 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='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/2b214d4d423707d97da9b5c7dcdd34dd.png' width='103' height='18' alt='\displaystyle{ (x, y) = (3,4) }' class='tex'>
<img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/a4ca4bb583d2542ab0eeb05f2faba973.png' width='102' height='18' alt='\displaystyle{ (y, z) = (4, 5) }' class='tex'>
<img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/43a3f96057809346b877f071453c6e82.png' width='103' height='18' alt='\displaystyle{ (x, z) = (3, 5) }' class='tex'></p>

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

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

<p>satisfies all 3 requirements! On the x-z plane, x doesn't care about y -- as long as the ratio to z is (3 , ?, 5) you'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'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't want to waste energy in our trajectory (3, ?, 5) in a useless direction. But that can'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 "figure out" what y should be, which is 0.</p>

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

<p><strong>Q: I still don'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'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's my answer: distance is distance. 13 units is 13 units. But in some situations we are "measuring our coordinates" (what are the values of x &amp; y) and <em>not</em> the distance itself.</p>

<p>Cartesian coordinates (x-axis, y-axis) are very inefficient for diagonal motion (i.e., you are measuring the sides of the triangle, not the hypotenuse). When $.707^2 + .707^2 = 1$, it's a measure of how "inefficient" our x &amp; 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 -- 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 "more ground" than 100% in x. In investing 1) money is not on a grid and 2) there'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="https://betterexplained.com/articles/types-of-graphs/">But not every graph is the same</a>. Graphs that aren't about distance (like "Money vs. Time") 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 -- it'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>https://betterexplained.com/articles/understanding-pythagorean-distance-and-the-gradient/feed/</wfw:commentRss>
			<slash:comments>30</slash:comments>
		
		
			</item>
		<item>
		<title>Vector Calculus: Understanding Circulation and Curl</title>
		<link>https://betterexplained.com/articles/vector-calculus-understanding-circulation-and-curl/</link>
					<comments>https://betterexplained.com/articles/vector-calculus-understanding-circulation-and-curl/#disqus_thread</comments>
		
		<dc:creator><![CDATA[kalid]]></dc:creator>
		<pubDate>Mon, 19 Feb 2007 23:02:22 +0000</pubDate>
				<category><![CDATA[Vector Calculus]]></category>
		<guid isPermaLink="false">http://betterexplained.com/articles/vector-calculus-understanding-circulation-and-curl/</guid>

					<description><![CDATA[Circulation is the amount of force that pushes along a closed boundary or path. It's the total "push" you get when going along a path, such as a circle. A vector field is usually the source of the circulation. If you had a paper boat in a whirlpool, the circulation would be the amount of [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Circulation</strong> is the amount of force that pushes along a closed boundary or path. It's the total  "push" you get when going along a path, such as a circle.</p>

<p>A vector field is usually the source of the circulation. If you had a paper boat in a whirlpool, the circulation would be the amount of force that pushed it along as it went in a circle. The more circulation, the more pushing force you have.</p>

<p><strong>Curl</strong> is simply the circulation per unit area, circulation density, or rate of rotation (amount of twisting at a single point). Imagine shrinking your whirlpool down smaller and smaller while keeping the force the same: you'll have a lot of power in a small area, so will have a large curl. If you widen the whirlpool while keeping the force the same as before, then you'll have a smaller curl. And of course, zero circulation means zero curl.</p>

<h2>Intuition</h2>

<p>Circulation is the amount of "pushing" force along a path. Curl is the amount of pushing, twisting, or turning force when you shrink the path down to a single point. Let's use water as an example.</p>

<p>Suppose we have a flow of water and we want to determine if it has curl or not: is there any twisting or pushing force? To test this, we put a paddle wheel into the water and notice if it turns (the paddle is <em>vertical</em>, sticking out of the water like a revolving door -- not like a paddlewheel boat):</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/curl/curl-paddlewheel.png" alt="curl paddlewheel" /></p>

<p>If the paddle does turn, it means this field has curl at that point. If it doesn't turn, then there's no curl.</p>

<p>What does it really mean if the paddle turns? Well, it means the water is pushing harder on one side than the other, making it twist. The larger the difference, the more forceful the twist and the bigger the curl. Also, a turning paddle wheel indicates that the field is "uneven" and not symmetric; if the field were even, then it would push on all sides equally and the paddle wouldn't turn at all.</p>

<p>The fact that there is a "twist" means the field is <strong>not conservative</strong> (this has nothing to do with its political views).</p>

<p>A conservative field is "fair" in the sense that work needed to move from point A to point B, along any path, is the same. For example, consider a river: its field is conservative. Sure, you can get a free ride downstream, but then you have to do work to get back to your starting point. Or, you can do work to move upstream, and get a free ride back. Either way, the amount of work you "put in" is the same as what you get back.</p>

<p>However, in a field with curl (like a whirlpool), you can get a free ride by moving in the direction of the twist. In a whirlpool, you can get a free trip by moving with the current in a circle. If you fight the current and go the wrong way, you have to use energy with no free ride at all.</p>

<p>Conservative fields have zero curl: there are no free twists to push you along. Alternatively, if a field has curl, it is not conservative.</p>

<p>Gravity is another example of a conservative field. Technically, if you lift a rock and then let it fall, the energy you get from falling is the same as what you put in to lift the rock. Theoretically speaking, no energy was gained or lost in this transaction.</p>

<h2>Additional Details</h2>

<p>To be technical, curl is a <strong>vector</strong>, which means it has a both a magnitude and a direction.  The magnitude is simply the amount of twisting force at a point.</p>

<p>The direction is a little more tricky: it's the orientation of the axis of your paddlewheel in order to get maximum rotation. In other words, it is the direction which will give you the most "free work" from the field. Imagine putting your paddlewheel sideways in the whirlpool - it wouldn't turn at all. If you put it in the proper direction, it begins turning.</p>

<p>But wait a minute -- aren't there two directions to get a twisting motion? Couldn't you just turn the paddlewheel "upside down" and get the maximum curl as well?</p>

<p>Yep, you're right. By convention alone, if the paddle wheel is rotating counterclockwise, its curl vector points out of the page. This is a type of right-hand rule: make a fist with your right hand and stick out your thumb. If the circulation/pushing force follows the twisting of your fingers (counterclockwise), then the curl vector will be in the direction of your thumb.</p>

<h2>Mathematics</h2>

<p>Circulation is the integral of a vector field along a path - you are adding how much the field "pushes" you along a path.</p>

<p>How do we find this? Well, we should expect some type of dot product, because we want to know the amount that one vector (the force) is pushing in the direction of another (the path). So, the two vectors we need are (1) the path vector and (2) the field vector at every point along the path.</p>

<p>If we have a function that defines the position at any time, $F(t)$, we can take the time derivative to get the velocity at that position.</p>

<p>The velocity vector is always in the direction of movement -- if you are moving from A to B, the velocity vector will be an arrow from A to B, i.e. your change in position or your direction of movement. So, we can use the velocity to get our direction.</p>

<p>It's important to understand why we aren't using the position vector itself -- it tells us where we are, but not where we're going. We need to know our direction to see how much "push" we are getting: Knowing your position in a river isn't important -- are you going upstream or downstream, and at what angle?</p>

<p>The force vector (2) is defined by the field we are in. No derivatives or other changes are necessary -- every point in the field has some force acting on it.</p>

<p>So, our formula for circulation is:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/c2c15254dfe141e51769b458755655e1.png' width='213' height='18' alt='\displaystyle{\text{ Force at position r } = F(r)}' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/c24699d9a5d9335384d4a6f114649e65.png' width='226' height='16' alt='\displaystyle{\text{ Direction at position r } = dr }' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/1bcb79be967c32dbb6d225855253b5fc.png' width='388' height='41' alt='\displaystyle{\text{ Total pushing force = Circulation } = \int F(r) \cdot dr }' class='tex'></p>

<p>Remember, velocity is simply the derivative of position (r), so (dr) is a vector giving us our direction. We integrate along the entire path and use the dot product to see how much pushing force is applied. We then sum up these "pushes" to get the total circulation.</p>

<p>Since curl is the circulation per unit area, we can take the circulation for a small area (letting the area shrink to 0). However, since curl is a vector, we need to give it a direction -- the direction is normal (perpendicular) to the surface with the vector field. The <strong>magnitude</strong> is the same as before: circulation/area.</p>

<p>Recall that by convention (a bunch of people agreeing), counterclockwise circulation will give a curl pointing out of the page. Using these facts, we can create the formula for curl:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/7b7ffbe80af66aaa29c52c6d3aaa6691.png' width='257' height='46' alt='\displaystyle{ \text{Curl} = \frac{\text{circulation}}{\text{area}} = \frac{\int F(r) \cdot dr}{\int S} }' class='tex'></p>

<p>Where &#40;S&#41; is the surface we are considering; the direction of the curl is the normal to the surface.</p>

<p>You'll see fancier equations for curl where the surface shrinks to zero (such as in <a href="http://en.wikipedia.org/wiki/Curl">wikipedia</a>), but recognize the basic intuition -- curl is the circulation per unit area.</p>

<h2>Parting Thoughts</h2>

<p>You'll often see curl of a field (F) written like this:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/33d942441d6d2a7270fc746a9d860d10.png' width='138' height='19' alt='\displaystyle{ \text{Curl}(F) = \nabla \times F }' class='tex'></p>

<p>which is a cross-product of the <a href="https://betterexplained.com/articles/vector-calculus-understanding-the-gradient/">gradient</a> and the field &#40;F&#41;. This has to do with how curl is actually computed, which will be material for another article (and probably in your textbook already -- see <a href="http://en.wikipedia.org/wiki/Curl">wikipedia</a> for details).</p>

<p>If I have been successful, you should understand intuitively what circulation and curl mean, and how we got the formulae above. They spring up naturally from our definition of circulation as "pushing force along a path" and curl as "pushing force/area".</p>

<p>Math should be a tool for clearly stating what we already know. Understand the intuition and then tackle the complicated formulas. Happy math.</p>

<p><span class="caps">PS.</span> Have some fun and check out this video of a famous whirlpool. Imagine the circulation on this (go on, imagine):</p>

<iframe loading="lazy" width="560" height="315" src="https://www.youtube.com/embed/ddlrGkeOzsI?rel=0" frameborder="0" allowfullscreen></iframe>
]]></content:encoded>
					
					<wfw:commentRss>https://betterexplained.com/articles/vector-calculus-understanding-circulation-and-curl/feed/</wfw:commentRss>
			<slash:comments>67</slash:comments>
		
		
			</item>
	</channel>
</rss>
