<?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</title>
	<atom:link href="https://betterexplained.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://betterexplained.com</link>
	<description>Math lessons that click</description>
	<lastBuildDate>Sat, 20 Aug 2022 03:09:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>How to Learn Trig Derivatives</title>
		<link>https://betterexplained.com/articles/trig-derivatives/</link>
					<comments>https://betterexplained.com/articles/trig-derivatives/#comments</comments>
		
		<dc:creator><![CDATA[kalid]]></dc:creator>
		<pubDate>Wed, 03 Aug 2022 20:18:29 +0000</pubDate>
				<category><![CDATA[Math]]></category>
		<guid isPermaLink="false">https://betterexplained.com/?p=12748</guid>

					<description><![CDATA[Quick confession? I never fully learned the trig derivatives. Sure, I memorized $\sin' = \cos$ and $\cos' = -\sin $ like everyone else, but the derivative of tangent? Cosecant? Forget it, magic spells. After years of searching, there's a middle ground between tedious derivation and rote memorization. Aha moment: all trig functions change using the [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Quick confession? I never fully learned the trig derivatives. Sure, I memorized $\sin' = \cos$ and $\cos' = -\sin $ like everyone else, but the derivative of tangent? Cosecant? Forget it, magic spells.</p>

<p>After years of searching, there's a middle ground between tedious derivation and rote memorization. <strong>Aha moment: all trig functions change using the same process: (sign)(scale)(swapped function)</strong>.</p>

<p>Here's the Table of Trig Derivatives we'll learn to fill out:</p>

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

<p>As background, learn to <a href="https://betterexplained.com/articles/intuitive-trigonometry/">visualize the trig functions</a>, and how they're related by the Pythagorean Theorem and similarity:</p>

<div style="display: flex;">
<img decoding="async" alt="How to Learn Trig Derivatives" src="https://betterexplained.com/wp-content/uploads/trig/trig-overall.png" style="flex: 50%; padding: 5px;" />
<img decoding="async" alt="How to Learn Trig Derivatives" src="https://betterexplained.com/wp-content/uploads/trig/trig-identities.png" style="flex: 50%; padding: 5px;" />
</div>

<h2>Part 1: Learn the table</h2>

<p>First, let's learn to make the table, one column at a time:</p>

<p><video width="100%" controls>   <source src="https://betterexplained.com/wp-content/uploads/trig/derivatives/TrigDerivativeTable.mp4" type="video/mp4"> Your browser does not support the video tag. </video></p>

<ol>
<li><strong>Function:</strong> The function to derive (sin, cos, tan, cot, sec, csc)</li>
<li><strong>Sign:</strong> The "primary" functions are positive, and the "co" (complementary) functions are negative</li>
<li><strong>Scale:</strong> The hypotenuse (red) used by each function</li>
<li><strong>Swap:</strong> The <em>other</em> function in each Pythagorean triangle (sin ⇄ cos, tan ⇄ sec, cot ⇄ csc)</li>
<li><strong>Derivative:</strong> Multiply to find the derivative</li>
</ol>

<p>Tada! This procedure somehow finds derivatives for trig fucntions. Learning tips:</p>

<ul>
<li>Think "triple S": sign, scale, swap</li>
<li>You've likely memorized $\sin' = \cos$ and $\cos' = -\sin$. Fill in those rows to kickstart the process.</li>
</ul>

<p>Normally, I prefer insight to memorization. But practically, you're asking about trig derivatives because you have a test, and I want to help you now.</p>

<p>Like a multiplication table, after filling in the entries, we notice patterns. Could $\sin' = \cos$ and $\csc' = -\csc \cot$ have something in common?</p>

<p>You bet.</p>

<h2>Part 2: Visualize the derivatives</h2>

<p>What's the derivative of sine?</p>

<p>The <a href="https://en.wikipedia.org/wiki/Differentiation_of_trigonometric_functions#Derivative_of_the_sine_function">formal approach</a> is to plug $\sin(x)$ into the definition of derivative, do the algebra, and see that $\cos(x)$ pops out. Accurate, but unsatisfying. If $\sec(x)$ was the derivative, would you notice something was amiss? Probably not.</p>

<p>Here's what's happening geometrically:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/derivatives/sin-cos-deriv.png" alt="Sine Cosine Derivative" /></p>

<p>The derivative of sine means "How much does our height change when I change my angle?"</p>

<p>I see it like this: we have a starting angle, $x$. We increase it a smidge ($dx$), which we can place <em>along</em> our unit circle (since radians are <a href="https://betterexplained.com/articles/intuitive-guide-to-angles-degrees-and-radians/">distance traveled</a> along the perimeter).</p>

<p>We then draw a mini-triangle based on $dx$, similar to the large one, which shows the height and width change as we move along the perimeter.</p>

<p>The large triangle has proportions $\text{red} : \text{blue} : \text{green} = 1 : \cos : \sin$. The mini-triangle has similar proportions, with the longest side of $dx$ instead of 1. Therefore, the mini lengths are:</p>

<p>$\text{mini red} : \text{mini blue} : \text{mini green} = dx : \cos dx : \sin dx$</p>

<p>Since mini blue is the change in sine, and mini green the change in cosine, we have:</p>

<p>$\sin'(x) = \text{height change} = \text{mini blue} = \cos(x) dx$</p>

<p>$\cos'(x) = \text{width change} = (-1) \cdot \text{mini green} = - \sin(x) dx$</p>

<p>Notice the negative sign with $\cos'$, since mini-green points to the left (negative).</p>

<h3>Quick Aside: How the Columns Work</h3>

<p>The "mini triangle" strategy works for all the trig functions. There are 3 factors:</p>

<p><strong>Q1: What's the sign?</strong></p>

<p>The trig co-functions are the original function applied to the <em>complementary angle</em>.</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/c61fe213372e732f9a155cc26fc79449.png' width='346' height='19' alt='\displaystyle{\cos(x) = \sin(90 - x) \ \ \ \ \sin(x) = \cos(90 - x) }' class='tex'>
<img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/149e532e47e0e28aaf34c936e979d691.png' width='354' height='19' alt='\displaystyle{\tan(x) = \cot(90 - x) \ \ \ \ \cot(x) = \tan(90 - x) }' class='tex'>
<img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/d40c27fce902e5a1cc0732dd95720cea.png' width='346' height='19' alt='\displaystyle{\sec(x) = \csc(90 - x) \ \ \ \ \sec(x) = \csc(90 - x) }' class='tex'></p>

<p>Just eyeballing it, we see parameters $x$ and $(90 - x)$ bandied about. The <a href="https://betterexplained.com/articles/derivatives-product-power-chain/">Chain Rule</a> is whispering (screaming?) that the derivatives should be opposite, right?</p>

<p>Let's try it:</p>

<p>$\cos'(x) = [\sin(90 - x)]' = [\sin'(90 - x)][(90-x)'] = \cos(90-x)(-1)$
$= \sin(x)(-1) = -\sin(x) $</p>

<p>Yep, we got a negative sign.</p>

<p>What happened? We converted $\cos$ into its $\sin$ form (turning the angle into the complement), took the derivative, got the $-1$ term, and converted back. All the cofunctions have a similar pattern, giving us a negative sign in the table.</p>

<p>(Note: the negative sign means the cofunction changes <em>opposite</em> the original function, not that the derivative is <em>less than zero</em>. Cosine increases when sine is negative.)</p>

<p><strong>Q2: What's the scale?</strong></p>

<p>Sine and cosine live on the unit circle (radius 1). The other functions use a radius of secant (tan/sec) or cosecant (cot/csc).</p>

<p><strong>Q3: What's the swapped function?</strong></p>

<p>We make a mini-triangle by shrinking the original triangle down, and rotating so $dx$ matches the side of length $1$. It would be strange if, after rotation, the original colors (functions) pointed the same way.</p>

<p>The change must be based on the other function in the triangle (sine's change is based on cosine, cosine on sine, tangent on secant, etc.)</p>

<p>Also, it would be strange for a function to grow based on its own current value, right? (Hold that thought.)</p>

<h2>Derivatives of tangent and secant</h2>

<p>Ok, let's draw the mini triangles for tangent and secant:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/derivatives/tan-sec-deriv.png" alt="Tangent Secant Derivative" /></p>

<ul>
<li>First, we draw the $dx$ mini-triangle on the unit circle (like sin/cos).</li>
<li>Next, we slide/scale the mini-triangle to fit on the "secant" radius: $dx$ becomes $\sec(x) dx$ on the secant circle.</li>
<li>Last, rotate the mini-triangle so the known $1$ side (blue) matches our change of $\sec(x)dx$.</li>
</ul>

<p>Ok. So how big are the sides of the mini triangle?</p>

<p>$\text{mini blue}: \text{mini green} : \text{mini red} = 1 : \tan(x) : \sec(x)$</p>

<p>We know $\text{mini blue} = \sec(x) dx$, so we just scale up the other sides by that amount:</p>

<ul>
<li>$d\sec = \text{mini green} = \tan(x) [\text{mini blue}] = \tan(x) \sec(x)dx = \sec(x) \tan(x) dx$</li>
<li>$d\tan= \text{mini red} = \sec(x) [\text{mini blue}] = \sec(x) \sec(x)dx = \sec^2(x) dx$</li>
</ul>

<p>Nice! I like how this matches the sine/cosine process. We're just measuring sides in the mini-triangle.</p>

<h2>Derivatives of Cosecant and Cotangent</h2>

<p>For completeness, here's csc/cot:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/derivatives/csc-cot-deriv.png" alt="Cosecant Cotangent Derivative" /></p>

<p>Notice how $d\cot$ and $d\csc$ in the mini-triangle move against their positive sides in the big triangle. Using the same sign, scale, swap process, we get:</p>

<p>$\cot' = (-)(\csc)(\csc) = -\csc^2$</p>

<p>$\csc' = (-)(\csc)(\cot) = -\csc \cot$</p>

<p>Colorizing the sides really helps me link the mini-triangle back to the original.</p>

<p>Now, we didn't have to draw this all out: we already know $\tan'$ and $\sec'$. Using the chain rule and complementary functions, we can do:</p>

<p>$\cot(x)' = [\tan(90-x)]' = \tan'(90-x)(90 - x)' = \sec^2(90-x)(-1) = -\csc^2(x)$</p>

<p>$\csc(x)' = [\sec(90-x)]' = \sec'(90-x)(90 - x)' = \sec(90-x)\tan(90-x)(-1)$
$= -\csc(x)\cot(x)$</p>

<h2>Summary: What do the derivatives mean?</h2>

<p>Blindly memorizing trig derivatives doesn't teach you much.</p>

<p>The deeper intuition: <strong>Trig derivatives are based on 3 effects: the sign, the radius (scale), and the other function.</strong></p>

<p>So instead of $\tan' = \sec^2$, think of it as $\tan' = (+)(\sec)(\sec)$, aka $(\text{sign})(\text{scale})(\text{swapped function})$. Heck, you can even see $\cos' = (-)(1)(\sin)$.</p>

<p>If you can complete the derivative table and draw the mini-triangles, you'll have a <em>much</em> better understanding of trig than I ever did.</p>

<p>Happy math.</p>

<h2>Appendix: Combined Diagram</h2>

<p>It's a bit busy, but here's all the mini-triangles together:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/trig/derivatives/trig-derivatives-diagram.png" alt="trig-derivatives-combined diagram" /></p>

<p>Again, the intuition: these mini red/green/blue triangles (which are all similar!) show the changes.</p>

<h2>Appendix: Exponential Behavior</h2>

<p>Remember how we didn't think a derivative should be based on the same function? Well,</p>

<p>$\tan' = \sec^2 = 1 + \tan^2$</p>

<p>which means tangent grows <em>faster</em> than <a href="https://betterexplained.com/articles/an-intuitive-guide-to-exponential-functions-e/">exponential</a>: it grows based on its own square (vs. "just" the current value).</p>

<p>We see that $\tan(x)$ beats $e^x$ in a race, and exponentials are no slouch! (I'm looking forward to "this is growing tangentially" to be the new catchphrase.)</p>

<iframe loading="lazy" src="https://www.desmos.com/calculator/m7tr9xrgps" width="100%" height="700px" style="left: 0%; max-width: 100vw; position: relative; width: 100vw; max-width: 900px;" frameborder="0"></iframe>

<h2>Appendix: Other mini-triangle layouts</h2>

<p>There's other ways we could arrange the mini-triangle. I think it's easiest when the change along the perimeter is mapped to the side of length 1.</p>

<p>But, when finding $\tan'$, you could use the red/blue/green ratios from the 1/cos/sin triangle and find:</p>

<p>$\tan' = \sec \frac{1}{\cos} = \sec^2$</p>

<p>The scale of $\sec$ is the same, but the unknown side is of length $\frac{1}{\cos} dx$. Different approach, same result.</p>

<h2>References</h2>

<ul>
<li><a href="https://math.stackexchange.com/questions/1299682/geometric-intuition-for-derivatives-of-basic-trig-functions">MathExchange discussion for seeing the initial geometric interpretation</a></li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://betterexplained.com/articles/trig-derivatives/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		<enclosure url="https://betterexplained.com/wp-content/uploads/trig/derivatives/TrigDerivativeTable.mp4" length="10296927" type="video/mp4" />

			</item>
		<item>
		<title>Intuitive Guide to Hyperbolic Functions</title>
		<link>https://betterexplained.com/articles/hyperbolic-functions/</link>
					<comments>https://betterexplained.com/articles/hyperbolic-functions/#respond</comments>
		
		<dc:creator><![CDATA[kalid]]></dc:creator>
		<pubDate>Mon, 26 Apr 2021 17:57:44 +0000</pubDate>
				<category><![CDATA[Math]]></category>
		<guid isPermaLink="false">https://betterexplained.com/?p=12532</guid>

					<description><![CDATA[If the exponential function $e^x$ is water, the hyperbolic functions ($\cosh$ and $\sinh$) are hydrogen and oxygen. They're the technical, rarely-discussed parts that combine into a famous whole. Admittedly, the hyperbolic functions were tucked into a dark part of my attic. They were defined with strained motivations ("Need yet another way to build a hyperbola?") [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>If the exponential function $e^x$ is water, the hyperbolic functions ($\cosh$ and $\sinh$) are hydrogen and oxygen. They're the technical, <a href="https://trends.google.com/trends/explore?date=all&amp;q=math.cos,math.cosh">rarely-discussed</a> parts that combine into a famous whole.</p>

<p>Admittedly, the hyperbolic functions were tucked into a dark part of my attic. They were defined with strained motivations (<em>"Need yet another way to build a hyperbola?"</em>) then crammed into <a href="https://en.wikipedia.org/wiki/Lists_of_integrals#Hyperbolic_functions">tables of integrals</a>, soon to be forgotten. I couldn't think with them.</p>

<p>After much struggle, I found their purpose:</p>

<ul>
<li><p><strong>What are the hyperbolic functions ($\cosh$ and $\sinh$)?</strong> The even/odd parts of the exponential function ($e^x$) that, funny enough, can build a hyperbola.</p></li>
<li><p><strong>Why are parts of the exponential called hyperbolic?</strong> That's the modern name. These functions are <em>so darn good</em> at making hyperbolas that they're typecast for that role. (Similarly, sine isn't <a href="https://betterexplained.com/articles/intuitive-understanding-of-sine-waves/">just about circles</a>, and we shouldn't name it "circular sine"!)</p></li>
<li><p><strong>Why are hyperbolic functions useful?</strong> A better framing is: Why are parts of $e^x$ useful? We now have "mini logarithms" and "mini exponentials", with partial versions of $e$'s famous properties.</p></li>
<li><p><strong>I can handle it: how do hyperbolas connect to exponentials?</strong> Hyperbolas come from inversions ($xy = 1$ or $y = \frac{1}{x}$). The area under an inversion grows logarithmically, and the corresponding coordinates grow exponentially. If we rotate the hyperbola, we rotate the formula to $(x-y)(x+y) = x^2 - y^2 = 1$. The area/coordinates now follow modified logarithms/exponentials: the hyperbolic functions.</p></li>
<li><p><strong>Actually, I couldn't handle it.</strong> That's ok. We'll build up to it. These functions took many years to be discovered, and their behavior is hardly obvious.</p></li>
</ul>

<p>This post is fairly technical: we're studying hydrogen, not water. If hyperbolic functions appear in class, you don't have much choice, and may as well get an intuition. If you're studying for fun, don't sweat the details, that's what calculus students are for.</p>

<p>As a prerequisite, have these insights in mind:</p>

<ul>
<li><a href="https://betterexplained.com/articles/an-intuitive-guide-to-exponential-functions-e/">$e^x$</a> is the process of continuous, 100% growth</li>
<li><a href="https://betterexplained.com/articles/demystifying-the-natural-logarithm-ln/">natural log</a> is the time for $e^x$ to grow to a given value</li>
</ul>

<p>Let's dive in.</p>

<p></p>

<h2>Part 1: Exponential Viewpoint</h2>

<h3>Background: Odd/Even Functions</h3>

<p>Chemical compounds can be separated into constituent atoms; math objects are similar.</p>

<p>The number 13 can be split into an even part (12) and odd part (1). They combine to the whole: 13 = 12 + 1.</p>

<p>This even/odd split works for functions, too:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/48984e36b38965800b1f2c6e59a940c5.png' width='199' height='19' alt='\displaystyle{f(x) = f_\text{even}(x) + f_\text{odd}(x)}' class='tex'></p>

<p>Functions are tricky to separate because they have multiple values. The separation we look for is between the future values ($x > 0$) and the past ones ($x &lt; 0$).</p>

<p>To see what the future and past have in common, take their average:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/2ebca6dd13e2517240cb5517dd8b6092.png' width='360' height='39' alt='\displaystyle{f_\text{even}(x) = \text{avg}[\text{future} + \text{past}] = \frac{f(x) + f(-x)}{2}}' class='tex'></p>

<p>To see how the future and past differ, average their gap:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/0162fe3f75aa6f77901cde5035475042.png' width='356' height='39' alt='\displaystyle{f_\text{odd}(x) = \text{avg}[\text{future} - \text{past}] = \frac{f(x) - f(-x)}{2}}' class='tex'></p>

<p>Can we combine these parts to get the original?</p>

<p>$f_\text{even}(x) + f_\text{odd}(x) = \frac{f(x) + f(-x)}{2} + \frac{f(x) - f(-x)}{2} = \frac{f(x) + f(-x) + f(x) - f(-x)}{2} = \frac{2f(x)}{2} = f(x)$</p>

<p>Neat trick. We can split any pattern into its even and odd parts.</p>

<h3>Taylor series</h3>

<p>The <a href="https://betterexplained.com/articles/taylor-series/">Taylor Series (Math DNA)</a> expresses a function as a polynomial:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/c3f9e195f6520dcc434c3212454e6dff.png' width='277' height='21' alt='\displaystyle{f(x) = c_0 + c_1 x + c_2 x^2 + c_3x^3 + \cdots}' class='tex'></p>

<p>The even exponents ($x^0, x^2, ...$) are symmetric in the past and future (for example: $x^2 = (-x)^2$), and the odd exponents are anti-symmetric ($x^3 = - (-x)^3$).</p>

<p>We can quickly extract the even/odd parts by separating the function's Taylor series into even/odd exponents:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/06b5d911a5e484010306cfa9f60649da.png' width='255' height='78' alt='&#10;\begin{align*}&#10;f(x) &amp;= f_\text{even}(x) + f_\text{odd}(x) \\&#10;f_\text{even}(x) &amp;= c_0 + c_2 x^2 + c_4x^4 + \cdots \\&#10;f_\text{odd}(x) &amp;= c_1 x + c_3x^3 + c_5x^5 \cdots&#10;\end{align*}&#10;' class='tex'></p>

<h3>Even and Odd Exponentials</h3>

<p>Ok, we have our trick. Why not try to split up the famous exponential function?</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/57c4683189f9e74ddebed533a6931e7b.png' width='341' height='111' alt='&#10;\begin{align*}&#10;e^x_{\text{even}} &amp;= \text{avg}[e^x, e^{-x}] = \frac{e^x + e^{-x}}{2} = \cosh(x) \\&#10;e^x_\text{odd} &amp;= \text{avg}[e^x, -e^{-x}] = \frac{e^x - e^{-x}}{2} = \sinh(x) \\&#10;e^x &amp;= e^x_{\text{even}}  + e^x_{\text{odd}} = \cosh(x) + \sinh(x)&#10;\end{align*}&#10;' class='tex'></p>

<p>Instead of the awkward $e^x_{\text{even}}$ and $e^x_{\text{odd}}$, we call the even part $\cosh$ (hyperbolic cosine) and the odd part $\sinh$ (hyperbolic sine). (The pronunciation <a href="https://math.stackexchange.com/questions/176055/pronunciation-of-sinh-x-cosh-x-tanh-x-for-short">varies</a>.)</p>

<p>Now, why the adjective "hyperbolic"? Euler used the quantity $(e^{x} + e^{-x})$ without giving it a special name. Lambert later called them "transcendental logarithmic functions", and even later the ability to build hyperbolas was seen. That use case has stuck.</p>

<p>Call me old-fashioned, but parts of $e^x$ are interesting for that reason alone. I don't need a hyperbola to justify their utility.</p>

<h2>Part 2: What do hyperbolic functions look like?</h2>

<p>Let's graph $\cosh$ and $\sinh$ with their parent:</p>

<iframe loading="lazy" src="https://www.desmos.com/calculator/fyktx2ea2p?embed" width="500px" height="500px" style="border: 1px solid #ccc" frameborder=0></iframe>

<ul>
<li>$e^x$ is our standard exponential, with Taylor series: $e^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + ...$</li>
<li>$\cosh(x)$ is a gentle bowl. It's roughly parabolic, then expands exponentially, with Taylor series: $\cosh(x) = 1 + \frac{x^2}{2!} + \frac{x^4}{4!} + ...$</li>
<li>$\sinh(x)$ looks linear at first, then grows exponentially also:
$\sinh(x) = x + \frac{x^3}{3!}...$</li>
</ul>

<p>Now for a usually-confusing question: <strong>What does the parameter $x$ in $\cosh(x)$ really mean?</strong></p>

<p>It's nothing special! It's the same $x$ we feed to any exponential, usually the time to grow: $e^x = e^{rt} = e^{100\% t}$.</p>

<p>We can see the hyperbolic trig functions as:</p>

<ul>
<li>$\cosh(x)$: What is the <em>even part</em> of $e^x$ after $x$ units of time?</li>
<li>$\sinh(x)$: What is the <em>odd part</em> of $e^x$ after $x$ units of time?</li>
</ul>

<p>A few gut checks:</p>

<ul>
<li>What's $\cosh(0)$? At $x=0$ (aka $\text{time} = 0$), we haven't moved from 1.0 (the exponential starting point). The average is 1, and there's no separation, so $\sinh(0) = 0$.</li>
<li>As time goes on, the future grows and the past ($e^{-x}$) vanishes. The average value becomes $\frac{e^x + 0}{2}$, and the average difference becomes $\frac{e^x - 0}{2}$. For large $x$, we'd expect $\cosh(x) \sim \sinh(x) \sim 0.5 e^x$.</li>
</ul>

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

<p>Now, how about the <em>inverse</em> hyperbolic functions like $\text{acosh}$ (also called $\text{arccosh}$ or $\text{arcosh}$)? "Inverse hyperbolic cosine" sounds scary, but think of it like this:</p>

<ul>
<li><p>$\ln(a)$: How long until $e^x$ reaches value $a$?</p></li>
<li><p>$\text{acosh(a)}$: How long until the <em>even</em> part of $e^x$ reaches $a$? This must take longer than $\ln(x)$, since we're only using the <em>even</em> powers in our exponential growth Taylor series.</p></li>
<li>$\text{asinh(a)}$: How long until the <em>odd</em> part of $e^x$ reaches $a$? Similarly, this must require more time $\ln(x)$.</li>
</ul>

<iframe loading="lazy" src="https://www.desmos.com/calculator/2obdnofcqg?embed" width="500px" height="500px" style="border: 1px solid #ccc" frameborder=0></iframe>

<p>In the graphs above, $\text{acosh}$ and $\text{asinh}$ require more time (i.e., are above) the natural log.</p>

<p>Intuitively, I see the various hyperbolic functions as modified exponentials and logarithms:</p>

<ul>
<li>$\cosh$ and $\sinh$ are partial/delayed exponential curves (with new behavior near zero, where the past still has influence).</li>
<li>$\text{acosh}$ and $\text{asinh}$ are slower versions of the natural log. It takes $\ln(3) = 1.09$ units for $e^x$ to grow from 1 to 3, but it takes $\text{acosh}(3) = 1.76$ units for just the even part of $e^x$ to do the same. </li>
</ul>

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

<h2>Part 3: Applications of the Exponential Interpretation</h2>

<p>Since $\cosh$ and $\sinh$ are mini exponentials (those little cherubs!), we'd guess they still have interesting properties.</p>

<h3>Function equal to its own second derivative</h3>

<p>$e^x$ is the function equal to its own derivative ($f' = f$).</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/7fd4fbaba0d5797c3437bafe1edfef92.png' width='176' height='23' alt='\displaystyle{e^x \xrightarrow{\text{d/dx}} e^x \xrightarrow{\text{d/dx}} e^x \dots }' class='tex'></p>

<p>Ok. And Sine and cosine are functions equal to their own <em>fourth</em> derivatives ($f'''' = f$).</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/c88872a854c9f2bc3014c7fb5c5ccc7a.png' width='476' height='27' alt='\displaystyle{\sin(x) \xrightarrow{\text{d/dx}} \cos(x) \xrightarrow{\text{d/dx}} -\sin(x) \xrightarrow{\text{d/dx}} -\cos(x) \xrightarrow{\text{d/dx}} \sin(x) }' class='tex'></p>

<p>Repeating after one derivative, repeating after four derivatves... that's a big gap. Anything in-between?</p>

<p>You bet. The hyperbolic functions equal their own <em>second</em> derivative ($f'' = f$):</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/c9a67ee0dd3d12d5423844f478b52cdf.png' width='379' height='38' alt='\displaystyle{\frac{d}{dx} \sinh(x) = \frac{d}{dx} \frac{e^x - e^{-x}}{2} = \frac{e^x + e^{-x}}{2} = \cosh(x)}' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/52c1b60ab4685c66afd3d09782e2cacd.png' width='379' height='38' alt='\displaystyle{\frac{d}{dx} \cosh(x) = \frac{d}{dx} \frac{e^x + e^{-x}}{2} = \frac{e^x - e^{-x}}{2}  = \sinh(x)}' class='tex'></p>

<p>Unlike $\sin$ and $\cos$, there's no awkward negative signs in the cycle, just a toggle:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/116a4369feacd0dbf5eba64739c956e0.png' width='456' height='27' alt='\displaystyle{\sinh(x) \xrightarrow{\text{d/dx}} \cosh(x) \xrightarrow{\text{d/dx}} \sinh(x) \xrightarrow{\text{d/dx}} \cosh(x) \xrightarrow{\text{d/dx}} \dots }' class='tex'></p>

<p>Neat. The hyperbolic functions are like "half exponentials" because it takes two derivatives to complete the cycle. This is why they're useful in calculus -- not because we care about the coordinates on a hyperbola!</p>

<h3>Understanding Integral Tables</h3>

<p>You'll see hyperbolic functions in tables of tricky integrals and derivatives:</p>

<p><img decoding="async" alt="Intuitive Guide to Hyperbolic Functions" src="https://betterexplained.com/wp-content/uploads/hyperbolic/inverse-hyperbolic-functions.svg?t=1" /></p>

<p>Ignore the specifics. Let's see the general pattern without getting lost in the details.</p>

<p>We have our standard relationship:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/4229903bc7c32f86a813a300bf95c5f5.png' width='101' height='38' alt='\displaystyle{\frac{d}{dx} \ln(x) = \frac{1}{x}}' class='tex'></p>

<p>Since the hyperbolic functions are variations of the exponentials, we'd expect $\frac{d}{dx}\text{asinh}$ to resemble $\frac{1}{x}$. From the table:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/e94bbea03949ec3b4ada6a709ab97db7.png' width='179' height='42' alt='\displaystyle{\frac{d}{dx} \text{asinh}(x) = \frac{1}{\sqrt{x^2 + 1}}}' class='tex'></p>

<p>When $x$ is large, the "$+ 1$" doesn't matter much, and the derivative becomes:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/346ba89b83c3966d2af2a082bccc3863.png' width='279' height='42' alt='\displaystyle{\frac{d}{dx} \text{asinh}(x) = \frac{1}{\sqrt{x^2 + 1}} \sim \frac{1}{\sqrt{x^2 }} \sim \frac{1}{x}}' class='tex'></p>

<p>Ah! The function $\text{asinh}(x)$ behaves like $\ln(x)$, except for small $x$ where the $+1$ term still matters. Without this exponential perspective, I'd have <em>no clue</em> what the derivative of $\text{asinh}$ should resemble. (<em>You want the rate of change of the inverse function that determines the y-coordinate a in a hyperbola? What?</em>)</p>

<h3>New descriptions of Sine and Cosine</h3>

<p>Remember, we can now split the exponential function whenever we want:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/fe78354b273043053d7de8e7d6901b3a.png' width='178' height='19' alt='\displaystyle{e^x = \cosh(x) + \sinh(x)}' class='tex'></p>

<p>So, what if we plug in $ix$? We'd get</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/c5c77de736989f876902e696b530d268.png' width='195' height='21' alt='\displaystyle{e^{ix} = \cosh(ix) + \sinh(ix)}' class='tex'></p>

<p>But <a href="https://betterexplained.com/articles/intuitive-understanding-of-eulers-formula/">Euler's formula</a> says:</p>

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

<p>Whoa. The even/odds parts of each function must be the same, so:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/4c7518fe0931e8c180c4a53e54e417da.png' width='136' height='19' alt='\displaystyle{\cosh(ix) = \cos(x)}' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/8019d94f66e5359f5795248d60687003.png' width='142' height='19' alt='\displaystyle{\sinh(ix) = i \sin(x)}' class='tex'></p>

<p>If we feed the imaginary axis to our everyday exponential function, we get the trig functions which live on a circle. The rotation is happening via the parameter $ix$, vs. in the function $e^{ix}$. (Instead of rotating the steering wheel, we're rotating the engine, so to speak.)</p>

<p>In sine's case, we have an awkward imaginary term to shuffle around:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/a52266f84d9d91130750b8482b9fbc51.png' width='247' height='40' alt='\displaystyle{\sin(x) = \frac{\sinh(ix)}{i} = -i \sinh(ix)}' class='tex'></p>

<p>These connections are more useful in complex analysis (still learning...), normally you'd prefer to pass real parameters into functions.</p>

<h3>New Trig Identities</h3>

<p>A few new identities doesn't hurt. With some quick algebra, we can turn regular trig identities into their hyperbolic versions. Starting with:</p>

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

<p>We swap in $\cos(x) = \cosh(ix)$ and $\sin(x) = -i \sinh(ix)$ to get:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/d0e992723f18aae63ab8f60ae6364261.png' width='232' height='80' alt='&#10;\begin{align*}&#10;\cosh^2(ix) + [-i\sinh(ix)]^2 &amp;= 1 \\&#10;\cosh^2(ix) + i^2\sinh^2(ix) &amp;= 1 \\&#10;\cosh^2(ix) -\sinh^2(ix) &amp;= 1&#10;\end{align*}&#10;' class='tex'></p>

<p>Now, the term $ix$ is just a parameter. To simplify things, just say $z = ix$ and write:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/6f9d8e1bf66dd2743e09736ad0a47229.png' width='184' height='21' alt='\displaystyle{\cosh(z)^2 -\sinh(z)^2 = 1}' class='tex'></p>

<p>We can leave out the specific parameter and write:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/f932ebcb3ac317ea83181ed6631fd1fa.png' width='135' height='17' alt='\displaystyle{\cosh^2 -\sinh^2 = 1}' class='tex'></p>

<p>This pattern works in general. To convert a regular trig formula to its hyperbolic equivalent (<a href="https://math.stackexchange.com/questions/138842/proof-of-osbornes-rule">Osborne's Rule</a>), swap:</p>

<ul>
<li>$\cos^2 \Rightarrow \cosh^2$ </li>
<li>$\sin^2 \Rightarrow -\sinh^2$ (due to the $i$ when converting $\sin$ into $\sinh$)</li>
</ul>

<h3>Machine Learning Functions</h3>

<p>While looking for applications of $\cosh$, I ran across this function, used in <a href="https://www.tensorflow.org/api_docs/python/tf/keras/losses/LogCosh">Machine Learning</a>:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/c07f78c73d7bd60d3e5a522f2ef9cc64.png' width='192' height='19' alt='\displaystyle{\text{logcosh(x)} = \ln(\cosh(x))}' class='tex'></p>

<p>A direct interpretation is confusing: "Take the natural log of the x-coordinate in a hyperbola". Huh? What does that represent?</p>

<p>The exponential perspective makes it simpler:</p>

<ul>
<li>We don't want to take the natural log of the regular exponential, since $\ln(e^x) = x$. A function like $x$ (or rather, the absolute value $|x|$) is too pointy, and doesn't have a clean derivative at zero.</li>
<li>However, $\cosh(x)$ only <em>resembles</em> the regular exponential function. Its natural log will only <em>resemble</em> $f(x) = x$. The resulting function $\ln(\cosh(x))$ looks parabolic near zero, and linear as we grow:</li>
</ul>

<iframe loading="lazy" src="https://www.desmos.com/calculator/lvzowokhhr?embed" width="500px" height="500px" style="border: 1px solid #ccc" frameborder=0></iframe>

<p>How does this work? For small $x$:</p>

<ul>
<li>$\cosh(x) \approx 1 + \frac{x^2}{2}$. These are the first few terms of its Taylor series. </li>
<li>$\ln(1 + x) \approx x$. The time to grow from 1.0 to 1 + .01 at 100% interest is only .01 units (not enough time for compounding)</li>
<li>Combining the approximations, we get: $\ln(\cosh(x)) \approx \ln(1 + \frac{x^2}{2}) \approx \frac{x^2}{2}$.</li>
</ul>

<p>As $x$ increases, we approach an offset line:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/b82889df0ce6427b526446532dd8799c.png' width='524' height='38' alt='\displaystyle{\text{logcosh(x)} = \ln(\cosh(x)) \approx \ln(\frac{e^x + 0}{2}) = \ln(e^x) - \ln(2) = x - \ln(2)}' class='tex'></p>

<p>Cool! We have a parabola-line hybrid. No need for hyperbolas, we're dealing with variations of the exponential function.</p>

<p><strong>Bonus: Lining Things Up</strong></p>

<p>Maybe we can get $\text{logcosh}$ to turn into the line $y = x$, instead of the offset line $y = x - \ln(2)$. We can add a term to undo the $-\ln(2)$:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/7455fce700f1732a76329febc19770d4.png' width='303' height='33' alt='\displaystyle{y\ =\ln\left(\cosh\left(x\right)\right)+\ln\left(2\right)\left(1-e^{-0.1x^{2}}\right)}' class='tex'></p>

<iframe loading="lazy" src="https://www.desmos.com/calculator/nbtdvmryfv?embed" width="400px" height="400px" style="border: 1px solid #ccc" frameborder=0></iframe>

<p>Notes:</p>

<ul>
<li>Our new function (purple) still looks like a parabola for small $x$.</li>
<li>The $x^2$ in the in $e^{-0.1x^2}$ makes the function symmetric.</li>
<li>Adjusting the constant $0.1$ changes how fast we approach the line $y=x$.</li>
</ul>

<p>A short while back, I'd have no idea how to make a parabola gently transition into a line. But seeing $\cosh$ as "parabolic short term, exponential long term" gives us a clue: use the natural log to undo the "exponential long term" behavior, giving us "parabolic short term, linear long term".</p>

<p><strong>Hyperbolic Tangent</strong></p>

<p>The hyperbolic tangent is used as a machine learning activation function:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/7df418726bd940c6ce996d02a1ebaae3.png' width='293' height='44' alt='\displaystyle{\tanh(x) = \frac{\sinh(x)}{\cosh(x)} = \frac{\text{odd part of } e^x}{\text{even part of } e^x}}' class='tex'>
<img decoding="async" alt="Intuitive Guide to Hyperbolic Functions" src="https://betterexplained.com/wp-content/uploads/hyperbolic/tanh.png" style="height: 300px;" /></p>

<p>What's its meaning? It's the ratio between the odd and even parts of the exponential function after a given amount of time.</p>

<ul>
<li>At $x=0$, the even part dominates (full symmetry between past and future)</li>
<li>As $x$ grows, the odd part catches up, and the ratio approaches 1 (equal parts symmetry and anti-symmetry)</li>
</ul>

<p>The function $\tanh$ is nicely centered at 0 and smoothly varies between -1 and 1. As $x$ increases, $\cosh(x) \sim \sinh(x) \sim 0.5e^x$ and $\frac{0.5e^x}{0.5e^x} = 1$.</p>

<h2>Part 4: Geometric Viewpoint</h2>

<p>Ok. We've gone pretty far without talking about hyperbolas. Why?</p>

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

<p>Well, just look at it. They aren't an everyday shape. What's their purpose? Catenaries, orbital mechanics? That's an <em>application</em> but not the reason they exist.</p>

<p>Time to build an intuition.</p>

<h3>The Inverse Function Hyperbola (xy=1)</h3>

<p>Hyperbolas are built from inverse functions, like $y = \frac{1}{x}$. It's a simple, useful relationship: what's the inverse of $x=2$? $y=1/2$. Multiply them and we undo all scaling: $xy=1$.</p>

<p>A burning math question might be: sure, we have this inverse relationship, but what's the area underneath?</p>

<iframe loading="lazy" src="https://www.desmos.com/calculator/jumkqmitkg?embed" width="300px" height="300px" style="border: 1px solid #ccc" frameborder=0></iframe>

<p>In calculus terms, this is:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/02b8240dfb36a3d7993a0776c24a17c6.png' width='120' height='42' alt='\displaystyle{\text{area} = \int_{1}^{x} \frac{1}{x} dx}' class='tex'></p>

<p>Where</p>

<ul>
<li>$\int_1^x$ specifies the boundaries. We start at $x=1$ and go to some upper value for $x$. (We can't start trapping area at $x=0$, since it shoots up to infinity.)</li>
<li>$\frac{1}{x} dx$ is the area we collect at each x-coordinate as we march along</li>
</ul>

<p>This integral is hard. Thankfully, one definition of the natural log is:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/28413008b197f57a9d8adc0099405aa5.png' width='97' height='41' alt='\displaystyle{\ln(x) = \int \frac{1}{x}}' class='tex'></p>

<p>so we have a ready-made solution. Starting from $x=1$, what upper x-coordinate will trap 5 units of area? We want to solve:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/02765dfbd6323e06b18987d951a554d5.png' width='159' height='42' alt='\displaystyle{5 = \int_{1}^{x} \frac{1}{x} dx = \ln(x)}' class='tex'></p>

<p>Which means</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/b5005852e6fa568c5f14f050d6b1a2b1.png' width='112' height='73' alt='&#10;\begin{align*}&#10;5 &amp;= \ln(x) \\ &#10;e^5 &amp;= e^{\ln(x)} \\&#10;148.41 &amp;= x &#10;\end{align*}&#10;' class='tex'></p>

<p>Wow! That's a large coordinate to trap 5 measly units of area.</p>

<p>In general, we have</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/a02973fb411b9d5fda31dfd10cc8f9db.png' width='157' height='14' alt='\displaystyle{e^{\text{area}} = \text{x-coordinate}}' class='tex'></p>

<p>And the y-coordinate (inverse) at that position is $y = \frac{1}{x} = \frac{1}{e^{\text{area}}} = e^{-\text{area}}$.</p>

<h3>The Rotated Hyperbola</h3>

<p>There's multiple ways to make a hyperbolic curve. If we rotate 45 degrees, we get something like this:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/hyperbolic/rotate-hyperbola-axis.png" alt="rotate-hyperbola-axis" /></p>

<p>How do we rotate the equation $xy=1$? The standard way is with a <a href="https://en.wikipedia.org/wiki/Change_of_basis">rotation matrix</a>, but let's do the rotation with <a href="https://betterexplained.com/articles/intuitive-arithmetic-with-complex-numbers/">complex numbers</a>.</p>

<p>Let's treat points as complex numbers: $(x, y) \rightarrow x + yi$. A sample point $(a + bi)$ is on the <em>rotated</em> hyperbola if, after undoing the rotation, we see our original $xy = 1$ relationship.</p>

<ul>
<li>Candidate point: ($a + bi$)</li>
<li>45-degree counterclockwise rotation: $\frac{(1 + i)}{\sqrt{2}}$</li>
</ul>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/fd9dd1a5b7384c1ec80bf6e28f571430.png' width='289' height='17' alt='\displaystyle{\text{original point} = \text{candidiate} \cdot \text{rotation} }' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/d5b869169557d80ba6012cf6eb78cf28.png' width='521' height='43' alt='\displaystyle{= (a + bi)\frac{(1 + i)}{\sqrt{2}} = \frac{1}{\sqrt{2}}[(a + bi^2) + (ai + bi)] = \frac{(a - b)}{\sqrt{2}} + \frac{(a + b)}{\sqrt{2}}i}' class='tex'></p>

<p>Ok, we turned our candidate back to its original (pre-rotation) point, which is at</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/d9b5e62e5505df04d55158d2e30d8d2a.png' width='212' height='44' alt='\displaystyle{(x, y) = \left( \frac{(a - b)}{\sqrt{2}},  \frac{(a + b)}{\sqrt{2}} \right) }' class='tex'></p>

<p>When does it have our $xy=1$ relationship?</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/a6934fd4b43c0664e387e33991ef8eda.png' width='147' height='96' alt='&#10;\begin{align*}&#10;\frac{(a-b)}{\sqrt{2}}\frac{(a+b)}{\sqrt{2}} &amp;= 1 \\&#10;(a - b)(a + b) &amp;= 2 \\&#10;a^2 - b^2 &amp;= 2&#10;\end{align*}&#10;' class='tex'></p>

<p>Ok! Our candidate is on the rotated hyperbola if: $a^2 - b^2 = 2$ or $\text{real magnitude}^2 - \text{imaginary magnitude}^2 = 2$. We can express this requirement in $(x, y)$ notation as:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/0cdb8ca5725f9ca3c2d9edd053340582.png' width='90' height='21' alt='\displaystyle{x^2 - y^2 = 2}' class='tex'></p>

<p>Almost there. Our original hyperbola ($xy = 1$) contains the point $(1, 1)$, which is a distance of $\sqrt{x^2 + y^2} = \sqrt{1^2 + 1^2} = \sqrt{2}$ from the origin. The constraint equation is really $x^2 - y^2 = r^2$.</p>

<p>If we set the radius to 1, we get a formula for the unit hyperbola:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/20d8b66b19f5e150e9aa643c773c988f.png' width='90' height='21' alt='\displaystyle{x^2 - y^2 = 1}' class='tex'></p>

<p>Tada! A nice, clean equation, but I also see it as $(x - y)(x + y) = 1$, which hints at the inverse relationship.</p>

<p>Ok. Time for the scary diagram you'll see in most textbooks:</p>

<p><img decoding="async" alt="Intuitive Guide to Hyperbolic Functions" src="https://betterexplained.com/wp-content/uploads/hyperbolic/hyperbolic-official.png?t=1" /></p>

<p>We have our rotated hyperbola, and want to trap $a/2$ units of area in red. (The full $a$ units would include the area under the x-axis. What functions determine the coordinates that trap this area?</p>

<p>The solution turns out to be the even and odd parts of the exponential, $\cosh$ and $\sinh$. There's a 1950's pamphlet "Hyperbolic Functions" by V. G. Shervatot, that <a href="https://books.google.com/books?id=Qp3RRkjloLsC&amp;printsec=frontcover#v=onepage&amp;q&amp;f=false">goes through the derivation</a>. The key intuition is realizing that hyperbolas (generally speaking) trap area logarithmically, so the necessary coordinates grow exponentially:</p>

<ul>
<li>$xy = 1$ hyperbola (trap area under curve)

<ul>
<li>$\text{x-coordinate} = e^{\text{area}}$</li>
<li>$\text{y-coordinate} = \frac{1}{e^{\text{area}}} =e^{-\text{area}} $</li>
</ul></li>
<li>$x^2 - y^2 = 1$ hyperbola (trap $\frac{\text{area}}{2}$ per diagram)

<ul>
<li>$\text{x-coordinate} = \frac{e^{\text{area}/2} + e^{-\text{area}/2}}{2} = \cosh(x)$</li>
<li>$\text{y-coordinate} = \frac{e^{\text{area}/2} - e^{-\text{area}/2}}{2} = \sinh(x)$</li>
</ul></li>
</ul>

<p>In case it needs to be said: it's <em>not obvious</em> that the even/odd parts of the exponential function determine the coordinates that trap area in a rotated hyperbola.</p>

<p>(Aside: Hyperbolas can be defined in terms of distance to fixed points or a conic section, but this gives no intuition for why exponentials are involved.)</p>

<h3>The Secant/Tangent hyperbola</h3>

<p>One more confusion is why we need <em>new</em> functions to parameterize the hyperbola, when existing trig functions do the trick:</p>

<ul>
<li><p>Start with a circle</p></li>
<li><p>For any angle $x$, we have coordinates $(x, y)$ = $(\cos(x), \sin(x))$</p></li>
<li>If we invert the x coordinate (hey, it's what hyperbolas do), we get $x = \frac{1}{\cos(x)} = \sec(x)$</li>
<li>If we scale the y coordinate by that <em>same inversion</em>, we get $y = \sin(x) \cdot \frac{1}{\cos(x)} = \tan(x)$</li>
</ul>

<p>Does this really make a hyperbola? It meets the requirements:</p>

<ul>
<li><p>$x^2 - y^2 = 1$ (relationship needed for rotated hyperbola)</p></li>
<li><p>$\sec^2(t) - \tan^2(t) = 1$ (rearrangement of the famous $\sec^2(t) = 1 + \tan^2(t)$)</p></li>
</ul>

<p>This video shows how the various parameterizations behave (<a href="https://www.desmos.com/calculator/9d8ez6mf8k">open the calculator</a>):</p>

<video height="500" autoplay loop muted playsinline>
  <source src="https://betterexplained.com/wp-content/uploads/hyperbolic/hyperbola-circle-moving.mp4" type="video/mp4" />
</video>

<p>Our familiar trig functions ($\sec(t), \tan(t))$ trace the <em>same hyperbola</em> as the fancy new $(\cosh(t), \sinh(t))$. They just go a different speed. And the parameter $t$ is just an everyday angle we plug into trig functions.</p>

<p>Although there are multiple parameterizations for the hyperbola, $\cosh$ and $\sinh$ are defined with exponentials and are the analog of $\sin$ and $\cos$ in Euler's Formula. They can wear the Official Hyperbolic Parameterization crown.</p>

<h3>Revisiting Inverse Functions</h3>

<p>The inverse hyperbolic functions go from coordinates back to area. Let's say I'm on the unit hyperbola, with an x-coordinate of 5. How much area have I trapped? $\text{acosh}(5) = 2.29$.</p>

<p>The inverse functions are sometimes called $\text{arcosh}$ ("area hyperbolic cosine"). This forces us to think about the coordinate-to-area conversion. I prefer to think about exponentials, and use $\text{acosh}$ ("inverse hyperbolic cosine"). Area is one interpretation, don't force me into it.</p>

<p>We can derive the formulas for the inverse functions by <a href="http://www.math.uaa.alaska.edu/~afmaf/classes/math252/notes/InverseHyperbolic.pdf">solving</a> $x = \cosh(y)$ and $x = \sinh(y)$:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/977b9b7c4260a1e7e2b4e610ddf4292e.png' width='219' height='24' alt='\displaystyle{\text{acosh(x)} = \ln(x + \sqrt{x^2 - 1})}' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/092cf7bf32539e1e97f5a974b08879a4.png' width='217' height='24' alt='\displaystyle{\text{asinh(x)} = \ln(x + \sqrt{x^2 + 1})}' class='tex'></p>

<p>As expected, these look like modified logarithms. As $x$ grows, they approach $\ln(x + x) = \ln(2x) = \ln(x) + \ln(2)$, or the natural logarithm with an offset.</p>

<h2>Part 5: Applications of the Geometric Interpretation</h2>

<h3>The Catenary</h3>

<p>The main application of the geometric view is that the $\cosh(x)$ is the shape a rope takes when hanging between two fixed points. It's not quite a parabola, it's a <a href="https://en.wikipedia.org/wiki/Catenary">catenary curve</a>, with the St. Louis Arch as a <a href="http://astro1.panet.utoledo.edu/~khare/teaching/CM-Fall-2007/notes/StLouisArch.htm">famous example</a>. Here's a few more curves (<a href="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3d/Catenary-tension.svg/700px-Catenary-tension.svg.png">source</a>) that follow $\cosh(x)$:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/hyperbolic/catenary-tension.png?t=1" alt="catenary chart" /></p>

<p>The process to build this curve is fairly subtle:</p>

<ul>
<li>First, create a rotated hyperbola with $x^2 - y^2 = 1$</li>
<li>Instead of using the hyperbola, make a graph of <em>just the x-coordinate</em>.</li>
<li>This graph of <em>just the x-coordinate</em> makes a new curve, which models how the rope hangs</li>
</ul>

<p>This convoluted process isn't how $\cosh$ was discovered. There's a differential equation that models the forces inside a hanging rope:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/f89cdd5876634456df62922f4371ab55.png' width='58' height='38' alt='\displaystyle{\frac{dy}{dx} = \frac{s}{a}}' class='tex'></p>

<p>To <a href="https://en.wikipedia.org/wiki/Catenary#Derivation_of_equations_for_the_curve">solve</a> the differential equation, we need the convenient exponential properties of $\cosh$, and wind up with:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/645c37e862f0fab3afa51607459417c3.png' width='107' height='34' alt='\displaystyle{y = a \cosh(\frac{x}{a})}' class='tex'></p>

<p>It's cute that $\cosh$ parameterizes a hyperbola, but that interpretation has nothing to do with why it's the solution. I think "the catenary follows the even part of the exponential function" not "the catenary follows the x-coordinate of the hyperbola".</p>

<h3>Shape Where Arc Length = Area</h3>

<p>The area under the exponential $e^x$ equals the current value (plus a constant). Consider the region from $x=0$ to $x=2$:</p>

<p><img decoding="async" alt="Intuitive Guide to Hyperbolic Functions" src="https://betterexplained.com/wp-content/uploads/hyperbolic/e-x-area.png" style="height: 300px;" /></p>

<ul>
<li>Area under curve: $\int_0^2 e^x = e^2 - e^0 = 7.389 - 1 = 6.389$</li>
<li>Current value: $e^2 = 7.389$</li>
<li>Pattern: $\text{current value} = \text{area under curve} - 1$</li>
</ul>

<p>A pretty clean connection, right? (Don't forget that $+C$)</p>

<p>Now how about $\cosh$?</p>

<p><img decoding="async" alt="Intuitive Guide to Hyperbolic Functions" src="https://betterexplained.com/wp-content/uploads/hyperbolic/cosh-x-area.png" style="height: 300px;" /></p>

<ul>
<li>Current value: $\cosh(x)$</li>
<li>Area under curve:  $\int \cosh(x) = \sinh(x)$</li>
<li><a href="https://en.wikipedia.org/wiki/Arc_length#Finding_arc_lengths_by_integrating">Arc length</a> of curve: $\int \sqrt{1 + (\cosh'(x))^2} = \int \sqrt{1 + \sinh^2(x)} = \int \cosh(x) = \sinh(x)$</li>
<li>Pattern: $\text{area under curve} = \text{arc length} = \sqrt{\text{current value}^2 - 1}$</li>
</ul>

<p>The current value of $\cosh$ can be swapped in using the identity $\sqrt{\cosh^2 - 1} = \sinh$.</p>

<p>For large $x$, the $-1$ is negligible and $\sqrt{\text{current value}^2 - 1} \sim \text{current value}$. So, for large $x$, we get equality between area, arc length, and current value (imagine the green rope hanging down and just touching the x-axis). It's more connected than regular $e^x$, not bad!</p>

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

<p>(Intuition for another day: Math deals with unitless quantities. $13 \ \text{cm}$ is not directly comparable with $13 \ \text{cm}^2$. Yet in math class, we can solve $x = 1 + x^2$ and nobody cares that constant, linear and squared terms are used in conjunction.)</p>

<h3>Hyperbolic Geometry</h3>

<p>The <a href="https://www.quantamagazine.org/what-is-the-geometry-of-the-universe-20200316/">shape of the universe</a> may be a hyperbola, and <a href="https://en.wikipedia.org/wiki/Hyperbolic_geometry">hyperbolic geometry</a> is used in special relativity (beyond my pay grade). If we do live in a giant hyperbola, I, uh, may be forced to recant my "exponentials first" stance.</p>

<h2>Summary</h2>

<p>The hyperbolic functions can be seen as exponential functions (relating time and growth) or geometric functions (relating area and coordinates). Hyperbolas, generally speaking, have logarithmic area and exponential coordinates.</p>

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

<p>It's been a long journey, but these functions don't haunt my attic any more.</p>

<p>Happy math.</p>

<h2>References</h2>

<ul>
<li><a href="https://archive.lib.msu.edu/crcmath/math/math/h/h409.htm">Various Hyperbolic Relations</a></li>
<li><a href="https://www.maa.org/sites/default/files/321922717729.pdf.bannered.pdf">Enter, Stage Center: The Early Drama of the Hyperbolic Function (pdf)</a></li>
<li><a href="https://math.stackexchange.com/questions/138842/proof-of-osbornes-rule">Proof of Osborne's Rule</a></li>
<li><a href="https://math.sci.ccny.cuny.edu/document/Rotation+of+Axes">Rotating the xy=1 hyperbola</a></li>
<li><a href="https://www.google.com/books/edition/Hyperbolic_Functions/Qp3RRkjloLsC?q=&amp;gbpv=0#f=false">Hyperbolic Functions by V. G. Shervatov</a> </li>
<li><a href="https://math.stackexchange.com/questions/757091/alternative-definition-of-hyperbolic-cosine-without-relying-on-exponential-funct/757241#757241">Geometric derivation of hyperbolic functions</a></li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://betterexplained.com/articles/hyperbolic-functions/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		<enclosure url="https://betterexplained.com/wp-content/uploads/hyperbolic/hyperbola-circle-moving.mp4" length="995151" type="video/mp4" />

			</item>
		<item>
		<title>Intuitive Guide to Convolution</title>
		<link>https://betterexplained.com/articles/intuitive-convolution/</link>
					<comments>https://betterexplained.com/articles/intuitive-convolution/#comments</comments>
		
		<dc:creator><![CDATA[kalid]]></dc:creator>
		<pubDate>Mon, 23 Nov 2020 19:08:46 +0000</pubDate>
				<category><![CDATA[Calculus]]></category>
		<category><![CDATA[Convolution]]></category>
		<category><![CDATA[Fourier Transform]]></category>
		<guid isPermaLink="false">https://betterexplained.com/?p=12383</guid>

					<description><![CDATA[Like making engineering students squirm? Have them explain convolution and (if you're barbarous) the convolution theorem. They'll mutter something about sliding windows as they try to escape through one. Convolution is usually introduced with its formal definition: Yikes. Let's start without calculus: Convolution is fancy multiplication. Part 1: Hospital Analogy Imagine you manage a hospital [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Like making engineering students squirm? Have them explain convolution and (if you're barbarous) the convolution theorem. They'll mutter something about sliding windows as they try to escape through one.</p>

<p>Convolution is usually introduced with its formal definition:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/3b38c59c70f4d4c69bbc5d81c2fd0d91.png' width='250' height='43' alt='\displaystyle{ (f * g )(t) = \int_{-\infty}^\infty f(\tau) g(t - \tau) d\tau }' class='tex'></p>

<p>Yikes. Let's start <em>without</em> calculus: <strong>Convolution is fancy multiplication.</strong></p>

<p></p>

<h2>Part 1: Hospital Analogy</h2>

<p>Imagine you manage a hospital treating patients with a single disease. You have:</p>

<ul>
<li><strong>A treatment plan:</strong> <code>[3]</code> Every patient gets 3 units of the cure on their first day.</li>
<li><strong>A list of patients:</strong> <code>[1 2 3 4 5]</code> Your patient count for the week (1 person Monday, 2 people on Tuesday, etc.).</li>
</ul>

<p>Question: How much medicine do you use each day? Well, that's just a quick multiplication:</p>

<pre><code>Plan  *  Patients       = Daily Usage
[3]   *  [1 2 3 4 5]    = [3 6 9 12 15]
</code></pre>

<p>Multiplying the plan by the patient list gives the usage for the upcoming days: <code>[3 6 9 12 15]</code>. Everyday multiplication (<code>3 x 4</code>) means using the plan with a single day of patients: <code>[3] * [4] = [12]</code>.</p>

<h3>Intuition For Convolution</h3>

<p>Let's say the disease mutates and requires a multi-day treatment. You create a new plan: <code>Plan: [3 2 1]</code></p>

<p>That means 3 units of the cure on the first day, 2 on the second, and 1 on the third. Ok. Given the same patient schedule  <code>[1 2 3 4 5]</code>, what's our medicine usage each day?</p>

<p>Uh... shoot. It's not a quick multiplication:</p>

<ul>
<li>On Monday, 1 patient comes in. It's her first day, so she gets 3 units.</li>
<li>On Tuesday, the Monday gal gets 2 units (her second day), but two new patients arrive, who get 3 each (2 * 3 = 6). The total is 2 + (2 * 3) = 8 units.</li>
<li>On Wednesday, it's trickier: The Monday gal finishes (1 unit, her last day), the Tuesday people get 2 units (2 * 2), and there are 3 new Wednesday people... argh.</li>
</ul>

<p>The patients are overlapping and it's hard to track. How can we organize this calculation?</p>

<p>An idea: imagine <em>flipping</em> the patient list, so the first patient is on the right:</p>

<pre><code>           Start of line
 5 4 3 2 1
</code></pre>

<p>Next, imagine we have 3 separate rooms where we apply the proper dose:</p>

<pre><code> Rooms     3 2 1              
</code></pre>

<p>On your first day, you walk into the first room and get 3 units of medicine. The next day, you walk into room #2 and get 2 units. On the last day, you walk into room #3 and get 1 unit. There's no rooms afterwards, and your treatment is done.</p>

<p>To calculate the total medicine usage, line up the patients and walk them through the rooms:</p>

<pre><code> Monday
 ----------------------------
 Rooms                  3 2 1                                      
 Patients       5 4 3 2 1

 Usage                  3
</code></pre>

<p>On Monday (our first day), we have a single patient in the first room. She gets 3 units, for a total usage of 3. Makes sense, right?</p>

<p>On Tuesday, everyone takes a step forward:</p>

<pre><code> Tuesday
 ----------------------------
 Rooms                  3 2 1              
 Patients -&gt;      5 4 3 2 1

 Usage                  6 2      = 8
</code></pre>

<p>The first patient is now in the second room, and there's 2 new patients in the first room. We multiply each room's dose by the patient count, then combine.</p>

<p>Every day we just walk the list forward:</p>

<pre><code> Wednesday
 ----------------------------
 Rooms                  3 2 1              
 Patients -&gt;        5 4 3 2 1

 Usage                  9 4 1    = 14


 Thursday
 -----------------------------
 Rooms                  3 2 1              
 Patients -&gt;          5 4 3 2 1

 Usage                 12 6 2    = 20


 Friday
 -----------------------------
 Rooms                  3 2 1              
 Patients -&gt;            5 4 3 2 1

 Usage                 15 8 3    = 26
</code></pre>

<p>Whoa! It's intricate, but we figured it out, right? We can find the usage for any day by reversing the list, sliding it to the desired day, and combining the doses.</p>

<p>The total day-by-day usage looks like this (don't forget Sat and Sun, since some patients began on Friday):</p>

<pre><code>Plan      *  Patient List   = Total Daily Usage

[3 2 1]   *  [1 2 3 4 5]    = [3 8 14 20 26 14 5]
              M T W T F        M T W  T  F  S  S
</code></pre>

<p>This calculation is the <em>convolution</em> of the plan and patient list. It's a fancy multiplication between a list of input numbers and a "program".</p>

<h3>Interactive Demo</h3>

<p>Here's a <a href="https://www.desmos.com/calculator/uxtsoxmppq">live demo</a>. Try changing <code>F</code> (the plan) or <code>G</code> (the patient list). The convolution $c(t)$ matches our manual calculation above.</p>

<iframe loading="lazy" src="https://www.desmos.com/calculator/lrcayuc5te" width="100%" height="700px" style="left: 0%; max-width: 100vw; position: relative; width: 100vw; max-width: 900px;" frameborder=0></iframe>

<p>(We define functions $f(x)$ and $g(x)$ to pad each list with zero, and adjust for the list index starting at 1.)</p>

<p>You can do a quick convolution with <a href="https://www.wolframalpha.com/input/?i=ListConvolve%5B%7B3%2C+2%2C+1%7D%2C+%7B1%2C+2%2C+3%2C+4%2C+5%7D%2C+%7B1%2C+-1%7D%2C+0%5D+">Wolfram Alpha</a>:</p>

<pre><code>ListConvolve[{3, 2, 1}, {1, 2, 3, 4, 5}, {1, -1}, 0]
{3, 8, 14, 20, 26, 14, 5}
</code></pre>

<p>(The extra <code>{1, -1}, 0</code> aligns the lists and pads with zero.)</p>

<h3>Application: COVID Ventilator Usage</h3>

<p>I started this article 5 years ago (intuition takes a while...), but unfortunately the analogy is relevant today.</p>

<p>Let's use convolution to estimate ventilator usage for incoming patients.</p>

<ul>
<li>Set $f(x)$ as the percent of patients needing ventilators. For example, <code>[.05 .03 .01]</code> means 5% of patients need ventilators the first week, 3% the second week, and 1% the third week.</li>
<li>Set $g(x)$ as the weekly incoming patients, in thousands.</li>
<li>The convolution $c(t) = f * g$, shows how many ventilators are needed each week (in thousands). $c(5)$ is how many ventilators are needed 5 weeks from now.</li>
</ul>

<p>Let's try it out:</p>

<ul>
<li><code>F = [.05, .03, .01]</code> is the ventilator use percentage by week</li>
<li><code>G = [10, 20, 30, 20, 10, 10, 10]</code>, is the incoming hospitalized patients. It starts at 10k per week, rises to 30k, then decays to 10k.</li>
</ul>

<p>With these numbers, we expect a max ventilator use of 2.2k in 2 weeks:</p>

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

<p>The convolution drops to 0 after 9 weeks because the patient list has run out. In this example, we're interested in the peak value the convolution hits, not the long-term total.</p>

<p>Other plans to convolve may be drug doses, vaccine appointments (one today, another a month from now), reinfections, and other complex interactions.</p>

<p>The hospital analogy is the mental model I wish I had when learning. Now that we've tried it with actual numbers, let's add the Math Juice and convert the analogy to calculus.</p>

<h2>Part 2: The Calculus Definition</h2>

<p>So, what happened in our example? We had a list of patients and a plan. If the plan were simple (single day <code>[3]</code>), regular multiplication would have worked. Because the plan was complex, we had to "convolve" it.</p>

<p>Time for some Fun Facts&#x2122;:</p>

<ul>
<li><p>Convolution is written $f * g$, with an asterisk. Yes, an asterisk usually indicates multiplciation, but in advanced calculus class, it indicates a convolution. Regular multiplication is just implied ($fg$).</p></li>
<li><p>The result of a convolution is a new <em>function</em> that gives the total usage for any day ("What was the total usage on day $t=3$?"). We can graph the convolution over time to see the day-by-day totals.</p></li>
</ul>

<p>Now the big aha: <strong>Convolution reverses one of the lists!</strong> Here's why.</p>

<p>Let's call our treatment plan $f(x)$. In our example, we used <code>[3 2 1]</code>.</p>

<p>The list of patients (inputs) is $g(x)$. However, we need to <em>reverse</em> this list as we slide it, so the earliest patient (Monday) enters the hospital first (first in, first out). This means we need to use $g(-x)$, the horizontal reflection of $g(x)$. <code>[1 2 3 4 5]</code> becomes <code>[5 4 3 2 1]</code>.</p>

<p>Now that we have the reversed list, pick a day to compute ($t = 0, 1, 2...$). To slide our patient list by this much, we use: $g(-x + t)$. That is, we reverse the list ($-x$) and jump to the correct day ($+t$).</p>

<p>We have our scenario:</p>

<ul>
<li>$f(x)$ is the plan to use</li>
<li>$g(-x + t)$ is the list of inputs (flipped and slid to the right day).</li>
</ul>

<p>To get the total usage on day $t$, we multiply each patient with the plan, and sum the results (an integral). To account for any possible length, we go from -infinity to +infinity.</p>

<p>Now we can describe convolution formally using calculus:</p>

<p><img decoding="async" src="https://betterexplained.com/ColorizedMath/img/Convolution.png" alt="convolution" /></p>

<p>(Like <a href="https://betterexplained.com/articles/colorized-math-equations/">colorized math</a>? There's more.)</p>

<p>Phew! That's quite few symbols. Some notes:</p>

<ul>
<li>We use a dummy variable $\tau$ (tau) for the intermediate computation. Imagine $\tau$ as knocking on each room ($\tau={0, 1, 2, 3...}$), finding the dosage [$f(\tau)$], the number of patients [$g(t - \tau)$], multiplying them, and totaling things in the integral. Yowza. The so-called "dummy" variable $\tau$ is like <code>i</code> in a <code>for</code> loop: it's temporary, but does the work. (By analogy, $t$ is a global variable has a fixed value during the loop: it's the day we're calculating the usage for, such as <code>t = Day 5</code>).</li>
<li>In the official definition, you'll see $g(t - \tau)$ instead of $g(- \tau+ t)$. The second version shows the flip ($-\tau$) and slide ($+t$). Writing $g(t - \tau)$ makes it seem like we're interested in the difference between the variables, which confused me.</li>
<li>The treatment plan (program to run) is called the <em>kernel</em>: you convolve a kernel with an input.</li>
</ul>

<p>Not too bad, right? The equation is a formal description of the analogy.</p>

<h2>Part 3: Mathematical Properties of Convolution</h2>

<p>We can't discover a new math operation without taking it for a spin. Let's see how it behaves.</p>

<h3>Convolution is commutative: f * g = g * f</h3>

<p>In our computation, we flipped the patient list and kept the plan the same. Could we have flipped the plan instead?</p>

<p>You bet. Imagine the patients are immobile, and stay in their rooms: <code>[1 2 3 4 5]</code>. To deliver the medicine, we have 3 medical carts that go to each room and deliver the dose. Each day, they slide forward one position.</p>

<pre><code>  Carts -&gt;
  1 2 3

      1 2 3 4 5
      Patients
</code></pre>

<p>As before, though our plan is written <code>[3 2 1]</code> (3 units on the first day), we flip the order of the carts to<code>[1 2 3]</code>. That way, a patient gets 3 units on their first day, as we expect. Checking with Wolfram Alpha, the <a href="https://www.wolframalpha.com/input/?i=ListConvolve%5B%7B1%2C+2%2C+3%2C+4%2C+5%7D%2C+%7B3%2C+2%2C+1%7D%2C+%7B1%2C+-1%7D%2C+0%5D+">calculation</a> is the same.</p>

<pre><code>ListConvolve[{1, 2, 3, 4, 5}, {3, 2, 1}, {1, -1}, 0]
{3, 8, 14, 20, 26, 14, 5}
</code></pre>

<p>Cool! It looks like convolution is commutative:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/e16bac899ff20ecdadbab51b60c37d3b.png' width='97' height='17' alt='\displaystyle{f * g = g * f}' class='tex'></p>

<p>and we can decide to flip either $f$ or $g$ when calculating the integral. Surprising, right?</p>

<h3>The integral of the convolution</h3>

<p>When all treatments are finished, what was the <em>total</em> medicine usage? This is the <strong>integral of the convolution</strong>. (A few minutes ago, that phrase would have you jumping out of a window.)</p>

<p>But it's a simple calculation. Our plan gives each patient <code>sum([3 2 1]) = 6</code> units of medicine. And we have <code>sum([1 2 3 4 5]) = 15</code> patients. The total usage is just <code>6 x 15 = 90</code> units.</p>

<p>Wow, that was easy: the usage for the <em>entire</em> convolution is just the product of the subtotals!</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/56e822f91d16dfbb8f13a0a8d52d0b46.png' width='168' height='41' alt='\displaystyle{\int (f * g) = \int f \cdot \int g }' class='tex'></p>

<p>I hope this clicks intuitively. Note that this trick works for convolution, but not integrals in general. For example:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/78f2d953a7a319e8866bcc10aa892a79.png' width='165' height='41' alt='\displaystyle{ \int (x \cdot x) \ne \int x \cdot \int x }' class='tex'></p>

<p>If we separate $x \cdot x$ into two integrals we get:</p>

<ul>
<li>$ \int (x \cdot x) = \int x^2 = \frac{1}{3} x^3 $ </li>
<li>$\int x \cdot \int x = \frac{1}{2}x^2 \cdot \frac{1}{2}x^2 = \frac{1}{4}x^4$</li>
</ul>

<p>and those aren't the same. (Calculus would be much easier if we could split integrals like this.) It's strange, but $\int (f * g)$ is probably easier to solve than $\int (fg)$.</p>

<h3>Impulse Response</h3>

<p>What happens if we sent a single patient through the hospital? The convolution would just be that day's plan.</p>

<pre><code>Plan    * Patients = Convolution
[3 2 1] * [1]      = [3 2 1]
</code></pre>

<p>In other words, convolving with <code>[1]</code> gives us the original plan.</p>

<p>In calculus terms, a spike of <code>[1]</code> (and 0 otherwise) is the <a href="https://en.wikipedia.org/wiki/Dirac_delta_function">Dirac Delta Function</a>. In terms of convolutions, this function acts like the number 1 and returns the original function:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/b29d7fb1b5d01e09a53c6559aa4b95a8.png' width='132' height='19' alt='\displaystyle{f(t) * \delta(t) = f(t)}' class='tex'></p>

<p>We can delay the delta function by T, which delays the resulting convolution function too. Imagine our single patient shows up a week late ($\delta(t - T)$), so our medicine usage gets delayed for a week too:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/1507a724e304125262fce84ee01f209c.png' width='202' height='19' alt='\displaystyle{f(t) * \delta(t - T) = f(t - T)}' class='tex'></p>

<h2>Part 4: Convolution Theorem &amp; The Fourier Transform</h2>

<p>The <a href="https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/">Fourier Transform</a> (written with a fancy $\mathscr{F}$) converts a function $f(t)$ into a list of cyclical ingredients $F(s)$:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/8c9ad40ce73b75644d58416c309d966d.png' width='101' height='25' alt='\displaystyle{f(t) \xrightarrow{\mathscr{F}} F(s)}' class='tex'></p>

<p>As an operator, this can be written $\mathscr{F}\lbrace f \rbrace = F$.</p>

<p>In our analogy, we convolved the plan and patient list with a fancy multiplication. Since the Fourier Transform gives us lists of ingredients, could we get the same result by mixing the <em>ingredient lists</em>?</p>

<p>Yep, we can: <strong>Fancy multiplication in the regular world is <em>regular</em> multiplication in the fancy world.</strong></p>

<p>In math terms, "Convolution in the time domain is multiplication in the frequency (Fourier) domain."</p>

<p>Mathematically, this is written:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/975d50cac9c5ad016dec8d02a36d609c.png' width='99' height='25' alt='\displaystyle{f * g \xrightarrow{\mathscr{F}} FG}' class='tex'></p>

<p>or</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/9de81fb69762e5905e57bfe66b54bdf8.png' width='126' height='19' alt='\displaystyle{\mathscr{F}\lbrace f * g \rbrace = FG}' class='tex'></p>

<p>where $f(x)$ and $g(x)$ are functions to convolve, with transforms $F(s)$ and $G(s)$.</p>

<p>We can <a href="https://www-structmed.cimr.cam.ac.uk/Course/Convolution/convolution.html">prove this theorem</a> with advanced calculus, that uses theorems I don't quite understand, but let's think through the meaning.</p>

<p>Because $F(s)$ is the Fourier Transform of $f(t)$, we can ask for a specific frequency ($s = 2\text{Hz}$) and get the <em>combined interaction</em> of every data point with that frequency. Let's suppose:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/0884a3f9a6e39cfddf47bc84424a6d89.png' width='98' height='19' alt='\displaystyle{F(2) = 3 + i}' class='tex'></p>

<p>That means after every data point has been multiplied against the 2Hz cycle, the result is $3 + i$. But we could have kept each interaction separate:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/23d27254660014f82e5c40701fc59a5e.png' width='303' height='19' alt='\displaystyle{F(2) = 3 + i = c_0 + c_1 + c_2 + c_3 ... + c_t}' class='tex'></p>

<p>Where $c_t$ is the contribution to the 2Hz frequency from datapoint $t$. Similarly, we can expand $G(s)$ into a list of interactions with the 2Hz ingredient. Let's suppose $G(2) = 7 - i$:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/173bd83355b2b44e61b86c691e34d49c.png' width='311' height='19' alt='\displaystyle{G(2) = 7 - i = d_0 + d_1 + d_2 + d_3 ... + d_t}' class='tex'></p>

<p>The Convolution Theorem is really saying:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/e7a16cd19ecb142a8c2905935522697b.png' width='414' height='25' alt='\displaystyle{f * g \xrightarrow{\mathscr{F}} FG = (c_0 + c_1 + c_2 + ...)(d_0 + d_1 + d_2 + ...)}' class='tex'></p>

<p>Our convolution in the regular domain involves a lot of cross-multiplications. In the fancy frequency domain, we <em>still</em> have a bunch of interactions, but $F(s)$ and $G(s)$ have consolidated them. We can just multiply $F(2)G(2) = (3 + i)(7-i)$ to find the 2Hz ingredient in the convolved result.</p>

<p>By analogy, suppose you want to calculate:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/833c92dbdffc2f4600786c0d34386a51.png' width='260' height='19' alt='\displaystyle{(1 + 2 + 3 + 4)(5 + 6 + 7 + 8) = ?}' class='tex'></p>

<p>It's a lot of work to cross-multiply every term: $(1 \cdot 5) + (1\cdot 6) + (1\cdot 7) + ...$</p>

<p>It's better to consolidate the groups into $(1 + 2 + 3 + 4) = 10$ and $(5 + 6 + 7 + 8) = 26$, and <em>then</em> multiply to get $10 \cdot 26 = 260$.</p>

<p>This nuance caused me a lot of confusion. It seems like $FG$ is a single multiplication, while $f * g$ involves a bunch of intermediate terms. I forgot that $F$ already did the work of merging a bunch of entries into a single one.</p>

<p>Now, we aren't <em>quite</em> done.</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/b16131bbdcf74439d0327764cc3d3874.png' width='154' height='25' alt='\displaystyle{f * g \xrightarrow{\mathscr{F}} FG \xrightarrow{\mathscr{F^{-1}}} \ ?}' class='tex'></p>

<p>We can convert $f * g$ in the time domain into $FG$ in the frequency domain, but we probably need it back in the time domain for a usable result:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/4838206025511ca3236c054e272048a5.png' width='144' height='21' alt='\displaystyle{f * g = \mathscr{F}^{-1} \lbrace FG \rbrace}' class='tex'></p>

<p>You have a riddle in English ($f * g$), you translate it to French ($FG$), get your smart French friend to work out that calculation, then convert it back to English ($\mathscr{F}^{-1}$).</p>

<h3>And in reverse...</h3>

<p>The convolution theorem works this way too:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/c5a0816925f9e3aa674885d90abe00b2.png' width='99' height='25' alt='\displaystyle{fg \xrightarrow{\mathscr{F}} F * G}' class='tex'></p>

<p><strong>Regular multiplication in the regular world is fancy multiplication in the fancy world.</strong></p>

<p>Cool, eh? Instead of multiplying two functions like some cave dweller, put on your monocle, convolve the Fourier Transforms, and and convert to the time domain:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/6869aaa36d056ce64f590d5d92220d83.png' width='144' height='21' alt='\displaystyle{fg = \mathscr{F}^{-1} \lbrace F*G \rbrace}' class='tex'></p>

<p>I'm not saying this is fun, just that it's possible. If your French friend has a gnarly calculation they're struggling with, it might look like arithmetic to you.</p>

<h3>Mini proof</h3>

<p>Remember how we said the integral of a convolution was a multiplication of the individual integrals?</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/56e822f91d16dfbb8f13a0a8d52d0b46.png' width='168' height='41' alt='\displaystyle{\int (f * g) = \int f \cdot \int g }' class='tex'></p>

<p>Well, the Fourier Transform is just a very specific integral, right?</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/502869363dd0f3b4dc8a76053bcbb534.png' width='64' height='41' alt='\displaystyle{\int \rightarrow \mathscr{F}}' class='tex'></p>

<p>So (handwaving), it seems we could swap the general-purpose integral $\int$ for $\mathscr{F}$ and get</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/56b33fef4c78829009660e538336af81.png' width='191' height='19' alt='\displaystyle{\mathscr{F} (f * g) = \mathscr{F} (f) \cdot \mathscr{F} (g) }' class='tex'></p>

<p>which is the convolution theorem. I need a deeper intuition for the <a href="https://math.stackexchange.com/questions/1077990/integral-of-the-convolution-of-two-functions-int-infty-infty-fgxd">proof</a>, but this helps things click.</p>

<h2>Part 5: Applications</h2>

<p>The trick with convolution is finding a useful "program" (kernel) to apply to your input. Here's a few examples.</p>

<h3>Moving averages</h3>

<p>Let's say you want a moving average between neighboring items in a list. That is half of each element, added together:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/4e9c801fbbc424a674e4e466d939a091.png' width='113' height='38' alt='\displaystyle{\frac{a + b}{2} = \frac{a}{2} + \frac{b}{2}}' class='tex'></p>

<p>This is a "multiplication program" of <code>[0.5 0.5]</code> convolved with our list:</p>

<pre><code>ListConvolve[{1, 4, 9, 16, 25}, {0.5, 0.5}, {1, -1}, 0] 
{0.5, 2.5, 6.5, 12.5, 20.5, 12.5}
</code></pre>

<p>We can perform a moving average with a single operation. Neat!</p>

<p>A 3-element moving average would be <code>[.33 .33 .33]</code>, a weighted average could be <code>[.5 .25 .25]</code>.</p>

<h3>Derivatives</h3>

<p>The derivative finds the difference between neighboring values. Here's the plan: <code>[1 -1]</code></p>

<pre><code>ListConvolve[{1, 2, 3, 4, 5}, {1, -1}, {1, -1}, 0] 
{1, 1, 1, 1, 1, -5}                         // -5 since we ran out of entries

ListConvolve[{1, 4, 9, 16, 25}, {1, -1}, {1, -1}, 0] 
{1, 3, 5, 7, 9, -25}                        // discrete derivative is 2x + 1
</code></pre>

<p>With a simple kernel, we can find a useful math property on a discrete list. And to get a second derivative, just apply the derivative convolution twice:</p>

<p><code>F * [1 -1] * [1 -1]</code></p>

<p>As a shortcut, we can precompute the final convolutions (<code>[1 -1] * [1 -1]</code> ) and get:</p>

<pre><code>ListConvolve[{1, -1}, {1,-1}, {1, -1}, 0] 
{1, -2, 1}
</code></pre>

<p>Now we have a <em>single</em> kernel <code>[1, -2, 1]</code> that gets the second derivative of a list:</p>

<pre><code>ListConvolve[{1, 4, 9, 16, 25}, {1, -2, 1}, {1, -1}, 0] 
{1, 2, 2, 2, 2, -34, 25}
</code></pre>

<p>Excluding the boundary items, we get the expected second derivative:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/93d03b535aa28ab5c13b0e3d7ef4dec2.png' width='147' height='23' alt='\displaystyle{x^2 \xrightarrow{d/dx} 2x \xrightarrow{d/dx} 2}' class='tex'></p>

<h3>Blurring / unblurring images</h3>

<p>An image blur is essentially a convolution of your image with some "blurring kernel":</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/a133d2923fb791fe5e9bd5474083ada4.png' width='178' height='17' alt='\displaystyle{\text{blurred} = \text{image} * \text{blur}}' class='tex'></p>

<p>The blur of our 2D image requires a <a href="https://en.wikipedia.org/wiki/Kernel_(image_processing)">2D average</a>:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/convolution/convolution-blur-wikipedia.png" alt="Kernel__image_processing__-_Wikipedia" /></p>

<p>Can we undo the blur? Yep! With our friend the Convolution Theorem, we can do:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/a133d2923fb791fe5e9bd5474083ada4.png' width='178' height='17' alt='\displaystyle{\text{blurred} = \text{image} * \text{blur}}' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/1e2717feb61734bf83d7818c909d24a5.png' width='250' height='19' alt='\displaystyle{\mathscr{F} \lbrace \text{blurred} \rbrace = \mathscr{F} \lbrace \text{image} * \text{blur} \rbrace}' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/45f6a8360051ab4ec3ba8e5af159b539.png' width='270' height='19' alt='\displaystyle{\mathscr{F} \lbrace \text{blurred} \rbrace = \mathscr{F} \lbrace \text{image} \rbrace \mathscr{F} \lbrace \text{blur} \rbrace}' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/417952a1063203f96d0b0428209b56fd.png' width='203' height='44' alt='\displaystyle{\frac{ \mathscr{F} \lbrace \text{blurred} \rbrace }{\mathscr{F} \lbrace \text{blur} \rbrace} = \mathscr{F} \lbrace \text{image} \rbrace }' class='tex'></p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/ac0a303f5414c3148279e482d396cae1.png' width='224' height='44' alt='\displaystyle{\mathscr{F}^{-1} \lbrace \frac{ \mathscr{F} \lbrace \text{blurred} \rbrace }{\mathscr{F} \lbrace \text{blur} \rbrace} \rbrace = \text{image}}' class='tex'></p>

<p>Whoa! We can recover the original image by dividing out the blur. Convolution is a simple multiplication in the frequency domain, and <em>deconvolution</em> is a simple division in the frequency domain.</p>

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

<p>A short while back, the concept of "deblurring by dividing Fourier Transforms" was gibberish to me. While it can be daunting mathematically, it's getting simpler conceptually.</p>

<p>More reading:</p>

<ul>
<li>Wikipedia on <a href="https://en.wikipedia.org/wiki/Deconvolution">deconvolution</a>,  <a href="https://en.wikipedia.org/wiki/Deblurring">deblurring</a>.</li>
<li><a href="http://www.robots.ox.ac.uk/~az/lectures/ia/lect3.pdf">Image Restoration Lecture</a>, <a href="http://user.engineering.uiowa.edu/~dip/LECTURE/PreProcessing4.html#invconvolution">another one</a>, and <a href="http://fourier.eng.hmc.edu/e161/demos/e161_demo4.html">example for above</a></li>
<li><a href="https://www.mathworks.com/help/images/deblurring-images-using-the-blind-deconvolution-algorithm.html">Blind deconvolution</a> is when you don't know the blur kernel (make a guess)</li>
</ul>

<h3>Algorithm Trick: Multiplication</h3>

<p>What is a number? A list of digits:</p>

<pre><code>1234 = 1000 + 200 + 30 + 4 = [1000 200 30 4]
5678 = 5000 + 600 + 70 + 8 = [5000 600 70 8]
</code></pre>

<p>And what is regular, grade-school multiplication? A digit-by-digit convolution! We sweep one list of digits by the other, multiplying and adding as we go:</p>

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

<p><a href="https://pythonandr.com/2015/10/13/karatsuba-multiplication-algorithm-python-code/">Source</a></p>

<p>We can perform the calculation by convolving the lists of digits (<a href="https://www.wolframalpha.com/input/?i=ListConvolve%5B%7B1000%2C+200%2C+30%2C+4%7D%2C+%7B8%2C+70%2C+600%2C+5000%7D%2C+%7B1%2C+-1%7D%2C+0%5D">wolfram alpha</a>):</p>

<pre><code>ListConvolve[{1000, 200, 30, 4}, {8, 70, 600, 5000}, {1, -1}, 0]
{8000, 71600, 614240, 5122132, 1018280, 152400, 20000}

sum {8000, 71600, 614240, 5122132, 1018280, 152400, 20000}
7006652
</code></pre>

<p>Note that we pre-flip one of the lists (it gets swapped in the convolution later), and the intermediate calculations are a bit different. But, combining the subtotals gives the expected result.</p>

<h3>Faster Convolutions</h3>

<p>Why convolve instead of doing a regular digit-by-digit multiplication? Well, the convolution theorem lets us substitute convolution with Fourier Transforms:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/4838206025511ca3236c054e272048a5.png' width='144' height='21' alt='\displaystyle{f * g = \mathscr{F}^{-1} \lbrace FG \rbrace}' class='tex'></p>

<p>The convolution ($f * g$) has complexity $O(n^2)$. We have $n$ positions to process, with $n$ intermediate multiplications at each position.</p>

<p>The right side involves:</p>

<ul>
<li>Two Fourier Transforms, which are normally $O(n^2)$. However, the Fast Fourier Transform (a <a href="https://www.youtube.com/watch?v=iTMn0Kt18tg">divide-and-conquer approach</a>) makes them $O(n\log(n))$.</li>
<li>Pointwise multiplication of the final result of the transforms  ($\sum a_n \cdot b_n$), which is $O(n)$</li>
<li>An inverse transform, which is $O(n\log(n))$</li>
</ul>

<p>And the total complexity is: $O(n\log(n)) + O(n\log(n)) + O(n) + O(n\log(n)) = O(n\log(n))$</p>

<p>Regular multiplication in the fancy domain is <em>faster</em> than a fancy multiplication in the regular domain. Our French friend is no slouch. (<a href="http://www.ams.org/publicoutreach/feature-column/fcarc-multiplication">More</a>)</p>

<h3>Convolutional Neural Nets (CNN)</h3>

<p>Machine learning is about discovering the math functions that transform input data into a desired result (a prediction, classification, etc.).</p>

<p>Starting with an input signal, we could convolve it with a bunch of kernels:</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/ec62a4fc08cd4f262a0f7fa9221eef1e.png' width='229' height='16' alt='\displaystyle{\text{input} * k_1 * k_2 * k_3 ... = \text{result}}' class='tex'></p>

<p>Given that convolution can do complex math (moving averages, blurs, derivatives...), it seems <em>some</em> combination of kernels should turn our input into something useful, right?</p>

<p>Convolutional Neural Nets (CNNs) process an input with layers of kernels, optimizing their weights (plans) to reach a goal. Imagine tweaking the treatment plan to keep medicine usage below some threshold.</p>

<p>CNNs are often used with image classifiers, but 1D data sets work just fine.</p>

<ul>
<li>Nice writeup: <a href="https://ujjwalkarn.me/2016/08/11/intuitive-explanation-convnets/">https://ujjwalkarn.me/2016/08/11/intuitive-explanation-convnets/</a></li>
<li>Digit classifier demo: <a href="https://cs.stanford.edu/people/karpathy/convnetjs/demo/mnist.html">https://cs.stanford.edu/people/karpathy/convnetjs/demo/mnist.html</a></li>
</ul>

<h3>LTI System Behavior</h3>

<p>A linear, time-invariant system means:</p>

<ul>
<li>Linear: Scaling and combining inputs scales and combines outputs by the same amount</li>
<li>Time invariant: Outputs depend on relative time, not absolute time. You get 3 units on <em>your</em> first day, and it doesn't matter if it's Wednesday or Thursday.</li>
</ul>

<p>A fancy phrase is "A LTI system is characterized by its impulse response". Translation: If we send a <em>single</em> patient through the hospital <code>[1]</code>, we'll discover the treatment plan. Then we can predict the usage for <em>any</em> sequence of patients by convolving it with the plan.</p>

<p><img src='https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/1ed77a8b2cc34caedc58aa7b05416c35.png' width='352' height='17' alt='\displaystyle{\text{system response} = \text{impulse response} * \text{inputs}}' class='tex'></p>

<p>If the system isn't LTI, we can't extrapolate based on a <em>single</em> person's experience. Scaling the inputs may not scale the outputs, and the actual calendar day, not relative day, may impact the result (imagine fewer rooms available on weekends).</p>

<h3>Engineering Analogies</h3>

<p>From <a href="https://www.quora.com/What-is-an-intuitive-explanation-for-convolution/answer/David-Greenspan">David Greenspan</a>: "Suppose you have a special laser pointer that makes a star shape on the wall. You tape together a bunch of these laser pointers in the shape of a square. The pattern on the wall now is the convolution of a star with a square."</p>

<p>Regular multiplication gives you a single scaled copy of an input. Convolution creates multiple overlapping copies that follow a pattern you've specified.</p>

<p>Real-world systems have squishy, not instantaneous, behavior: they ramp up, peak, and drop down. The convolution lets us model systems that echo, reverb and overlap.</p>

<p>Now it's time for the famous sliding window example. Think of a pulse of inputs (red) sliding through a system (blue), and having a combined effect (yellow): the convolution.</p>

<p><img decoding="async" src="https://upload.wikimedia.org/wikipedia/commons/b/b9/Convolution_of_spiky_function_with_box2.gif" alt="" /></p>

<p>(<a href="https://commons.wikimedia.org/wiki/File:Convolution_of_spiky_function_with_box2.gif">Source</a>)</p>

<h2>Summary</h2>

<p>Convolution has an advanced technical definition, but the basics can be understood with the right analogy.</p>

<p>Quick rant: I study math for fun, yet it took years to find a satisfying intuition for:</p>

<ul>
<li>Why is one function reversed?</li>
<li>Why is convolution commutative?</li>
<li>Why does the integral of the convolution = product of integrals?</li>
<li>Why are the Fourier Transforms multiplied point-by-point, and not overlapped?</li>
</ul>

<p>Why'd it take so long? Imagine learning multiplication with $f \times g = z$ instead of  $3 \times 5 = 15$. Without an example I can explore <em>in my head</em>, I could only memorize results, not intuit them. Hopefully this analogy can save you years of struggle.</p>

<p>Happy math.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://betterexplained.com/articles/intuitive-convolution/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Integral of Sin(x): Geometric Intuition</title>
		<link>https://betterexplained.com/articles/integral-sinx/</link>
					<comments>https://betterexplained.com/articles/integral-sinx/#respond</comments>
		
		<dc:creator><![CDATA[kalid]]></dc:creator>
		<pubDate>Wed, 20 Nov 2019 00:01:09 +0000</pubDate>
				<category><![CDATA[Calculus]]></category>
		<guid isPermaLink="false">https://betterexplained.com/?p=12244</guid>

					<description><![CDATA[You're minding your own business when some punk asks what the integral of $\sin(x)$ means. Your options: Pretend to be asleep (except not in the engineering library again) Canned response: "As with any function, the integral of sine is the area under its curve." Geometric intuition: "The integral of sine is the horizontal distance along [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>You're minding your own business when some punk asks what the integral of $\sin(x)$ means. Your options:</p>

<ul>
<li>Pretend to be asleep (except not in the engineering library again)</li>
<li>Canned response: "As with any function, the integral of sine is the area under its curve."</li>
<li>Geometric intuition: "The integral of sine is the <strong>horizontal distance</strong> along a circular path."</li>
</ul>

<p>Option 1 is tempting, but let's take a look at the others.</p>

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

<h2>Why "Area Under the Curve" is Unsatisfying</h2>

<p>Describing an integral as "area under the curve" is like describing a book as a list of words. Technically correct, but misses the message and I suspect you haven't done the assigned reading.</p>

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

<p>Unless you're trapped in LegoLand, integrals mean something besides rectangles.</p>

<h2>Decoding the Integral</h2>

<p>My calculus conundrum was not having an intuition for all the mechanics.</p>

<p>When we see:</p>

<p>$\int \sin(x) dx$</p>

<p>We can call on a few insights:</p>

<ul>
<li><p>The integral is just <a href="https://betterexplained.com/articles/a-calculus-analogy-integrals-as-multiplication/">fancy multiplication</a>. Multiplication accumulates numbers that don't change (3 + 3 + 3 + 3). Integrals add up numbers that <em>might</em> change, based on a pattern (1 + 2 + 3 + 4). But if we squint our eyes and pretend items are identical we have a multiplication.</p></li>
<li><p>$\sin(x)$ just a <a href="https://betterexplained.com/articles/intuitive-trigonometry/">percentage</a>. Yes, it's also fancy curve with nice properties. But at any point (like 45 degrees), it's a single <em>percentage</em> from -100% to +100%. Just regular numbers.</p></li>
<li><p>$dx$ is a tiny, <a href="https://betterexplained.com/articles/why-do-we-need-limits-and-infinitesimals/">infinitesimal part</a> of the path we're taking. 0 to $x$ is the full path, so $dx$ is (intuitively) a nanometer wide.</p></li>
</ul>

<p>Ok. With those 3 intuitions, our rough (rough!) conversion to Plain English is:</p>

<blockquote>
  <p>The integral of sin(x) multiplies our intended path length (from 0 to x) by a percentage</p>
</blockquote>

<p>We <em>intend</em> to travel a simple path from 0 to x, but we end up with a smaller percentage instead. (Why? Because $\sin(x)$ is usually less than 100%). So we'd expect something like 0.75x.</p>

<p>In fact, if $\sin(x)$ did have a fixed value of 0.75, our integral would be:</p>

<p>$\int \text{fixedsin}(x) \ dx = \int 0.75 \ dx = 0.75 \int dx = 0.75x$</p>

<p>But the real $\sin(x)$, that rascal, changes as we go. Let's see what fraction of our path we really get.</p>

<h2>Visualize The Change in Sin(x)</h2>

<p>Now let's visualize $\sin(x)$ and its changes:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/2019/11/sine-dx-change.png" alt="" /></p>

<p>Here's the decoder key:</p>

<ul>
<li><p>$x$ is our current angle in <a href="https://betterexplained.com/articles/intuitive-guide-to-angles-degrees-and-radians/">radians</a>. On the unit circle (radius=1), the angle is the distance along the circumference.</p></li>
<li><p>$dx$ is a tiny change in our angle, which becomes the same change along the circumference (moving 0.01 units in our angle moves 0.01 along the circumference).</p></li>
<li><p>At our tiny scale, a circle is a <a href="https://betterexplained.com/articles/prehistoric-calculus-discovering-pi/">a polygon with many sides</a>, so we're moving along a <em>line segment</em> of length $dx$. This puts us at a new position.</p></li>
</ul>

<p>With me? With trigonometry, we can find the exact change in height/width as we slide along the circle by $dx$.</p>

<p>By similar triangles, our change just just our original triangle, rotated and scaled.</p>

<ul>
<li>Original triangle (hypotenuse = 1): height = $\sin(x)$, width = $\cos(x)$</li>
<li>Change triangle (hypotenuse = dx): height = $\sin(x) dx$, width = $\cos(x)  dx$</li>
</ul>

<p>Now, remember that sine and cosine are functions that return percentages. (A number like 0.75 doesn't have its orientation. It shows up and makes things 75% of their size in whatever direction they're facing.)</p>

<p>So, given how we've drawn our Triangle of Change, $\sin(x) dx$ is our horizontal change. Our plain-English intuition is:</p>

<blockquote>
  <p>The integral of sin(x) adds up the horizontal change along our path</p>
</blockquote>

<h2>Visualize The Integral Intuition</h2>

<p>Ok. Let's graph this bad boy to see what's happening. With our "$\sin(x) dx$ = tiny horizontal change" insight we have:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/2019/11/sine-integral-horizontal.png" alt="" /></p>

<p>As we circle around, we have a bunch of $dx$ line segments (in red). When sine is small (around x=0) we barely get any horizontal motion. As sine gets larger (top of circle), we are moving up to 100% horizontally.</p>

<p>Ultimately, the various $\sin(x) dx$ segments move us horizontally from one side of the circle to the other.</p>

<p>A more technical description:</p>

<p>$\int_0^x \sin(x) dx = \text{horizontal distance traveled on arc from 0 to x}$</p>

<p>Aha! That's the meaning. Let's eyeball it. When moving from $x=0$ to $x=\pi$ we move exactly 2 units horizontally. It makes complete sense in the diagram.</p>

<h2>The Official Calculation</h2>

<p>Using the Official Calculus Fact that $\int \sin(x) dx = -\cos(x)$ we would calculate:</p>

<p>$ \int_0^\pi \sin(x) dx = -\cos(x) \Big|_0^\pi = -\cos(\pi) - -\cos(0) = -(-1) -(-1) = 1 + 1 = 2$</p>

<p>Yowza. See how awkward it is, those double negations? Why was the visual intuition so much simpler?</p>

<p>Our path along the circle ($x=0$ to $x=\pi$) moves from right-to-left. But the x-axis goes positive from left-to-right. When convert distance along our path into Standard Area&#x2122;, we have to flip our axes:</p>

<p><img decoding="async" src="https://betterexplained.com/wp-content/uploads/2019/11/sine-unroll-changes.png" alt="" /></p>

<p>Our excitement to put things in the official format stamped out the intuition of what was happening.</p>

<h2>Fundamental Theorem of Calculus</h2>

<p>We don't really talk about the <a href="https://betterexplained.com/calculus/lesson-11/">Fundamental Theorem of Calculus</a> anymore. (Is it something I did?)</p>

<p>Instead of adding up all the tiny segments, just do: end point - start point.</p>

<p>The intuition was staring us in the face: $\cos(x)$ is the anti-derivative, and tracks the horizontal position, so we're just taking a difference between horizontal positions! (With awkward negatives to swap the axes.)</p>

<p><em>That's</em> the power of the Fundamental Theorem of Calculus. Skip the intermediate steps and just subtract endpoints.</p>

<h2>Onward and Upward</h2>

<p>Why did I write this? Because I couldn't <a href="https://betterexplained.com/articles/gutcheck/">instantly figure out</a>:</p>

<p>$ \int_0^\pi \sin(x) dx = 2$</p>

<p>This isn't an exotic function with strange parameters. It's like asking someone to figure out $2^3$ without a calculator. If you claim to understand exponents, it should be possible, right?</p>

<p>Now, we can't always visualize things. But for the <em>most common</em> functions we owe ourselves a visual intuition. I certainly can't eyeball the 2 units of area from 0 to $\pi$ under a sine curve.</p>

<p>Happy math.</p>

<h2>Appendix: Average Efficiency</h2>

<p>As a fun fact, the "average" efficiency of motion around the top of a circle (0 to $\pi$) is: $ \frac{2}{\pi} = .6366 $</p>

<p>So on average, 63.66% of your path's length is converted to horizontal motion.</p>

<h2>Appendix: Height controls width?</h2>

<p>It seems weird that height controls the width, and vice-versa, right?</p>

<p>If height controlled height, we'd have runaway <a href="https://betterexplained.com/articles/an-intuitive-guide-to-exponential-functions-e/">exponential growth</a>. But a circle needs to regulate itself.</p>

<p>$e^x$ is the kid who eats candy, grows bigger, and can therefore eat more candy.</p>

<p>$\sin(x) $ is the kid who eats candy, gets sick, waits for an appetite, and eats more candy.</p>

<h2>Appendix: Area isn't literal</h2>

<p>The "area" in our integral isn't literal area, it's a percentage of our length. We visualized the multiplication as a 2d rectangle in our generic integral, but it can be confusing. If you earn money and are taxed, do you visualize 2d area (income * (1 - tax))? Or just a quantity helplessly shrinking?</p>

<p>Area primarily indicates a multiplication happened. Don't let team Integrals Are Literal Area win every battle!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://betterexplained.com/articles/integral-sinx/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
