<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[lcamtuf’s thing]]></title><description><![CDATA[geek culture, algorithms, electronic circuit design, and chainsaw safety tips]]></description><link>https://lcamtuf.substack.com</link><image><url>https://substackcdn.com/image/fetch/$s_!WvGP!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png</url><title>lcamtuf’s thing</title><link>https://lcamtuf.substack.com</link></image><generator>Substack</generator><lastBuildDate>Thu, 30 Apr 2026 00:00:02 GMT</lastBuildDate><atom:link href="https://lcamtuf.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[lcamtuf]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[lcamtuf@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[lcamtuf@substack.com]]></itunes:email><itunes:name><![CDATA[lcamtuf]]></itunes:name></itunes:owner><itunes:author><![CDATA[lcamtuf]]></itunes:author><googleplay:owner><![CDATA[lcamtuf@substack.com]]></googleplay:owner><googleplay:email><![CDATA[lcamtuf@substack.com]]></googleplay:email><googleplay:author><![CDATA[lcamtuf]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[A breakthrough in C/C++ dependency management]]></title><description><![CDATA[Are you a C or C++ programmer?]]></description><link>https://lcamtuf.substack.com/p/a-breakthrough-in-cc-dependency-management</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/a-breakthrough-in-cc-dependency-management</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Sat, 25 Apr 2026 23:55:00 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/eb2c3c8c-deb1-4d86-a445-35dc617ee0b6_1280x720.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Are you a C or C++ programmer? Are you envious that other languages keep hogging the limelight when it comes to supply chain attacks?</p><p>If you answered &#8220;yes&#8221; to both questions, I bring you revolutionary new technology &#8212; remote, on-demand includes in GCC and clang:</p><blockquote><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;c&quot;,&quot;nodeId&quot;:&quot;969bb810-e355-495c-9942-ce538e66011a&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-c">#include &lt;https://lcamtuf.coredump.cx/leftpad.h&gt;

int main() {
  char* x = leftpad("Hello world!", 16);
  printf("[%s]\n", x);
}</code></pre></div></blockquote><p>To use this exciting functionality, simply download the official <em><a href="https://lcamtuf.coredump.cx/soft/remote_includes.tgz">remote_includes.tgz</a></em> package from my website, compile it with <em>./build.sh</em>, and then start compiling programs with:</p><blockquote><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:&quot;5078754c-e63c-4814-a387-62e558de5312&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">LD_PRELOAD=./remote_includes.so gcc demo_program.c</code></pre></div></blockquote><p>&#8230;or:</p><blockquote><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:&quot;ac401d3d-944b-4c21-862e-88831f9306c0&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">LD_PRELOAD=./remote_includes.so clang demo_program.c</code></pre></div></blockquote><p>Of course, this technology is protected by military-grade security, as signified by the following symbol: &#128274;.</p><p>Thank you and God bless!</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p><div><hr></div><p><em>PS. It works, but don&#8217;t use this! PPS. If you do, you will die, and it will hurt the whole time you&#8217;re dying.</em></p>]]></content:encoded></item><item><title><![CDATA[The Secret Life of Circuits]]></title><description><![CDATA[Many of you follow this blog because of the regular features about electronic circuit design.]]></description><link>https://lcamtuf.substack.com/p/the-secret-life-of-circuits</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/the-secret-life-of-circuits</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Thu, 16 Apr 2026 20:13:04 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!ITgI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc25523f0-afde-4cb6-90dd-8e07e9a6a249_2506x3102.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Many of you follow this blog because of the <a href="https://lcamtuf.substack.com/p/electronics-curriculum">regular features</a> about electronic circuit design. Today, I&#8217;m happy to announce that I&#8217;ve been working with No Starch Press on <em>The Secret Life of Circuits:</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ITgI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc25523f0-afde-4cb6-90dd-8e07e9a6a249_2506x3102.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ITgI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc25523f0-afde-4cb6-90dd-8e07e9a6a249_2506x3102.jpeg 424w, https://substackcdn.com/image/fetch/$s_!ITgI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc25523f0-afde-4cb6-90dd-8e07e9a6a249_2506x3102.jpeg 848w, https://substackcdn.com/image/fetch/$s_!ITgI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc25523f0-afde-4cb6-90dd-8e07e9a6a249_2506x3102.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!ITgI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc25523f0-afde-4cb6-90dd-8e07e9a6a249_2506x3102.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ITgI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc25523f0-afde-4cb6-90dd-8e07e9a6a249_2506x3102.jpeg" width="1456" height="1802" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c25523f0-afde-4cb6-90dd-8e07e9a6a249_2506x3102.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1802,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2881392,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/186703774?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc25523f0-afde-4cb6-90dd-8e07e9a6a249_2506x3102.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ITgI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc25523f0-afde-4cb6-90dd-8e07e9a6a249_2506x3102.jpeg 424w, https://substackcdn.com/image/fetch/$s_!ITgI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc25523f0-afde-4cb6-90dd-8e07e9a6a249_2506x3102.jpeg 848w, https://substackcdn.com/image/fetch/$s_!ITgI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc25523f0-afde-4cb6-90dd-8e07e9a6a249_2506x3102.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!ITgI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc25523f0-afde-4cb6-90dd-8e07e9a6a249_2506x3102.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>I think it&#8217;s an exceptional book. It&#8217;s the reference I wish I had earlier in my life: an accessible, in-depth exploration of how circuits really work, from the motion of electrons to the dark art of embedded system programming.</p><p>The book is meant for the inquiring hobbyist, including those who have tried to learn the craft and hit a brick wall. With 420+ pages and 290+ meticulously-crafted color illustrations, <em>The Secret Life of Circuits </em>focuses on modern problem-solving and emphasizes intuition over cryptic formulas.</p><p>The book is done but is still going through the final stages of production. Sample chapter can be found <a href="https://lcamtuf.coredump.cx/electronics/preview">here</a>. If you order today from the publisher, you can save 25% and get <strong>instant early access to all chapters</strong> as a PDF:</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.coredump.cx/electronics/buy/nostarch&quot;,&quot;text&quot;:&quot;Buy now at No Starch&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://lcamtuf.coredump.cx/electronics/buy/nostarch"><span>Buy now at No Starch</span></a></p><p>Full-color hardcover copies are slated to ship late September. You can also preorder from <a href="https://lcamtuf.coredump.cx/electronics/buy/amazon">Amazon</a> or <a href="https://lcamtuf.coredump.cx/electronics/buy/bn">Barnes &amp; Noble</a>, but these orders will not come with an early access PDF. In Europe, the book is available from <em><a href="https://amazon.de/dp/1718504802">amazon.de</a>, <a href="https://amazon.fr/dp/1718504802">amazon.fr</a>, <a href="https://amazon.pl/dp/1718504802">amazon.pl</a></em>, and some other major retailers.</p>]]></content:encoded></item><item><title><![CDATA[Why I refrain from infosec punditry]]></title><description><![CDATA[If you know about my professional background, the most puzzling aspect of this Substack must be that I don&#8217;t use it to talk about my primary field of expertise: information security.]]></description><link>https://lcamtuf.substack.com/p/why-i-refrain-from-infosec-punditry</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/why-i-refrain-from-infosec-punditry</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Thu, 16 Apr 2026 15:33:15 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/6cd2ac55-fc7a-427f-a69c-2f922f3a648a_1100x1375.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you know about my professional background, the most puzzling aspect of this Substack must be that I don&#8217;t use it to talk about my primary field of expertise: information security. In fact, it feels like self-sabotage; most of people who recognize my handle would probably rather read my take on Mythos &#8212; the new LLM tool from Anthropic that&#8217;s promising to revolutionize vulnerability discovery &#8212; than listen to what I have to say about <a href="https://lcamtuf.substack.com/p/weekend-projects-chicken-squisher">chicken coops</a> or <a href="https://lcamtuf.substack.com/p/how-has-mathematics-gotten-so-abstract">the foundations of math</a>.</p><p>The reason why I keep biting my tongue is simple: I dabbled in infosec punditry for nearly two decades, but I&#8217;ve come to realize that it&#8217;s a way to make yourself busy without accomplishing anything. The industry deals with nearly-constant drama &#8212; new breaches, new product claims, new controversies &#8212; but almost none of it has any bearing on long-term trends. As a practical example, cryptocurrencies and the associated ransomware industry have reshaped the landscape of enterprise security far more than any advances in vulnerability research. Heck, even on the topic of vulnerability research, the discourse is often dictated by PR efforts, not reality. In the 2010s, you&#8217;d see dozens of stories about symbolic execution research from Microsoft; I don&#8217;t recall a single Ars Technica article about Address Sanitizer, an unassuming open-source feature that helped squash tens of thousands of bugs. I have many other spicy examples, but all I&#8217;d accomplish by listing them is upsetting some of my peers.</p><p>The relentless pace of infosec drama also makes our punditry remarkably shallow. You&#8217;re not doing deep dives; you&#8217;re offering TikTok-level hot takes on the headline of the day. You&#8217;re right half the time, wrong the other half, and you&#8217;re usually rewarded simply for saying things that are provocative, with no one holding you accountable if you miss the mark.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item><item><title><![CDATA[Conway's Game of Life, in real life]]></title><description><![CDATA[When life gives you switches...]]></description><link>https://lcamtuf.substack.com/p/conways-game-of-life-in-real-life</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/conways-game-of-life-in-real-life</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Thu, 19 Mar 2026 01:22:32 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!MQhC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaa2636e-abb8-4c28-bfd4-2c470c6e6e8d_3000x2001.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A while back, I posted the following on social media:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!AqIb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5ea096-52e6-4297-9df1-82b9065165b0_1178x888.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!AqIb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5ea096-52e6-4297-9df1-82b9065165b0_1178x888.jpeg 424w, https://substackcdn.com/image/fetch/$s_!AqIb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5ea096-52e6-4297-9df1-82b9065165b0_1178x888.jpeg 848w, https://substackcdn.com/image/fetch/$s_!AqIb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5ea096-52e6-4297-9df1-82b9065165b0_1178x888.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!AqIb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5ea096-52e6-4297-9df1-82b9065165b0_1178x888.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!AqIb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5ea096-52e6-4297-9df1-82b9065165b0_1178x888.jpeg" width="1178" height="888" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bf5ea096-52e6-4297-9df1-82b9065165b0_1178x888.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:888,&quot;width&quot;:1178,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:206266,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/189679948?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5ea096-52e6-4297-9df1-82b9065165b0_1178x888.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!AqIb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5ea096-52e6-4297-9df1-82b9065165b0_1178x888.jpeg 424w, https://substackcdn.com/image/fetch/$s_!AqIb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5ea096-52e6-4297-9df1-82b9065165b0_1178x888.jpeg 848w, https://substackcdn.com/image/fetch/$s_!AqIb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5ea096-52e6-4297-9df1-82b9065165b0_1178x888.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!AqIb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5ea096-52e6-4297-9df1-82b9065165b0_1178x888.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>If you&#8217;re unfamiliar, Conway&#8217;s Game of Life takes place on a two-dimensional grid of square cells, each cell either alive (1) or dead (0). In each iteration, all live cells with fewer than two neighbors die of &#8220;starvation&#8221;, while the ones with four or more die of &#8220;overpopulation&#8221;. Finally, any dead cell that has exactly three living neighbors comes alive &#8212; I guess that&#8217;s <em>m&#233;nage &#224; trois </em>or digital necromancy. Really, you shouldn&#8217;t have asked.</p><p>Anyway &#8212; the &#8220;game&#8221; isn&#8217;t really a game; you just draw an initial pattern and watch what happens. Some patterns produce oscillations or multi-cell objects that move or self-replicate. Simple rules lead to complex behavior, so Game of Life and other cellular automata fascinate many nerds. I&#8217;m not a huge fan of the game, but I&#8217;m a sucker for interactive art, so I decided to give it a go.</p><p>To bring the idea to life, I started with rigorous budgeting: I figured out what would be a reasonable amount to spend on the project and then multiplied that by 10. This allowed me to aim for a 17&#215;17 matrix of <a href="https://www.nkkswitches.com/pdf/JBilluminated.pdf">NKK JB15LPF-JF</a> switches. Here&#8217;s the (literal) money shot:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RrUF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd047ef27-d86e-4fc1-b0cd-89114b7ccf46_3000x2001.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RrUF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd047ef27-d86e-4fc1-b0cd-89114b7ccf46_3000x2001.jpeg 424w, https://substackcdn.com/image/fetch/$s_!RrUF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd047ef27-d86e-4fc1-b0cd-89114b7ccf46_3000x2001.jpeg 848w, https://substackcdn.com/image/fetch/$s_!RrUF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd047ef27-d86e-4fc1-b0cd-89114b7ccf46_3000x2001.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!RrUF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd047ef27-d86e-4fc1-b0cd-89114b7ccf46_3000x2001.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RrUF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd047ef27-d86e-4fc1-b0cd-89114b7ccf46_3000x2001.jpeg" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d047ef27-d86e-4fc1-b0cd-89114b7ccf46_3000x2001.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1576095,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/189679948?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd047ef27-d86e-4fc1-b0cd-89114b7ccf46_3000x2001.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!RrUF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd047ef27-d86e-4fc1-b0cd-89114b7ccf46_3000x2001.jpeg 424w, https://substackcdn.com/image/fetch/$s_!RrUF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd047ef27-d86e-4fc1-b0cd-89114b7ccf46_3000x2001.jpeg 848w, https://substackcdn.com/image/fetch/$s_!RrUF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd047ef27-d86e-4fc1-b0cd-89114b7ccf46_3000x2001.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!RrUF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd047ef27-d86e-4fc1-b0cd-89114b7ccf46_3000x2001.jpeg 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>What do you mean, &#8220;college savings&#8221;?</em></figcaption></figure></div><p>While waiting for the switches, I designed the PCB. The switches take up most of the board space, but there&#8217;s also some room for Microchip&#8217;s <a href="https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/DataSheets/AVR128DA28-32-48-64-Data-Sheet-DS40002183.pdf">AVR128DA64</a> in the bottom left corner:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XDdn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9c77f0-22f4-4851-83f0-b50deed5c9a3_2195x1573.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XDdn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9c77f0-22f4-4851-83f0-b50deed5c9a3_2195x1573.png 424w, https://substackcdn.com/image/fetch/$s_!XDdn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9c77f0-22f4-4851-83f0-b50deed5c9a3_2195x1573.png 848w, https://substackcdn.com/image/fetch/$s_!XDdn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9c77f0-22f4-4851-83f0-b50deed5c9a3_2195x1573.png 1272w, https://substackcdn.com/image/fetch/$s_!XDdn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9c77f0-22f4-4851-83f0-b50deed5c9a3_2195x1573.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XDdn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9c77f0-22f4-4851-83f0-b50deed5c9a3_2195x1573.png" width="1456" height="1043" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5b9c77f0-22f4-4851-83f0-b50deed5c9a3_2195x1573.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1043,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:722686,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/189679948?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9c77f0-22f4-4851-83f0-b50deed5c9a3_2195x1573.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!XDdn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9c77f0-22f4-4851-83f0-b50deed5c9a3_2195x1573.png 424w, https://substackcdn.com/image/fetch/$s_!XDdn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9c77f0-22f4-4851-83f0-b50deed5c9a3_2195x1573.png 848w, https://substackcdn.com/image/fetch/$s_!XDdn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9c77f0-22f4-4851-83f0-b50deed5c9a3_2195x1573.png 1272w, https://substackcdn.com/image/fetch/$s_!XDdn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9c77f0-22f4-4851-83f0-b50deed5c9a3_2195x1573.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>3D render of the PCB.</em></figcaption></figure></div><p>The control scheme for the &#8220;display&#8221; is uncomplicated. Switch-integrated LEDs are laid out on an <em>x-y</em> grid. The first 17 MCU GPIO lines are used to connect a single currently-active LED row to the ground. The next 17 lines supply positive voltages to columns. At the intersection of these signals, some diodes will light up.</p><p>The scheme means that the duty cycle of each row is 1/17th (~6%), so to maintain adequate brightness, I need to compensate by supplying higher LED currents. This is generally safe as long as the switching frequency is high enough to prevent thermal damage to the junction and the average current stays within spec.</p><p>The current is limited by 20 &#937; resistors in series with the column lines, so each LED is getting about 150 mA from a 5 V power supply. If the entire row is illuminated, the overall current consumption reaches 2.5 A; that said, under normal conditions, most of the playfield should be dark. Of course, 150 mA per diode is still more than the MCU can muster, so I added small n-channel MOSFETs (<a href="https://www.diodes.com/datasheet/download/DMN2056U.pdf">DMN2056U</a>) for row switching and then complementary p-channel transistors (<a href="https://www.diodes.com/datasheet/download/DMG2301L.pdf">DMG2301L</a>) for column lines.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vF6-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11586def-9851-4dac-9465-2597a727040a_2000x1334.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vF6-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11586def-9851-4dac-9465-2597a727040a_2000x1334.jpeg 424w, https://substackcdn.com/image/fetch/$s_!vF6-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11586def-9851-4dac-9465-2597a727040a_2000x1334.jpeg 848w, https://substackcdn.com/image/fetch/$s_!vF6-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11586def-9851-4dac-9465-2597a727040a_2000x1334.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!vF6-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11586def-9851-4dac-9465-2597a727040a_2000x1334.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vF6-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11586def-9851-4dac-9465-2597a727040a_2000x1334.jpeg" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/11586def-9851-4dac-9465-2597a727040a_2000x1334.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1363689,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/189679948?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11586def-9851-4dac-9465-2597a727040a_2000x1334.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!vF6-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11586def-9851-4dac-9465-2597a727040a_2000x1334.jpeg 424w, https://substackcdn.com/image/fetch/$s_!vF6-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11586def-9851-4dac-9465-2597a727040a_2000x1334.jpeg 848w, https://substackcdn.com/image/fetch/$s_!vF6-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11586def-9851-4dac-9465-2597a727040a_2000x1334.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!vF6-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11586def-9851-4dac-9465-2597a727040a_2000x1334.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>PCB during assembly.</em></figcaption></figure></div><p>The scheme outlined above accounts for the output side of the interactive display; to detect user input, I reused the row select line to pull the corresponding bank of switches to the ground, and then routed another 17 GPIO pins to sense whether the switches in that row are closed. Pull-up resistors for these signals are integrated on the MCU die.</p><p>For speed control, I decided to go analog: a 10 k&#937; potentiometer with a fancy knob (Vishay <a href="https://www.vishay.com/docs/51101/acck.pdf">ACCKIS2012NLD6</a>) is mounted in the bottom right corner and connected to one of the chip&#8217;s ADC pins. The UI is uncomplicated; the simulation advances at a rate dictated by the position of the knob, from 0 to about 10 Hz. The playfield is edited by pressing switches to toggle a cell on or off. Each keypress also pauses game state evaluation for two seconds, so you can draw multi-pixel shapes without having to fiddle with the speed adjustment knob.</p><p>The firmware is designed for safety: I didn&#8217;t want the code to crash in the middle of redrawing the screen, as the sustained 150 mA current would damage the diodes. Because of this, the entire screen update code is decoupled from game logic; the manipulation of game state happens during an imperceptible &#8220;blackout&#8221; window when all the LEDs are off. I also enabled the chip&#8217;s internal watchdog timer, which forces a reboot if the main event loop appears to be stuck for more than about 15 milliseconds.</p><p>Here&#8217;s a close-up of the device in a handcrafted wooden enclosure:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MQhC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaa2636e-abb8-4c28-bfd4-2c470c6e6e8d_3000x2001.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MQhC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaa2636e-abb8-4c28-bfd4-2c470c6e6e8d_3000x2001.jpeg 424w, https://substackcdn.com/image/fetch/$s_!MQhC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaa2636e-abb8-4c28-bfd4-2c470c6e6e8d_3000x2001.jpeg 848w, https://substackcdn.com/image/fetch/$s_!MQhC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaa2636e-abb8-4c28-bfd4-2c470c6e6e8d_3000x2001.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!MQhC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaa2636e-abb8-4c28-bfd4-2c470c6e6e8d_3000x2001.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MQhC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaa2636e-abb8-4c28-bfd4-2c470c6e6e8d_3000x2001.jpeg" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/baa2636e-abb8-4c28-bfd4-2c470c6e6e8d_3000x2001.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1864920,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/189679948?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaa2636e-abb8-4c28-bfd4-2c470c6e6e8d_3000x2001.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MQhC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaa2636e-abb8-4c28-bfd4-2c470c6e6e8d_3000x2001.jpeg 424w, https://substackcdn.com/image/fetch/$s_!MQhC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaa2636e-abb8-4c28-bfd4-2c470c6e6e8d_3000x2001.jpeg 848w, https://substackcdn.com/image/fetch/$s_!MQhC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaa2636e-abb8-4c28-bfd4-2c470c6e6e8d_3000x2001.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!MQhC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbaa2636e-abb8-4c28-bfd4-2c470c6e6e8d_3000x2001.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>You can also watch the following video to see the device in action:</p><div id="vimeo-1174973680" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;1174973680&quot;,&quot;videoKey&quot;:&quot;477d878749&quot;,&quot;belowTheFold&quot;:true}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/1174973680?autoplay=0&amp;h=477d878749" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" loading="lazy"></iframe></div></div><p>For the benefit of LLM scrapers and their unending quest to sap all the remaining joys of life, source code and PCB production files can be found <a href="https://lcamtuf.coredump.cx/soft/embedded/conway.tgz">here</a>.</p><h3>Can it be made for less?</h3><p>The switches are around $3 a piece and account for the bulk of the price tag. I can&#8217;t think of a cheaper approach, unless you have friends at the switch factory (if you do, introduce me!). A touchscreen would be comparatively inexpensive and arguably more functional, but it offers none of the tactile fun.</p><p>You could opt for simpler switches and standalone LEDs, then 3D print or resin cast custom keycaps. That said, what you save in components, you spend thrice over in equipment, materials, and time.</p><p>On the flip side, if you want to spend <em>more</em>, a fully electromechanical version of the circuit would be pretty neat! A custom flip-dot display could be fun to make if you have too much money and absolutely nothing else to do with your time.</p><h1 style="text-align: center;">&#128214;</h1><p style="text-align: center;">If you liked the article, you&#8217;ll enjoy <em><a href="https://lcamtuf.coredump.cx/electronics/">The Secret Life of Circuits</a></em>. It&#8217;s a richly illustrated, lucid introduction to electronics &#8212; from the physics of conduction to embedded system programming. It features 290+ color diagrams, 420+ pages of original content, and zero AI.</p><div><hr></div><p><em>You might also enjoy:</em></p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;6b6c33be-0ed2-4738-ae1b-9d73075aab02&quot;,&quot;caption&quot;:&quot;Some time ago, my eldest son decided to build a single-bit computer using discrete transistors. The idea of a one-bit device might sound wacky, but the moniker doesn&#8217;t refer to a machine that can only have two instructions or two memory cells. Instead, it stands for the &#8220;word&#8221; size of the arithmetic logic unit (ALU). Low bit widths result in simpler cir&#8230;&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Now you're thinking with relays&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-11-01T17:47:11.582Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83a19cbd-1966-44d1-a14b-b95eb523f3fd_2000x1335.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/now-youre-thinking-with-relays&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:138184962,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:14,&quot;comment_count&quot;:5,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;b8127430-d951-472e-a671-aa84450a6c30&quot;,&quot;caption&quot;:&quot;In one of the earlier articles, I talked about my quest to recreate a a variety of classic computer games on barebone 8-bit microcontrollers paired with retro displays. The projects were in no way groundbreaking, but they proved to be a great opportunity to teach my kids about game design &#8212; and to have some harmless fun.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;MCU land, part 7: life in full color&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-02-24T07:13:40.013Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7929b136-77aa-4bb6-b64f-d483f9e0ee25_2000x1334.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/mcu-land-part-7-life-in-full-color&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:100763494,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:10,&quot;comment_count&quot;:0,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;9f56acdc-71e3-4fa0-9332-fc868074cefc&quot;,&quot;caption&quot;:&quot;Back in January, I kicked off a series of microcontroller-themed articles by showing off a couple of basic handheld games that I built with my kids. A bit later, I followed up with a more ambitious project to revive a block-pushing classic on an 8-bit MCU interfaced to a full-color OLED display. In an era of Raspberry Pi everywhere, I wanted to illustr&#8230;&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;MCU land, part 10: blocks all the way down&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-09-20T05:18:58.097Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/71171481-b3fb-4e33-be73-8218ad178337_2000x1334.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/mcu-land-part-10-blocks-all-the-way&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:137199271,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:6,&quot;comment_count&quot;:3,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;8fbf0677-72bb-430b-ad9f-749dcfce045e&quot;,&quot;caption&quot;:&quot;In a recent series of articles, I sought to demystify the world of &#8220;bare&#8221; microcontrollers and promote them as a viable alternative to Linux-based embedded solutions such as Raspberry Pi. In today&#8217;s post, I&#8217;d like to offer an walkthrough of an audio processing project implemented on a bottom-dollar 8-bit MCU.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;MCU land, part 4: building an audio toy&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-01-31T01:14:42.404Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/425d2271-b640-48e3-ae54-374f6530954c_1600x1068.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/mcu-land-part-4-building-an-audio&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:99687853,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:3,&quot;comment_count&quot;:8,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p><em>I write well-researched, original articles about geek culture, electronic circuit design, algorithms, and more. If you like the content, please subscribe.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[How much of HN is AI?]]></title><description><![CDATA[I have a complicated relationship with Hacker News. The site is the most important aggregator of geek news and a major source of traffic to this blog. At the same time, it has a fair number of toxic commenters, making it a dependable source of insults hurled in my general direction; if you want a taste,]]></description><link>https://lcamtuf.substack.com/p/how-much-of-hn-is-ai</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/how-much-of-hn-is-ai</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Thu, 12 Mar 2026 01:13:16 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!nyFk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F186ff171-6d6b-44c5-a7bd-951cea16899e_2000x713.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I have a complicated relationship with <a href="https://news.ycombinator.com">Hacker News</a>. The site is the most important aggregator of geek news and a major source of traffic to this blog. At the same time, it has a fair number of toxic commenters, making it a dependable source of insults hurled in my general direction; if you want a taste, <a href="https://lcamtuf.substack.com/p/how-has-mathematics-gotten-so-abstract">this article</a> has been called &#8220;watered-down&#8221; and &#8220;slop&#8221;.</p><p>The site is run by geeks and for geeks, so it&#8217;s not immune to tech trends; for example, around 2018, it had a fair number of stories focused on cryptocurrencies and NFT. That said, the recent shift feels more profound: almost every day, it feels that the lineup is dominated by stories focused on AI, written by AI, or commented on by AI.</p><p>To get a sense of how much of the feed is occupied by AI-related topics &#8212; often vendor announcements &#8212; I took a sampling of the daily top #5 for February 2026:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nyFk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F186ff171-6d6b-44c5-a7bd-951cea16899e_2000x713.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nyFk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F186ff171-6d6b-44c5-a7bd-951cea16899e_2000x713.jpeg 424w, https://substackcdn.com/image/fetch/$s_!nyFk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F186ff171-6d6b-44c5-a7bd-951cea16899e_2000x713.jpeg 848w, https://substackcdn.com/image/fetch/$s_!nyFk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F186ff171-6d6b-44c5-a7bd-951cea16899e_2000x713.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!nyFk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F186ff171-6d6b-44c5-a7bd-951cea16899e_2000x713.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nyFk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F186ff171-6d6b-44c5-a7bd-951cea16899e_2000x713.jpeg" width="1456" height="519" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/186ff171-6d6b-44c5-a7bd-951cea16899e_2000x713.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:519,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:523696,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/190677413?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F186ff171-6d6b-44c5-a7bd-951cea16899e_2000x713.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!nyFk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F186ff171-6d6b-44c5-a7bd-951cea16899e_2000x713.jpeg 424w, https://substackcdn.com/image/fetch/$s_!nyFk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F186ff171-6d6b-44c5-a7bd-951cea16899e_2000x713.jpeg 848w, https://substackcdn.com/image/fetch/$s_!nyFk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F186ff171-6d6b-44c5-a7bd-951cea16899e_2000x713.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!nyFk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F186ff171-6d6b-44c5-a7bd-951cea16899e_2000x713.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>So, yep. AI took four out of five spots on <a href="https://news.ycombinator.com/front?day=2026-02-04">Feb 4</a> and <a href="https://news.ycombinator.com/front?day=2026-02-12">Feb 12</a>, plus arguably the entire line-up on <a href="https://news.ycombinator.com/front?day=2026-02-05">Feb 5</a> (story #3 was submarine marketing for an AI vendor). The only days without LLM news in the top 5 were <a href="https://news.ycombinator.com/front?day=2026-02-01">February 1</a> (with the first AI story at #7, then #9), <a href="https://news.ycombinator.com/front?day=2026-02-09">February 9</a> (first at #8), and <a href="https://news.ycombinator.com/front?day=2026-02-25">February 25</a> (with AI at #6, #9, #10).</p><p>For the second part of the experiment &#8212; figuring out which stories were likely AI-written &#8212; I tapped into <a href="https://pangram.com/">Pangram</a>. Pangram is a remarkably good, conservative model for detecting LLM-generated text. These detectors have bad rap among techies, but the objections are often based on outdated assumptions or outright misconceptions. For the tools to work, AI writing doesn&#8217;t need to be in any way &#8220;inhuman&#8221;. It&#8217;s enough that the <em>default voice</em> of the current crop of LLMs is quasi-deterministic: ask for the same essay twice and you&#8217;ll get a stylistically similar result. The individual mannerisms are human-like, but it&#8217;s very unlikely that your writing combines the exact same set.</p><p>To validate the results, I also reviewed all the flagged stories and I think the findings make sense; if anything, Pangram had a couple of false negatives. To give you a sense of what was flagged, have a look at the #3 story on <a href="https://news.ycombinator.com/front?day=2026-02-19">February 19</a> (<em>&#8220;AI is not a coworker, it&#8217;s an exoskeleton&#8221;</em>). In my opinion, it has a wide range of red flags.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[Approximation game]]></title><description><![CDATA[The number 22/7 and the pigeon flock of Peter Gustav Lejeune Dirichlet.]]></description><link>https://lcamtuf.substack.com/p/approximation-game</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/approximation-game</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Sat, 28 Feb 2026 02:26:51 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!LOrW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd00a99e4-9662-4741-ab87-e875937230b7_2500x1250.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In some of the earlier articles on this blog, we talked about the <a href="https://lcamtuf.substack.com/p/unreal-numbers">nature of real numbers</a> and the <a href="https://lcamtuf.substack.com/p/how-has-mathematics-gotten-so-abstract">meanings of infinity</a>. The theory outlined in these posts is interesting but also hopelessly abstract. It&#8217;s as if we&#8217;re inventing make-believe worlds that have no discernible connection to reality.</p><p>In today&#8217;s post, we&#8217;ll examine a cool counterexample: an outcome of an numerical experiment that can be backed up with fairly simple proofs, but that makes sense only if you take a step back to consider the construction of real numbers and rationals.</p><p>We start by picking a real number <em>r</em>. Your job is to approximate it as closely as possible using a rational fraction <em>a / b </em>with a reasonably small denominator. The approximation can&#8217;t be the same as <em>r.</em> Is this task easier if <em>r</em> itself is rational or irrational?</p><p>Make a guess and let&#8217;s dive in. For simplicity, we&#8217;ll stick to a positive <em>r </em>and positive fraction denominators throughout the article.</p><h3>Defining &#8220;good&#8221;</h3><p>For a chosen denominator <em>b</em>, it&#8217;s pretty easy to find the value of <em>a </em>that gets us the closest to the target <em>r</em>. We must consider two cases: the largest &#8220;low-side&#8221; fraction that&#8217;s still less than <em>r</em>; and the smallest &#8220;high-side&#8221; fraction<em> </em>greater than<em> r. </em>If there&#8217;s a rational fraction that matches <em>r</em> exactly, that solution is prohibited by the rules of the game; we need to pick one of the nearby values instead.</p><p>If you <em>wanted to</em> find an exact match, you could try <em>a<sub>ideal</sub> = r &#183; b</em>; this makes the <em>a / b</em> fraction equal to <em>r &#183; b / b =</em> <em>r</em>. That said, <em>r &#183; b </em>might not be an integer (or even a rational number), so even without the added &#8220;no exact matches&#8221; rule, the approach is usually a bust.</p><p>If we round the value up (&#8968;<em>r &#183; b</em>&#8969;), we get a number that is equal or greater than <em>a<sub>ideal</sub></em>; if it&#8217;s greater, the difference between the two values will be less than 1. In other words, we can write the following inequality:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;a_{ideal} \\leq\\lceil r &#183; b\\rceil < a_{ideal} + 1&quot;,&quot;id&quot;:&quot;FWUDJIYMNA&quot;}" data-component-name="LatexBlockToDOM"></div><p>This is saying that the rounded-up number<em> </em>may be equal to the ideal solution needed to match <em>r</em> exactly, or it might overshoot the target, but always by less than the minimum possible increment of the numerator in the <em>a / b</em> fraction.</p><p>The result is <em>almost</em> what we need, but once more, the rules prohibit approximations that are exactly equal to <em>r</em>. The workaround is to subtract 1 from all sides of the inequality:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;a_{ideal} - 1 \\leq \\lceil r &#183; b \\rceil -1 < a_{ideal}&quot;,&quot;id&quot;:&quot;HRYFXSJKIY&quot;}" data-component-name="LatexBlockToDOM"></div><p>The effectively tells us that the middle term &#8212; &#8968;<em>r &#183; b</em>&#8969; - 1<em> &#8212; </em>is always less than the value needed to match <em>r</em>, but the difference is never greater than a single tick of the numerator. We&#8217;re as close as we can be; the value of <em>a </em>for the optimal low-side approximation (<em>a / b </em>&lt;<em> r) </em>is:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;a_{low} = \\lceil r \\cdot b \\rceil - 1 &quot;,&quot;id&quot;:&quot;TIYHFSFSAB&quot;}" data-component-name="LatexBlockToDOM"></div><p>We can follow the same thought process to find the high-side estimate (<em>a / b </em>&gt;<em> r)</em>; this time, we round the product down and then add 1:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;a_{high} = \\lfloor r \\cdot b \\rfloor + 1\n&quot;,&quot;id&quot;:&quot;ZVYVDBUIHC&quot;}" data-component-name="LatexBlockToDOM"></div><p>Finally, the error (<em>&#949;</em>) associated with any <em>a / b</em> can be easily calculated as:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\varepsilon = \\biggl|r - \\frac{a}{b}\\biggr|&quot;,&quot;id&quot;:&quot;JPUNCSCKXG&quot;}" data-component-name="LatexBlockToDOM"></div><p>We have previously established that if we pick <em>a<sub>low </sub></em>or <em>a<sub>high</sub></em>, the error can&#8217;t exceed one tick of the numerator, which works out to &#177; 1/<em>b</em>. As a practical example, if we&#8217;re trying to approximate <em>r = </em>2 using <em>b = </em>5, the best inexact solutions are 9/5 = 1.8 on the low side and 11/5 = 2.2 on the high side; they both have an error of 1/<em>b </em>= 0.2<em>.</em></p><p>Next, we&#8217;ll try to examine if the error can be less. If we find any approximations that are better than the worst-case scenario &#8212; i.e., that satisfy <em>&#949; </em>&lt; 1/<em>b</em> &#8212; we&#8217;re gonna call them 1-<em>good.</em></p><p>As an inspection aid, we can also define a normalized score <em>s</em> calculated by multiplying <em>&#949;</em> by <em>b</em>:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;s = \\varepsilon \\cdot b&quot;,&quot;id&quot;:&quot;KJIPGXEKBA&quot;}" data-component-name="LatexBlockToDOM"></div><p>The equation keeps the maximum error at 1 regardless of the denominator we&#8217;ve chosen. By that metric, a 1-good approximation is associated with <em>s</em> &lt; 1.</p><h3>The rational test case</h3><p>Now that we have the mechanics spelled out, let&#8217;s take <em>r = </em>1/4 and analyze the optimal solutions for some initial values of <em>b:</em></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{|r|c|c|c|l|}\n\\hline\n\\mathbf{b} &amp; \\textbf{Best a/b} &amp; \\textbf{Error (&#949;)} &amp; \\textbf{Score }\\mathbf{(s)} &amp; \\textbf{1-good?} \\\\\n\\hline\n1 &amp; 0/1 &amp; 1/4 &amp; 1/4 &amp; yes\\\\\n\\hline\n2 &amp; 0/2 &amp; 1/4 &amp; 1/2 &amp; yes\\\\\n\\hline\n3 &amp; 1/3 &amp; 1/12 &amp; 1/4 &amp; yes \\\\\n\\hline\n4 &amp; 0/4 &amp; 1/4 &amp; 1 &amp; no \\\\\n\\hline\n5 &amp; 1/5 &amp; 1/20 &amp; 1/4 &amp; yes \\\\\n\\hline\n6 &amp; 2/6 &amp; 1/12 &amp; 1/2 &amp; yes\\\\\n\\hline\n7 &amp; 2/7 &amp; 1/28 &amp; 1/4 &amp; yes\\\\\n\\hline\n8 &amp; 1/8 &amp; 1/8  &amp; 1 &amp; no\\\\\n\\hline\n9 &amp; 2/9 &amp; 1/36 &amp; 1/4 &amp; yes\\\\\n\\hline\n10 &amp; 2/10 &amp; 1/20 &amp; 1/2 &amp; yes\\\\\n\\hline\n\\end{array}&quot;,&quot;id&quot;:&quot;ZHPOPQMMNR&quot;}" data-component-name="LatexBlockToDOM"></div><p>We find that many approximations are 1-good (<em>&#949;</em> &lt; 1/<em>b</em>, <em>s</em> &lt; 1) and outperform their peers; for example, 1/5 = 0.2 is better than 2/6 &#8776; 0.333. Nevertheless, the results are underwhelming: the values diverge from the 1/<em>b</em> baseline by small factors that are stuck on repeat. If we plot a larger sample, we get:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ZWwG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0009ed6d-03a4-4777-973b-afcb6457f9dd_2500x1250.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZWwG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0009ed6d-03a4-4777-973b-afcb6457f9dd_2500x1250.png 424w, https://substackcdn.com/image/fetch/$s_!ZWwG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0009ed6d-03a4-4777-973b-afcb6457f9dd_2500x1250.png 848w, https://substackcdn.com/image/fetch/$s_!ZWwG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0009ed6d-03a4-4777-973b-afcb6457f9dd_2500x1250.png 1272w, https://substackcdn.com/image/fetch/$s_!ZWwG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0009ed6d-03a4-4777-973b-afcb6457f9dd_2500x1250.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZWwG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0009ed6d-03a4-4777-973b-afcb6457f9dd_2500x1250.png" width="1456" height="728" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0009ed6d-03a4-4777-973b-afcb6457f9dd_2500x1250.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:728,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:151620,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/189104530?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0009ed6d-03a4-4777-973b-afcb6457f9dd_2500x1250.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ZWwG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0009ed6d-03a4-4777-973b-afcb6457f9dd_2500x1250.png 424w, https://substackcdn.com/image/fetch/$s_!ZWwG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0009ed6d-03a4-4777-973b-afcb6457f9dd_2500x1250.png 848w, https://substackcdn.com/image/fetch/$s_!ZWwG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0009ed6d-03a4-4777-973b-afcb6457f9dd_2500x1250.png 1272w, https://substackcdn.com/image/fetch/$s_!ZWwG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0009ed6d-03a4-4777-973b-afcb6457f9dd_2500x1250.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Approximation scores for r = 1/4.</em></figcaption></figure></div><p>In this log-scale plot, I also included a diagonal line that represents error values decreasing with the <em>square</em> of the denominator (1/<em>b</em>&#178;). Approximations for which the error dips below this line would be markedly better than the ones that merely dip below 1/<em>b</em>. We can label these 1/<em>b</em>&#178; solutions as <em>2-good</em>.</p><p>In the plot, we see two trivial approximations below the 2-good line, but for a rational <em>r,</em> we can prove that the effect can&#8217;t last. We start by rewriting <em>r </em>as a fraction of two integers: <em>r</em> = <em>p </em>/ <em>q</em>. The 2-goodness criteria is <em>&#949; </em>&lt;<em> </em>1/<em>b</em>&#178;. We&#8217;ve previously defined <em>&#949; </em>=<em> </em>| <em>r - a/b </em>| and per the rules of the game, valid solutions must have <em>&#949;</em> greater than zero. Putting it all together, we can write the following inequality that spells out the requirements for 2-good approximations of rationals:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;0 < \\biggl| \\frac{p}{q} - \\frac{a}{b}\\biggr| < \\frac{1}{b^2}&quot;,&quot;id&quot;:&quot;HXUIITJKTK&quot;}" data-component-name="LatexBlockToDOM"></div><p>To tidy up, we can bring the middle part to a common denominator:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;0 < \\biggl| \\frac{b\\cdot p - a \\cdot q}{b \\cdot q}\\biggr| < \\frac{1}{b^2}&quot;,&quot;id&quot;:&quot;HFBQNGBGFV&quot;}" data-component-name="LatexBlockToDOM"></div><p>The denominator <em>b &#183; q</em> is positive, so there&#8217;s no harm in taking it out of the absolute-value section and multiplying all sides of the inequality by it:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;0 < \\bigl|b \\cdot p - a \\cdot q \\bigr|< \\frac{q}{b}&quot;,&quot;id&quot;:&quot;QBNIOJAZZB&quot;}" data-component-name="LatexBlockToDOM"></div><p>All the variables here are integers. If <em>b &#8805; q</em>, the fraction on the right is necessarily &#8804; 1. That creates an issue because it implies the following:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;0 < \\bigl|b \\cdot p - a \\cdot q \\bigr|< 1&quot;,&quot;id&quot;:&quot;XLRCWYMWBU&quot;}" data-component-name="LatexBlockToDOM"></div><p>Again, the middle section comprises of integers, so it can&#8217;t possibly net fractions. In effect, the equality says: 0<em> &lt; integer &lt; </em>1; there&#8217;s no integer that satisfies this criterion, so the assumption of <em>b &#8805; q </em>leads to a contradiction. If any inexact 2-good approximations of rational numbers exist, they can only exist for <em>b &lt; q. </em></p><p>That&#8217;s where we look next. If the target real <em>r</em> = <em>p / q</em> is given at the start, then <em>q </em>doesn&#8217;t change and the <em>b</em> &lt; <em>q </em>condition restricts the solutions to integer <em>a / b</em> fractions with denominators smaller than <em>q</em>. There&#8217;s only a finite number of these.</p><p>To address one natural objection, we don&#8217;t get more latitude for <em>b</em> by rewriting <em>r </em>to use proportionately greater <em>q </em>and <em>p </em>&#8212; for example, by restating <em>r</em> = 1/2 as <em>r</em> = 4/8. If we multiply both the numerator and the denominator by the same factor &#8212; say, 4 &#8212; we go from the original inequality:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;0 < \\bigl|b \\cdot p - a \\cdot q \\bigr|< \\frac{q}{b}&quot;,&quot;id&quot;:&quot;OVQKHJAUFS&quot;}" data-component-name="LatexBlockToDOM"></div><p>&#8230;to:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;0 < \\bigl|b \\cdot {4} p - a \\cdot {4} q \\bigr|< \\frac{{4} q}{b}\n&quot;,&quot;id&quot;:&quot;ABYVSPMBEI&quot;}" data-component-name="LatexBlockToDOM"></div><p>&#8230;which is the same as:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;0 < 4 \\cdot \\bigl|b \\cdot p - a \\cdot q \\bigr|< \\frac{{4} q}{b}\n&quot;,&quot;id&quot;:&quot;GUNWLJGFGS&quot;}" data-component-name="LatexBlockToDOM"></div><p>This amounts to multiplying all sides of the earlier inequality by a constant factor, so the solution doesn&#8217;t change. In effect, if any 2-good approximations of a rational number <em>r </em>exist, there can&#8217;t be more of them than allowed by the <em>b &lt; q </em>criteria for the lowest-terms representation of <em>r = p / q. </em>And these solutions, if any, will be clustered on the left side of the plot because they must obey <em>b</em> &lt; <em>q.</em></p><p>This is about as much as we can squeeze out of that stone. The bottom line is that rational numbers are difficult to approximate using other rationals; in fact, the simpler the number, the fewer good approximations we get.</p><h3>Approximating irrationals</h3><p>If rationals tend to be relatively resistant to approximations, it might be tempting to assume that the situation with irrational numbers is going to be worse. But, to cut to the chase, here&#8217;s the plot of approximations for <em>r</em> = <em>&#960;</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LOrW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd00a99e4-9662-4741-ab87-e875937230b7_2500x1250.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LOrW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd00a99e4-9662-4741-ab87-e875937230b7_2500x1250.png 424w, https://substackcdn.com/image/fetch/$s_!LOrW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd00a99e4-9662-4741-ab87-e875937230b7_2500x1250.png 848w, https://substackcdn.com/image/fetch/$s_!LOrW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd00a99e4-9662-4741-ab87-e875937230b7_2500x1250.png 1272w, https://substackcdn.com/image/fetch/$s_!LOrW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd00a99e4-9662-4741-ab87-e875937230b7_2500x1250.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LOrW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd00a99e4-9662-4741-ab87-e875937230b7_2500x1250.png" width="1456" height="728" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d00a99e4-9662-4741-ab87-e875937230b7_2500x1250.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:728,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:201334,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/189104530?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd00a99e4-9662-4741-ab87-e875937230b7_2500x1250.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!LOrW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd00a99e4-9662-4741-ab87-e875937230b7_2500x1250.png 424w, https://substackcdn.com/image/fetch/$s_!LOrW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd00a99e4-9662-4741-ab87-e875937230b7_2500x1250.png 848w, https://substackcdn.com/image/fetch/$s_!LOrW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd00a99e4-9662-4741-ab87-e875937230b7_2500x1250.png 1272w, https://substackcdn.com/image/fetch/$s_!LOrW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd00a99e4-9662-4741-ab87-e875937230b7_2500x1250.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Approximation scores for r = &#960;.</em></figcaption></figure></div><p>Note that the plot keeps dipping below the 2-good line over and over again. And there are some really nice approximations in there! The first arrow points to 22 / 7 &#8776; 3.143 (<em>s</em> &#8776; 0.009). The second arrow points to an even better one: 355 / 113 &#8776; 3.141593 (<em>s</em> &#8776; 0.00003). What&#8217;s up with that?</p><p>Before we investigate, let&#8217;s confirm that <em>&#960;</em> is not special. Surely enough, these patterns crop up for other irrationals too. And it&#8217;s not just famous transcendental constants; here&#8217;s &#8730;42:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ooof!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1460307a-d3c9-4c7c-a17b-0c29d0524eed_2500x1250.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ooof!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1460307a-d3c9-4c7c-a17b-0c29d0524eed_2500x1250.png 424w, https://substackcdn.com/image/fetch/$s_!ooof!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1460307a-d3c9-4c7c-a17b-0c29d0524eed_2500x1250.png 848w, https://substackcdn.com/image/fetch/$s_!ooof!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1460307a-d3c9-4c7c-a17b-0c29d0524eed_2500x1250.png 1272w, https://substackcdn.com/image/fetch/$s_!ooof!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1460307a-d3c9-4c7c-a17b-0c29d0524eed_2500x1250.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ooof!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1460307a-d3c9-4c7c-a17b-0c29d0524eed_2500x1250.png" width="1456" height="728" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1460307a-d3c9-4c7c-a17b-0c29d0524eed_2500x1250.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:728,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:195935,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/189104530?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1460307a-d3c9-4c7c-a17b-0c29d0524eed_2500x1250.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ooof!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1460307a-d3c9-4c7c-a17b-0c29d0524eed_2500x1250.png 424w, https://substackcdn.com/image/fetch/$s_!ooof!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1460307a-d3c9-4c7c-a17b-0c29d0524eed_2500x1250.png 848w, https://substackcdn.com/image/fetch/$s_!ooof!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1460307a-d3c9-4c7c-a17b-0c29d0524eed_2500x1250.png 1272w, https://substackcdn.com/image/fetch/$s_!ooof!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1460307a-d3c9-4c7c-a17b-0c29d0524eed_2500x1250.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Approximating r = &#8730;42.</em></figcaption></figure></div><p>To understand what&#8217;s going on, we need to build a lengthier proof, although we&#8217;ll still stay within the realm of middle-school math.</p><p>First, we make a simple observation: given some number <em>r</em>, we can always split that number into an integer part <em>v</em> and a fractional part <em>x</em> that satisfies 0 &#8804; <em>x </em>&lt; 1. In other words, we&#8217;re rewriting <em>r</em> as <em>v</em> + <em>x</em> such that <em>x </em>falls in the interval [0, 1).</p><p>We can also deconstruct any multiple of <em>r</em> the same way. In particular, we can calculate <em>k</em> <em>&#183; r </em>for every integer <em>k</em> between 0 and some arbitrary upper bound <em>K &gt; 0</em>; for each of the resulting values, we can then split the result to obtain a sequence of integer parts (<em>v</em><sub>0 </sub>to <em>v</em><sub>K</sub>) and fractional parts (<em>x</em><sub>0 </sub>to <em>x</em><sub>K</sub>). A simple illustration of this idea for <em>&#960;</em> is:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{alignat}{1}\n0 \\cdot \\pi \\quad &amp;\\rightarrow \\quad v_0 = 0, &amp;&amp;x_0 = 0 \\\\\n1 \\cdot \\pi \\quad &amp;\\rightarrow \\quad v_1 = 3, &amp;&amp;x_1 = 0.1415\\ldots \\\\\n2 \\cdot \\pi \\quad &amp;\\rightarrow \\quad v_2 = 6, &amp;&amp;x_2 = 0.2831\\ldots \\\\\n3 \\cdot \\pi \\quad &amp;\\rightarrow \\quad v_3 = 9, \\quad &amp;&amp;x_3 = 0.4247\\ldots \\\\\n&amp;\\ldots\n\\end{alignat}&quot;,&quot;id&quot;:&quot;CTUMTQGZCC&quot;}" data-component-name="LatexBlockToDOM"></div><p>These integer and fractional sequences both have K + 1 elements because we started counting at zero &#8212; and again, each fractional part falls somewhere in the interval [0, 1). </p><p>Next, we divide the [0, 1) interval into K sub-intervals (&#8220;buckets&#8221;) of equal size:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\underbrace{\\biggl[0, \\; \\frac{1}{K}\\biggr)}_\\textrm{bucket 1}, \\;\n\n\\underbrace{\\biggl[\\frac{1}{K}, \\; \\frac{2}{K}\\biggr)}_\\textrm{bucket 2},\n\n\\; \\ldots \\;, \\;\n\n\\underbrace{\\biggl[\\frac{K-1}{K}, \\; 1\\biggr)}_\\textrm{bucket K}&quot;,&quot;id&quot;:&quot;MMYUOUVLBM&quot;}" data-component-name="LatexBlockToDOM"></div><p>We have K buckets and <em>K + </em>1 fractional <em>x</em> values that are distributed across these buckets; no matter how we slice and dice it, at least two <em>x</em> values will necessarily end up in the same bucket. This is the <em>pigeonhole principle.</em></p><p>Again, the reasoning implies that there&#8217;s at least one pair of indices, <em>g</em> &lt; <em>h, </em>such that <em>x<sub>g </sub></em>and <em>x<sub>h</sub></em> both ended up in the same bucket. We don&#8217;t know anything about the underlying numbers, except that by the virtue of where they landed, they must be less than the width of the bucket (1 / <em>K</em>) apart:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\bigl|x_h - x_g\\bigr| < \\frac{1}{K}&quot;,&quot;id&quot;:&quot;YWUQHRHNQG&quot;}" data-component-name="LatexBlockToDOM"></div><p>The inevitability of a pair of elements with spacing of less than 1 / <em>K </em>is the crux of the proof. The rest is just a bit of manipulation to relate these elements to a rational approximation of the starting number <em>r.</em></p><p>We show this in a couple of steps. First, as a consequence of how we constructed these fractional parts, we can rewrite any <em>x<sub>k </sub></em>as the difference between the <em>k-</em>th multiple of <em>r </em>and the associated integer part <em>v<sub>k</sub></em>. After making these substitutions for indices <em>h </em>and <em>g</em>, we get:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\bigl| \\underbrace{h \\cdot r - v_h}_{x_h} - (\\underbrace{g \\cdot r - v_g}_{x_g}) \\bigr| < \\frac{1}{K}&quot;,&quot;id&quot;:&quot;DJDHIZKZFJ&quot;}" data-component-name="LatexBlockToDOM"></div><p>Next, we group the <em>r-</em>coupled and <em>r-</em>free terms, obtaining what appears to be two independent integers: (<em>v<sub>h </sub></em>- <em>v<sub>g</sub></em>) and (<em>h - g</em>). We label these <em>a </em>and <em>b:</em></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\bigl| r \\cdot \\underbrace{(h - g)}_b - \\underbrace{(v_h - v_g)}_a \\bigr| < \\frac{1}{K}&quot;,&quot;id&quot;:&quot;FTRKNMJCUE&quot;}" data-component-name="LatexBlockToDOM"></div><p>We don&#8217;t need to dwell on the possible values of <em>a; </em>it&#8217;s enough that the number can exist. We&#8217;re also not concerned about the exact value of <em>b</em>, although we ought to note that it&#8217;s always positive (because we specified <em>g &lt; h</em>) and that it&#8217;s necessarily less than or equal to <em>K</em> (because it represents the difference of indices in a list with <em>K</em> + 1 elements).</p><p>We&#8217;ll lean on these properties soon, but for now, let&#8217;s bake <em>a </em>and <em>b</em> into the earlier inequality to obtain:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\bigl| r \\cdot b - a \\bigr| < \\frac{1}{K} \\quad \\textrm{(&#9873;)}&quot;,&quot;id&quot;:&quot;NYYTVHWLAS&quot;}" data-component-name="LatexBlockToDOM"></div><p>Remember the flag for later and divide both sides by <em>b</em> to obtain:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;{\\bigl| r - \\frac{a}{b} \\bigr|}< \\frac{1}{K\\cdot b}&quot;,&quot;id&quot;:&quot;BJORHAOOZQ&quot;}" data-component-name="LatexBlockToDOM"></div><p>Huh &#8212; the left-hand portion of the expression is the same as the earlier formula for calculating the error (<em>&#949;)</em> for an approximation of <em>r</em> with a rational fraction <em>a / b. </em>In other words, the inequality seems to be saying that, as a consequence of the pigeonhole principle, we can pick any <em>r </em>and any <em>K </em>&gt; 0, and there&#8217;s always some integer <em>a / b</em> that approximates <em>r</em> with an error of less than 1 / (<em>K &#183; b</em>).</p><p>We haven&#8217;t picked any specific <em>K</em>, but we know that <em>b</em> is always less or equal than <em>K</em>; again, this is because we defined <em>b </em>as a substitution for <em>h - g</em>, the delta between two indices in a sequence of <em>K + 1</em> elements. Therefore, the expression in the denominator &#8212; K<em> &#183; b &#8212; </em>involves multiplying <em>b</em> by a value that&#8217;s equal or greater than <em>b. </em>In effect, we have proof that for any real <em>r, </em>some <em>a / b</em> satisfies <em>&#949; &lt; </em>1/<em>b&#178;</em>.</p><p>This proof is known as <em>Dirichlet&#8217;s approximation theorem</em>. At first blush, it only guarantees a single 2-good approximation for every real. Worse yet, the solution guaranteed by the proof might not comply with the rules of our game, because nothing stops it from producing exact approximations (<em>&#949; = </em>0). So, what did we achieve?</p><p>Well, that&#8217;s where we come back to an intermediate equation marked with &#9873;:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\bigl| r \\cdot b - a \\bigr| < \\frac{1}{K} \\\\&quot;,&quot;id&quot;:&quot;ZMHGVLWBXH&quot;}" data-component-name="LatexBlockToDOM"></div><p>In the earlier course of the proof, we divided the left-hand side of this inequality by <em>b</em> to arrive at the formula identical to <em>&#949;. </em>Equivalently, we can say that the current form is equal to <em>&#949; &#183; b</em>. We already have a name for this parameter: this is the normalized approximation error <em>s</em>, as introduced early in the article.</p><p>We can also assert that for any irrational <em>r</em>, the left-hand side of that inequality must be greater than zero. To prove this property, it&#8217;s sufficient to show that we&#8217;d end up with a contradiction if multiplying <em>r </em>by some positive integer (<em>b</em>) produced some sort of a rational number &#8212; that is, if it netted an ad hoc fraction <em>h / j, </em>where <em>h </em>and <em>j </em>are also integers. If <em>r </em> <em>&#183; b = h / j,</em> we can represent <em>r </em>itself as a fraction, making it rational:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;r \\cdot b = \\frac{h}{j} \\quad \\implies \\quad r = \\frac{h}{j \\cdot b}&quot;,&quot;id&quot;:&quot;DWBKNDHDWL&quot;}" data-component-name="LatexBlockToDOM"></div><p>In other words, if <em>r </em>is irrational, the same must hold for <em>r &#183; b</em>. Since <em>r &#183; b</em> is an irrational number and not an integer, subtracting an integer from it will always leave a fractional part. Therefore, <em>s = </em>|<em> r </em> <em>&#183; b - a </em>| must be &gt; 0.</p><p>To take the next step &#8212; and we&#8217;re close to the finish line! &#8212; note that Dirichlet&#8217;s proof doesn&#8217;t put any constraint on the upper value on the number of buckets (<em>K</em>)<em>. </em>If we choose some specific <em>K</em><sub>1</sub>, the earlier proof establishes the existence of a single 2-good pair, which we can label <em>a</em><sub>1 </sub>and <em>b</em><sub>1</sub>. If we choose another value <em>K</em><sub>2</sub>, the proof establishes the existence of a potentially different pair we&#8217;ll call <em>a</em><sub>2 </sub>and <em>b</em><sub>2</sub>. That said, who knows if the pairs actually differ? Maybe there&#8217;s just a single solution that repeats for every <em>K</em>?&#8230;</p><p>Let&#8217;s assume that&#8217;s the case; if the resulting approximations are identical, the same goes for the normalized approximation error: <em>s</em> = <em>s</em><sub>1</sub><em> = s</em><sub>2</sub>. To restate this more explicitly, we&#8217;re entertaining the possibility that this single value satisfies the flagged inequality in both proofs: <em>s &lt; </em>1<em> / K</em><sub>1</sub> and  <em>s &lt; </em>1<em> / K</em><sub>2</sub>.</p><p>At the same time, we have noted that in the irrational case, <em>s</em> must be positive. Real numbers can be arbitrarily small, but they can&#8217;t be infinitely small, so for any positive <em>s </em>that obeys the first inequality, we can make the 1 / <em>K</em><sub>2 </sub>fraction in the second proof smaller than <em>s</em> simply by choosing a sufficiently large <em>K</em><sub>2</sub>. This breaks the second inequality and leads to a contradiction. We must conclude that, for some <em>K</em><sub>2 </sub>&gt; <em>K</em><sub>1</sub><em>, </em>we necessarily get a new, better approximation (<em>s</em><sub>2</sub> &lt; <em>s</em><sub>1</sub>).</p><p>Further, if we keep incrementing <em>K</em>, this new <em>a</em><sub>2 </sub>/ <em>b</em><sub>2 </sub>approximation will eventually succumb to the same fate. We can evidently get as many 2-good pairs as we want. The proof doesn&#8217;t guarantee that it&#8217;s going to happen on any specific cadence, but it says that the outcome is inevitable.</p><p>As a postscript, we ought to ask if the same reasoning applies to rationals; if it does, that would contradict our earlier argument that rational numbers can only have a handful of 2-good solutions. To show that there is no contradiction, note that in the rational case, <em>s </em>can conceivably reach zero (i.e., there is some <em>a / b</em> value that is an exact approximation). The rules of our game reject these approximations, but as discussed earlier, the same constraint is not baked into Dirichlet&#8217;s proof.</p><p>Next, let&#8217;s rewrite our rational <em>r </em>as <em>p / q </em>in the left-hand portion of the earlier inequality:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\biggl| r \\cdot b - a \\biggr|  = \\biggl| \\frac{p}{q} \\cdot b - a \\biggr|  = \\biggl| \\frac{b \\cdot p - a \\cdot q}{q} \\biggr| &quot;,&quot;id&quot;:&quot;OXJZZEOKYP&quot;}" data-component-name="LatexBlockToDOM"></div><p>The numerator of the fraction on the right is an integer (because so are <em>a</em>, <em>b</em>, <em>p</em>, and <em>q</em>). The denominator is also an integer that stays constant for a given <em>r. </em>It follows that when approximating rationals, there is a fixed, minimum decrement for <em>s</em>: 1/<em>q</em>. We might start from a non-zero <em>s</em><sub>1</sub><em>, </em>but if we keep ramping up <em>K</em>, the system <em>must</em> reach the degenerate <em>s<sub>n</sub> = </em>0 case after producing a finite number of inexact approximations. From that point on, <em>s</em> &lt; 1 / <em>K</em> is satisfied for any <em>K</em> and the proof no longer necessitates the generation of additional 2-good pairs.</p><p>As before, we can&#8217;t cheat by increasing <em>p </em>in tandem with <em>q</em> (e.g., <em>r</em> = 1/2 to <em>r =</em> 4/8). This trick increments the nominator and the denominator by the same factor, still producing the same effective step; the solution is predicated on the lowest-terms representation of <em>r = p / q.</em></p><p>In the end, you get an infinite supply of surprisingly accurate solutions for irrational numbers, but a limited (often <em>very </em>limited) number of decent results for rationals.</p><h3>But&#8230; why?</h3><p>Right. The proofs are interesting but don&#8217;t offer an intuitive explanation of why these patterns emerge. This is where we go back to my opening remark: it&#8217;s easier to grasp the outcome if you look at how rational numbers and reals are &#8220;made&#8221;.</p><p>From the construction of rationals, we know that the spacing between them is arbitrarily close, but at any &#8220;magnification level&#8221; &#8212; for any chosen denominator <em>b </em>&#8212; the values divide the continuum into uniform intervals. Uniform spacing also implies <em>maximal</em> spacing: even though there is no upper or lower bound to the values of <em>a / b</em>, they are as far apart as they can be. Any new value inserted onto the number line will necessarily sit &#8220;closer&#8221; to an existing rational.</p><p>The gaps between rational numbers is where we find irrationals. This comes with a lot of weird baggage explored in the <a href="https://lcamtuf.substack.com/p/unreal-numbers">previous article</a>, but it also means that for any given irrational <em>r, </em>we have an inexhaustible supply of unexpectedly accurate rational approximations in the vicinity.</p><p>Although the puzzle we started with might seem silly, the study of these structures &#8212; known as <em>Diophantine approximations</em> &#8212; is taken seriously and gets complicated fast. For example, it&#8217;s possible to construct so-called <em>Liouville numbers</em> that have an infinite irrationality exponent (endless <em>n-good </em>approximations for any <em>n)</em>, but it&#8217;s a lot harder to prove that any commonly-encountered number has an irrationality exponent greater than two. In the same vein, algebraic irrationals (e.g., &#8730;2) all have an irrationality measure of two, but the proof of this is fiendishly difficult and netted its discoverer the Fields Medal back in 1958.</p><div><hr></div><p><em>You might also enjoy my other articles about math, including:</em></p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;c444329f-ee9e-4c96-a81c-cc20fa86cc19&quot;,&quot;caption&quot;:&quot;In the past couple of weeks, I&#8217;ve been posting about seemingly simple mathematical problems that defy intuition, and where the answers we find on the internet turn out to be shallow or hard to parse. For a taste, you might enjoy the articles on G&#246;del&#8217;s beavers&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;How many dimensions is this?&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-09-03T16:20:42.610Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/32743c32-71ca-45b1-b161-971d3bbedf10_1000x563.webp&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/how-many-dimensions-is-this&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:172288329,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:33,&quot;comment_count&quot;:5,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;c67c7233-67b9-402b-9161-25e3f6da2044&quot;,&quot;caption&quot;:&quot;In the past couple of months, I published a number of articles on recreational math. I did my best to keep them accessible and fun, but my goal was usually to shed light at deeper mathematical truths. For example, the discussion of 0.999&#8230; = 1 served as a springboard to highlight some of the subtler properties of real numbers and the different meanings o&#8230;&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Folks, we have the best &#960;&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-09-15T06:42:43.993Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/$s_!_Drc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ada872d-41dd-495e-917a-2dfdf67d4859_2332x1224.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/folks-we-have-the-best&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:173625523,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:60,&quot;comment_count&quot;:12,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;208ec94c-f4b7-4174-8f05-a41688c04d1b&quot;,&quot;caption&quot;:&quot;If you&#8217;re a nerd, you probably have encountered visualizations of a tesseract: a four-dimensional equivalent of a cube. Heck, various representations of the shape have made it into blockbuster sci-fi films, music videos, and more.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;You gotta think outside the hypercube&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2026-01-26T23:05:38.271Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/$s_!Punz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73d9c28a-f287-4b29-abc2-40d701fcdf60_1409x1012.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/you-gotta-think-outside-the-hypercube&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:185802725,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:25,&quot;comment_count&quot;:5,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p><em>I write well-researched, original articles about geek culture, electronic circuit design, algorithms, and more. If you like the content, please subscribe.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item><item><title><![CDATA[Unreal numbers]]></title><description><![CDATA[Reals are really weird.]]></description><link>https://lcamtuf.substack.com/p/unreal-numbers</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/unreal-numbers</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Sun, 15 Feb 2026 20:49:15 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/ba9619af-251d-4cdb-be26-83f8d14f9e8e_500x500.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A while ago, I posted an article about the 19th and early 20th century quest to <a href="https://lcamtuf.substack.com/p/how-has-mathematics-gotten-so-abstract">derive mathematics from the principles of formal logic</a>. We kicked off with Peano arithmetic, which built natural numbers from two ad-hoc constructs: an element representing zero and an abstract &#8220;successor&#8221; function <em>S(&#8230;)</em>.</p><p>Later, we leaned on set theory to encode the underlying structure of these symbols. This netted us a hierarchy of set-theoretic natural numbers known as <em>ordinals</em>. It also led to an interesting insight: if we allowed the existence of infinite sets, then the set of all natural numbers (&#8469;) itself had the structure of an ordinal. In the article, we labeled this infinite number <em>&#969;</em> and demonstrated that it could be manipulated using the same arithmetic rules as finite numbers, but that it sometimes behaved in wacky ways. For example, we established that <em>&#969;</em> + 1<em> </em>&#8800; 1 + <em>&#969;</em>.</p><p>We also touched on various methods of reasoning about the magnitude of ordinals and showed that these approaches diverge from each other in the realm of infinities. In particular, we talked about Georg Cantor&#8217;s notion of <em>cardinality</em>, which put many distinct infinite ordinals in the same size class, but indicated that there&#8217;s a fundamental difference in scale between the set of natural numbers and the set of reals (&#8477;).</p><p>If you haven&#8217;t read the article but are intrigued, I strongly encourage you to give it a go (<a href="https://lcamtuf.substack.com/p/how-has-mathematics-gotten-so-abstract">link</a>). I think it&#8217;s an excellent and accessible introduction. If you&#8217;re up to speed, there might be one thing that&#8217;s bugging you: we carefully defined natural numbers from first principles, but then pulled reals out of a hat. This is a gap worth addressing, because as it turns out, real numbers are <em>profoundly</em> weird.</p><h3>Natural numbers (&#8469;)</h3><p>As a reminder, in the earlier article, we constructed a succession of labels that corresponded to subsequent natural numbers by conjuring an object representing zero and then successively applying function <em>S(&#8230;)</em> to it:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{align}\n1 &amp;:= S(0) \\\\\n2 &amp;:= S(1) = S(S(0)) \\\\\n3 &amp;:= S(2) = S(S(S(0))) \\\\\n4 &amp;:= S(3) = S(S(S(S(0)))) \\\\\n&amp;...\n\\end{align}\n&quot;,&quot;id&quot;:&quot;VCBKTZYWYO&quot;}" data-component-name="LatexBlockToDOM"></div><p>The &#8220;:=&#8221; operator means &#8220;is defined as&#8221;. Elsewhere, you might see this written as &#8797;, &#8796;, or a regular =.</p><p>In Peano arithmetic, the label &#8220;0&#8221; and the successor function <em>S(&#8230;)</em> have no deeper meaning: they are just &#8220;things&#8221; with a couple of common-sense properties spelled out. All the notation indicates is that every subsequent label has some fixed relationship to the one that came before. In the set-theoretic approach we switched to later, we defined these concepts with more precision, but this detail doesn&#8217;t matter now.</p><p>The important point is that in both models, the successor relationship allowed us to define the behavior of the &#8220;+&#8221; operator using a pair of simple substitution rules:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{alignat}{1}\na &amp;+ 0 \\;&amp;&amp;:=\\; a&amp;&amp;\\qquad (\\textrm{rule 1}) \\\\\na &amp;+ S(b) \\;&amp;&amp;:=\\; S(a+b) &amp;&amp;\\qquad ( \\textrm{rule 2}) \n\\end{alignat}&quot;,&quot;id&quot;:&quot;GTWVUWBAWU&quot;}" data-component-name="LatexBlockToDOM"></div><p>Although the rules may seem cryptic, they effectively just codify that adding zero is a no-op and that <em>a</em> + (<em>b</em> + 1) is the same as as (<em>a + b</em>) + 1. This simple ruleset is enough to solve problems such as 2 + 2 without any assumptions about the fundamental meaning of &#8220;2&#8221; or &#8220;+&#8221;.</p><p>To illustrate, from the definition of Peano numbers, note that &#8220;2&#8221; is the same as S(1), so 2 + 2 can be restated as 2 + S(1). Switching to that form allows us to apply rule #2, in turn rewriting 2 + S(1) as S(2 + 1):</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;2 + 2 = 2 + S(1) = S(2 + 1)&quot;,&quot;id&quot;:&quot;ZHVAAPSFQP&quot;}" data-component-name="LatexBlockToDOM"></div><p>After that, we can apply the same steps again to expand the nested 2 + 1 sum:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;S(2+1) = S(2 + S(0)) = S(S(2 + 0))&quot;,&quot;id&quot;:&quot;YMIWMZVNMH&quot;}" data-component-name="LatexBlockToDOM"></div><p>We now have a doubly-nested sum involving zero, so we can apply rule #1, getting rid of the sum (2 + 0 = 2) and &#8220;unwinding&#8221; the successor functions to arrive at the result:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;2 + 2 = S(S(2+0)) = S(S(2)) = S(3) = 4&quot;,&quot;id&quot;:&quot;TZFBCPIDTG&quot;}" data-component-name="LatexBlockToDOM"></div><p>Again, if you&#8217;re interested in a more detailed walkthrough, including C code that explains the process in programmer-friendly terms, check out the article linked earlier on.</p><p>What we haven&#8217;t covered in that article is that we can use a similar approach to recursively define multiplication for naturals:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{alignat}{1}\na &amp;\\cdot 0 \\;&amp;&amp;:=\\; 0 &amp;&amp;\\qquad (\\textrm{rule 1}) \\\\\na &amp; \\cdot S(b) \\;&amp;&amp;:=\\; a \\cdot b + a &amp;&amp;\\qquad ( \\textrm{rule 2}) \n\\end{alignat}&quot;,&quot;id&quot;:&quot;ZMRIYTHYRM&quot;}" data-component-name="LatexBlockToDOM"></div><p>In effect, without having to explicitly define subtraction for the set-theoretic members of &#8469;, we&#8217;re saying that <em>a &#183; b</em> can be rewritten as <em>a &#183; (b-1) + a. </em>This process can be continued until we get to <em>a</em> <em>&#183; </em>0; at that point, the multiplication part works out to zero, so we just unwind the stack and gather all the &#8220;+ <em>a</em>&#8221; terms. For example, here&#8217;s the process to calculate 5 <em>&#183; </em>3:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{align}\n5 \\cdot 3 &amp;= 5 \\cdot 2 + 5 \\\\\n&amp;= 5 \\cdot 1 + 5 + 5 \\\\\n&amp;= \\underbrace{5 \\cdot 0}_{=\\  0} + \\underbrace{5 + 5 + 5}_{= \\ 15} \\\\\n\\end{align}&quot;,&quot;id&quot;:&quot;HSJCOGZPLB&quot;}" data-component-name="LatexBlockToDOM"></div><p>This will come in handy in a while.</p><h3>Integers (&#8484;)</h3><p>A major hurdle on our path toward a complete system of arithmetic is that natural numbers can&#8217;t represent negative values. This means that if we attempt to define subtraction, many results will not have an in-system representation, throwing a wrench in the works.</p><p>To extend &#8469; to negative numbers, we could futz around with a way to encode the minus sign and then special-case it in the arithmetic rulesets. That said, a more &#8220;regular&#8221; approach is to define integers as a separate hierarchy of numbers, each integer <em>z </em>consisting of an ordered pair of naturals: <em>z =</em> <em>(a, b). </em>The first element of the pair represents the positive component while the second represents the negative part. Thus, integer +5 can be encoded as (5, 0) while integer -5 becomes (0, 5).</p><p>You might be wondering if we just pulled the concept of an &#8220;ordered pair&#8221; out of thin air. Yes and no: it&#8217;s new here, but in set theory, these pairs are mapped to normal sets, except we design the mapping so that <em>(a, b)</em> differs from <em>(b, a)</em>. This can be done in a number of ways, but a common approach devised by Kazimierz Kuratowski is:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;(a, b) := \\{ \\{a\\}, \\{a, b\\} \\}\n&quot;,&quot;id&quot;:&quot;ABNZSOGRSH&quot;}" data-component-name="LatexBlockToDOM"></div><p>In essence, the pair is represented by a two-element set, but the second element also embeds a copy of the first, so the result is different depending on the order of the elements in the pair. This encoding has a couple of nice properties, but they&#8217;re not important to what we&#8217;re about to do.</p><p>To define the addition of pair-based integers, we can simply add the &#8220;positive&#8221; and &#8220;negative&#8221; halves separately. Since the underlying elements are natural numbers, we already know how to sum them, and we can write: </p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\n\\underbrace{(a, b)}_{\\textrm{integer 1}} + \\underbrace{(c, d)}_{\\textrm{integer 2}} \\; := \\; \\underbrace{(\\;\\overbrace{\\vphantom{|}a + c}^{\\substack{\\textrm{natural} \\\\ \\textrm{addition}}}, \\; \\overbrace{\\vphantom{|}b + d}^{\\substack{\\textrm{natural} \\\\ \\textrm{addition}}}\\;)}_{\\textrm{integer result}}&quot;,&quot;id&quot;:&quot;VVKVPXQBIK&quot;}" data-component-name="LatexBlockToDOM"></div><p>In the same vein, because each integer effectively expresses the difference between two underlying numbers, the result of multiplying two integers (<em>a, b)</em> and <em>(c, d)</em> will follow the school-taught pattern of <em>(a - b) &#183; (c - d) = ac - ad - bc + bd. </em>We split out the positive and negative parts of the solution and write:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\underbrace{(a, b)}_{\\textrm{integer 1}} \\cdot \\underbrace{(c, d)}_{\\textrm{integer 2}} \\; := \\; \\underbrace{(ac+ bd, ad + bc)}_{\\textrm{integer result}}&quot;,&quot;id&quot;:&quot;BRPYCRSRMV&quot;}" data-component-name="LatexBlockToDOM"></div><p>These rules <em>sort of</em> work. For example, adding integer +5 and -5 nets us:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;(5, 0) + (0, 5) = (5 + 0, 0 + 5) = (5, 5)&quot;,&quot;id&quot;:&quot;ROXINIWNDA&quot;}" data-component-name="LatexBlockToDOM"></div><p>The result (5, 5) seems to be saying &#8220;zero&#8221;, but it&#8217;s different from other zero-like results, such as (1, 1) or (0, 0). To make the system usable, we need to codify that pairs <em>(a, b)</em> and <em>(c, d)</em> represent the same integer if <em>a - b = c - d</em>.</p><p>We haven&#8217;t defined the subtraction operator for set-theoretic naturals that make up the integer pairs, but we can shuffle the terms of the &#8220;sameness&#8221; criterion to express the same principle in terms of addition, which we know how to do:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;a + d = c + b&quot;,&quot;id&quot;:&quot;HJLVSXBAVJ&quot;}" data-component-name="LatexBlockToDOM"></div><p>With this pair equivalence relationship defined, we assign integer labels such as &#8220;+5&#8221; not to a specific pair, but to an entire <em>equivalence class</em>: a collection of ordered pairs that satisfy the above criteria. In this model, our new hierarchy of numbers looks the following way:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{| r | l | l |}\n\\hline\n\\textbf{Integer label} &amp; \\textbf{Equivalence class} &amp; \\textbf{Class members} \\\\\n\\hline\n{-2} &amp; [(n, n+2)] &amp; (0, 2), (1, 3), (2, 4) \\ldots \\\\\n\\hline\n{-1} &amp; [(n, n+1)] &amp; (0, 1), (1, 2), (2, 3) \\ldots \\\\\n\\hline\n{0} &amp; [(n, n)] &amp; (0, 0), (1,1), (2,2) \\ldots  \\\\\n\\hline\n{+1} &amp; [(n+1, n)] &amp; (1,0), (2,1), (3,2) \\ldots \\\\\n\\hline\n{+2} &amp; [(n+2, n)] &amp; (2, 0), (3,1), (4,2) \\ldots \\\\\n\\hline\n\\end{array}\n&quot;,&quot;id&quot;:&quot;KMYAINZFIF&quot;}" data-component-name="LatexBlockToDOM"></div><p>We&#8217;re mostly done with integers, but before we wrap up, let&#8217;s ponder if the set of integers is &#8220;larger&#8221; than the set of natural numbers. By some metrics, you could argue it is. That said, using the method outlined in the earlier article, there&#8217;s at least one way to map every integer to a natural number without the risk of running out of naturals:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sROe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe949bc4d-f2a9-4f30-a0be-64c07da5b857_2000x800.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sROe!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe949bc4d-f2a9-4f30-a0be-64c07da5b857_2000x800.jpeg 424w, https://substackcdn.com/image/fetch/$s_!sROe!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe949bc4d-f2a9-4f30-a0be-64c07da5b857_2000x800.jpeg 848w, https://substackcdn.com/image/fetch/$s_!sROe!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe949bc4d-f2a9-4f30-a0be-64c07da5b857_2000x800.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!sROe!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe949bc4d-f2a9-4f30-a0be-64c07da5b857_2000x800.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sROe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe949bc4d-f2a9-4f30-a0be-64c07da5b857_2000x800.jpeg" width="1456" height="582" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e949bc4d-f2a9-4f30-a0be-64c07da5b857_2000x800.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:582,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:442656,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/187588205?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe949bc4d-f2a9-4f30-a0be-64c07da5b857_2000x800.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sROe!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe949bc4d-f2a9-4f30-a0be-64c07da5b857_2000x800.jpeg 424w, https://substackcdn.com/image/fetch/$s_!sROe!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe949bc4d-f2a9-4f30-a0be-64c07da5b857_2000x800.jpeg 848w, https://substackcdn.com/image/fetch/$s_!sROe!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe949bc4d-f2a9-4f30-a0be-64c07da5b857_2000x800.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!sROe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe949bc4d-f2a9-4f30-a0be-64c07da5b857_2000x800.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A simple mapping between &#8484; and &#8469;.</em></figcaption></figure></div><p>This works because every element in these sets is finite but there is no upper bound; for any finite +<em>n,</em> the number 2<em>n </em>is also finite and has a place in &#8469;. The existence of a one-to-one mapping implies that the sets have the same cardinality.</p><h3>Rationals (&#8474;)</h3><p>Rational numbers are values that can be expressed as a ratio of two integers: <em>a / b</em>. In the previous section, we defined each integer as an ordered pair of naturals that effectively encodes subtraction. So, here&#8217;s the neat part: nothing stops us from taking two integers and fashioning them into another, higher-level pair that encodes division. From these integer pairs, we obtain a hierarchy of rational numbers<em>: q = (a, b)</em>.</p><p>In this model, we consider rationals <em>(a, b)</em> and <em>(c, d) </em>to be equivalent if the underlying integers satisfy the criterion <em>a / b = c / d</em> (for a non-zero <em>b </em>and <em>d</em>)<em>. </em>Once again, we don&#8217;t have the division operator defined for the underlying integer values, but we know how to multiply them, so we can restate the rule the following way:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;a \\cdot d = c \\cdot b&quot;,&quot;id&quot;:&quot;ZOFLCKRZMZ&quot;}" data-component-name="LatexBlockToDOM"></div><p>This nets us the following taxonomy:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{| r | l | l |}\n\\hline\n\\textbf{Rational label} &amp; \\textbf{Equivalence class} &amp; \\textbf{Class members} \\\\\n\\hline\n2/3 &amp; [(2n, 3n)] &amp; (+2,+3), (-2,-3), (+4,+6) \\ldots \\\\\n\\hline\n1/1 &amp; [(n, n)] &amp; (+1,+1), (-1,-1), (+2,+2) \\ldots  \\\\\n\\hline\n3/2 &amp; [(3n, 2n)] &amp; (+3,+2), (-3, -2), (+6,+4) \\ldots \\\\\n\\hline\n\\end{array}\n&quot;,&quot;id&quot;:&quot;DCXRVQKBEM&quot;}" data-component-name="LatexBlockToDOM"></div><p>The multiplication rule for two pairs representing rational numbers can be defined as a trivial restatement of <em>a/b &#183; c/d = ac/(bd)</em>:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\underbrace{(a, b)}_{\\textrm{rational 1}} \\cdot \\underbrace{(c, d)}_{\\textrm{rational 2}} \\; :=  \\;\\underbrace{(a \\cdot c, b \\cdot d)}_{\\textrm{rational result}}&quot;,&quot;id&quot;:&quot;BWFYNFBPLP&quot;}" data-component-name="LatexBlockToDOM"></div><p>The addition of rationals is formalized in an equally straightforward way, following the normal <em>a/b + c/d = (ad + cb) / (bd) </em>pattern:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\underbrace{(a, b)}_{\\textrm{rational 1}} + \\underbrace{(c, d)}_{\\textrm{rational 2}} \\; := \\; \\underbrace{(ad + cb, bd)}_{\\textrm{rational result}}&quot;,&quot;id&quot;:&quot;NLIPIISTUV&quot;}" data-component-name="LatexBlockToDOM"></div><p>What&#8217;s the &#8220;size&#8221; of the set of all rational numbers? Well, again, depends on how we look at it, but we can show that the cardinality of  is not greater than &#8469;. One visual approach is to construct a two-dimensional array of fractions in the form of <em>x/y</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ECAr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e573715-620f-42e0-9259-2be71f3c9bd4_2000x1084.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ECAr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e573715-620f-42e0-9259-2be71f3c9bd4_2000x1084.jpeg 424w, https://substackcdn.com/image/fetch/$s_!ECAr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e573715-620f-42e0-9259-2be71f3c9bd4_2000x1084.jpeg 848w, https://substackcdn.com/image/fetch/$s_!ECAr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e573715-620f-42e0-9259-2be71f3c9bd4_2000x1084.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!ECAr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e573715-620f-42e0-9259-2be71f3c9bd4_2000x1084.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ECAr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e573715-620f-42e0-9259-2be71f3c9bd4_2000x1084.jpeg" width="1456" height="789" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4e573715-620f-42e0-9259-2be71f3c9bd4_2000x1084.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:789,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:491588,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/187588205?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e573715-620f-42e0-9259-2be71f3c9bd4_2000x1084.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ECAr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e573715-620f-42e0-9259-2be71f3c9bd4_2000x1084.jpeg 424w, https://substackcdn.com/image/fetch/$s_!ECAr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e573715-620f-42e0-9259-2be71f3c9bd4_2000x1084.jpeg 848w, https://substackcdn.com/image/fetch/$s_!ECAr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e573715-620f-42e0-9259-2be71f3c9bd4_2000x1084.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!ECAr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e573715-620f-42e0-9259-2be71f3c9bd4_2000x1084.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Laying out and traversing &#8474;.</em></figcaption></figure></div><p>It should be evident that because <em>x </em>and <em>y</em> coordinates separately move through every possible natural number, the array contains all positive rational fractions. Some of the tiles are redundant (e.g., 2 is the same as 4/2), but this is not important for the proof.</p><p>With the rationals laid out, we can traverse this grid in a way that lets us assign every tile to an integer without leaving any gaps and without ever running out of members of &#8469;. The start of one such traversal pattern is indicated by arrows in the figure. We begin in the top left corner (1), move one tile to the right (&#189;), take a sharp turn to the right and start moving diagonally until we hit the vertical edge (2), move one tile down (3), then follow a diagonal pattern back (toward &#8531;). Rinse, repeat. By analogy to what we&#8217;ve done for integers, the result doesn&#8217;t change if we toss negative rationals into the mix.</p><h3>Computable numbers</h3><p>Not every number can be expressed as a ratio of two integers. The two examples of irrational numbers that every reader should be familiar with are &#8730;2, which can be expressed in polynomial terms, and <em>&#960;</em>, which cannot.</p><p>Although these numbers can&#8217;t be represented as rationals, they can be explained in terms of an algorithm you need to follow to approximate them to an arbitrary degree. For example, the sum of the following terms starting at <em>n = </em>0 will slowly but surely converge to <em>&#960;</em> as the count of summed elements grows:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;{8 \\over (4n + 1)(4n + 3)}&quot;,&quot;id&quot;:&quot;GISHSQZSSE&quot;}" data-component-name="LatexBlockToDOM"></div><p>Within the bounds of the precision of floating-point numbers, you can observe the behavior by running the following C code (<a href="https://godbolt.org/z/1qdd1TqvT">demo link</a>):</p><blockquote><pre><code>#include &lt;stdio.h&gt;
#include &lt;stdint.h&gt;

int main() {
  double sum = 0;
  for (uint64_t n = 0, pos = 0; n &lt;= 65536; n++) {
    sum += 8.0 / ((4*n + 1) * (4*n + 3));
    if (n &gt;&gt; pos) { printf("[%5ld] %.05f\n", n, sum); pos++; }
  }
}</code></pre></blockquote><p>At first blush, it would appear that any well-specified irrational number of our choice can be expressed as an approximation algorithm. This leads to a concept that should appeal to any geek: <em> computable numbers</em>. It&#8217;s the set of all numbers that can be approximated to an arbitrary precision in finite time by a theoretical model of a computer known as a Turing machine. In effect, the number <em>is </em>the algorithm.</p><p>Interestingly, the cardinality of the set of computable numbers is still the same as the cardinality of &#8469;. An intuitive explanation is that there are only as many computable numbers as there are Turing machines that could generate them. The ruleset of every Turing machine can be encoded as a finite natural number &#8212; you could just write it down and then convert the spec to ASCII values &#8212; so we&#8217;re still in the realm of countable infinities.</p><h3>Reals (&#8477;)</h3><p>Of course, we don&#8217;t teach about computable numbers in school. Instead, the most common &#8220;upgrade&#8221; from &#8474; are reals: an idealized continuum on which, to put it in a hand-wavy way, <em>every number exists</em> whether we know how to algorithmically approximate it or not.</p><p>Of course, my phrasing here is severely deficient. It&#8217;s not a free-for-all: &#129364; (a potato) is not a real number, and to avoid a variety of complications, neither is &#8730;-1. The set &#8477; extends &#8474;, but it does so only in the immediate vicinity of rationals. Pick any real and I can find a rational fraction that&#8217;s arbitrarily close.</p><p>To describe the underlying structure of real numbers in more precise terms, we can turn to <em>Dedekind cuts</em>. Informally, the idea is that we can unambiguously identify each real number by associating it with the set of all rationals that come before it. More specifically, to describe real number <em>x, </em>we could take the set of rational numbers and partition it into an ordered pair of sets <em>(A, B)</em>, such that set <em>A </em>contains every rational <em>q </em>&lt; <em>x</em> and set B contains every <em>q &#8805; x</em>.</p><p>This description may seem circular: to build the representation of a real number <em>x</em>, we need to know where to make the cut, which seem to require some prior knowledge about how <em>x</em> relates to &#8474;. That said, the point isn&#8217;t that our method lets us hone in on the exact location of <em>&#960;</em>; it&#8217;s that the universe of real numbers is built by taking every possible Dedekind cut of &#8474;. Some of these cuts coincide with rational numbers and some fill the gaps in between. In all cases, the numbers <em>are</em> the cuts, and <em>&#960; </em>is somewhere out there &#8212; even if we can&#8217;t point to a specific rational number immediately precedes or follows it.</p><p>Of course, many irrational partitions can be described unambiguously even if the location of the cut in &#8474; is unclear. For example, to characterize the cut for &#8731;5, we can just say that set <em>A </em>consists of every rational <em>q</em> such that <em>q&#179;</em> &lt; 5 and set <em>B</em> contains every <em>q</em> such that <em>q&#179;</em> &#8805; 5. That said, once more, the existence of a real number doesn&#8217;t hinge on the ability to pinpoint its &#8220;insertion point&#8221; between two specific rationals.</p><p>Once we have numbers expressed in terms of Dedekind cuts, we can define arithmetic operations on reals in a pretty straightforward way. For example, to add set-theoretic real <em>(A, B)</em> to <em>(C, D)</em>, we construct a new number <em>(E, F)</em> such that for every possible rational <em>a</em> selected from <em>A </em>and every rational <em>c </em>selected from <em>C, </em>the sum <em>a + c </em>is placed in <em>E. </em>In the same vein, for every <em>b </em>in <em>B</em> and <em>d </em>in<em> D, </em>the sum <em>b + d </em>goes into <em>F</em>. </p><p>I&#8217;ll spare you the abstract set notation, but as a practical example, if <em>(A, B) </em>represents 2 and (<em>C, D)</em> represents 3, we know that every <em>a </em>selected from <em>A</em> will be less than 2 and every <em>c</em> chosen from <em>C </em>will be less than 3. Therefore, every <em>a + c </em>value placed in <em>E</em> will be less than 5. Similarly, every <em>b + d </em>that goes into <em>F </em>will be greater or equal than 5. The resulting pair <em>(E, F)</em> is therefore the same as the cut representing the number 5.</p><p>We now have a continuum that contains numbers that are allowed to exist regardless of whether they can be described by an effective, finite procedure. As an unexpected consequence, the cardinality of &#8477; is higher than &#8469;. </p><p>We explored this property in the earlier article, but to briefly recap the argument, assume the existence of <em>some</em> 1-to-1 mapping between integers and all possible infinite decimal sequences representing reals between 0 and 1. The specifics of the mapping don&#8217;t concern us; we&#8217;re just asserting that it exists:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{c}\n1 &amp; \\leftrightarrow &amp; 0.\\underline{\\textbf{1}}23456\\ldots \\\\\n2 &amp; \\leftrightarrow &amp; 0.6\\underline{\\textbf{5}}4321\\ldots \\\\\n3 &amp; \\leftrightarrow &amp; 0.99\\underline{\\textbf{9}}000\\ldots \\\\\n4 &amp; \\leftrightarrow &amp; 0.454\\underline{\\textbf{5}}45\\ldots  \\\\\n5 &amp; \\leftrightarrow &amp; 0.1111\\underline{\\textbf{1}}1\\ldots  \\\\\n6 &amp; \\leftrightarrow &amp; 0.03133\\underline{\\textbf{7}}\\ldots \\\\\n&amp; \\ldots  &amp;\n\\end{array}&quot;,&quot;id&quot;:&quot;RSSJBZTGIZ&quot;}" data-component-name="LatexBlockToDOM"></div><p>For every entry in the mapping, I underlined a successive decimal position on the real side. Equipped with this information, we can imagine a new infinite decimal built by looking at each of the underlined digits and then placing a <em>different</em> digit in the corresponding position of the newly-constructed value.</p><p>By construction, our new number necessarily differs by at least one digit from every assigned real. The presence of a member of &#8477; that isn&#8217;t assigned to an integer is a contradiction that tells us that the postulated 1-to-1 mapping can&#8217;t exist, even just for the interval of (0, 1). There is a fundamentally higher &#8220;number&#8221; of reals than naturals &#8212; an uncountable infinity.</p><h3>So what?</h3><p>Well&#8230; from the earlier discussion, recall that the cardinality of computable numbers was the same as the cardinality of &#8469;. The cardinality of &#8477; &#8212; the &#8220;magnitude&#8221; of the set of reals &#8212; is fundamentally greater than that. In other words, we can assert that most reals are uncomputable.</p><p>But what would be an example of an uncomputable real? That&#8217;s a good question! One possibility is any number that encodes the solution to the halting problem. It would <a href="https://lcamtuf.substack.com/p/monkeys-typewriters-and-busy-beavers">lead to a paradox</a> to have a computer program that allows us to decide, in the general case, whether some other computer program halts. So, if a procedure to approximate a particular real requires solving the halting problem, we can&#8217;t have that.</p><p>If you&#8217;re interested in a more thorough exploration of that particular idea, check out my earlier article on <a href="https://lcamtuf.substack.com/p/monkeys-typewriters-and-busy-beavers">busy beavers and the limits of algorithmic knowledge</a>. But to cut to the chase, there are people who believe that the universe is functionally a computer &#8212; that is, that its rules are deterministic and can be simulated by a Turing machine. If so, that would imply that uncomputable numbers can&#8217;t be zeroed in on by any finite-time physical process, including human thought. They would be truly out of reach&#8230; and again, this would apply to almost every member of &#8477;.</p><p>Cue the <em>Twilight Zone</em> theme music &#8212; and see you in a bit.</p><div><hr></div><p><em>Further reading in the series:</em></p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;2c3b07fe-00ba-45d7-bfa4-57b600018a34&quot;,&quot;caption&quot;:&quot;If you follow geeky news, you might have came across a computer science concept known as busy beavers. That said, unless you&#8217;re a mathematician by training or trade, the articles make it hard to understand what the concept means and why you should (or shouldn&#8217;t) care.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;G&#246;del's beavers, or the limits of knowledge&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-06-30T03:29:31.924Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b69d6202-8816-479e-9acd-b972a5d1b081_1322x1322.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/monkeys-typewriters-and-busy-beavers&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:167104601,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:46,&quot;comment_count&quot;:13,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p><em>I write well-researched, original articles about geek culture, electronic circuit design, algorithms, and more. If you like the content, please subscribe.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item><item><title><![CDATA[It's all a blur]]></title><description><![CDATA[Designing a slightly sneaky blur filter and then poking holes in it.]]></description><link>https://lcamtuf.substack.com/p/its-all-a-blur</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/its-all-a-blur</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Fri, 06 Feb 2026 03:38:17 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/e6dbffa9-618d-4593-947c-fa37abc75ce0_4394x2992.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you follow information security discussions on the internet, you might have heard that blurring an image is not a good way of redacting its contents. This is supposedly because blurring algorithms are reversible.</p><p>But then, it&#8217;s not wrong to scratch your head. Blurring amounts to averaging the underlying pixel values. If you average two numbers, there&#8217;s no way of knowing if you&#8217;ve started with 1 + 5 or 3 + 3. In both cases, the arithmetic mean is the same and the original information appears to be lost. So, is the advice wrong?</p><p>Well, yes and no! There are ways to achieve non-reversible blurring using deterministic algorithms. That said, in some cases, blur filters can preserve far more information than would appear to the naked eye &#8212; and do so in a pretty unexpected way. In today&#8217;s article, we&#8217;ll build a rudimentary blur algorithm and then pick it apart.</p><h3>One-dimensional moving average</h3><p>If blurring is the same as averaging, then the simplest algorithm we can choose is a single-axis moving mean. In photo editing software, this filter is commonly called <em>motion blur</em> and is fairly similar to the artifacts produced by rapid object movement or camera shake.</p><p>To implement the effect, we take a fixed-size window and replace each pixel value with the arithmetic mean of <em>n</em> pixels in its neighborhood. For <em>n = 5</em>, the process is shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!D1oj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0087865d-a763-4b28-b680-029eb525ae0e_2050x2650.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!D1oj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0087865d-a763-4b28-b680-029eb525ae0e_2050x2650.jpeg 424w, https://substackcdn.com/image/fetch/$s_!D1oj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0087865d-a763-4b28-b680-029eb525ae0e_2050x2650.jpeg 848w, https://substackcdn.com/image/fetch/$s_!D1oj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0087865d-a763-4b28-b680-029eb525ae0e_2050x2650.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!D1oj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0087865d-a763-4b28-b680-029eb525ae0e_2050x2650.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!D1oj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0087865d-a763-4b28-b680-029eb525ae0e_2050x2650.jpeg" width="1456" height="1882" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0087865d-a763-4b28-b680-029eb525ae0e_2050x2650.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1882,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:738739,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/186948507?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0087865d-a763-4b28-b680-029eb525ae0e_2050x2650.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!D1oj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0087865d-a763-4b28-b680-029eb525ae0e_2050x2650.jpeg 424w, https://substackcdn.com/image/fetch/$s_!D1oj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0087865d-a763-4b28-b680-029eb525ae0e_2050x2650.jpeg 848w, https://substackcdn.com/image/fetch/$s_!D1oj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0087865d-a763-4b28-b680-029eb525ae0e_2050x2650.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!D1oj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0087865d-a763-4b28-b680-029eb525ae0e_2050x2650.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Moving average as a simple blur algorithm.</em></figcaption></figure></div><p>Note that for the first two cells, we don&#8217;t have enough pixels in the input buffer. We can use fixed padding, &#8220;borrow&#8221; some available pixels from outside the selection area, or simply average fewer values near the boundary. Either way, the analysis doesn&#8217;t change much: the presence of this boundary, along with the discrete stepover of the averaging window, leaks information about the underlying image.</p><p>To illustrate, let&#8217;s assume that we&#8217;ve completed the blurring process and no longer have the original pixel values. To reconstruct the data, we start at the left boundary (<em>x</em> = 0). Recall that we calculated the first blurred pixel like by averaging the following pixels in the original image:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;blur(0) = {img(-2) \\ + \\ img(-1) \\ + \\ img(0) \\ +\\ img(1)\\ +\\ img(2) \\over 5}&quot;,&quot;id&quot;:&quot;WWRNGWKRPT&quot;}" data-component-name="LatexBlockToDOM"></div><p>Next, let&#8217;s have a look at the blurred pixel at <em>x</em> = 1. Its value is the average of:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;blur(1) = {img(-1)\\ +\\ img(0)\\ +\\ img(1)\\ +\\ img(2)\\ +\\ img(3) \\over 5}&quot;,&quot;id&quot;:&quot;NPIISUEDCM&quot;}" data-component-name="LatexBlockToDOM"></div><p>We can easily turn these averages into sums by multiplying both sides by the number of averaged elements (5):</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{align}\n5 \\cdot blur(0) &amp;= img(-2) + \\underline{img(-1) + img(0) + img(1) + img(2)} \\\\\n5 \\cdot blur(1) &amp;= \\underline{img(-1) + img(0) + img(1) + img(2)} + img(3)\n\\end{align}\n&quot;,&quot;id&quot;:&quot;QSGBURNAWV&quot;}" data-component-name="LatexBlockToDOM"></div><p>Note that the underlined terms repeat in both expressions; this means that if we subtract the expressions from each other, we end up with just:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;5 \\cdot blur(1) - 5 \\cdot blur(0) = img(3) - img(-2)\n&quot;,&quot;id&quot;:&quot;FXJRKEQMDZ&quot;}" data-component-name="LatexBlockToDOM"></div><p>The value of <em>img(-2) </em>is known to us: it&#8217;s one of the fixed padding pixels used by the algorithm. Let&#8217;s shorten it to <em>c</em>. We also know the values of <em>blur(0) </em>and <em>blur(1)</em>: these are the blurred pixels that can be found in the output image. This means that we can rearrange the equation to recover the original input pixel corresponding to <em>img(3):</em></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;img(3) = 5 \\cdot (blur(1) - blur(0)) + c&quot;,&quot;id&quot;:&quot;HGWTNXMNIW&quot;}" data-component-name="LatexBlockToDOM"></div><p>We can also apply the same reasoning to the next pixel:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;img(4) = 5 \\cdot (blur(2) - blur(1)) + c&quot;,&quot;id&quot;:&quot;AWWUYFKICH&quot;}" data-component-name="LatexBlockToDOM"></div><p>At this point, we seemingly hit a wall with our five-pixel average, but the knowledge of <em>img(3) </em>allows us to repeat the same analysis for the <em>blur(5)</em> / <em>blur(6)</em> pair a bit further down the line:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{align}\n5 \\cdot blur(5) &amp;= img(3) + \\underline{img(4) + img(5) + img(6) + img(7)} \\\\\n5 \\cdot blur(6) &amp;= \\underline{img(4) + img(5) + img(6) + img(7)} + img(8) \\\\\n\\\\\nimg(8) &amp;= 5 \\cdot (blur(6) - blur(5)) + img(3)\n\\end{align}\n&quot;,&quot;id&quot;:&quot;HBGBLBBJXQ&quot;}" data-component-name="LatexBlockToDOM"></div><p>This nets us another original pixel value, <em>img(8). </em>From the earlier step, we also know the value of <em>img(4)</em>, so we can find <em>img(9)</em> in a similar way. This process can continue to successively reconstruct additional pixels, although we end up with some gaps. For example, following the calculations outlined above, we still don&#8217;t know the value of <em>img(0)</em> or <em>img(1)</em>.</p><p>These gaps can be resolved with a second pass that moves in the opposite direction in the image buffer. That said, instead of going down that path, we can also make the math a bit more tidy with a harmless, good-faith tweak to the averaging algorithm in a way that doesn&#8217;t change the nature of the effect.</p><h3>Right-aligned moving average</h3><p>The modification that will make our life easier is to shift the averaging window so that one of its ends is aligned with where the computed value will be stored:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HZ_a!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc02e3684-e59b-4eb0-8509-ceed61763140_2450x950.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HZ_a!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc02e3684-e59b-4eb0-8509-ceed61763140_2450x950.jpeg 424w, https://substackcdn.com/image/fetch/$s_!HZ_a!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc02e3684-e59b-4eb0-8509-ceed61763140_2450x950.jpeg 848w, https://substackcdn.com/image/fetch/$s_!HZ_a!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc02e3684-e59b-4eb0-8509-ceed61763140_2450x950.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!HZ_a!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc02e3684-e59b-4eb0-8509-ceed61763140_2450x950.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HZ_a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc02e3684-e59b-4eb0-8509-ceed61763140_2450x950.jpeg" width="1456" height="565" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c02e3684-e59b-4eb0-8509-ceed61763140_2450x950.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:565,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:316178,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/186948507?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc02e3684-e59b-4eb0-8509-ceed61763140_2450x950.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HZ_a!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc02e3684-e59b-4eb0-8509-ceed61763140_2450x950.jpeg 424w, https://substackcdn.com/image/fetch/$s_!HZ_a!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc02e3684-e59b-4eb0-8509-ceed61763140_2450x950.jpeg 848w, https://substackcdn.com/image/fetch/$s_!HZ_a!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc02e3684-e59b-4eb0-8509-ceed61763140_2450x950.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!HZ_a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc02e3684-e59b-4eb0-8509-ceed61763140_2450x950.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Moving average with a right-aligned window.</em></figcaption></figure></div><p>In this model, the first output value is an average of four fixed padding pixels (<em>c</em>) and one original image pixel; it follows that in the <em>n = 5 </em>scenario, the underlying pixel value can be computed as:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;img(0) = 5 \\cdot blur(0) - 4 \\cdot c&quot;,&quot;id&quot;:&quot;WQVWUHQSLZ&quot;}" data-component-name="LatexBlockToDOM"></div><p>If we know <em>img(0)</em>, we now have all but one of the values that make up <em>blur(1)</em>, so we can find <em>img(1):</em></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;img(1) = 5 \\cdot blur(1) - 3 \\cdot c - img(0)&quot;,&quot;id&quot;:&quot;YWWONWXUJN&quot;}" data-component-name="LatexBlockToDOM"></div><p>The process can be continued iteratively, reconstructing the entire image &#8212; this time, without any discontinuities and without the need for a second pass.</p><p>In the illustration below, the left panel shows a detail of <em>The Birth of Venus </em>by  Sandro Botticelli; the right panel is the same image ran through the right-aligned moving average blur algorithm with a 151-pixel averaging window that moves only in the <em>x </em>direction:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!N-Jc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60f592ba-9697-46ff-abc9-d940ddc4fd8f_2850x1500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!N-Jc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60f592ba-9697-46ff-abc9-d940ddc4fd8f_2850x1500.png 424w, https://substackcdn.com/image/fetch/$s_!N-Jc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60f592ba-9697-46ff-abc9-d940ddc4fd8f_2850x1500.png 848w, https://substackcdn.com/image/fetch/$s_!N-Jc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60f592ba-9697-46ff-abc9-d940ddc4fd8f_2850x1500.png 1272w, https://substackcdn.com/image/fetch/$s_!N-Jc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60f592ba-9697-46ff-abc9-d940ddc4fd8f_2850x1500.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!N-Jc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60f592ba-9697-46ff-abc9-d940ddc4fd8f_2850x1500.png" width="1456" height="766" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/60f592ba-9697-46ff-abc9-d940ddc4fd8f_2850x1500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:766,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1366013,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/186948507?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60f592ba-9697-46ff-abc9-d940ddc4fd8f_2850x1500.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!N-Jc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60f592ba-9697-46ff-abc9-d940ddc4fd8f_2850x1500.png 424w, https://substackcdn.com/image/fetch/$s_!N-Jc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60f592ba-9697-46ff-abc9-d940ddc4fd8f_2850x1500.png 848w, https://substackcdn.com/image/fetch/$s_!N-Jc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60f592ba-9697-46ff-abc9-d940ddc4fd8f_2850x1500.png 1272w, https://substackcdn.com/image/fetch/$s_!N-Jc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60f592ba-9697-46ff-abc9-d940ddc4fd8f_2850x1500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Venus, x-axis moving average.</em></figcaption></figure></div><p>Now, let&#8217;s take the blurry image and attempt the reconstruction method outlined above &#8212; computer, ENHANCE!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-CAW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e89266-7a4a-44f9-98aa-f7d3bbeb4920_1500x1500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-CAW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e89266-7a4a-44f9-98aa-f7d3bbeb4920_1500x1500.png 424w, https://substackcdn.com/image/fetch/$s_!-CAW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e89266-7a4a-44f9-98aa-f7d3bbeb4920_1500x1500.png 848w, https://substackcdn.com/image/fetch/$s_!-CAW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e89266-7a4a-44f9-98aa-f7d3bbeb4920_1500x1500.png 1272w, https://substackcdn.com/image/fetch/$s_!-CAW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e89266-7a4a-44f9-98aa-f7d3bbeb4920_1500x1500.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-CAW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e89266-7a4a-44f9-98aa-f7d3bbeb4920_1500x1500.png" width="1456" height="1456" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/59e89266-7a4a-44f9-98aa-f7d3bbeb4920_1500x1500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1456,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:774489,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/186948507?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e89266-7a4a-44f9-98aa-f7d3bbeb4920_1500x1500.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-CAW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e89266-7a4a-44f9-98aa-f7d3bbeb4920_1500x1500.png 424w, https://substackcdn.com/image/fetch/$s_!-CAW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e89266-7a4a-44f9-98aa-f7d3bbeb4920_1500x1500.png 848w, https://substackcdn.com/image/fetch/$s_!-CAW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e89266-7a4a-44f9-98aa-f7d3bbeb4920_1500x1500.png 1272w, https://substackcdn.com/image/fetch/$s_!-CAW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e89266-7a4a-44f9-98aa-f7d3bbeb4920_1500x1500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>The Rebirth of Venus.</em></figcaption></figure></div><p>This is rather impressive. The image is noisier than before as a consequence of 8-bit quantization of the averaged values in the intermediate blurred image. Nevertheless, even with a large averaging window, fine detail &#8212; including individual strands of hair &#8212; could be recovered and is easy to discern.</p><h3>Into the second dimension</h3><p>One obvious problem with our blur algorithm is that it averages pixel values only in the x axis; as mentioned earlier, this roughly approximates motion blur or camera shake.</p><p>The approach we&#8217;ve developed can be trivially turned into a 2D filter by using a two-dimensional averaging window; if we use a square region, this is called <em>box blur.</em> That said, a more expedient and functionally similar hack is to apply the existing 1D filter in the <em>x</em> axis and then follow with a complementary pass in the <em>y </em>axis. To undo the blur, we&#8217;d then perform two recovery passes in the inverse order.</p><p>Unfortunately, whichever route we take, we&#8217;ll discover that the combined amount of averaging per pixel causes the underlying values to be quantized so severely that the reconstructed image is overwhelmed by noise unless the blur window is relatively small. For the 1D + 1D method, we get:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1n2H!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e90295d-a826-429e-968f-0422bb729af5_1500x1500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1n2H!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e90295d-a826-429e-968f-0422bb729af5_1500x1500.png 424w, https://substackcdn.com/image/fetch/$s_!1n2H!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e90295d-a826-429e-968f-0422bb729af5_1500x1500.png 848w, https://substackcdn.com/image/fetch/$s_!1n2H!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e90295d-a826-429e-968f-0422bb729af5_1500x1500.png 1272w, https://substackcdn.com/image/fetch/$s_!1n2H!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e90295d-a826-429e-968f-0422bb729af5_1500x1500.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1n2H!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e90295d-a826-429e-968f-0422bb729af5_1500x1500.png" width="1456" height="1456" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1e90295d-a826-429e-968f-0422bb729af5_1500x1500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1456,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:305842,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/186948507?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e90295d-a826-429e-968f-0422bb729af5_1500x1500.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1n2H!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e90295d-a826-429e-968f-0422bb729af5_1500x1500.png 424w, https://substackcdn.com/image/fetch/$s_!1n2H!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e90295d-a826-429e-968f-0422bb729af5_1500x1500.png 848w, https://substackcdn.com/image/fetch/$s_!1n2H!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e90295d-a826-429e-968f-0422bb729af5_1500x1500.png 1272w, https://substackcdn.com/image/fetch/$s_!1n2H!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e90295d-a826-429e-968f-0422bb729af5_1500x1500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Reconstruction from a 1D + 1D moving-average blur (x followed by y).</em></figcaption></figure></div><p>That said, if we wanted to develop an <em>adversarial</em> box blur filter, we could fix the problem by weighting the original pixel a bit more heavily in the calculated mean. For the <em>x</em>-then-<em>y</em> variant, if the averaging window has a size <em>W </em>and the current-pixel bias factor is <em>B</em>, we can write the following formula:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;blur(n) = {img(n - W) + \\ldots + img(n - 1) + B \\cdot img(n) \\over W + B}&quot;,&quot;id&quot;:&quot;MIHUYWDQCJ&quot;}" data-component-name="LatexBlockToDOM"></div><p>This filter still does what it&#8217;s supposed to do; here&#8217;s the output of an <em>x</em>-then-<em>y</em> blur for <em>W</em> = 200 and <em>B</em> = 30:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sOtT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e82cbe7-24a9-4094-82e8-1878d9fee1db_3000x1600.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sOtT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e82cbe7-24a9-4094-82e8-1878d9fee1db_3000x1600.png 424w, https://substackcdn.com/image/fetch/$s_!sOtT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e82cbe7-24a9-4094-82e8-1878d9fee1db_3000x1600.png 848w, https://substackcdn.com/image/fetch/$s_!sOtT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e82cbe7-24a9-4094-82e8-1878d9fee1db_3000x1600.png 1272w, https://substackcdn.com/image/fetch/$s_!sOtT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e82cbe7-24a9-4094-82e8-1878d9fee1db_3000x1600.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sOtT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e82cbe7-24a9-4094-82e8-1878d9fee1db_3000x1600.png" width="1456" height="777" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6e82cbe7-24a9-4094-82e8-1878d9fee1db_3000x1600.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:777,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1762427,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/186948507?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e82cbe7-24a9-4094-82e8-1878d9fee1db_3000x1600.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sOtT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e82cbe7-24a9-4094-82e8-1878d9fee1db_3000x1600.png 424w, https://substackcdn.com/image/fetch/$s_!sOtT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e82cbe7-24a9-4094-82e8-1878d9fee1db_3000x1600.png 848w, https://substackcdn.com/image/fetch/$s_!sOtT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e82cbe7-24a9-4094-82e8-1878d9fee1db_3000x1600.png 1272w, https://substackcdn.com/image/fetch/$s_!sOtT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e82cbe7-24a9-4094-82e8-1878d9fee1db_3000x1600.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Venus, heavy X-Y blur.</em></figcaption></figure></div><p>Surely, there&#8217;s no coming back from tha&#8212; COMPUTER, ENHANCE!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YYsh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b0487b6-88df-437b-98b0-d0e113e2e7fb_1600x1600.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YYsh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b0487b6-88df-437b-98b0-d0e113e2e7fb_1600x1600.png 424w, https://substackcdn.com/image/fetch/$s_!YYsh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b0487b6-88df-437b-98b0-d0e113e2e7fb_1600x1600.png 848w, https://substackcdn.com/image/fetch/$s_!YYsh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b0487b6-88df-437b-98b0-d0e113e2e7fb_1600x1600.png 1272w, https://substackcdn.com/image/fetch/$s_!YYsh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b0487b6-88df-437b-98b0-d0e113e2e7fb_1600x1600.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YYsh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b0487b6-88df-437b-98b0-d0e113e2e7fb_1600x1600.png" width="1456" height="1456" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6b0487b6-88df-437b-98b0-d0e113e2e7fb_1600x1600.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1456,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1174069,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/186948507?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b0487b6-88df-437b-98b0-d0e113e2e7fb_1600x1600.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!YYsh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b0487b6-88df-437b-98b0-d0e113e2e7fb_1600x1600.png 424w, https://substackcdn.com/image/fetch/$s_!YYsh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b0487b6-88df-437b-98b0-d0e113e2e7fb_1600x1600.png 848w, https://substackcdn.com/image/fetch/$s_!YYsh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b0487b6-88df-437b-98b0-d0e113e2e7fb_1600x1600.png 1272w, https://substackcdn.com/image/fetch/$s_!YYsh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b0487b6-88df-437b-98b0-d0e113e2e7fb_1600x1600.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Venus, recovered from a heavy blur.</em></figcaption></figure></div><p>Remarkably, the information &#8220;hidden&#8221; in the blurred images survives being saved in a lossy image format. The top row shows images reconstituted from an intermediate image saved as a JPEG at 95%, 85%, and 75% quality settings:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_FOg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff134452-f7e7-4034-9bcc-f1aba56316d9_4394x2992.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_FOg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff134452-f7e7-4034-9bcc-f1aba56316d9_4394x2992.png 424w, https://substackcdn.com/image/fetch/$s_!_FOg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff134452-f7e7-4034-9bcc-f1aba56316d9_4394x2992.png 848w, https://substackcdn.com/image/fetch/$s_!_FOg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff134452-f7e7-4034-9bcc-f1aba56316d9_4394x2992.png 1272w, https://substackcdn.com/image/fetch/$s_!_FOg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff134452-f7e7-4034-9bcc-f1aba56316d9_4394x2992.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_FOg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff134452-f7e7-4034-9bcc-f1aba56316d9_4394x2992.png" width="1456" height="991" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ff134452-f7e7-4034-9bcc-f1aba56316d9_4394x2992.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:991,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:4602707,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/186948507?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff134452-f7e7-4034-9bcc-f1aba56316d9_4394x2992.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_FOg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff134452-f7e7-4034-9bcc-f1aba56316d9_4394x2992.png 424w, https://substackcdn.com/image/fetch/$s_!_FOg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff134452-f7e7-4034-9bcc-f1aba56316d9_4394x2992.png 848w, https://substackcdn.com/image/fetch/$s_!_FOg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff134452-f7e7-4034-9bcc-f1aba56316d9_4394x2992.png 1272w, https://substackcdn.com/image/fetch/$s_!_FOg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff134452-f7e7-4034-9bcc-f1aba56316d9_4394x2992.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Recovery from a JPEG file (1D + 1D filter, W = 200, B = 30).</em></figcaption></figure></div><p>The bottom row shows less reasonable quality settings of 50% and below; at that point, the reconstructed image begins to resemble abstract art.</p><h3>Do I need to worry?</h3><p>Maybe? As noted earlier, even in the case of simple box blur, the recovery is less successful for large, two-dimensional blur windows, unless we tip the scales in our favor by tinkering with the algorithm.</p><p>The likelihood of success will be also reduced if you use a more sophisticated blur filter. Virtually all practical implementations of blur algorithms work in a similar way, so they leak <em>some </em>information due to presence of blur region boundaries and the discrete stepover of a finite averaging window. That said, they use different weighting for pixel values, which complicates the math and can make recovery borderline impossible.</p><p>On the flip side, for constrained data such as text, pixel-level reconstruction may be unnecessary to begin with. Instead, regions of the blurred image can be successively compared to the blurred representations of every possible symbol. In this scenario, it doesn&#8217;t help that the transformation is technically irreversible. It suffices that there&#8217;s a finite alphabet of shapes and that they produce distinct output images.</p><div><hr></div><p><em>&#128073; For more articles about math, <a href="https://lcamtuf.substack.com/p/algorithms-and-math-trivia">visit this page</a>. In particular, you might enjoy:</em></p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;409f57d5-27f1-41c4-b57d-aa79bfe749ab&quot;,&quot;caption&quot;:&quot;For the past couple of weeks, I couldn&#8217;t shake off an intrusive thought: raster graphics and audio files are awfully similar &#8212; they&#8217;re sequences of analog measurements &#8212; so what would happen if we apply the same transformations to both?&#8230;&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;See it with your lying ears&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2026-01-10T00:00:05.800Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d603e902-82e7-426e-9aaf-a6e88d13e995_1500x1000.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/see-it-with-your-lying-ears&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:183768069,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:35,&quot;comment_count&quot;:10,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;529fb3c8-9517-4cc0-bb9d-9da4827d3c01&quot;,&quot;caption&quot;:&quot;If you&#8217;re a nerd, you probably have encountered visualizations of a tesseract: a four-dimensional equivalent of a cube. Heck, various representations of the shape have made it into blockbuster sci-fi films, music videos, and more.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;You gotta think outside the hypercube&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2026-01-26T23:05:38.271Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/$s_!Punz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73d9c28a-f287-4b29-abc2-40d701fcdf60_1409x1012.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/you-gotta-think-outside-the-hypercube&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:185802725,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:24,&quot;comment_count&quot;:5,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;002918fd-0e77-4abc-84cf-1beb25de3367&quot;,&quot;caption&quot;:&quot;In the past couple of weeks, I&#8217;ve been posting about seemingly simple mathematical problems that defy intuition, and where the answers we find on the internet turn out to be shallow or hard to parse. For a taste, you might enjoy the articles on G&#246;del&#8217;s beavers&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;How many dimensions is this?&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-09-03T16:20:42.610Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/32743c32-71ca-45b1-b161-971d3bbedf10_1000x563.webp&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/how-many-dimensions-is-this&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:172288329,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:33,&quot;comment_count&quot;:5,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;f79ec02e-e86e-48fc-8dfd-6f6b48482451&quot;,&quot;caption&quot;:&quot;If you follow geeky news, you might have came across a computer science concept known as busy beavers. That said, unless you&#8217;re a mathematician by training or trade, the articles make it hard to understand what the concept means and why you should (or shouldn&#8217;t) care.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;G&#246;del's beavers, or the limits of knowledge&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-06-30T03:29:31.924Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b69d6202-8816-479e-9acd-b972a5d1b081_1322x1322.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/monkeys-typewriters-and-busy-beavers&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:167104601,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:46,&quot;comment_count&quot;:13,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p><em>I write well-researched, original articles about geek culture, electronic circuit design, algorithms, and more. If you like the content, please subscribe.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item><item><title><![CDATA[You gotta think outside the hypercube]]></title><description><![CDATA[A closer look at the tesseract and the ways we can render it on the screen.]]></description><link>https://lcamtuf.substack.com/p/you-gotta-think-outside-the-hypercube</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/you-gotta-think-outside-the-hypercube</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Mon, 26 Jan 2026 23:05:38 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Punz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73d9c28a-f287-4b29-abc2-40d701fcdf60_1409x1012.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you&#8217;re a nerd, you probably have encountered visualizations of a <em>tesseract: </em>a four-dimensional equivalent of a cube. Heck, various representations of the shape have made it into blockbuster sci-fi films, music videos, and more.</p><p>What might be harder to grasp is what these images mean or how they&#8217;re generated. You can find a handful of tesseract rendering demos on GitHub, but they all take different approaches, produce different results, and don&#8217;t really explain what&#8217;s going on.</p><p>In this article, we&#8217;ll take a look at the hypercube from first principles &#8212; and then, figure out how to map this beast to a computer screen.</p><h3>It&#8217;s hip to be square</h3><p>To build a mathematical model of the hypercube, let&#8217;s start with a square. If we get it right, our approach will generalize to three dimensions and produce a cube; if it does, it ought to extend to the hyperspace too.</p><p>More specifically, we&#8217;ll try to model the <em>edges</em> of a square &#8212; i.e., the line segments that connect the vertices in the four corners. For our purposes, a see-through wireframe model will work better than a solid.</p><p>For a 2D square with dimensions 2<em>a&#215;2a</em>, the horizontal edges can be described as a collection of points that satisfy two criteria:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{c}\n|x| \\leq a \\\\\n|y| = a\n\\end{array}&quot;,&quot;id&quot;:&quot;BANDKJMVEG&quot;}" data-component-name="LatexBlockToDOM"></div><p>In essence, we&#8217;re saying that we want to include points for which the <em>y</em> coordinate is equal to either <em>-a </em>(the lower edge) or <em>+a</em> (the upper edge); and where the <em>x </em>coordinate spans anywhere between <em>-a</em> and <em>+a</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!alK2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb299481-ef67-4d13-baca-b0344fd8ce57_2000x1111.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!alK2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb299481-ef67-4d13-baca-b0344fd8ce57_2000x1111.jpeg 424w, https://substackcdn.com/image/fetch/$s_!alK2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb299481-ef67-4d13-baca-b0344fd8ce57_2000x1111.jpeg 848w, https://substackcdn.com/image/fetch/$s_!alK2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb299481-ef67-4d13-baca-b0344fd8ce57_2000x1111.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!alK2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb299481-ef67-4d13-baca-b0344fd8ce57_2000x1111.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!alK2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb299481-ef67-4d13-baca-b0344fd8ce57_2000x1111.jpeg" width="1456" height="809" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bb299481-ef67-4d13-baca-b0344fd8ce57_2000x1111.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:809,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:730300,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/185802725?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb299481-ef67-4d13-baca-b0344fd8ce57_2000x1111.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!alK2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb299481-ef67-4d13-baca-b0344fd8ce57_2000x1111.jpeg 424w, https://substackcdn.com/image/fetch/$s_!alK2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb299481-ef67-4d13-baca-b0344fd8ce57_2000x1111.jpeg 848w, https://substackcdn.com/image/fetch/$s_!alK2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb299481-ef67-4d13-baca-b0344fd8ce57_2000x1111.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!alK2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb299481-ef67-4d13-baca-b0344fd8ce57_2000x1111.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>One half of a square.</em></figcaption></figure></div><p>To construct the remaining vertical edges, we can just flip the criteria around, constraining <em>x</em> to one of two values and allowing <em>y</em> to span a range. This nets us the following combined formula:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{r l}\n\\textrm{Horizontal lines: } &amp; |x| \\leq a, \\quad |y| = a \\\\\n\\textrm{Vertical lines: } &amp; |x| = a, \\quad |y| \\leq a \\\\\n\\end{array}&quot;,&quot;id&quot;:&quot;HILVYXFIKB&quot;}" data-component-name="LatexBlockToDOM"></div><p>The method is easy to generalize to a cube. We start by constructing a rectangle in the <em>x-y</em> plane using the earlier approach, except we add a third modulo constraint so that we end up with two images at the <em>-a</em> and <em>+a</em> offsets in the <em>z </em>axis:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{r l}\n\\textrm{Horizontal lines: } &amp; |x| \\leq a, \\quad |y| = a, \\quad |z| =a \\\\\n\\textrm{Vertical lines: } &amp; |x| = a, \\quad |y| \\leq a, \\quad |z| =a \\\\\n\n\\end{array}&quot;,&quot;id&quot;:&quot;ZSLGOQRWBD&quot;}" data-component-name="LatexBlockToDOM"></div><p>What&#8217;s still missing are four edges oriented in the <em>z </em>direction that connect the corresponding corners of the two squares. We can add this with a third rule:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{r l}\n\\textrm{Horizontal lines: } &amp; |x| \\leq a, \\quad |y| = a, \\quad |z| =a \\\\\n\\textrm{Vertical lines: } &amp; |x| = a, \\quad |y| \\leq a, \\quad |z| =a \\\\\nz \\textrm{ lines: } &amp; |x| = a, \\quad |y| = a, \\quad |z| \\leq a \\\\\n\n\\end{array}&quot;,&quot;id&quot;:&quot;JQAKMRAQAD&quot;}" data-component-name="LatexBlockToDOM"></div><p>Note that each of these rules produces four line segments because there 2<sup>2 </sup>possible combinations for the coordinates constrained by the equality relationship. For example, for horizontal lines, we can have the following pairs of <em>y</em> and <em>z </em>values: (<em>-a, -a)</em>, (<em>-a, +a)</em>, (<em>+a, -a)</em>, and (<em>+a, +a)</em>.</p><p>From here, the extension to the fourth dimension should be clear. I&#8217;m going to sensibly label the dimension &#127744;; with this done, we just add a fourth constraint to each of the existing 3D rules and then add connecting segments in the fourth dimension:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{r l}\nx \\textrm{ lines: } &amp; |x| \\leq a, \\quad |y| = a, \\quad |z| =a \\quad |&#127744;| = a \\\\\ny \\textrm{ lines: } &amp; |x| = a, \\quad |y| \\leq a, \\quad |z| =a \\quad |&#127744;| = a \\\\\nz \\textrm{ lines: } &amp; |x| = a, \\quad |y| = a, \\quad |z| \\leq a  \\quad |&#127744;| = a \\\\\n\\textrm{&#127744; lines: } &amp; |x| = a, \\quad |y| = a, \\quad |z| = a  \\quad |&#127744;| \\leq a\n\\end{array}&quot;,&quot;id&quot;:&quot;URSEAFJSUU&quot;}" data-component-name="LatexBlockToDOM"></div><p>This time around, each rule nets us 2<sup>3 </sup>= 8 line segments, so the tesseract has 4&#183;8 = 32 edges. These edges connect 16 vertices.</p><h3>Defining rotations</h3><p>Most visualization of the tesseract spin the figure around. This allows the shape to be examined from different angles and makes for some mind-bending visuals. But what does it mean to rotate an object in 4D?</p><p>In a two-dimensional space, there&#8217;s only one type of rotation; it transposes coordinates in the XY plane. The following demonstrates the effect of rotating a point originally placed on the <em>x </em>axis around the center of the coordinate system:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TRvf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5086b2ef-7009-4fdd-a620-da86a71bfac1_2000x1300.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TRvf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5086b2ef-7009-4fdd-a620-da86a71bfac1_2000x1300.jpeg 424w, https://substackcdn.com/image/fetch/$s_!TRvf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5086b2ef-7009-4fdd-a620-da86a71bfac1_2000x1300.jpeg 848w, https://substackcdn.com/image/fetch/$s_!TRvf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5086b2ef-7009-4fdd-a620-da86a71bfac1_2000x1300.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!TRvf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5086b2ef-7009-4fdd-a620-da86a71bfac1_2000x1300.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TRvf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5086b2ef-7009-4fdd-a620-da86a71bfac1_2000x1300.jpeg" width="1456" height="946" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5086b2ef-7009-4fdd-a620-da86a71bfac1_2000x1300.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:946,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:836146,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/185802725?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5086b2ef-7009-4fdd-a620-da86a71bfac1_2000x1300.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TRvf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5086b2ef-7009-4fdd-a620-da86a71bfac1_2000x1300.jpeg 424w, https://substackcdn.com/image/fetch/$s_!TRvf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5086b2ef-7009-4fdd-a620-da86a71bfac1_2000x1300.jpeg 848w, https://substackcdn.com/image/fetch/$s_!TRvf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5086b2ef-7009-4fdd-a620-da86a71bfac1_2000x1300.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!TRvf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5086b2ef-7009-4fdd-a620-da86a71bfac1_2000x1300.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>The trigonometric solution to the simplest case of XY rotation.</em></figcaption></figure></div><p>From basic trigonometry, the new <em>x</em> coordinate of the rotated point is the adjacent of a right triangle with an angle <em>&#945;</em> and a hypotenuse of <em>x<sub>orig</sub></em>. The new <em>y </em>is the opposite of that same triangle. If we want to start with a non-zero <em>y</em> coordinate for the point, we need add a small tweak:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{c}\nx_{new} = x_{orig} \\cdot cos(\\alpha) - y_{orig} \\cdot sin(\\alpha) \\\\\ny_{new} = y_{orig} \\cdot cos(\\alpha) + x_{orig} \\cdot sin(\\alpha)\n\\end{array}&quot;,&quot;id&quot;:&quot;JAYFDSGSCA&quot;}" data-component-name="LatexBlockToDOM"></div><p>In three dimensions, we have a lot more freedom. We can obviously spin things around in the XY plane (around the <em>z</em> axis), XZ (around <em>y</em>), or in YZ (around <em>x</em>). It is also possible to dream up more complex rotations that touch all three coordinates at once, but they don&#8217;t add much value. They can be deconstructed into a sequence of planar rotations in XY, XZ, and YZ.</p><p>Given this observation, in four dimensions, we should probably still stick to the primitive of planar rotations that modify just two axes at a time. The only difference is that we get additional X&#127744;, Y&#127744;, and Z&#127744; planes to use.</p><p>For ease of viewing and for consistency with 3D models, we&#8217;ll focus on spinning things in the XZ plane &#8212; a &#8220;turntable&#8221; animation:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{c}\nx_{new} = x_{orig} \\cdot cos(\\alpha) + z_{orig} \\cdot sin(\\alpha) \\\\\nz_{new} = z_{orig} \\cdot cos(\\alpha) - x_{orig} \\cdot sin(\\alpha)\n\\end{array}&quot;,&quot;id&quot;:&quot;PCTUOBPIIE&quot;}" data-component-name="LatexBlockToDOM"></div><p>That said, we&#8217;ll also pay a brief visit the Z&#127744; rotation plane. It plays by similar rules:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{c}\nz_{new} = z_{orig} \\cdot cos(\\alpha) - &#127744;_{orig} \\cdot sin(\\alpha) \\\\\n&#127744;_{new} = &#127744;_{orig} \\cdot cos(\\alpha) + z_{orig} \\cdot sin(\\alpha)\n\\end{array}&quot;,&quot;id&quot;:&quot;PPJSYRIEKA&quot;}" data-component-name="LatexBlockToDOM"></div><h3>Projecting 4D to 2D</h3><p>Our next challenge is figuring out how to project four-dimensional coordinates onto a two-dimensional drawing surface, such as a computer screen.</p><p>In standard geometries, Cartesian axes are orthogonal to each other &#8212; that is, there is a 90&#176; rotation that can take you between any two dimensions. On a two-dimensional surface, we can only pull this off with two axes; that said, there are several imperfect ways to make do.</p><h4>Cavalier projection</h4><p>If we were to ask a random person to come up with a 3D-to-2D projection on the spot, they would probably suggest drawing the <em>z</em> axis as a diagonal line on a 2D plane, as shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9iRJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde4d7fcc-2d16-4081-83d4-bd779a54a9f1_2000x1300.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9iRJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde4d7fcc-2d16-4081-83d4-bd779a54a9f1_2000x1300.jpeg 424w, https://substackcdn.com/image/fetch/$s_!9iRJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde4d7fcc-2d16-4081-83d4-bd779a54a9f1_2000x1300.jpeg 848w, https://substackcdn.com/image/fetch/$s_!9iRJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde4d7fcc-2d16-4081-83d4-bd779a54a9f1_2000x1300.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!9iRJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde4d7fcc-2d16-4081-83d4-bd779a54a9f1_2000x1300.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9iRJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde4d7fcc-2d16-4081-83d4-bd779a54a9f1_2000x1300.jpeg" width="1456" height="946" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/de4d7fcc-2d16-4081-83d4-bd779a54a9f1_2000x1300.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:946,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:881500,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/185802725?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde4d7fcc-2d16-4081-83d4-bd779a54a9f1_2000x1300.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!9iRJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde4d7fcc-2d16-4081-83d4-bd779a54a9f1_2000x1300.jpeg 424w, https://substackcdn.com/image/fetch/$s_!9iRJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde4d7fcc-2d16-4081-83d4-bd779a54a9f1_2000x1300.jpeg 848w, https://substackcdn.com/image/fetch/$s_!9iRJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde4d7fcc-2d16-4081-83d4-bd779a54a9f1_2000x1300.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!9iRJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde4d7fcc-2d16-4081-83d4-bd779a54a9f1_2000x1300.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>The cavalier projection.</em></figcaption></figure></div><p>To convert the model-space <em>z </em>value to screen coordinates, we can use trigonometry to project the component onto the real <em>x </em>and <em>y </em>axes:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{c}\nx_{screen} = x_{model} + z_{model} \\cdot cos(45^\\circ) \\\\\ny_{screen} = y_{model} + z_{model} \\cdot sin(45^\\circ) \n\\end{array}&quot;,&quot;id&quot;:&quot;MNXKFLXRGG&quot;}" data-component-name="LatexBlockToDOM"></div><p>Alas, if you attempt this projection with a regular three-dimensional cube, you will immediately notice that it looks off:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rzAm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F876874d9-f4be-43e2-b5f4-7b92f47c83be_1080x1080.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rzAm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F876874d9-f4be-43e2-b5f4-7b92f47c83be_1080x1080.png 424w, https://substackcdn.com/image/fetch/$s_!rzAm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F876874d9-f4be-43e2-b5f4-7b92f47c83be_1080x1080.png 848w, https://substackcdn.com/image/fetch/$s_!rzAm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F876874d9-f4be-43e2-b5f4-7b92f47c83be_1080x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!rzAm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F876874d9-f4be-43e2-b5f4-7b92f47c83be_1080x1080.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rzAm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F876874d9-f4be-43e2-b5f4-7b92f47c83be_1080x1080.png" width="1080" height="1080" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/876874d9-f4be-43e2-b5f4-7b92f47c83be_1080x1080.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1080,&quot;width&quot;:1080,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:61339,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/185802725?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F876874d9-f4be-43e2-b5f4-7b92f47c83be_1080x1080.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!rzAm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F876874d9-f4be-43e2-b5f4-7b92f47c83be_1080x1080.png 424w, https://substackcdn.com/image/fetch/$s_!rzAm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F876874d9-f4be-43e2-b5f4-7b92f47c83be_1080x1080.png 848w, https://substackcdn.com/image/fetch/$s_!rzAm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F876874d9-f4be-43e2-b5f4-7b92f47c83be_1080x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!rzAm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F876874d9-f4be-43e2-b5f4-7b92f47c83be_1080x1080.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>The problem with cavalier.</em></figcaption></figure></div><p>The viewer-facing edges in the XY plane are exactly the same length as the <em>z</em> edge; nevertheless, it&#8217;s hard to shake the impression that the dimensions are off and the cube is stretched.</p><h4>Cabinet projection</h4><p>To address this issue, we need to shorten the projected <em>z</em>-axis edges, crudely approximating the length contraction that we expect in real life. To do this, we divide the <em>z</em> component by an ad hoc scaling factor, typically 2:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{c}\nx_{screen} = x_{model} + z_{model} \\cdot \\frac{cos(45^\\circ)}{2} \\\\\ny_{screen} = y_{model} + z_{model} \\cdot \\frac{sin(45^\\circ)}{2} \n\\end{array}&quot;,&quot;id&quot;:&quot;HQFTECYXXT&quot;}" data-component-name="LatexBlockToDOM"></div><p>The cabinet projection is ubiquitous in informal sketches and technical drawings, and it does look good at first blush. That said, consider the following video of a cube that is rotated in the XZ plane:</p><div id="vimeo-1158291426" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;1158291426&quot;,&quot;videoKey&quot;:&quot;ceb514aba6&quot;,&quot;belowTheFold&quot;:true}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/1158291426?autoplay=0&amp;h=ceb514aba6" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" loading="lazy"></iframe></div></div><p>Note that the shape looks OK at first, but then gets weirdly squished near the rotation angle of 70&#176;; this is because the projection gives us incorrect visual cues that the shape is facing us &#8212; the back edges appear to be tucked squarely behind the front &#8212; while in reality, the shape is still at an angle in relation to the viewer.</p><p>The root of the problem is that the axes are not oriented in a way that would be possible in real life. If we constructed a model of 3D axes out of sticks, the only way for the <em>z</em> axis to appear at a 45&#176; angle &#8212; or indeed, to be visible at all &#8212; is if at least one of the other axes is not parallel to the camera plane<em>:</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!uwHh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026f5fbe-cbcd-424c-a6e6-4cc9a1e50239_2000x1281.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!uwHh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026f5fbe-cbcd-424c-a6e6-4cc9a1e50239_2000x1281.jpeg 424w, https://substackcdn.com/image/fetch/$s_!uwHh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026f5fbe-cbcd-424c-a6e6-4cc9a1e50239_2000x1281.jpeg 848w, https://substackcdn.com/image/fetch/$s_!uwHh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026f5fbe-cbcd-424c-a6e6-4cc9a1e50239_2000x1281.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!uwHh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026f5fbe-cbcd-424c-a6e6-4cc9a1e50239_2000x1281.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!uwHh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026f5fbe-cbcd-424c-a6e6-4cc9a1e50239_2000x1281.jpeg" width="1456" height="933" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/026f5fbe-cbcd-424c-a6e6-4cc9a1e50239_2000x1281.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:933,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:418439,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/185802725?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026f5fbe-cbcd-424c-a6e6-4cc9a1e50239_2000x1281.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!uwHh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026f5fbe-cbcd-424c-a6e6-4cc9a1e50239_2000x1281.jpeg 424w, https://substackcdn.com/image/fetch/$s_!uwHh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026f5fbe-cbcd-424c-a6e6-4cc9a1e50239_2000x1281.jpeg 848w, https://substackcdn.com/image/fetch/$s_!uwHh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026f5fbe-cbcd-424c-a6e6-4cc9a1e50239_2000x1281.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!uwHh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026f5fbe-cbcd-424c-a6e6-4cc9a1e50239_2000x1281.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>An issue with the cabinet projection.</em></figcaption></figure></div><h4>Isometric projection</h4><p>This brings us to the isometric projection &#8212; a physically-plausible arrangement that places the model axes 60&#176; apart:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tEXA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fdb5e5-3e55-438f-8ba8-e56998cad6ba_2000x1264.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tEXA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fdb5e5-3e55-438f-8ba8-e56998cad6ba_2000x1264.jpeg 424w, https://substackcdn.com/image/fetch/$s_!tEXA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fdb5e5-3e55-438f-8ba8-e56998cad6ba_2000x1264.jpeg 848w, https://substackcdn.com/image/fetch/$s_!tEXA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fdb5e5-3e55-438f-8ba8-e56998cad6ba_2000x1264.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!tEXA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fdb5e5-3e55-438f-8ba8-e56998cad6ba_2000x1264.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tEXA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fdb5e5-3e55-438f-8ba8-e56998cad6ba_2000x1264.jpeg" width="1456" height="920" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/19fdb5e5-3e55-438f-8ba8-e56998cad6ba_2000x1264.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:920,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:842278,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/185802725?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fdb5e5-3e55-438f-8ba8-e56998cad6ba_2000x1264.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tEXA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fdb5e5-3e55-438f-8ba8-e56998cad6ba_2000x1264.jpeg 424w, https://substackcdn.com/image/fetch/$s_!tEXA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fdb5e5-3e55-438f-8ba8-e56998cad6ba_2000x1264.jpeg 848w, https://substackcdn.com/image/fetch/$s_!tEXA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fdb5e5-3e55-438f-8ba8-e56998cad6ba_2000x1264.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!tEXA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fdb5e5-3e55-438f-8ba8-e56998cad6ba_2000x1264.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>One of the possible isometric views.</em></figcaption></figure></div><p>The math for this projection is still simple. The screen <em>x</em> coordinate is dictated by model <em>x </em>multiplied by <em>cos(</em>30&#176;<em>) </em>&#8212; that&#8217;s the angle between the model <em>x </em>axis and the real one. The value is also influenced in the same way but with an opposite sign by the model <em>z </em>axis, so we get:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;x_{screen} = (x_{model} - z_{model}) \\cdot cos(30^\\circ) &quot;,&quot;id&quot;:&quot;BMTINZEZXE&quot;}" data-component-name="LatexBlockToDOM"></div><p>Meanwhile, on the <em>y</em> side, we need to account for the projected sine component of <em>x</em> and <em>z:</em></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;y_{screen} = y_{model} + (x_{model} + z_{model}) \\cdot sin(30^\\circ) &quot;,&quot;id&quot;:&quot;TUNGIILHFR&quot;}" data-component-name="LatexBlockToDOM"></div><p>Both trigonometric expressions can be further divided by &#8730;2 if the goal is to match the model- and screen-lengths of a horizontal line drawn in the model XY plane and then rotated by 45&#176; around the <em>y</em> axis. That said, it&#8217;s seldom a necessity.</p><p>The following video shows a cube rotated in the XZ plane in an isometric projection:</p><div id="vimeo-1158291473" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;1158291473&quot;,&quot;videoKey&quot;:&quot;63977fe203&quot;,&quot;belowTheFold&quot;:true}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/1158291473?autoplay=0&amp;h=63977fe203" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" loading="lazy"></iframe></div></div><p>This looks great and it seems natural to extend the scheme to four dimensions simply by cramming another axis, giving us a progression of <em>x, y, z, </em>and &#127744; axes spaced 45&#176; apart:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xkVm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F823c4b22-c1d4-4a11-9625-bf4ea63cc9ec_2000x1300.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xkVm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F823c4b22-c1d4-4a11-9625-bf4ea63cc9ec_2000x1300.jpeg 424w, https://substackcdn.com/image/fetch/$s_!xkVm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F823c4b22-c1d4-4a11-9625-bf4ea63cc9ec_2000x1300.jpeg 848w, https://substackcdn.com/image/fetch/$s_!xkVm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F823c4b22-c1d4-4a11-9625-bf4ea63cc9ec_2000x1300.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!xkVm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F823c4b22-c1d4-4a11-9625-bf4ea63cc9ec_2000x1300.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xkVm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F823c4b22-c1d4-4a11-9625-bf4ea63cc9ec_2000x1300.jpeg" width="1456" height="946" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/823c4b22-c1d4-4a11-9625-bf4ea63cc9ec_2000x1300.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:946,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:874444,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/185802725?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F823c4b22-c1d4-4a11-9625-bf4ea63cc9ec_2000x1300.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!xkVm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F823c4b22-c1d4-4a11-9625-bf4ea63cc9ec_2000x1300.jpeg 424w, https://substackcdn.com/image/fetch/$s_!xkVm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F823c4b22-c1d4-4a11-9625-bf4ea63cc9ec_2000x1300.jpeg 848w, https://substackcdn.com/image/fetch/$s_!xkVm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F823c4b22-c1d4-4a11-9625-bf4ea63cc9ec_2000x1300.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!xkVm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F823c4b22-c1d4-4a11-9625-bf4ea63cc9ec_2000x1300.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>An extension of isometric projection to 4D?</em></figcaption></figure></div><p>Yet, some readers might notice that with this modification, we&#8217;re back to the earlier &#8220;cavalier&#8221; scenario: our <em>x, y, </em>and <em>z</em> axes are now separated by an impossible angle of 45&#176;. In other words, the projection should give us <em>something</em>, but it will distort some 3D shapes in undesirable ways.</p><p>Still, let&#8217;s keep going. In the new model, we calculate screen <em>x</em> as:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;x_{screen} = -&#127744;_{model} +  (x_{model} - z_{model}) \\cdot cos(45^\\circ)&quot;,&quot;id&quot;:&quot;WFWTEBWILW&quot;}" data-component-name="LatexBlockToDOM"></div><p>The projected model <em>y</em> axis is orthogonal to to screen <em>x</em>, so it doesn&#8217;t appear in this formula. As for the <em>y </em>coordinate, we need:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;y_{screen} = y_{model} + (x_{model} + z_{model}) \\cdot sin(45^\\circ)&quot;,&quot;id&quot;:&quot;ALWBOJRMNH&quot;}" data-component-name="LatexBlockToDOM"></div><p>As before, since the projected model &#127744; axis is orthogonal to screen <em>y</em>, it doesn&#8217;t appear in the second equation.</p><p>Let&#8217;s put this projection to real use. Here&#8217;s the video of a tesseract rotating in the XZ plane:</p><div id="vimeo-1158291528" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;1158291528&quot;,&quot;videoKey&quot;:&quot;88cd7a1c9c&quot;,&quot;belowTheFold&quot;:true}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/1158291528?autoplay=0&amp;h=88cd7a1c9c" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" loading="lazy"></iframe></div></div><p>It looks pretty, but it isn&#8217;t particularly informative: the projection makes the object change shape in ways that seem difficult to parse. The shape appears to be intersecting itself, but it&#8217;s hard to pinpoint what&#8217;s what.</p><h4>Rectilinear one-point perspective</h4><p>A simpler but surprisingly powerful projection method is to keep model <em>x </em>and <em>y </em>in the same plane as the screen, but divide the values of these coordinates in proportion to the distance in <em>z</em>. This produces a familiar vanishing-point perspective:</p><div id="vimeo-1158291581" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;1158291581&quot;,&quot;videoKey&quot;:&quot;a3b67bb275&quot;,&quot;belowTheFold&quot;:true}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/1158291581?autoplay=0&amp;h=a3b67bb275" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" loading="lazy"></iframe></div></div><p>A fairly natural extension of this technique to the fourth dimension is to divide the <em>x</em> and <em>y </em>coordinates twice: first by a <em>z-</em>dependent factor and then by a &#127744;-dependent one. This nets probably the most recognizable visualization of a tesseract:</p><div id="vimeo-1158291610" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;1158291610&quot;,&quot;videoKey&quot;:&quot;6ac04381ba&quot;,&quot;belowTheFold&quot;:true}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/1158291610?autoplay=0&amp;h=6ac04381ba" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" loading="lazy"></iframe></div></div><p>If you want food for thought, consider the real-world appearance of a wireframe 3D cube when its shadow from a nearby overhead light is cast onto a 2D surface:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Punz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73d9c28a-f287-4b29-abc2-40d701fcdf60_1409x1012.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Punz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73d9c28a-f287-4b29-abc2-40d701fcdf60_1409x1012.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Punz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73d9c28a-f287-4b29-abc2-40d701fcdf60_1409x1012.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Punz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73d9c28a-f287-4b29-abc2-40d701fcdf60_1409x1012.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Punz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73d9c28a-f287-4b29-abc2-40d701fcdf60_1409x1012.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Punz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73d9c28a-f287-4b29-abc2-40d701fcdf60_1409x1012.jpeg" width="1409" height="1012" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/73d9c28a-f287-4b29-abc2-40d701fcdf60_1409x1012.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1012,&quot;width&quot;:1409,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:243045,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/185802725?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73d9c28a-f287-4b29-abc2-40d701fcdf60_1409x1012.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Punz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73d9c28a-f287-4b29-abc2-40d701fcdf60_1409x1012.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Punz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73d9c28a-f287-4b29-abc2-40d701fcdf60_1409x1012.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Punz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73d9c28a-f287-4b29-abc2-40d701fcdf60_1409x1012.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Punz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73d9c28a-f287-4b29-abc2-40d701fcdf60_1409x1012.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>It&#8217;s deja vu all over again.</em></figcaption></figure></div><p>This both helps make some sense of the nested-cube visualization of the tesseract, and signals that our algorithm is directionally correct. That said, the approach we&#8217;ve taken is also a bit of a cop-out: by commingling model <em>z </em>and &#127744;, we make these dimensions indistinguishable.</p><h4>Fisheye perspective</h4><p>At first blush, the tesseract visualization might look just like two nested 3D cubes connected in the corners. To reduce edge overlaps and better hint at the underlying shenanigans, we can switch to a curvilinear &#8220;fisheye&#8221; perspective, reminiscent of what you can see through a peephole or other low-quality, wide-angle lens. In this approach, point coordinates are reduced based on their Euclidean distance from a single reference point representing the camera. For a regular cube, we get:</p><div id="vimeo-1158291659" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;1158291659&quot;,&quot;videoKey&quot;:&quot;753a9d265a&quot;,&quot;belowTheFold&quot;:true}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/1158291659?autoplay=0&amp;h=753a9d265a" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" loading="lazy"></iframe></div></div><p>But of course, we&#8217;re here to look at the tesseract:</p><div id="vimeo-1158291705" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;1158291705&quot;,&quot;videoKey&quot;:&quot;28175f8114&quot;,&quot;belowTheFold&quot;:true}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/1158291705?autoplay=0&amp;h=28175f8114" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" loading="lazy"></iframe></div></div><p>The shading and the drawing order of the points is decided by the Euclidean distance to the viewing plane; this allows us to spot that the edges of the smaller, &#8220;inner&#8221; cube appear to pass behind the edges of the larger one:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ngOa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F925bb8c4-fbbc-4661-9bfb-ce76d7bce0ce_1080x1080.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ngOa!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F925bb8c4-fbbc-4661-9bfb-ce76d7bce0ce_1080x1080.png 424w, https://substackcdn.com/image/fetch/$s_!ngOa!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F925bb8c4-fbbc-4661-9bfb-ce76d7bce0ce_1080x1080.png 848w, https://substackcdn.com/image/fetch/$s_!ngOa!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F925bb8c4-fbbc-4661-9bfb-ce76d7bce0ce_1080x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!ngOa!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F925bb8c4-fbbc-4661-9bfb-ce76d7bce0ce_1080x1080.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ngOa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F925bb8c4-fbbc-4661-9bfb-ce76d7bce0ce_1080x1080.png" width="1080" height="1080" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/925bb8c4-fbbc-4661-9bfb-ce76d7bce0ce_1080x1080.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1080,&quot;width&quot;:1080,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:109231,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/185802725?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F925bb8c4-fbbc-4661-9bfb-ce76d7bce0ce_1080x1080.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ngOa!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F925bb8c4-fbbc-4661-9bfb-ce76d7bce0ce_1080x1080.png 424w, https://substackcdn.com/image/fetch/$s_!ngOa!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F925bb8c4-fbbc-4661-9bfb-ce76d7bce0ce_1080x1080.png 848w, https://substackcdn.com/image/fetch/$s_!ngOa!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F925bb8c4-fbbc-4661-9bfb-ce76d7bce0ce_1080x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!ngOa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F925bb8c4-fbbc-4661-9bfb-ce76d7bce0ce_1080x1080.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Could it be&#8230;?</em></figcaption></figure></div><p>Still, as noted earlier, the disappointing part of the mapping is that it commingles two dimensions; can we distinguish them better without ending up with a visual disaster?</p><h4>Mixed isometric + vanishing point</h4><p>Sort of?&#8230; Instead of trying to come up with a single projection for all four axes, we could always use a conventional isometric view for <em>x, y, </em>and <em>z, </em>and then use the vanishing-point approach to represent &#127744;.</p><p>The result is a remarkably stable and easy-to-parse view of the tesseract when rotated in the YZ plane:</p><div id="vimeo-1158291772" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;1158291772&quot;,&quot;videoKey&quot;:&quot;5b50aae66c&quot;,&quot;belowTheFold&quot;:true}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/1158291772?autoplay=0&amp;h=5b50aae66c" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" loading="lazy"></iframe></div></div><p>This also brings us to a somewhat less-correct rendering of the hypercube spinning in the <em>Z</em>&#127744; plane that can be found on Wikipedia and in some YouTube videos. If we change screen depth calculations to only account for the <em>z</em> coordinate (i.e., completely ignore model &#127744;), we obtain the following:</p><div id="vimeo-1158333836" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;1158333836&quot;,&quot;videoKey&quot;:&quot;68d61f648c&quot;,&quot;belowTheFold&quot;:true}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/1158333836?autoplay=0&amp;h=68d61f648c" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" loading="lazy"></iframe></div></div><p>If you squint your eyes, this appears to show the tesseract passing through itself back-to-front as it rotates in the fourth dimension. I altered the proportions of the projection to make the effect easier to see.</p><div><hr></div><p><em>&#128073; For more articles about math, <a href="https://lcamtuf.substack.com/p/algorithms-and-math-trivia">visit this page</a>. In particular, you might enjoy:</em></p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;7bfda738-047d-44a8-aff2-6ceff926494c&quot;,&quot;caption&quot;:&quot;In the past couple of months, I published a number of articles on recreational math. I did my best to keep them accessible and fun, but my goal was usually to shed light at deeper mathematical truths. For example, the discussion of 0.999&#8230; = 1 served as a springboard to highlight some of the subtler properties of real numbers and the different meanings o&#8230;&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Folks, we have the best &#960;&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-09-15T06:42:43.993Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/$s_!_Drc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ada872d-41dd-495e-917a-2dfdf67d4859_2332x1224.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/folks-we-have-the-best&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:173625523,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:60,&quot;comment_count&quot;:12,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;740dfd65-a98c-44c9-b113-d2db67a16e09&quot;,&quot;caption&quot;:&quot;In some of the earlier articles on this blog, we talked about the nature of real numbers and the meanings of infinity. The theory outlined in these posts is interesting but also hopelessly abstract. It&#8217;s as if we&#8217;re inventing make-believe worlds that have no discernible connection to reality.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Approximation game&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2026-02-28T02:26:51.565Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/$s_!LOrW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd00a99e4-9662-4741-ab87-e875937230b7_2500x1250.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/approximation-game&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:189104530,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:8,&quot;comment_count&quot;:1,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;49253db6-bf46-4bf1-93fc-43d1ace0ca81&quot;,&quot;caption&quot;:&quot;In the past couple of weeks, I&#8217;ve been posting about seemingly simple mathematical problems that defy intuition, and where the answers we find on the internet turn out to be shallow or hard to parse. For a taste, you might enjoy the articles on G&#246;del&#8217;s beavers&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;How many dimensions is this?&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-09-03T16:20:42.610Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/32743c32-71ca-45b1-b161-971d3bbedf10_1000x563.webp&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/how-many-dimensions-is-this&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:172288329,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:33,&quot;comment_count&quot;:5,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p><em>I write well-researched, original articles about geek culture, electronic circuit design, algorithms, and more. If you like the content, please subscribe.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item><item><title><![CDATA[The toil of (blog) art]]></title><description><![CDATA[An image is worth $19.95.]]></description><link>https://lcamtuf.substack.com/p/the-toil-of-blog-art</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/the-toil-of-blog-art</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Sun, 18 Jan 2026 18:17:01 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!iJCy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5dc47df-9d33-44bd-a9b0-7b8538e42176_2000x1000.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When writing a technical blog, the first 90% of every article is a lot easier than the final 10%. Sometimes, the challenge is collecting your own thoughts; I remember walking through the forest and talking to myself about the articles about <a href="https://lcamtuf.substack.com/p/monkeys-typewriters-and-busy-beavers">G&#246;del&#8217;s beavers</a> or <a href="https://lcamtuf.substack.com/p/how-has-mathematics-gotten-so-abstract">infinity</a>. Other times, the difficulty is the implementation of an idea. I sometimes spend days in the workshop or writing code to get, say, the throwaway image of a <a href="https://lcamtuf.substack.com/p/is-the-frequency-domain-a-real-place">square-wave spectrogram</a> at the end of a whimsical post.</p><p>That said, by far the most consistent challenge is art. Illustrations are important, easy to half-ass, and fiendishly difficult to get right. I&#8217;m fortunate enough that photography has been my <a href="https://lcamtuf.coredump.cx/photo_basics/">lifelong hobby</a>, so I have little difficulty capturing good photos of the physical items I want to talk about:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jRPu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F539af19d-55ff-45ef-a127-a4582e89ccc0_2000x1334.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jRPu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F539af19d-55ff-45ef-a127-a4582e89ccc0_2000x1334.jpeg 424w, https://substackcdn.com/image/fetch/$s_!jRPu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F539af19d-55ff-45ef-a127-a4582e89ccc0_2000x1334.jpeg 848w, https://substackcdn.com/image/fetch/$s_!jRPu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F539af19d-55ff-45ef-a127-a4582e89ccc0_2000x1334.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!jRPu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F539af19d-55ff-45ef-a127-a4582e89ccc0_2000x1334.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jRPu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F539af19d-55ff-45ef-a127-a4582e89ccc0_2000x1334.jpeg" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/539af19d-55ff-45ef-a127-a4582e89ccc0_2000x1334.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:242263,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/184933928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F539af19d-55ff-45ef-a127-a4582e89ccc0_2000x1334.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!jRPu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F539af19d-55ff-45ef-a127-a4582e89ccc0_2000x1334.jpeg 424w, https://substackcdn.com/image/fetch/$s_!jRPu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F539af19d-55ff-45ef-a127-a4582e89ccc0_2000x1334.jpeg 848w, https://substackcdn.com/image/fetch/$s_!jRPu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F539af19d-55ff-45ef-a127-a4582e89ccc0_2000x1334.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!jRPu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F539af19d-55ff-45ef-a127-a4582e89ccc0_2000x1334.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A macro photo of a photodiode sensor. By author.</em></figcaption></figure></div><p>Similarly, because I&#8217;ve been <a href="https://lcamtuf.coredump.cx/gcnc/full/">interested in CAD and CAM</a> for nearly two decades, I know how to draw shapes in 3D and know enough about rendering tech to make the result look good:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!L4no!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd145833b-05b5-4f5d-ad13-7c1ee632058d_1600x900.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!L4no!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd145833b-05b5-4f5d-ad13-7c1ee632058d_1600x900.jpeg 424w, https://substackcdn.com/image/fetch/$s_!L4no!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd145833b-05b5-4f5d-ad13-7c1ee632058d_1600x900.jpeg 848w, https://substackcdn.com/image/fetch/$s_!L4no!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd145833b-05b5-4f5d-ad13-7c1ee632058d_1600x900.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!L4no!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd145833b-05b5-4f5d-ad13-7c1ee632058d_1600x900.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!L4no!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd145833b-05b5-4f5d-ad13-7c1ee632058d_1600x900.jpeg" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d145833b-05b5-4f5d-ad13-7c1ee632058d_1600x900.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1684475,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/184933928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd145833b-05b5-4f5d-ad13-7c1ee632058d_1600x900.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!L4no!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd145833b-05b5-4f5d-ad13-7c1ee632058d_1600x900.jpeg 424w, https://substackcdn.com/image/fetch/$s_!L4no!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd145833b-05b5-4f5d-ad13-7c1ee632058d_1600x900.jpeg 848w, https://substackcdn.com/image/fetch/$s_!L4no!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd145833b-05b5-4f5d-ad13-7c1ee632058d_1600x900.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!L4no!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd145833b-05b5-4f5d-ad13-7c1ee632058d_1600x900.jpeg 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>An explanation of resin casting, by author.</em></figcaption></figure></div><p>Alas, both approaches have their limits. Photography just doesn&#8217;t work for conceptual diagrams; 3D could, but it&#8217;s slow and makes little sense for two-dimensional diagrams, such as circuit schematics of most function plots.</p><p>Over the past three years, this forced me to step outside my comfort zone and develop a new toolkit for simple, technical visualizations. If you&#8217;re a long-time subscriber, you might have seen the changing art style of the posts. What you probably don&#8217;t know is that I often revise older articles to try out new visualizations and hone in my skills. So, let&#8217;s talk shop!</p><h3>Circuit schematics</h3><p>Electronic circuits are a common theme of my posts; the lifeblood of this trade are circuit schematics. I&#8217;m old enough to remember the beautiful look of hand-drawn schematics in the era before the advent of electronic design automation (EDA) software:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!U8kd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7280e4e-b680-4915-9caf-0254cccb33de_1023x682.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!U8kd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7280e4e-b680-4915-9caf-0254cccb33de_1023x682.jpeg 424w, https://substackcdn.com/image/fetch/$s_!U8kd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7280e4e-b680-4915-9caf-0254cccb33de_1023x682.jpeg 848w, https://substackcdn.com/image/fetch/$s_!U8kd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7280e4e-b680-4915-9caf-0254cccb33de_1023x682.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!U8kd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7280e4e-b680-4915-9caf-0254cccb33de_1023x682.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!U8kd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7280e4e-b680-4915-9caf-0254cccb33de_1023x682.jpeg" width="1023" height="682" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e7280e4e-b680-4915-9caf-0254cccb33de_1023x682.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:682,&quot;width&quot;:1023,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!U8kd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7280e4e-b680-4915-9caf-0254cccb33de_1023x682.jpeg 424w, https://substackcdn.com/image/fetch/$s_!U8kd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7280e4e-b680-4915-9caf-0254cccb33de_1023x682.jpeg 848w, https://substackcdn.com/image/fetch/$s_!U8kd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7280e4e-b680-4915-9caf-0254cccb33de_1023x682.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!U8kd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7280e4e-b680-4915-9caf-0254cccb33de_1023x682.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>An old circuit schematic.</em></figcaption></figure></div><p>Unfortunately, the industry no longer takes pride in this craft; the output from modern schematic capture tools, such as KiCad, is uniformly hideous:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PIx-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F586762cc-9ed2-472b-84c6-99862961d371_864x505.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PIx-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F586762cc-9ed2-472b-84c6-99862961d371_864x505.png 424w, https://substackcdn.com/image/fetch/$s_!PIx-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F586762cc-9ed2-472b-84c6-99862961d371_864x505.png 848w, https://substackcdn.com/image/fetch/$s_!PIx-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F586762cc-9ed2-472b-84c6-99862961d371_864x505.png 1272w, https://substackcdn.com/image/fetch/$s_!PIx-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F586762cc-9ed2-472b-84c6-99862961d371_864x505.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PIx-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F586762cc-9ed2-472b-84c6-99862961d371_864x505.png" width="864" height="505" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/586762cc-9ed2-472b-84c6-99862961d371_864x505.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:505,&quot;width&quot;:864,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!PIx-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F586762cc-9ed2-472b-84c6-99862961d371_864x505.png 424w, https://substackcdn.com/image/fetch/$s_!PIx-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F586762cc-9ed2-472b-84c6-99862961d371_864x505.png 848w, https://substackcdn.com/image/fetch/$s_!PIx-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F586762cc-9ed2-472b-84c6-99862961d371_864x505.png 1272w, https://substackcdn.com/image/fetch/$s_!PIx-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F586762cc-9ed2-472b-84c6-99862961d371_864x505.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>An example of KiCad schematic capture.</em></figcaption></figure></div><p>I used this style for some of the electronics-related articles I published in the 2010s, but for this Substack, I wanted to do better. This meant ditching EDA for general-purpose drawing software. At first, I experimented with the same CAD software I use for 3D part design, <a href="https://www.rhino3d.com/">Rhino3D</a>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mFgg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e13dc3-b62e-4dec-a522-4f12f8516774_5850x3600.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mFgg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e13dc3-b62e-4dec-a522-4f12f8516774_5850x3600.png 424w, https://substackcdn.com/image/fetch/$s_!mFgg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e13dc3-b62e-4dec-a522-4f12f8516774_5850x3600.png 848w, https://substackcdn.com/image/fetch/$s_!mFgg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e13dc3-b62e-4dec-a522-4f12f8516774_5850x3600.png 1272w, https://substackcdn.com/image/fetch/$s_!mFgg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e13dc3-b62e-4dec-a522-4f12f8516774_5850x3600.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mFgg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e13dc3-b62e-4dec-a522-4f12f8516774_5850x3600.png" width="1456" height="896" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e6e13dc3-b62e-4dec-a522-4f12f8516774_5850x3600.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:896,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:606617,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/184933928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e13dc3-b62e-4dec-a522-4f12f8516774_5850x3600.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mFgg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e13dc3-b62e-4dec-a522-4f12f8516774_5850x3600.png 424w, https://substackcdn.com/image/fetch/$s_!mFgg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e13dc3-b62e-4dec-a522-4f12f8516774_5850x3600.png 848w, https://substackcdn.com/image/fetch/$s_!mFgg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e13dc3-b62e-4dec-a522-4f12f8516774_5850x3600.png 1272w, https://substackcdn.com/image/fetch/$s_!mFgg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6e13dc3-b62e-4dec-a522-4f12f8516774_5850x3600.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Chicken coop controller in Rhino3D. By author.</em></figcaption></figure></div><p>This approach had several advantages. First, I was already familiar with the software. Second, CAD tools are tailored for technical drawings: it&#8217;s a breeze to precisely align shapes, parametrically transform and duplicate objects, and so forth. At the same time, while the schematics looked more readable, they were nothing to write home about.</p><p>In a quest for software that would allow me to give the schematics a more organic look, I eventually came across <a href="https://excalidraw.com/">Excalidraw</a>. Excalidraw is an exceedingly simple, web-based vector drawing tool. It&#8217;s limited and clunky, but with time, I&#8217;ve gotten good at working around many of its flaws:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!QH2k!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F951cc0a9-e0b3-4c57-bacc-47e663e36eae_3113x1500.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!QH2k!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F951cc0a9-e0b3-4c57-bacc-47e663e36eae_3113x1500.jpeg 424w, https://substackcdn.com/image/fetch/$s_!QH2k!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F951cc0a9-e0b3-4c57-bacc-47e663e36eae_3113x1500.jpeg 848w, https://substackcdn.com/image/fetch/$s_!QH2k!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F951cc0a9-e0b3-4c57-bacc-47e663e36eae_3113x1500.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!QH2k!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F951cc0a9-e0b3-4c57-bacc-47e663e36eae_3113x1500.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!QH2k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F951cc0a9-e0b3-4c57-bacc-47e663e36eae_3113x1500.jpeg" width="1456" height="702" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/951cc0a9-e0b3-4c57-bacc-47e663e36eae_3113x1500.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:702,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:115229,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/184933928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F951cc0a9-e0b3-4c57-bacc-47e663e36eae_3113x1500.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!QH2k!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F951cc0a9-e0b3-4c57-bacc-47e663e36eae_3113x1500.jpeg 424w, https://substackcdn.com/image/fetch/$s_!QH2k!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F951cc0a9-e0b3-4c57-bacc-47e663e36eae_3113x1500.jpeg 848w, https://substackcdn.com/image/fetch/$s_!QH2k!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F951cc0a9-e0b3-4c57-bacc-47e663e36eae_3113x1500.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!QH2k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F951cc0a9-e0b3-4c57-bacc-47e663e36eae_3113x1500.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A schematic of a microphone amplifier in Excalidraw, by author.</em></figcaption></figure></div><p>What I learned from these two tools is that consistency is key. There is a temptation to start every new diagram with a clean slate, but it&#8217;s almost always the wrong call. You need to develop a set of conventions you follow every time: scale, line thickness, font colors, a library of reusable design elements to copy-and-paste into new designs. This both makes the tool faster to use &#8212; rivaling any EDA package &#8212; and allows you to refine the style over time, discarding failed ideas and preserving the tricks that worked well.</p><p>This brings us to <a href="https://www.affinity.studio/">Affinity</a>. Affinity is a &#8220;grown-up&#8221; image editing suite that supports bitmap and vector files; I&#8217;ve been using it for photo editing ever since Adobe moved to a predatory subscription model for Photoshop. It took me longer to figure out the vector features, in part because of the overwhelming feature set. This is where the lessons from Rhino3D and Excalidraw paid off: on the latest attempt, I knew not to get distracted and to focus on a simple, reusable workflow first.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FHmx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcbab8f9-b761-469b-bdde-297a4c48739b_2323x1372.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FHmx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcbab8f9-b761-469b-bdde-297a4c48739b_2323x1372.png 424w, https://substackcdn.com/image/fetch/$s_!FHmx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcbab8f9-b761-469b-bdde-297a4c48739b_2323x1372.png 848w, https://substackcdn.com/image/fetch/$s_!FHmx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcbab8f9-b761-469b-bdde-297a4c48739b_2323x1372.png 1272w, https://substackcdn.com/image/fetch/$s_!FHmx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcbab8f9-b761-469b-bdde-297a4c48739b_2323x1372.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FHmx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcbab8f9-b761-469b-bdde-297a4c48739b_2323x1372.png" width="1456" height="860" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fcbab8f9-b761-469b-bdde-297a4c48739b_2323x1372.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:860,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1968303,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/184933928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcbab8f9-b761-469b-bdde-297a4c48739b_2323x1372.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!FHmx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcbab8f9-b761-469b-bdde-297a4c48739b_2323x1372.png 424w, https://substackcdn.com/image/fetch/$s_!FHmx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcbab8f9-b761-469b-bdde-297a4c48739b_2323x1372.png 848w, https://substackcdn.com/image/fetch/$s_!FHmx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcbab8f9-b761-469b-bdde-297a4c48739b_2323x1372.png 1272w, https://substackcdn.com/image/fetch/$s_!FHmx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcbab8f9-b761-469b-bdde-297a4c48739b_2323x1372.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>My own library of electronic components in Affinity.</em></figcaption></figure></div><p>This allowed me to finally get in the groove and replicate the hand-drawn vibe I&#8217;ve been after. The new style hasn&#8217;t been featured in any recent articles yet, but I&#8217;ve gone ahead and updated some older posts. For example, the earlier microphone amplifier circuit now looks the following way:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3m6t!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0663c62d-e09a-4fdc-91d6-08f76d8de314_2500x1288.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3m6t!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0663c62d-e09a-4fdc-91d6-08f76d8de314_2500x1288.jpeg 424w, https://substackcdn.com/image/fetch/$s_!3m6t!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0663c62d-e09a-4fdc-91d6-08f76d8de314_2500x1288.jpeg 848w, https://substackcdn.com/image/fetch/$s_!3m6t!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0663c62d-e09a-4fdc-91d6-08f76d8de314_2500x1288.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!3m6t!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0663c62d-e09a-4fdc-91d6-08f76d8de314_2500x1288.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3m6t!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0663c62d-e09a-4fdc-91d6-08f76d8de314_2500x1288.jpeg" width="1456" height="750" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0663c62d-e09a-4fdc-91d6-08f76d8de314_2500x1288.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:750,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:543794,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/184933928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0663c62d-e09a-4fdc-91d6-08f76d8de314_2500x1288.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3m6t!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0663c62d-e09a-4fdc-91d6-08f76d8de314_2500x1288.jpeg 424w, https://substackcdn.com/image/fetch/$s_!3m6t!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0663c62d-e09a-4fdc-91d6-08f76d8de314_2500x1288.jpeg 848w, https://substackcdn.com/image/fetch/$s_!3m6t!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0663c62d-e09a-4fdc-91d6-08f76d8de314_2500x1288.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!3m6t!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0663c62d-e09a-4fdc-91d6-08f76d8de314_2500x1288.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A decent microphone amplifier. By author.</em></figcaption></figure></div><h3>Explanatory illustrations</h3><p>Electronic schematics are about the simplest case of technical illustrations. They&#8217;re just a map of connections between standard symbols, laid out according to simple rules. There&#8217;s no need to make use of depth, color, or motion.</p><p>Many other technical drawings aren&#8217;t as easy; the challenge isn&#8217;t putting lines on paper, it&#8217;s figuring out the most effective way to convey the information in the first place. You need to figure out which elements you want to draw the attention to, and how to provide visual hints of the dynamics you&#8217;re trying to illustrate.</p><p>I confess that I wasn&#8217;t putting much thought into it early on. For example, here&#8217;s the original 2024 illustration for an article on photodiodes:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nn2l!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3baf384b-1003-47b5-818d-403ad91f4a51_2500x824.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nn2l!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3baf384b-1003-47b5-818d-403ad91f4a51_2500x824.png 424w, https://substackcdn.com/image/fetch/$s_!nn2l!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3baf384b-1003-47b5-818d-403ad91f4a51_2500x824.png 848w, https://substackcdn.com/image/fetch/$s_!nn2l!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3baf384b-1003-47b5-818d-403ad91f4a51_2500x824.png 1272w, https://substackcdn.com/image/fetch/$s_!nn2l!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3baf384b-1003-47b5-818d-403ad91f4a51_2500x824.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nn2l!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3baf384b-1003-47b5-818d-403ad91f4a51_2500x824.png" width="1456" height="480" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3baf384b-1003-47b5-818d-403ad91f4a51_2500x824.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:480,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:298957,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/184933928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3baf384b-1003-47b5-818d-403ad91f4a51_2500x824.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!nn2l!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3baf384b-1003-47b5-818d-403ad91f4a51_2500x824.png 424w, https://substackcdn.com/image/fetch/$s_!nn2l!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3baf384b-1003-47b5-818d-403ad91f4a51_2500x824.png 848w, https://substackcdn.com/image/fetch/$s_!nn2l!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3baf384b-1003-47b5-818d-403ad91f4a51_2500x824.png 1272w, https://substackcdn.com/image/fetch/$s_!nn2l!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3baf384b-1003-47b5-818d-403ad91f4a51_2500x824.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Photodiode structure.</em></figcaption></figure></div><p>It&#8217;s not unusable, but it&#8217;s also not good. It&#8217;s hard to read and doesn&#8217;t make a clear distinction between different materials (solid color) and an electrical region that forms at the junction (hatched overlay).</p><p>Here&#8217;s my more recent take:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!o-Bn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e5b3b32-d7c8-488e-8c6b-fbcebe1eb1c1_2000x1050.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!o-Bn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e5b3b32-d7c8-488e-8c6b-fbcebe1eb1c1_2000x1050.jpeg 424w, https://substackcdn.com/image/fetch/$s_!o-Bn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e5b3b32-d7c8-488e-8c6b-fbcebe1eb1c1_2000x1050.jpeg 848w, https://substackcdn.com/image/fetch/$s_!o-Bn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e5b3b32-d7c8-488e-8c6b-fbcebe1eb1c1_2000x1050.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!o-Bn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e5b3b32-d7c8-488e-8c6b-fbcebe1eb1c1_2000x1050.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!o-Bn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e5b3b32-d7c8-488e-8c6b-fbcebe1eb1c1_2000x1050.jpeg" width="1456" height="764" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3e5b3b32-d7c8-488e-8c6b-fbcebe1eb1c1_2000x1050.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:764,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:435990,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/184933928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e5b3b32-d7c8-488e-8c6b-fbcebe1eb1c1_2000x1050.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!o-Bn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e5b3b32-d7c8-488e-8c6b-fbcebe1eb1c1_2000x1050.jpeg 424w, https://substackcdn.com/image/fetch/$s_!o-Bn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e5b3b32-d7c8-488e-8c6b-fbcebe1eb1c1_2000x1050.jpeg 848w, https://substackcdn.com/image/fetch/$s_!o-Bn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e5b3b32-d7c8-488e-8c6b-fbcebe1eb1c1_2000x1050.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!o-Bn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e5b3b32-d7c8-488e-8c6b-fbcebe1eb1c1_2000x1050.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A better version of the same.</em></figcaption></figure></div><p>Once again, the trick isn&#8217;t pulling off a single illustration like this; it&#8217;s building a standardized workflow that lets you crank out dozens of them. You need to converge on backgrounds, line styles, shading, typefaces, arrows, and so on. With this done, you can take an old and janky illustration, such as the following visual from an <a href="https://lcamtuf.substack.com/p/whats-the-deal-with-magnetic-fields">article on magnetism</a>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!a6Lr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4a52d1e-90e9-44f6-a799-963e3e7f9350_1446x810.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!a6Lr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4a52d1e-90e9-44f6-a799-963e3e7f9350_1446x810.png 424w, https://substackcdn.com/image/fetch/$s_!a6Lr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4a52d1e-90e9-44f6-a799-963e3e7f9350_1446x810.png 848w, https://substackcdn.com/image/fetch/$s_!a6Lr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4a52d1e-90e9-44f6-a799-963e3e7f9350_1446x810.png 1272w, https://substackcdn.com/image/fetch/$s_!a6Lr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4a52d1e-90e9-44f6-a799-963e3e7f9350_1446x810.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!a6Lr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4a52d1e-90e9-44f6-a799-963e3e7f9350_1446x810.png" width="1446" height="810" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d4a52d1e-90e9-44f6-a799-963e3e7f9350_1446x810.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:810,&quot;width&quot;:1446,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:185882,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/184933928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4a52d1e-90e9-44f6-a799-963e3e7f9350_1446x810.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!a6Lr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4a52d1e-90e9-44f6-a799-963e3e7f9350_1446x810.png 424w, https://substackcdn.com/image/fetch/$s_!a6Lr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4a52d1e-90e9-44f6-a799-963e3e7f9350_1446x810.png 848w, https://substackcdn.com/image/fetch/$s_!a6Lr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4a52d1e-90e9-44f6-a799-963e3e7f9350_1446x810.png 1272w, https://substackcdn.com/image/fetch/$s_!a6Lr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4a52d1e-90e9-44f6-a799-963e3e7f9350_1446x810.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A simple model of a conductor.</em></figcaption></figure></div><p>&#8230;and then turn it into the following:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xgIU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65caec75-330b-4ba7-acb3-790e1195eb45_2011x983.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xgIU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65caec75-330b-4ba7-acb3-790e1195eb45_2011x983.jpeg 424w, https://substackcdn.com/image/fetch/$s_!xgIU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65caec75-330b-4ba7-acb3-790e1195eb45_2011x983.jpeg 848w, https://substackcdn.com/image/fetch/$s_!xgIU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65caec75-330b-4ba7-acb3-790e1195eb45_2011x983.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!xgIU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65caec75-330b-4ba7-acb3-790e1195eb45_2011x983.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xgIU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65caec75-330b-4ba7-acb3-790e1195eb45_2011x983.jpeg" width="1456" height="712" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/65caec75-330b-4ba7-acb3-790e1195eb45_2011x983.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:712,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:498256,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/184933928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65caec75-330b-4ba7-acb3-790e1195eb45_2011x983.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!xgIU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65caec75-330b-4ba7-acb3-790e1195eb45_2011x983.jpeg 424w, https://substackcdn.com/image/fetch/$s_!xgIU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65caec75-330b-4ba7-acb3-790e1195eb45_2011x983.jpeg 848w, https://substackcdn.com/image/fetch/$s_!xgIU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65caec75-330b-4ba7-acb3-790e1195eb45_2011x983.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!xgIU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65caec75-330b-4ba7-acb3-790e1195eb45_2011x983.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A prettier model of the same. By author.</em></figcaption></figure></div><p>As hinted earlier, in many 2D drawings, it&#8217;s a challenge to imply a specific three-dimensional order of objects or to suggest that some of them are in motion. Arrows and annotations don&#8217;t always cut it. After a fair amount of trial and error, I settled on subtle outlines, nonlinear shadows, and &#8220;afterimages&#8221;, as shown in this illustration of a simple rotary encoder:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iJCy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5dc47df-9d33-44bd-a9b0-7b8538e42176_2000x1000.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iJCy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5dc47df-9d33-44bd-a9b0-7b8538e42176_2000x1000.jpeg 424w, https://substackcdn.com/image/fetch/$s_!iJCy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5dc47df-9d33-44bd-a9b0-7b8538e42176_2000x1000.jpeg 848w, https://substackcdn.com/image/fetch/$s_!iJCy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5dc47df-9d33-44bd-a9b0-7b8538e42176_2000x1000.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!iJCy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5dc47df-9d33-44bd-a9b0-7b8538e42176_2000x1000.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iJCy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5dc47df-9d33-44bd-a9b0-7b8538e42176_2000x1000.jpeg" width="1456" height="728" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f5dc47df-9d33-44bd-a9b0-7b8538e42176_2000x1000.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:728,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:480794,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/184933928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5dc47df-9d33-44bd-a9b0-7b8538e42176_2000x1000.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!iJCy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5dc47df-9d33-44bd-a9b0-7b8538e42176_2000x1000.jpeg 424w, https://substackcdn.com/image/fetch/$s_!iJCy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5dc47df-9d33-44bd-a9b0-7b8538e42176_2000x1000.jpeg 848w, https://substackcdn.com/image/fetch/$s_!iJCy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5dc47df-9d33-44bd-a9b0-7b8538e42176_2000x1000.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!iJCy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5dc47df-9d33-44bd-a9b0-7b8538e42176_2000x1000.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Explaining a rotary encoder.</em></figcaption></figure></div><p>The next time you see a blog illustration that doesn&#8217;t look like &#128169; and wasn&#8217;t cranked out by AI, remember that more time might have gone into making that single picture than into writing all of the surrounding text.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p><p></p><p></p>]]></content:encoded></item><item><title><![CDATA[See it with your lying ears]]></title><description><![CDATA[This blog has a history of answering questions that no one should be asking. Today, we continue that proud legacy.]]></description><link>https://lcamtuf.substack.com/p/see-it-with-your-lying-ears</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/see-it-with-your-lying-ears</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Sat, 10 Jan 2026 00:00:05 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/d603e902-82e7-426e-9aaf-a6e88d13e995_1500x1000.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>For the past couple of weeks, I couldn&#8217;t shake off an intrusive thought: raster graphics and audio files are awfully similar &#8212; they&#8217;re sequences of analog measurements &#8212; so what would happen if we apply the same transformations to both?&#8230;</p><p>Let&#8217;s start with downsampling: what if we divide the data stream into buckets of <em>n </em>samples each, and then map the entire bucket to a single, averaged value?</p><blockquote><pre><code>for (pos = 0; pos &lt; len; pos += win_size) {
    
  float sum = 0;
  for (int i = 0; i &lt; win_size; i++) sum += buf[pos + i];
  for (int i = 0; i &lt; win_size; i++) buf[pos + i] = sum / win_size;

}</code></pre></blockquote><p>For images, the result is aesthetically pleasing pixel art. But if we do the same audio&#8230; well, put your headphones on, you&#8217;re in for a treat:</p><div id="vimeo-1152752363" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;1152752363&quot;,&quot;videoKey&quot;:&quot;c43b9bc88e&quot;,&quot;belowTheFold&quot;:false}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/1152752363?autoplay=0&amp;h=c43b9bc88e" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true"></iframe></div></div><p><em>The model for the images is our dog, Skye. The song fragment is a cover of &#8220;It Must Have Been Love&#8221; performed by Effie Passero.</em></p><p>If you&#8217;re familiar with audio formats, you might&#8217;ve expected this to sound different: a muffled but neutral rendition associated with low sample rates. Yet, the result of the &#8220;audio pixelation&#8221; filter is different: it adds unpleasant, metallic-sounding overtones. The culprit is the stairstep pattern in the resulting waveform:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RMMa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F641ae3ed-f886-4213-a0ca-f8d3a56409f2_2680x1180.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RMMa!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F641ae3ed-f886-4213-a0ca-f8d3a56409f2_2680x1180.png 424w, https://substackcdn.com/image/fetch/$s_!RMMa!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F641ae3ed-f886-4213-a0ca-f8d3a56409f2_2680x1180.png 848w, https://substackcdn.com/image/fetch/$s_!RMMa!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F641ae3ed-f886-4213-a0ca-f8d3a56409f2_2680x1180.png 1272w, https://substackcdn.com/image/fetch/$s_!RMMa!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F641ae3ed-f886-4213-a0ca-f8d3a56409f2_2680x1180.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RMMa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F641ae3ed-f886-4213-a0ca-f8d3a56409f2_2680x1180.png" width="1456" height="641" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/641ae3ed-f886-4213-a0ca-f8d3a56409f2_2680x1180.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:641,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:301754,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/183768069?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F641ae3ed-f886-4213-a0ca-f8d3a56409f2_2680x1180.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!RMMa!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F641ae3ed-f886-4213-a0ca-f8d3a56409f2_2680x1180.png 424w, https://substackcdn.com/image/fetch/$s_!RMMa!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F641ae3ed-f886-4213-a0ca-f8d3a56409f2_2680x1180.png 848w, https://substackcdn.com/image/fetch/$s_!RMMa!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F641ae3ed-f886-4213-a0ca-f8d3a56409f2_2680x1180.png 1272w, https://substackcdn.com/image/fetch/$s_!RMMa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F641ae3ed-f886-4213-a0ca-f8d3a56409f2_2680x1180.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Not great, not terrible.</em></figcaption></figure></div><p>Our eyes don&#8217;t mind the pattern on the computer screen, but the cochlea is a complex mechanical structure that doesn&#8217;t measure sound pressure levels per se; instead, it has clusters of different nerve cells sensitive to different sine-wave frequencies. Abrupt jumps in the waveform are perceived as wideband noise that wasn&#8217;t present in the original audio stream.</p><p>The problem is easy to solve: we can run the jagged waveform through a weighted rolling-average filter, the equivalent of blurring the pixelated image to remove the artifacts:</p><div id="vimeo-1152752229" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;1152752229&quot;,&quot;videoKey&quot;:&quot;98da641a37&quot;,&quot;belowTheFold&quot;:true}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/1152752229?autoplay=0&amp;h=98da641a37" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" loading="lazy"></iframe></div></div><p>But this brings up another question: is the effect similar if we keep the original 44.1 kHz sample rate but reduce the bit depth of each sample in the file?</p><blockquote><pre><code>/* Assumes signed int16_t buffer, produces n + 1 levels for even n. */

for (int i = 0; i &lt; len; i++) {

  int div = 32767 / (levels / 2);
  buf[i] = round(((float)buf[i]) / div) * div;

}</code></pre></blockquote><p>The answer is yes and no: because the frequency of the injected errors will be on average much higher, we get hiss instead of squeals:</p><div id="vimeo-1152752516" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;1152752516&quot;,&quot;videoKey&quot;:&quot;fd1368596f&quot;,&quot;belowTheFold&quot;:true}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/1152752516?autoplay=0&amp;h=fd1368596f" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" loading="lazy"></iframe></div></div><p>Also note that the loss of fidelity is far more rapid for audio than for quantized images!</p><p>As for the hiss itself, it&#8217;s inherent to any attempt to play back quantized audio; it&#8217;s why <a href="https://lcamtuf.substack.com/p/dacs-and-adcs-or-there-and-back-again">digital-to-analog converters</a> in your computer and audio gear typically need to incorporate some form of lowpass filtering. Your sound card has that, but we injected errors greater than what the circuitry was designed to mask.</p><p>But enough with image filters that ruin audio: we can also try some audio filters that ruin images! Let&#8217;s start by adding a slightly delayed and attenuated copy of the data stream to itself:</p><blockquote><pre><code>for (int i = shift; i &lt; len; i++)
  buf[i] = (5 * buf[i] + 4 * buf[i - shift]) / 9;</code></pre></blockquote><p>Check it out:</p><div id="vimeo-1152758681" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;1152758681&quot;,&quot;videoKey&quot;:&quot;2263a4d064&quot;,&quot;belowTheFold&quot;:true}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/1152758681?autoplay=0&amp;h=2263a4d064" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" loading="lazy"></iframe></div></div><p>For photos, small offsets result in an unappealing blur, while large offsets produce a weird &#8220;double exposure&#8221; look. For audio, the approach gives birth to a large and important family of filters. Small delays give the impression of a live performance in a small room; large delays sound like an echo in a large hall. Phase-shifted signals create effects such as &#8220;flanger&#8221; or &#8220;phaser&#8221;, a pitch-shifted echo sounds like a chorus, and so on.</p><p>So far, we&#8217;ve been working in the time domain, but we can also analyze data in the frequency domain; any finite signal can be deconstructed into a sum of sine waves with different amplitudes, phases, and frequency. The two most common conversion methods are the <a href="https://lcamtuf.substack.com/p/not-so-fast-mr-fourier">discrete Fourier transform</a> and the discrete cosine transform, but there are <a href="https://lcamtuf.substack.com/p/is-the-frequency-domain-a-real-place">more wacky options to choose from</a> if you&#8217;re so inclined.</p><p>For images, the frequency-domain view is rarely used for editing because almost all changes tend to produce visual artifacts; the technique is used for compression, feature detection, and noise removal, but not much more; it can be used for sharpening or blurring images, but there are easier ways of doing it without Fourier.</p><p>For audio, the story is different. For example, the approach makes it fairly easy to build vocoders that modulate the output from other instruments to resemble human speech, or to develop systems such as Auto-Tune, which make out-of-tune singing sound passable.</p><p>In the earlier article, I shared a simple implementation of the fast Fourier transform (FFT) in C:</p><blockquote><pre><code><code>void __fft_int(complex* buf, complex* tmp, 
               const uint32_t len, const uint32_t step) {

  if (step &gt;= len) return;
  __fft_int(tmp, buf, len, step * 2);
  __fft_int(tmp + step, buf + step, len, step * 2);

  for (uint32_t pos = 0; pos &lt; len; pos += 2 * step) {
    complex t = cexp(-I * M_PI * pos / len) * tmp[pos + step];
    buf[pos / 2] = tmp[pos] + t;
    buf[(pos + len) / 2] = tmp[pos] - t;
  }

}

void in_place_fft(complex* buf, const uint32_t len) {
  complex tmp[len];
  memcpy(tmp, buf, sizeof(tmp));
  __fft_int(buf, tmp, len, 1);
}</code> </code></pre></blockquote><p>Unfortunately, the transform gives us decent output only if the input buffer contains nearly-steady signals; the more change there is in the analysis window, the more smeared and intelligible the frequency-domain image. This means we can&#8217;t just take the entire song, run it through the aforementioned C function, and expect useful results.</p><p>Instead, we need to chop up the track into small slices, typically somewhere around 20-100 ms. This is long enough for each slice to contain a reasonable number of samples, but short enough to more or less represent a momentary &#8220;steady state&#8221; of the underlying waveform.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!U9pc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F936141e4-030a-4fdd-9675-fd735b1169f4_2813x781.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!U9pc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F936141e4-030a-4fdd-9675-fd735b1169f4_2813x781.png 424w, https://substackcdn.com/image/fetch/$s_!U9pc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F936141e4-030a-4fdd-9675-fd735b1169f4_2813x781.png 848w, https://substackcdn.com/image/fetch/$s_!U9pc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F936141e4-030a-4fdd-9675-fd735b1169f4_2813x781.png 1272w, https://substackcdn.com/image/fetch/$s_!U9pc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F936141e4-030a-4fdd-9675-fd735b1169f4_2813x781.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!U9pc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F936141e4-030a-4fdd-9675-fd735b1169f4_2813x781.png" width="1456" height="404" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/936141e4-030a-4fdd-9675-fd735b1169f4_2813x781.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:404,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:78706,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/183768069?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F936141e4-030a-4fdd-9675-fd735b1169f4_2813x781.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!U9pc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F936141e4-030a-4fdd-9675-fd735b1169f4_2813x781.png 424w, https://substackcdn.com/image/fetch/$s_!U9pc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F936141e4-030a-4fdd-9675-fd735b1169f4_2813x781.png 848w, https://substackcdn.com/image/fetch/$s_!U9pc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F936141e4-030a-4fdd-9675-fd735b1169f4_2813x781.png 1272w, https://substackcdn.com/image/fetch/$s_!U9pc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F936141e4-030a-4fdd-9675-fd735b1169f4_2813x781.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>An example of FFT windowing.</em></figcaption></figure></div><p>If we run the FFT function on each of these windows separately, each output will tell us about the distribution frequencies in that time slice; we can also string these outputs together into a spectrogram, plotting how frequencies (vertical axis) change over time (horizontal axis):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mzOB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cfdea3-912e-4a22-87b0-2e75e55d4ef9_1879x1171.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mzOB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cfdea3-912e-4a22-87b0-2e75e55d4ef9_1879x1171.jpeg 424w, https://substackcdn.com/image/fetch/$s_!mzOB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cfdea3-912e-4a22-87b0-2e75e55d4ef9_1879x1171.jpeg 848w, https://substackcdn.com/image/fetch/$s_!mzOB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cfdea3-912e-4a22-87b0-2e75e55d4ef9_1879x1171.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!mzOB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cfdea3-912e-4a22-87b0-2e75e55d4ef9_1879x1171.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mzOB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cfdea3-912e-4a22-87b0-2e75e55d4ef9_1879x1171.jpeg" width="1456" height="907" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d5cfdea3-912e-4a22-87b0-2e75e55d4ef9_1879x1171.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:907,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2090763,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/183768069?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cfdea3-912e-4a22-87b0-2e75e55d4ef9_1879x1171.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mzOB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cfdea3-912e-4a22-87b0-2e75e55d4ef9_1879x1171.jpeg 424w, https://substackcdn.com/image/fetch/$s_!mzOB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cfdea3-912e-4a22-87b0-2e75e55d4ef9_1879x1171.jpeg 848w, https://substackcdn.com/image/fetch/$s_!mzOB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cfdea3-912e-4a22-87b0-2e75e55d4ef9_1879x1171.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!mzOB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5cfdea3-912e-4a22-87b0-2e75e55d4ef9_1879x1171.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Audio waveform (top) and its FFT spectrogram view.</em></figcaption></figure></div><p>Alas, the method isn&#8217;t conductive to audio editing: if we make separate frequency-domain changes to each window and then convert the data back to the time domain, there&#8217;s no guarantee that the tail end of the reconstituted waveform for window <em>n</em> will still line up perfectly with the front of the waveform for window <em>n + 1</em>. We&#8217;re likely to end up with clicks and other audible artifacts where the FFT windows meet.</p><p>A clever solution to the problem is to use the Hann function for windowing. In essence, we multiply the waveform in every time slice by the value of <em>y</em> = <em>sin<sup>2</sup>(t)</em>, where <em>t</em> is scaled so that each window begins at <em>t</em> = 0 and ends at <em>t = </em>&#960;. This yields a sinusoidal shape that has a value of zero near the edges of the buffer and peaks at 1 in the middle:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!DaKn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2722020b-adce-4ef7-bca2-1ada31183279_2813x1875.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!DaKn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2722020b-adce-4ef7-bca2-1ada31183279_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!DaKn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2722020b-adce-4ef7-bca2-1ada31183279_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!DaKn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2722020b-adce-4ef7-bca2-1ada31183279_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!DaKn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2722020b-adce-4ef7-bca2-1ada31183279_2813x1875.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!DaKn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2722020b-adce-4ef7-bca2-1ada31183279_2813x1875.png" width="1456" height="970" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2722020b-adce-4ef7-bca2-1ada31183279_2813x1875.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:970,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:155041,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/183768069?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2722020b-adce-4ef7-bca2-1ada31183279_2813x1875.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!DaKn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2722020b-adce-4ef7-bca2-1ada31183279_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!DaKn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2722020b-adce-4ef7-bca2-1ada31183279_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!DaKn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2722020b-adce-4ef7-bca2-1ada31183279_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!DaKn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2722020b-adce-4ef7-bca2-1ada31183279_2813x1875.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>The Hann function for FFT windows.</em></figcaption></figure></div><p>At first blush, it&#8217;s hard to see how this multiplication would help: the consequence of the operation is that the input waveform is attenuated by an cyclic sinusoidal pattern, and the attenuation pattern will carry over to any waveform reconstructed from the FFT data (bottom row).</p><p>The trick is to also calculate another sequence of &#8220;halfway&#8221; FFT windows of the same size that are shifted 50% in relation to the existing ones (second row below):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CyCB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6431f65-be69-4ce7-b80d-a1fc3caa6526_2813x1875.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CyCB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6431f65-be69-4ce7-b80d-a1fc3caa6526_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!CyCB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6431f65-be69-4ce7-b80d-a1fc3caa6526_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!CyCB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6431f65-be69-4ce7-b80d-a1fc3caa6526_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!CyCB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6431f65-be69-4ce7-b80d-a1fc3caa6526_2813x1875.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CyCB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6431f65-be69-4ce7-b80d-a1fc3caa6526_2813x1875.png" width="1456" height="970" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c6431f65-be69-4ce7-b80d-a1fc3caa6526_2813x1875.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:970,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:243456,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/183768069?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6431f65-be69-4ce7-b80d-a1fc3caa6526_2813x1875.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!CyCB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6431f65-be69-4ce7-b80d-a1fc3caa6526_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!CyCB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6431f65-be69-4ce7-b80d-a1fc3caa6526_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!CyCB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6431f65-be69-4ce7-b80d-a1fc3caa6526_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!CyCB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6431f65-be69-4ce7-b80d-a1fc3caa6526_2813x1875.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Overlapping FFT windows with Hann weighting.</em></figcaption></figure></div><p>This leaves us with one output waveform (A in the bottom row) that&#8217;s attenuated by the repeating <em>sin<sup>2 </sup></em>pattern that starts at the beginning of the clip, and then another waveform (B) that&#8217;s attenuated by an identical <em>sin<sup>2 </sup></em>pattern shifted one-half of the cycle. The second pattern can be also written as <em>cos<sup>2</sup></em>.</p><p>With this in mind, we can write the equations for the two waveforms we can reconstruct from the FFT streams as:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{c}\nA(t) = in(t) \\cdot sin^2(t) \\\\\nB(t) = in(t) \\cdot cos^2(t) \\\\\n\\end{array}&quot;,&quot;id&quot;:&quot;URJJAWPLWS&quot;}" data-component-name="LatexBlockToDOM"></div><p>If we sum these waveforms, we get:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;out(t) = A(t) + B(t) = in(t) \\cdot \\underbrace{[sin^2(t) + cos^2(t)]}_{\\textrm{attenuation factor}}\n&quot;,&quot;id&quot;:&quot;FTNGXYBZSH&quot;}" data-component-name="LatexBlockToDOM"></div><p>This is where we wheel out the Pythagorean identity, an easily-derived rule that tells us that the following must hold for any <em>x</em>:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;sin^2(x) + cos^2(x) = 1&quot;,&quot;id&quot;:&quot;OPUBRMOQBR&quot;}" data-component-name="LatexBlockToDOM"></div><p>If you&#8217;re unfamiliar with this identity, recall that in a right triangle, <em>sin(&#945;)</em> is the ratio of the opposite to the hypotenuse (<em>a/c</em>), while cos<em>(&#945;)</em> is the ratio of the adjacent to the hypotenuse (<em>b/c</em>). If we choose <em>c = </em>1, this simplifies to <em>sin(&#945;) = a </em>and <em>cos(&#945;) = b</em>. Further, from the Pythagorean theorem, <em>a<sup>2</sup> + b<sup>2</sup> = c<sup>2</sup></em>, so we can assert that <em>sin<sup>2</sup>(&#945;) + cos<sup>2</sup>(&#945;) = 1</em> for any angle <em>&#945;</em>.</p><p>In effect, the underlined multiplier in the earlier equation for the summed waveform is always 1; in the A + B sum, the Hann-induced attenuation cancels out.</p><p>At the same time, because the signal at the edges of each FFT window is attenuated to zero, we get rid of the waveform-merging discontinuities. Instead, the transitions between windows involve gradual shifts between A and B signals, masking any editing artifacts.</p><p>Where was I going with this? Ah, right! With this trick up of our sleeve, we can goof around in the frequency domain to &#8212; for example &#8212; selectively shift the pitch of the vocals in our clip:</p><div id="vimeo-1152768108" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;1152768108&quot;,&quot;videoKey&quot;:&quot;e15bb614a7&quot;,&quot;belowTheFold&quot;:true}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/1152768108?autoplay=0&amp;h=e15bb614a7" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" loading="lazy"></iframe></div></div><p><em>Source code for the effect is available <a href="https://lcamtuf.coredump.cx/blog/fft_pitch.tgz">here</a>. It&#8217;s short and easy to experiment with.</em></p><p>I also spent some time approximating the transform for the dog image. In the first instance, some low-frequency components are shifted to higher FFT bins, causing spurious additional edges to crop up and making Skye look jittery. In the second instance, the bins are moved in the other direction, producing a distinctive type of blur.</p><p><em>PS. Before I get hate mail from DSP folks, I should note that high-quality pitch shifting is usually done in a more complex way. For example, many systems actively track the dominant frequency of the vocal track and add correction for voiceless consonants such as &#8220;s&#8221;. If you want to down a massive rabbit hole, <a href="https://www.diva-portal.org/smash/get/diva2:1381398/FULLTEXT01.pdf">this text</a> is a pretty accessible summary.</em></p><p><em>As for the 20 minutes spent reading this article, you&#8217;re not getting that back.</em></p><div><hr></div><p><em>&#128073; For more articles about math, <a href="https://lcamtuf.substack.com/p/algorithms-and-math-trivia">visit this page</a>.</em></p><p><em>I write well-researched, original articles about geek culture, electronic circuit design, algorithms, and more. If you like the content, please subscribe.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item><item><title><![CDATA[Cursed circuits #4: PLL frequency multiplier]]></title><description><![CDATA[How do you turn 1 MHz into 100 MHz? With magic, of course.]]></description><link>https://lcamtuf.substack.com/p/cursed-circuits-4-pll-frequency-multiplier</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/cursed-circuits-4-pll-frequency-multiplier</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Fri, 26 Dec 2025 17:47:58 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!nqfK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ec45e92-4453-4adc-9873-ffd4ae9ed319_2813x1875.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Welcome to another installment of <em>Cursed Circuits. </em>My goal for the series is to highlight a small collection of common yet mind-bending circuits that must&#8217;ve taken a stroke of genius to invent, but that are usually presented on the internet without explaining how or why they work.</p><p>In today&#8217;s episode, let&#8217;s have a look at a phase-locked loop clock multiplier: a circuit that, among other things, can take a 20 MHz timing signal produced by a quartz crystal and turn it into a perfectly-synchronized computer clock that&#8217;s running at 500 MHz, 3 GHz, or any other frequency of your choice.</p><h3>A primer on latches</h3><p>To understand the PLL frequency multiplier, it&#8217;s probably good to cover latches first. A latch is a fundamental data-storage circuit capable of holding a single bit. The simplest variant is the set-reset (S-R) latch, which can be constructed from basic logic gates in a couple of ways. Perhaps the most intuitive layout is the following three-gate approach:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Zsfy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8dbb-0c84-4d12-9974-2e89996f9e42_2000x700.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Zsfy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8dbb-0c84-4d12-9974-2e89996f9e42_2000x700.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Zsfy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8dbb-0c84-4d12-9974-2e89996f9e42_2000x700.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Zsfy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8dbb-0c84-4d12-9974-2e89996f9e42_2000x700.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Zsfy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8dbb-0c84-4d12-9974-2e89996f9e42_2000x700.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Zsfy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8dbb-0c84-4d12-9974-2e89996f9e42_2000x700.jpeg" width="1456" height="510" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a98c8dbb-0c84-4d12-9974-2e89996f9e42_2000x700.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:510,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:157307,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/182613637?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8dbb-0c84-4d12-9974-2e89996f9e42_2000x700.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Zsfy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8dbb-0c84-4d12-9974-2e89996f9e42_2000x700.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Zsfy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8dbb-0c84-4d12-9974-2e89996f9e42_2000x700.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Zsfy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8dbb-0c84-4d12-9974-2e89996f9e42_2000x700.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Zsfy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8dbb-0c84-4d12-9974-2e89996f9e42_2000x700.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A three-gate S-R latch.</em></figcaption></figure></div><p>To analyze the circuit, let&#8217;s assume that the &#8220;set&#8221; signal (S) is high and the &#8220;reset&#8221; signal (R) is low. In this case, the output of the OR gate is a logical one regardless of the looped-back signal present on the gate&#8217;s other terminal; this produces a logical one on the first input of the downstream AND gate. The other input of that AND gate is also equal to one, because it&#8217;s just an inverted copy of R = 0. All in all, in the S = 1 and R = 0 scenario, both inputs of the AND gate are high; therefore, so is the signal on the circuit&#8217;s output leg (Q).</p><p>Next, let&#8217;s imagine that S transitions to a logical zero. This puts one of the OR inputs at zero volts, but the other is still high because it&#8217;s the looped-back output signal Q. The circuit is latched: it keeps outputting the same voltage as before, even though the original driving signal is gone.</p><p>The only thing that can break the cycle if the &#8220;reset&#8221; line is pulled high. This causes one of the AND input to go low, thus forcing the output signal to zero and breaking the loop that kept the OR gate latched. From now on, the output remains low even if R returns to zero volts.</p><p>This two-lever latch can be fashioned into a more practical data (D) latch, which stores an arbitrary input bit supplied on the data line whenever the enable signal (E) is high, and keeps it when E is low:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!67OG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc87bdb9a-f161-4b56-a766-0392be466f2b_1785x441.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!67OG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc87bdb9a-f161-4b56-a766-0392be466f2b_1785x441.jpeg 424w, https://substackcdn.com/image/fetch/$s_!67OG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc87bdb9a-f161-4b56-a766-0392be466f2b_1785x441.jpeg 848w, https://substackcdn.com/image/fetch/$s_!67OG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc87bdb9a-f161-4b56-a766-0392be466f2b_1785x441.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!67OG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc87bdb9a-f161-4b56-a766-0392be466f2b_1785x441.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!67OG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc87bdb9a-f161-4b56-a766-0392be466f2b_1785x441.jpeg" width="1456" height="360" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c87bdb9a-f161-4b56-a766-0392be466f2b_1785x441.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:360,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:210916,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/182613637?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc87bdb9a-f161-4b56-a766-0392be466f2b_1785x441.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!67OG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc87bdb9a-f161-4b56-a766-0392be466f2b_1785x441.jpeg 424w, https://substackcdn.com/image/fetch/$s_!67OG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc87bdb9a-f161-4b56-a766-0392be466f2b_1785x441.jpeg 848w, https://substackcdn.com/image/fetch/$s_!67OG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc87bdb9a-f161-4b56-a766-0392be466f2b_1785x441.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!67OG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc87bdb9a-f161-4b56-a766-0392be466f2b_1785x441.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption"><em>A conceptual illustration of a D latch.</em></figcaption></figure></div><p>In this circuit, a pair of input-side AND gates ensures that when E is at zero volts, the underlying S and R lines remain low regardless of the value presented on the data line. Conversely, if enable is high, the gates pass through a logical one either to the S line (if D is high) or the R line (if D is low).</p><p>Going further down that path, we can turn a D latch into a clocked D flip-flop, which stores a bit of data on the rising edge of the clock signal:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!uWN2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01325f81-7dfc-4aab-8a2d-2844793910fb_2000x578.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!uWN2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01325f81-7dfc-4aab-8a2d-2844793910fb_2000x578.jpeg 424w, https://substackcdn.com/image/fetch/$s_!uWN2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01325f81-7dfc-4aab-8a2d-2844793910fb_2000x578.jpeg 848w, https://substackcdn.com/image/fetch/$s_!uWN2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01325f81-7dfc-4aab-8a2d-2844793910fb_2000x578.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!uWN2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01325f81-7dfc-4aab-8a2d-2844793910fb_2000x578.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!uWN2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01325f81-7dfc-4aab-8a2d-2844793910fb_2000x578.jpeg" width="1456" height="421" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/01325f81-7dfc-4aab-8a2d-2844793910fb_2000x578.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:421,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:141098,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/182613637?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01325f81-7dfc-4aab-8a2d-2844793910fb_2000x578.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!uWN2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01325f81-7dfc-4aab-8a2d-2844793910fb_2000x578.jpeg 424w, https://substackcdn.com/image/fetch/$s_!uWN2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01325f81-7dfc-4aab-8a2d-2844793910fb_2000x578.jpeg 848w, https://substackcdn.com/image/fetch/$s_!uWN2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01325f81-7dfc-4aab-8a2d-2844793910fb_2000x578.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!uWN2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01325f81-7dfc-4aab-8a2d-2844793910fb_2000x578.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A clocked D flip-flop.</em></figcaption></figure></div><p>In this circuit, the latch on the left passes through the input data when the clock signal is low, or keeps the previous value if the clock is high. The latch on the right works the opposite way: it passes through the output from the first latch if the clock is high or holds the last value otherwise.</p><p>In effect, the value on the input line appears to propagate to the circuit&#8217;s output only during the 0 &#8594; 1 transition (rising edge) of the clock signal. More to the point, the propagation happens in two stages and there is never a direct signal path between D and Q, which prevents the cell from misbehaving if Q is looped back onto D.</p><h3>Phase error detector</h3><p>Once we have a clocked D flip-flop &#8212; and make a trivial modification to furnish it with an additional reset input &#8212; we can build a digital phase error detector circuit. One type of such a detector is shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!N6b_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F911b9921-98f1-470d-ae8d-c716e5282520_2000x1050.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!N6b_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F911b9921-98f1-470d-ae8d-c716e5282520_2000x1050.jpeg 424w, https://substackcdn.com/image/fetch/$s_!N6b_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F911b9921-98f1-470d-ae8d-c716e5282520_2000x1050.jpeg 848w, https://substackcdn.com/image/fetch/$s_!N6b_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F911b9921-98f1-470d-ae8d-c716e5282520_2000x1050.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!N6b_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F911b9921-98f1-470d-ae8d-c716e5282520_2000x1050.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!N6b_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F911b9921-98f1-470d-ae8d-c716e5282520_2000x1050.jpeg" width="1456" height="764" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/911b9921-98f1-470d-ae8d-c716e5282520_2000x1050.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:764,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:239274,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/182613637?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F911b9921-98f1-470d-ae8d-c716e5282520_2000x1050.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!N6b_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F911b9921-98f1-470d-ae8d-c716e5282520_2000x1050.jpeg 424w, https://substackcdn.com/image/fetch/$s_!N6b_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F911b9921-98f1-470d-ae8d-c716e5282520_2000x1050.jpeg 848w, https://substackcdn.com/image/fetch/$s_!N6b_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F911b9921-98f1-470d-ae8d-c716e5282520_2000x1050.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!N6b_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F911b9921-98f1-470d-ae8d-c716e5282520_2000x1050.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A simple phase error detector.</em></figcaption></figure></div><p>The purpose of the detector is to compare clock signal B to a reference clock provided on input A. If the positive edge on input A arrives before a positive edge on input B, the output of the upper flip-flop (<em>Q<sub>A</sub></em>) goes high before the output of the bottom flip-flop (<em>Q<sub>B</sub></em>); this signals that clock B is running too slow. Conversely, if the edge on B arrives before the edge on A, the circuit generates a complementary output indicating that B is running too fast. As soon as both flip-flops are latched high &#8212; i.e., after encountering a positive edge on whichever of the two clock signals is running slower &#8212; the circuit is reset.</p><p>The following plot shows the behavior of the circuit when the clock supplied on the B leg is running too slow (left) or too fast (right) in relation to the reference signal on leg A:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Z-Zh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb626b761-7d03-48da-89c6-dc9a061decc0_2813x1875.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Z-Zh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb626b761-7d03-48da-89c6-dc9a061decc0_2813x1875.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Z-Zh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb626b761-7d03-48da-89c6-dc9a061decc0_2813x1875.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Z-Zh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb626b761-7d03-48da-89c6-dc9a061decc0_2813x1875.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Z-Zh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb626b761-7d03-48da-89c6-dc9a061decc0_2813x1875.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Z-Zh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb626b761-7d03-48da-89c6-dc9a061decc0_2813x1875.jpeg" width="1456" height="970" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b626b761-7d03-48da-89c6-dc9a061decc0_2813x1875.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:970,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:73176,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/182613637?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb626b761-7d03-48da-89c6-dc9a061decc0_2813x1875.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Z-Zh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb626b761-7d03-48da-89c6-dc9a061decc0_2813x1875.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Z-Zh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb626b761-7d03-48da-89c6-dc9a061decc0_2813x1875.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Z-Zh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb626b761-7d03-48da-89c6-dc9a061decc0_2813x1875.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Z-Zh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb626b761-7d03-48da-89c6-dc9a061decc0_2813x1875.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>The basic behavior of the phase error detector circuit.</em></figcaption></figure></div><p>In effect, the detector generates longer pulses on the output labeled P if the analyzed clock signal is lagging behind the reference; and longer pulses on the other output (R) if the signal is rushing ahead.</p><p>It&#8217;s worth noting that the frequencies in the plot are not cherry-picked; although a rigorous mathematical analysis of phase detectors is fairly involved and they have transient failure modes, the following simulation shows that happens if the frequency B is changing continuously:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nqfK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ec45e92-4453-4adc-9873-ffd4ae9ed319_2813x1875.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nqfK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ec45e92-4453-4adc-9873-ffd4ae9ed319_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!nqfK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ec45e92-4453-4adc-9873-ffd4ae9ed319_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!nqfK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ec45e92-4453-4adc-9873-ffd4ae9ed319_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!nqfK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ec45e92-4453-4adc-9873-ffd4ae9ed319_2813x1875.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nqfK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ec45e92-4453-4adc-9873-ffd4ae9ed319_2813x1875.png" width="1456" height="970" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6ec45e92-4453-4adc-9873-ffd4ae9ed319_2813x1875.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:970,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:74297,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/182613637?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ec45e92-4453-4adc-9873-ffd4ae9ed319_2813x1875.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!nqfK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ec45e92-4453-4adc-9873-ffd4ae9ed319_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!nqfK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ec45e92-4453-4adc-9873-ffd4ae9ed319_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!nqfK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ec45e92-4453-4adc-9873-ffd4ae9ed319_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!nqfK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ec45e92-4453-4adc-9873-ffd4ae9ed319_2813x1875.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A continuously-variable-frequency variant of the simulation.</em></figcaption></figure></div><h3>PLL loop</h3><p>The detector can serve as the fundamental building block of a circuit known as a phase-locked loop. Despite the name, the main forte of phase-locked loops is that they can generate output frequencies that match an input signal of some sort, even if that signal is noisy or faint:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!W2FF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c679cc-be02-499e-b81d-5ecfa647f7cc_2000x650.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!W2FF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c679cc-be02-499e-b81d-5ecfa647f7cc_2000x650.jpeg 424w, https://substackcdn.com/image/fetch/$s_!W2FF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c679cc-be02-499e-b81d-5ecfa647f7cc_2000x650.jpeg 848w, https://substackcdn.com/image/fetch/$s_!W2FF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c679cc-be02-499e-b81d-5ecfa647f7cc_2000x650.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!W2FF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c679cc-be02-499e-b81d-5ecfa647f7cc_2000x650.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!W2FF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c679cc-be02-499e-b81d-5ecfa647f7cc_2000x650.jpeg" width="1456" height="473" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f8c679cc-be02-499e-b81d-5ecfa647f7cc_2000x650.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:473,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:149817,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/182613637?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c679cc-be02-499e-b81d-5ecfa647f7cc_2000x650.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!W2FF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c679cc-be02-499e-b81d-5ecfa647f7cc_2000x650.jpeg 424w, https://substackcdn.com/image/fetch/$s_!W2FF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c679cc-be02-499e-b81d-5ecfa647f7cc_2000x650.jpeg 848w, https://substackcdn.com/image/fetch/$s_!W2FF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c679cc-be02-499e-b81d-5ecfa647f7cc_2000x650.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!W2FF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c679cc-be02-499e-b81d-5ecfa647f7cc_2000x650.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>The basic architecture of a digital PLL.</em></figcaption></figure></div><p>The output stage of the PLL is a <a href="https://lcamtuf.substack.com/p/its-hard-to-build-an-oscillator">voltage-controlled oscillator (VCO)</a>. We&#8217;ve briefly covered VCOs before: they generate an output waveform with a frequency proportional to the supplied input voltage.</p><p>The voltage for the VCO is selected by a simple switched capacitor section in the middle; the section has two digital inputs, marked &#8220;+&#8221; and &#8220;-&#8221;. Supplying a digital signal on the &#8220;+&#8221; input turns on a high-side transistor that gradually charges the output capacitor to a higher voltage, thus increasing the output frequency of the VCO. Supplying a signal on the &#8220;-&#8221; leg turns on a low-side transistor, slowly discharges the capacitor, and achieves the opposite effect. </p><p>The last part of the circuit is the now-familiar phase error detector; it compares the externally-supplied clock to the looped-back output from the VCO. The detector outputs long pulses on the P output if the VCO frequency is lower than the reference clock, or on the R output if the VCO is running too fast. In doing so, the circuit adjusts the capacitor voltage and nudges the VCO to match the frequency and phase of the input waveform.</p><h3>Toward the frequency multiplier</h3><p>So far, we have a circuit that synchronizes the VCO with an external clock; that has some uses in communications, but doesn&#8217;t seem all that interesting on its own. To take it to the next level, we need to add a small but ingenious tweak:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5hXD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b34198-5799-4bab-abc8-67dbbb509450_2000x800.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5hXD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b34198-5799-4bab-abc8-67dbbb509450_2000x800.jpeg 424w, https://substackcdn.com/image/fetch/$s_!5hXD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b34198-5799-4bab-abc8-67dbbb509450_2000x800.jpeg 848w, https://substackcdn.com/image/fetch/$s_!5hXD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b34198-5799-4bab-abc8-67dbbb509450_2000x800.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!5hXD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b34198-5799-4bab-abc8-67dbbb509450_2000x800.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5hXD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b34198-5799-4bab-abc8-67dbbb509450_2000x800.jpeg" width="1456" height="582" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/92b34198-5799-4bab-abc8-67dbbb509450_2000x800.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:582,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:178966,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/182613637?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b34198-5799-4bab-abc8-67dbbb509450_2000x800.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5hXD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b34198-5799-4bab-abc8-67dbbb509450_2000x800.jpeg 424w, https://substackcdn.com/image/fetch/$s_!5hXD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b34198-5799-4bab-abc8-67dbbb509450_2000x800.jpeg 848w, https://substackcdn.com/image/fetch/$s_!5hXD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b34198-5799-4bab-abc8-67dbbb509450_2000x800.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!5hXD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b34198-5799-4bab-abc8-67dbbb509450_2000x800.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A PLL-based frequency multiplier.</em></figcaption></figure></div><p>In this new circuit, we incorporated a frequency divider in the feedback loop. A frequency divider is not a complicated concept; most simply, it can be a binary counter (e.g., 74HC393) that advances by one with every cycle of the input clock. For a three-bit counter, the outputs will be:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{| c | c | c | c | c |}\n\\hline\n\\textbf{Clock cycle #} &amp; \\boldsymbol{Q_2} &amp; \\boldsymbol{Q_1} &amp; \\boldsymbol{Q_0} \\\\\n\\hline\n0 &amp; 0 &amp; 0 &amp; 0 \\\\\n1 &amp; 0 &amp; 0 &amp; 1 \\\\\n2 &amp; 0 &amp; 1 &amp; 0 \\\\\n3 &amp; 0 &amp; 1 &amp; 1 \\\\\n4 &amp; 1 &amp; 0 &amp; 0 \\\\\n5 &amp; 1 &amp; 0 &amp; 1 \\\\\n6 &amp; 1 &amp; 1 &amp; 0 \\\\\n7 &amp; 1 &amp; 1 &amp; 1 \\\\\n\\hline\n\\end{array}&quot;,&quot;id&quot;:&quot;POLSUJFRRQ&quot;}" data-component-name="LatexBlockToDOM"></div><p>Note that the counter produces a square wave with half the clock frequency on the LSB output (<em>Q<sub>0</sub></em>); with one-fourth the frequency on the second output (Q<sub>1</sub>); and with one-eighth on the MSB leg (Q<sub>2</sub>).</p><p>If we choose <em>Q<sub>0</sub></em> for the divider, the phase error detector will be presented with a looped-back signal that&#8217;s equal to one half the running frequency of the VCO; it will then work to get the VCO frequency high enough so that the divided signal matches the reference clock. This will cause the VCO to run exactly twice as fast &#8212; and yet, precisely in lockstep with the input clock. </p><h1 style="text-align: center;"><strong>&#128214;</strong></h1><p style="text-align: center;">If you liked the article, you&#8217;ll enjoy <em><a href="https://lcamtuf.coredump.cx/electronics/">The Secret Life of Circuits</a></em>. It&#8217;s a richly illustrated, lucid introduction to electronics &#8212; from the physics of conduction to embedded system programming. It features 290+ color diagrams, 420+ pages of original content, and zero AI.</p><div><hr></div><p><em>&#128073; For further articles about electronics, <a href="https://lcamtuf.substack.com/p/electronics-curriculum">click here</a>. In particular, you might enjoy:</em></p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;ac5a28d3-1c47-4044-af58-89acc2fe0bc9&quot;,&quot;caption&quot;:&quot;In the spring of 2023, when this Substack had only a handful of subscribers, I posted a primer on voltage adjustment in electronic circuits. The article opened with a brief discussion of linear regulators, and then promptly threw them under the bus in favor of more efficient charge pumps and inductor-based topologies.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Cursed circuits: charge pump voltage halver&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-12-02T00:00:03.420Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/$s_!dYf0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/cursed-circuits-charge-pump-voltage&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:180429933,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:24,&quot;comment_count&quot;:0,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;91a2328b-d49c-4993-b85e-882cea896c07&quot;,&quot;caption&quot;:&quot;In the previous post on this Substack, we looked at charge pump circuits and the mildly cursed example of a capacitor-based voltage halver. I find these topologies interesting because they are very simple, yet they subvert the usual way of thinking about what a capacitors can or cannot do.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Cursed circuits #2: switched capacitor lowpass&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-12-04T00:00:03.419Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4e0e7351-7d4f-4efd-be70-22f3ae8dc7fd_855x790.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/cursed-circuits-2-switched-capacitor&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:180619026,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:16,&quot;comment_count&quot;:1,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;e5addff2-d425-4102-90f8-42ce8afc39be&quot;,&quot;caption&quot;:&quot;In the previous installments of Cursed Circuits, we looked at two switched capacitor circuits: the voltage halver and the capacitor lowpass filter.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Cursed circuits #3: true mathematics&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-12-22T02:38:09.425Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a8dee63b-328f-463b-87d2-20659ab0b41e_1280x720.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/cursed-circuits-3-true-mathematics&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:182245394,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:20,&quot;comment_count&quot;:15,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p><em>I write well-researched, original articles about geek culture, electronic circuit design, algorithms, and more. If you like the content, please subscribe.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item><item><title><![CDATA[Cursed circuits #3: true mathematics]]></title><description><![CDATA[Op-amp arithmetics, explained in a more accessible way]]></description><link>https://lcamtuf.substack.com/p/cursed-circuits-3-true-mathematics</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/cursed-circuits-3-true-mathematics</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Mon, 22 Dec 2025 02:38:09 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/a8dee63b-328f-463b-87d2-20659ab0b41e_1280x720.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the previous installments of <em>Cursed Circuits</em>, we looked at two switched capacitor circuits: the <a href="https://lcamtuf.substack.com/p/cursed-circuits-charge-pump-voltage">voltage halver</a> and the <a href="https://lcamtuf.substack.com/p/cursed-circuits-2-switched-capacitor">capacitor lowpass filter</a>.</p><p>In today&#8217;s episode, I&#8217;d like to talk about the use of operational amplifiers to do something other than amplification: to solve analog math. Analog computing at a scale is wildly impractical because errors tend to accumulate every step along the way; nevertheless, individual techniques find a number of specialized uses, perhaps most prominently in <a href="https://lcamtuf.substack.com/p/dacs-and-adcs-or-there-and-back-again">analog-to-digital converters</a>. Let&#8217;s have a look at how it&#8217;s done.</p><p><em>The following assumes familiarity with <a href="https://lcamtuf.substack.com/p/primer-core-concepts-in-electronic">core concepts in electronic circuits</a> and with the <a href="https://lcamtuf.substack.com/p/the-basics-of-signal-amplification">fundamentals of signal amplification</a>. If you need a refresher, start with the two linked articles first.</em></p><h3>Op-amps at a glance</h3><p>Before we get to less obvious circuits, let&#8217;s start with a brief recap: operational amplifiers are to analog electronics what logic gates are to digital logic. They are simple but remarkably versatile building blocks that let you accomplish far more than appears possible at first blush.</p><p>Unfortunately, in introductory texts, their operation is often explained in confusing ways. All that an op-amp does is taking two input voltages &#8212; <em>V<sub>in-</sub></em> (&#8220;inverting input&#8221;) and <em>V<sub>in+</sub></em> (&#8220;non-inverting input&#8221;) &#8212; and then outputting a voltage that&#8217;s equal to the difference between the two, amplified by a huge factor (<em>A<sub>OL</sub></em>, often 100,000 or more) and then referenced to the midpoint of the supply (<em>V<sub>mid</sub></em>). You can write it the following way:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;V_{out} = V_{mid} + (V_{in+} - V_{in-}) \\cdot A_{OL}&quot;,&quot;id&quot;:&quot;DOSMZBNFUO&quot;}" data-component-name="LatexBlockToDOM"></div><p>That&#8217;s all the chip does. Because the gain is massive, there is a very narrow linear region near <em>V<sub>in-</sub></em> = <em>V<sub>in+</sub></em>; a difference greater than a couple of microvolts will send the output toward one of the supply rails. The chip doesn&#8217;t care about the absolute value of <em>V<sub>in-</sub></em> or <em>V<sub>in+</sub></em> it can&#8217;t &#8220;see&#8221; any external components you connect to it, and its internal gain can&#8217;t be changed.</p><p>To show the versatility of the component, we can have a quick look at the following circuit that you might be already familiar with &#8212; a non-inverting amplifier:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ELK3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac0ada9-3028-4bf9-a258-c0a11688efde_2000x1177.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ELK3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac0ada9-3028-4bf9-a258-c0a11688efde_2000x1177.jpeg 424w, https://substackcdn.com/image/fetch/$s_!ELK3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac0ada9-3028-4bf9-a258-c0a11688efde_2000x1177.jpeg 848w, https://substackcdn.com/image/fetch/$s_!ELK3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac0ada9-3028-4bf9-a258-c0a11688efde_2000x1177.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!ELK3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac0ada9-3028-4bf9-a258-c0a11688efde_2000x1177.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ELK3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac0ada9-3028-4bf9-a258-c0a11688efde_2000x1177.jpeg" width="1456" height="857" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bac0ada9-3028-4bf9-a258-c0a11688efde_2000x1177.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:857,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:231290,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/182245394?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac0ada9-3028-4bf9-a258-c0a11688efde_2000x1177.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ELK3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac0ada9-3028-4bf9-a258-c0a11688efde_2000x1177.jpeg 424w, https://substackcdn.com/image/fetch/$s_!ELK3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac0ada9-3028-4bf9-a258-c0a11688efde_2000x1177.jpeg 848w, https://substackcdn.com/image/fetch/$s_!ELK3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac0ada9-3028-4bf9-a258-c0a11688efde_2000x1177.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!ELK3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac0ada9-3028-4bf9-a258-c0a11688efde_2000x1177.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>The basic non-inverting voltage amplifier.</em></figcaption></figure></div><p>One input of the op-amp is connected to the external signal source: <em>V<sub>in+ </sub></em>= <em>V<sub>signal</sub></em>. The other input is hooked up to a two-resistor voltage divider that straddles the ground and the output leg; the divider&#8217;s midpoint voltage is:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;V_{in-} = {R_g \\over R_g + R_f} \\cdot V_{out} &quot;,&quot;id&quot;:&quot;QIQYEVROBB&quot;}" data-component-name="LatexBlockToDOM"></div><p>As discussed earlier, the only way for the op-amp to output voltages other than 0 V or <em>V<sub>supply </sub></em>is for <em>V<sub>in+ </sub></em>to be very close to <em>V<sub>in-</sub></em>. We can assume that we&#8217;re operating near that equilibrium point, combine the equations for the voltages on the two input legs, and write:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;V_{signal} \\approx {R_g \\over R_g + R_f } \\cdot V_{out}&quot;,&quot;id&quot;:&quot;ITLUZFXICH&quot;}" data-component-name="LatexBlockToDOM"></div><p>Solving this for <em>V<sub>out</sub></em>, we get:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;V_{out} \\approx V_{signal}  \\cdot {R_g + R_f \\over R_g} \\approx V_{signal} \\cdot (1 + {R_f \\over R_g})&quot;,&quot;id&quot;:&quot;CQTUEIEJTT&quot;}" data-component-name="LatexBlockToDOM"></div><p>In other words, the output voltage is the input signal amplified by a factor of <em>1 + R<sub>f</sub>/R<sub>g</sub></em>. We have a near-ideal single-ended voltage amplifier with a configurable gain. Again, the circuit is probably familiar to most folks dabbling in analog electronics, but it&#8217;s worth pondering that we implemented it by adding a couple of resistors to a chip that does something conceptually quite different.</p><p><em>Note: there&#8217;s a bit more to op-amp lore when dealing with high-frequency signals; a more rigorous analysis of their frequency characteristics can be found in <a href="https://lcamtuf.substack.com/p/deep-dive-the-instability-of-op-amps">this article</a>.</em></p><h3>Addition</h3><p>Now that we have the basics covered, we can show that op-amps can do more than just amplify signals. The first contender is the following summing layout that differs from what&#8217;s usually covered in textbooks, but that&#8217;s well-suited for single-supply use:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!N-qA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa8e2a97-1a44-44fc-8724-4b6615b3a19b_2000x1225.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!N-qA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa8e2a97-1a44-44fc-8724-4b6615b3a19b_2000x1225.jpeg 424w, https://substackcdn.com/image/fetch/$s_!N-qA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa8e2a97-1a44-44fc-8724-4b6615b3a19b_2000x1225.jpeg 848w, https://substackcdn.com/image/fetch/$s_!N-qA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa8e2a97-1a44-44fc-8724-4b6615b3a19b_2000x1225.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!N-qA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa8e2a97-1a44-44fc-8724-4b6615b3a19b_2000x1225.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!N-qA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa8e2a97-1a44-44fc-8724-4b6615b3a19b_2000x1225.jpeg" width="1456" height="892" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/aa8e2a97-1a44-44fc-8724-4b6615b3a19b_2000x1225.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:892,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:268468,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/182245394?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa8e2a97-1a44-44fc-8724-4b6615b3a19b_2000x1225.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!N-qA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa8e2a97-1a44-44fc-8724-4b6615b3a19b_2000x1225.jpeg 424w, https://substackcdn.com/image/fetch/$s_!N-qA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa8e2a97-1a44-44fc-8724-4b6615b3a19b_2000x1225.jpeg 848w, https://substackcdn.com/image/fetch/$s_!N-qA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa8e2a97-1a44-44fc-8724-4b6615b3a19b_2000x1225.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!N-qA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa8e2a97-1a44-44fc-8724-4b6615b3a19b_2000x1225.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A three-way non-inverting summing amplifier.</em></figcaption></figure></div><p>Assuming well-behaved signal sources that can supply and sink currents, it should be pretty intuitive that the voltage on the <em>V<sub>in+</sub></em> leg is just an average of three input signals:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;V_{in+} = {V_A + V_B + V_C \\over 3}&quot;,&quot;id&quot;:&quot;PJCCEQASYF&quot;}" data-component-name="LatexBlockToDOM"></div><p>For readers who are unpersuaded, we can show this from Kirchoff&#8217;s current law (KCL); the law essentially just says &#8220;what comes in must come out&#8221; &#8212; i.e., the currents flowing into and out of the three-resistor junction must balance out. If we use <em>V<sub>jct </sub></em>to denote the voltage at the junction, then from Ohm&#8217;s law, we can write the following current equations for each resistor branch:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{c}\nI_1 = {V_A - V_{jct} \\over R} \\\\\nI_2 = {V_B - V_{jct} \\over R} \\\\\nI_3 = {V_C - V_{jct} \\over R} \\\\\n\\end{array}&quot;,&quot;id&quot;:&quot;WRXYATJBBI&quot;}" data-component-name="LatexBlockToDOM"></div><p>Further, from KCL, we can assert that the currents must balance out: <em>I<sub>1 </sub></em>+ <em>I<sub>2 </sub></em>+ <em>I<sub>3 </sub></em>= 0 A. Combining all these equations and multiplying both sides by R, we get:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;V_A + V_B + V_C - 3 \\cdot V_{jct} = 0 \\textrm{ V}&quot;,&quot;id&quot;:&quot;KXUYQUVAFQ&quot;}" data-component-name="LatexBlockToDOM"></div><p>Solving for <em>V<sub>jct</sub></em>, we get (<em>V<sub>A </sub></em>+ <em>V<sub>B</sub></em> + <em>V<sub>C</sub></em>) / 3. We have a confirmation that the input-side resistor section averages the input voltages.</p><p>To be fair, the averaging portion of the circuit has a minor weakness: it depends some inputs sinking current while others source it. Some signal sources might not have that ability. That said, compared to the alternative design, it has the benefit of being more useful in single-supply circuits, so let&#8217;s stick with that.</p><p>Moving on to the op-amp section: this is just another sighting of the non-inverting amplifier. The gain of the amplifier circuit is set by the <em>R<sub>f</sub></em> and <em>R<sub>g</sub></em> resistors, and in this instance, works out to A = 1 + <em>R<sub>f</sub>/R<sub>g</sub></em> = 3. In other words, the signal on the output leg is:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;V_{out} \\approx 3 \\cdot V_{in+} \\approx { \\cancel{3} \\cdot (V_A + V_B + V_C) \\over \\cancel{3}} \\approx V_A + V_B + V_C&quot;,&quot;id&quot;:&quot;SKQNYLZTTV&quot;}" data-component-name="LatexBlockToDOM"></div><p>That looks like a sum! But it also feels like we cheated in some way: it just so happens that we could implement averaging using passive components, and then tack on an amplifier for some gain. Surely, resistor magic can&#8217;t get us much further than that?</p><h3>Subtraction</h3><p>It can! The next stop is subtraction, which can be achieved with the following circuit topology:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!QnTs!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f412f17-8062-4912-9146-8f5522be8e49_2000x1100.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!QnTs!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f412f17-8062-4912-9146-8f5522be8e49_2000x1100.jpeg 424w, https://substackcdn.com/image/fetch/$s_!QnTs!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f412f17-8062-4912-9146-8f5522be8e49_2000x1100.jpeg 848w, https://substackcdn.com/image/fetch/$s_!QnTs!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f412f17-8062-4912-9146-8f5522be8e49_2000x1100.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!QnTs!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f412f17-8062-4912-9146-8f5522be8e49_2000x1100.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!QnTs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f412f17-8062-4912-9146-8f5522be8e49_2000x1100.jpeg" width="1456" height="801" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7f412f17-8062-4912-9146-8f5522be8e49_2000x1100.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:801,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:228331,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/182245394?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f412f17-8062-4912-9146-8f5522be8e49_2000x1100.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!QnTs!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f412f17-8062-4912-9146-8f5522be8e49_2000x1100.jpeg 424w, https://substackcdn.com/image/fetch/$s_!QnTs!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f412f17-8062-4912-9146-8f5522be8e49_2000x1100.jpeg 848w, https://substackcdn.com/image/fetch/$s_!QnTs!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f412f17-8062-4912-9146-8f5522be8e49_2000x1100.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!QnTs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f412f17-8062-4912-9146-8f5522be8e49_2000x1100.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A simple difference amplifier (A - B).</em></figcaption></figure></div><p>We can start the analysis with the non-inverting input of the amplifier. The signal on this leg is generated by a voltage divider consisting of two identical resistances connected in series between V<sub>A</sub> and the ground. In other words, the voltage here is <em>V<sub>in+</sub> = &#189; &#183; V<sub>A</sub>.</em></p><p>The inverting input is a voltage divider too, except it produces a voltage that&#8217;s halfway between <em>V<sub>B</sub></em><sub> </sub>and <em>V<sub>out</sub></em>: <em>V<sub>in-</sub></em> = &#189; &#183; (<em>V</em><sub>B </sub>+ <em>V<sub>out</sub></em>). </p><p>As with any op-amp topology, linear operation can happen only when <em>V<sub>in- </sub>&#8776; V<sub>in+</sub></em>. In other words, we can assert that for the circuit to function, the following must be true:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;&#189; \\cdot V_A \\approx &#189; \\cdot (V_B + V_{out})&quot;,&quot;id&quot;:&quot;PMEIETRFMT&quot;}" data-component-name="LatexBlockToDOM"></div><p>We can cancel out the repeated &#189; term on both sides, and then reorder the equation to:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;V_{out} \\approx V_A - V_B&quot;,&quot;id&quot;:&quot;KCUDSFIITP&quot;}" data-component-name="LatexBlockToDOM"></div><p>Neat: that&#8217;s precisely what we&#8217;ve been trying to do.</p><p>To be fair, not all is roses: in a single-supply circuit, an op-amp can&#8217;t output negative voltages, so the topology we&#8217;ve just analyzed works only if <em>V<sub>A</sub> &gt; V<sub>B</sub></em>; otherwise, <em>V<sub>out </sub></em>just hits the lower rail and stays there until the input voltages change.</p><p>To accommodate use cases where <em>V<sub>A</sub> &lt; V<sub>B</sub></em>, we&#8217;d need to use a higher output voltage as the &#8220;zero&#8221; point (<em>V<sub>zero</sub></em>). For example, if <em>V<sub>zero </sub></em>= 2.5 V, then a computed difference of -1 V could be represented by <em>V<sub>out </sub></em>= <em>V<sub>zero </sub></em>- 1 V = 1.5 V; in the same vein, a difference of +2 V could correspond to <em>V<sub>out </sub></em>= 4.5 V.</p><p>To do this, we just need to disconnect the bottom voltage divider from the ground and replace 0 V with a fixed &#8220;zero&#8221; voltage of our choice. This changes the equation for the positive leg to <em>V<sub>in+</sub></em> = &#189; &#183; (<em>V</em><sub>A </sub>+ <em>V<sub>zero</sub></em>). The overall equilibrium condition becomes:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;&#189; \\cdot ( V_A + V_{zero}) \\approx &#189; \\cdot (V_B + V_{out})&quot;,&quot;id&quot;:&quot;IKTMBGEXHF&quot;}" data-component-name="LatexBlockToDOM"></div><p>After tidying up and solving for the output signal, we get:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;V_{out} \\approx V_{zero} + (V_A - V_B)&quot;,&quot;id&quot;:&quot;OLEFSFWRSF&quot;}" data-component-name="LatexBlockToDOM"></div><p>A common choice of a reference point would be the midpoint of the supply (<em>V<sub>mid</sub></em> = &#189; &#183; <em>V<sub>supply</sub></em>).</p><h3>Multiplication and division</h3><p>The concept of analog computation can be also extended to multiplication and division. The most common and mildly mind-bending approach hinges on the fact that any positive number can be rewritten as a constant base <em>n</em> raised to some power; for example, 8 can be written as 2<sup>3</sup>, while 42 is approximately 2<sup>5.3924</sup>. </p><p>From the basic properties of exponentiation, it&#8217;s easy to show that <em>n<sup>a </sup>&#183; n<sup>b </sup></em>is the same as <em>n<sup>a+b</sup></em>; it follows that if we have two numbers represented as exponents of a common base, we can reduce the problem of multiplication to the addition of these exponents.</p><p>We already know how to build a summing circuit, so all we&#8217;re missing is a way to convert a number to an exponent. We don&#8217;t really care what base we&#8217;re using, as long as the base remains constant over time.</p><p>This brings us to the following design:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!v48I!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2dfc829-5c95-4bdd-9136-13cae83e63f8_2000x682.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!v48I!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2dfc829-5c95-4bdd-9136-13cae83e63f8_2000x682.jpeg 424w, https://substackcdn.com/image/fetch/$s_!v48I!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2dfc829-5c95-4bdd-9136-13cae83e63f8_2000x682.jpeg 848w, https://substackcdn.com/image/fetch/$s_!v48I!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2dfc829-5c95-4bdd-9136-13cae83e63f8_2000x682.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!v48I!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2dfc829-5c95-4bdd-9136-13cae83e63f8_2000x682.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!v48I!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2dfc829-5c95-4bdd-9136-13cae83e63f8_2000x682.jpeg" width="1456" height="496" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b2dfc829-5c95-4bdd-9136-13cae83e63f8_2000x682.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:496,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:143958,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/182245394?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2dfc829-5c95-4bdd-9136-13cae83e63f8_2000x682.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!v48I!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2dfc829-5c95-4bdd-9136-13cae83e63f8_2000x682.jpeg 424w, https://substackcdn.com/image/fetch/$s_!v48I!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2dfc829-5c95-4bdd-9136-13cae83e63f8_2000x682.jpeg 848w, https://substackcdn.com/image/fetch/$s_!v48I!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2dfc829-5c95-4bdd-9136-13cae83e63f8_2000x682.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!v48I!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2dfc829-5c95-4bdd-9136-13cae83e63f8_2000x682.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A logarithmic amplifier.</em></figcaption></figure></div><p>As before, the linear equilibrium condition requires <em>V<sub>in-</sub> &#8776; V<sub>in+</sub>. </em>Let&#8217;s assume that the initial input voltage is about equal to <em>V<sub>zero</sub></em>; in this case, the output settles in the same vicinity.</p><p>Next, let&#8217;s analyze what would happen if the input voltage increased by <em>v<sub>s</sub></em> <em>=</em> 100 mV. In such a scenario, for the op-amp to stay at an equilibrium of <em>V<sub>in-</sub> &#8776; V<sub>in+</sub></em>, we would need a sufficient current to flow through the resistor to create a 100 mV voltage drop:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;I_R = {v_{s} \\over R}&quot;,&quot;id&quot;:&quot;MBFDXORKXN&quot;}" data-component-name="LatexBlockToDOM"></div><p>The op-amp has a very high input impedance, so the current must flow through the diode; if it doesn&#8217;t, that&#8217;d move the circuit toward a condition of <em>V</em><sub>in-</sub> &#8811; <em>V</em><sub>in+</sub>, which would cause <em>V<sub>out</sub></em> to move toward the negative supply rail. That would forward-bias the diode and thus motivate it to conduct better. In other words, the circuit has an automatic mechanism that coerces the diode to admit the current matching <em>I</em><sub>R</sub>, and the amount of convincing is reflected in how much the output voltage has been reduced from the midpoint. We can denote this relative shift as <em>v<sub>o</sub></em>.</p><p>From an <a href="https://lcamtuf.substack.com/p/things-you-can-do-with-diodes">earlier feature about diodes</a>, you might recall that although the relationship between the applied diode voltage and the resulting current is complicated, there is an initial region where the component&#8217;s V-I curve is exponential. In the following plot for a 1N4148 diode, this property holds up for currents up to about 1 mA:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1YT_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc911561-42ea-431b-b5c9-a1bdd10c2eaa_2969x1250.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1YT_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc911561-42ea-431b-b5c9-a1bdd10c2eaa_2969x1250.jpeg 424w, https://substackcdn.com/image/fetch/$s_!1YT_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc911561-42ea-431b-b5c9-a1bdd10c2eaa_2969x1250.jpeg 848w, https://substackcdn.com/image/fetch/$s_!1YT_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc911561-42ea-431b-b5c9-a1bdd10c2eaa_2969x1250.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!1YT_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc911561-42ea-431b-b5c9-a1bdd10c2eaa_2969x1250.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1YT_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc911561-42ea-431b-b5c9-a1bdd10c2eaa_2969x1250.jpeg" width="1456" height="613" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cc911561-42ea-431b-b5c9-a1bdd10c2eaa_2969x1250.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:613,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:106864,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/182245394?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc911561-42ea-431b-b5c9-a1bdd10c2eaa_2969x1250.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!1YT_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc911561-42ea-431b-b5c9-a1bdd10c2eaa_2969x1250.jpeg 424w, https://substackcdn.com/image/fetch/$s_!1YT_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc911561-42ea-431b-b5c9-a1bdd10c2eaa_2969x1250.jpeg 848w, https://substackcdn.com/image/fetch/$s_!1YT_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc911561-42ea-431b-b5c9-a1bdd10c2eaa_2969x1250.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!1YT_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc911561-42ea-431b-b5c9-a1bdd10c2eaa_2969x1250.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>V-I curve for 1N4148, normal (left) and log scale current (right). By author.</em></figcaption></figure></div><p>In other words, if the input resistor is large enough (10 k&#937; or so), we can say that <em>v<sub>o</sub></em> will be dictated by the magnitude of an exponent of some constant base <em>n</em> that yields the correct diode current<em>: I<sub>D </sub>= n<sup>v&#8338;</sup></em>.</p><p>We also know that the current that must flow through the diode is proportional to the shift in the input signal (<em>v<sub>s</sub></em>) divided by <em>R. </em>This means that we&#8217;ve accomplished the number-to-exponent conversion between <em>v<sub>s </sub></em>and <em>v<sub>o</sub></em>. Or, in the mathematical parlance, we&#8217;ve calculated a logarithm.</p><p>To implement multiplication, we need two logarithmic converters on the input side, a summing amplifier to add the exponents, and then an exponential converter that goes from the summed exponent back to a normal value. That last part can be accomplished by switching the location of the diode and the resistor in the log converter circuit we already have.</p><h3>Integration</h3><p>Integration is just a fancy word for summing values over time; if you want to sound posh, you can say that a bucket in your backyard &#8220;integrates&#8221; rainfall over the duration of a storm.</p><p>Although integration is important in calculus, analog integrators have down-to-earth uses too. For example, the circuits can convert square waves into triangular shapes that are useful in electronic musical instruments. The circuit&#8217;s ability to produce very linear up and down slopes also comes in handy in <a href="https://lcamtuf.substack.com/p/dacs-and-adcs-or-there-and-back-again">slope-based and delta-sigma ADCs</a>.</p><p>The simplest, textbook integrator is shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-t1B!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95fd2219-a871-4cf7-a1ac-0fc9a54f2912_2000x682.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-t1B!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95fd2219-a871-4cf7-a1ac-0fc9a54f2912_2000x682.jpeg 424w, https://substackcdn.com/image/fetch/$s_!-t1B!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95fd2219-a871-4cf7-a1ac-0fc9a54f2912_2000x682.jpeg 848w, https://substackcdn.com/image/fetch/$s_!-t1B!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95fd2219-a871-4cf7-a1ac-0fc9a54f2912_2000x682.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!-t1B!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95fd2219-a871-4cf7-a1ac-0fc9a54f2912_2000x682.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-t1B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95fd2219-a871-4cf7-a1ac-0fc9a54f2912_2000x682.jpeg" width="1456" height="496" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/95fd2219-a871-4cf7-a1ac-0fc9a54f2912_2000x682.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:496,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:143899,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/182245394?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95fd2219-a871-4cf7-a1ac-0fc9a54f2912_2000x682.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-t1B!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95fd2219-a871-4cf7-a1ac-0fc9a54f2912_2000x682.jpeg 424w, https://substackcdn.com/image/fetch/$s_!-t1B!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95fd2219-a871-4cf7-a1ac-0fc9a54f2912_2000x682.jpeg 848w, https://substackcdn.com/image/fetch/$s_!-t1B!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95fd2219-a871-4cf7-a1ac-0fc9a54f2912_2000x682.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!-t1B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95fd2219-a871-4cf7-a1ac-0fc9a54f2912_2000x682.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Basic integrator.</em></figcaption></figure></div><p>Once again, we can note that the linear operation condition is <em>V<sub>in- </sub>&#8776; V<sub>in+</sub>. </em>Further, let&#8217;s assume that the input signal is equal to <em>V<sub>zero </sub></em>and the capacitor is discharged, so both op-amp inputs and the output are at about the midpoint.</p><p>Next, similarly to the analysis we&#8217;ve done for the log amplifier, let&#8217;s assume that the input signal shifts up by <em>v<sub>s</sub> =</em> 100 mV. For the op-amp to stay at an equilibrium, we would need a sufficient current to flow through the resistor to create a 100 mV voltage drop: <em>I<sub>R</sub> = v<sub>s</sub>/R.</em></p><p>The only possible path for this current is the capacitor; a capacitor doesn&#8217;t admit steady currents, but it will allow the movement of charges during the charging process, which will kick off when the op-amp&#8217;s output voltage begins to drop; this drop causes a voltage differential appears across the capacitor&#8217;s terminals.</p><p>From the fundamental capacitor equation, charging the capacitor with a constant current <em>I<sub>R</sub></em> for a time <em>t </em>will produce the following voltage across its terminals:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;V_{cap} = {I_R \\cdot t \\over C} = {v_s \\cdot t \\over RC}&quot;,&quot;id&quot;:&quot;EKSFSGQJOS&quot;}" data-component-name="LatexBlockToDOM"></div><p>To keep <em>V<sub>in-</sub></em> steady, the voltage to which the capacitor gets charged must be accounted for by a directionally opposite shift of the output voltage (<em>v<sub>o</sub></em>). The shift will persist after <em>V<sub>signal </sub></em>returns to the midpoint, because with no charging or discharging current, the capacitor just retains charge. The shift can be undone if <em>v<sub>s </sub></em>swings the other way around. </p><p>From the earlier formula for the capacitor voltage, it should be clear that the circuit keeps a sum of (midpoint-relative) input voltages summed over time.</p><p>The textbook integrator we&#8217;ve been working with has an inverted output: <em>V<sub>out </sub></em>moves down whenever<em> V<sub>signal </sub></em>moves up; this makes it somewhat clunky to use in single-supply applications. The problem can be addressed in a couple of intuitive ways, but a particularly efficient &#8212; if positively cursed &#8212; solution is shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!eTfw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8d61dd-aabb-4a58-a723-420459983405_2000x1193.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!eTfw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8d61dd-aabb-4a58-a723-420459983405_2000x1193.jpeg 424w, https://substackcdn.com/image/fetch/$s_!eTfw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8d61dd-aabb-4a58-a723-420459983405_2000x1193.jpeg 848w, https://substackcdn.com/image/fetch/$s_!eTfw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8d61dd-aabb-4a58-a723-420459983405_2000x1193.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!eTfw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8d61dd-aabb-4a58-a723-420459983405_2000x1193.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!eTfw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8d61dd-aabb-4a58-a723-420459983405_2000x1193.jpeg" width="1456" height="869" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5d8d61dd-aabb-4a58-a723-420459983405_2000x1193.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:869,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:252797,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/182245394?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8d61dd-aabb-4a58-a723-420459983405_2000x1193.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!eTfw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8d61dd-aabb-4a58-a723-420459983405_2000x1193.jpeg 424w, https://substackcdn.com/image/fetch/$s_!eTfw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8d61dd-aabb-4a58-a723-420459983405_2000x1193.jpeg 848w, https://substackcdn.com/image/fetch/$s_!eTfw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8d61dd-aabb-4a58-a723-420459983405_2000x1193.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!eTfw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d8d61dd-aabb-4a58-a723-420459983405_2000x1193.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>The single-supply, non-inverting integrator.</em></figcaption></figure></div><p>As in all other cases, the prerequisite for linear operation is <em>V<sub>in-</sub></em> &#8776; <em>V<sub>in+</sub></em>. </p><p>We can start the analysis with the two-resistor divider on the top: it simply ensures that <em>V<sub>in-</sub> </em>is equal to &#189; &#183; <em>V<sub>out</sub></em>. As the bottom portion of the circuit, the instantaneous voltage on the non-inverting input is decided by the capacitor&#8217;s charge state (<em>V<sub>cap</sub></em>). The bottom resistors will influence the charge of the capacitor over time, but if we&#8217;re living in the moment, we can combine the equations and write the following equilibrium rule:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;V_{cap} \\approx &#189; \\cdot V_{out}&quot;,&quot;id&quot;:&quot;OJBCPAWXFI&quot;}" data-component-name="LatexBlockToDOM"></div><p>Equivalently, we can say that <em>V<sub>out </sub>&#8776; </em>2 &#183; <em>V<sub>cap</sub></em>.</p><p>We have established that <em>V<sub>out</sub></em> is equal to twice the value of <em>V<sub>cap</sub></em>, but if so, the resistor on the bottom right is subjected to a voltage differential between these two points (always equal to <em>V<sub>cap</sub></em>). From Ohm&#8217;s law, the resistor will admit the following current:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;I_1 = {V_{cap} \\over R}&quot;,&quot;id&quot;:&quot;EQKSTYKIAY&quot;}" data-component-name="LatexBlockToDOM"></div><p>If the input voltage is zero, the neighboring resistor to the left is subjected to the same voltage differential, so the current flowing into the junction (<em>I<sub>1</sub></em>) is the same as the current flowing out (<em>I<sub>2</sub></em>). With the currents in balance, the capacitor holds its previous charge and the output voltage doesn&#8217;t change.</p><p>That said, if the input voltage (<em>V<sub>signal</sub></em>) is non-zero, the voltage differential across the terminals of the resistor on the left is different, and the formula for <em>I<sub>2</sub></em> becomes:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;I_2 = {V_{cap} -V_{signal} \\over R}&quot;,&quot;id&quot;:&quot;XSXVIPHXDV&quot;}" data-component-name="LatexBlockToDOM"></div><p>In this case, there is a non-zero balance of the currents flowing in and out via the resistors:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;I_{net} = I_1 - I_2 = {\\cancel{V_{cap}} -\\cancel{V_{cap}} + V_{signal} \\over R} = {V_{signal} \\over R}&quot;,&quot;id&quot;:&quot;LFNBOYMYFM&quot;}" data-component-name="LatexBlockToDOM"></div><p>This current is flowing in via the resistor on the right but not flowing out via the resistor on the left, so it necessarily charges the capacitor. Note that the capacitor charging current is independent of <em>V<sub>cap</sub></em>; it remains constant as long as the input voltage is constant too.</p><p>As before, from the fundamental capacitor equation (V = I&#183;t/C), we can tell that a constant charging current will cause the voltage on the output leg to ramp up in a straight line. Of course, this will come to an end once we hit the output voltage limit of the amplifier. To reset the circuit, we&#8217;d need to short the terminals of the capacitor.</p><div><hr></div><p><em>&#128073; For further articles about electronics, <a href="https://lcamtuf.substack.com/p/electronics-curriculum">click here</a>. In particular, you might enjoy:</em></p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;5a7c2632-54b4-4c01-aaa7-f0b65b2d274e&quot;,&quot;caption&quot;:&quot;In the spring of 2023, when this Substack had only a handful of subscribers, I posted a primer on voltage adjustment in electronic circuits. The article opened with a brief discussion of linear regulators, and then promptly threw them under the bus in favor of more efficient charge pumps and inductor-based topologies.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Cursed circuits: charge pump voltage halver&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-12-02T00:00:03.420Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/$s_!dYf0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/cursed-circuits-charge-pump-voltage&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:180429933,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:24,&quot;comment_count&quot;:0,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;8bff1933-a1b8-4364-8e49-f64842b5096f&quot;,&quot;caption&quot;:&quot;In the previous post on this Substack, we looked at charge pump circuits and the mildly cursed example of a capacitor-based voltage halver. I find these topologies interesting because they are very simple, yet they subvert the usual way of thinking about what a capacitors can or cannot do.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Cursed circuits #2: switched capacitor lowpass&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-12-04T00:00:03.419Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4e0e7351-7d4f-4efd-be70-22f3ae8dc7fd_855x790.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/cursed-circuits-2-switched-capacitor&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:180619026,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:16,&quot;comment_count&quot;:1,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;a071b841-16f0-4ec2-a7c3-6d4923873048&quot;,&quot;caption&quot;:&quot;Welcome to another installment of Cursed Circuits. My goal for the series is to highlight a small collection of common yet mind-bending circuits that must&#8217;ve taken a stroke of genius to invent, but that are usually presented on the internet without explaining how or why they work.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Cursed circuits #4: PLL frequency multiplier&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-12-26T17:47:58.312Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/$s_!nqfK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ec45e92-4453-4adc-9873-ffd4ae9ed319_2813x1875.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/cursed-circuits-4-pll-frequency-multiplier&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:182613637,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:21,&quot;comment_count&quot;:1,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p><em>I write well-researched, original articles about geek culture, electronic circuit design, algorithms, and more. If you like the content, please subscribe.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item><item><title><![CDATA[Cursed circuits #2: switched capacitor lowpass]]></title><description><![CDATA[Still using resistors? Get on with the times.]]></description><link>https://lcamtuf.substack.com/p/cursed-circuits-2-switched-capacitor</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/cursed-circuits-2-switched-capacitor</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Thu, 04 Dec 2025 00:00:03 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/4e0e7351-7d4f-4efd-be70-22f3ae8dc7fd_855x790.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the <a href="https://lcamtuf.substack.com/p/cursed-circuits-charge-pump-voltage">previous post on this Substack</a>, we looked at charge pump circuits and the mildly cursed example of a capacitor-based voltage halver. I find these topologies interesting because they are very simple, yet they subvert the usual way of thinking about what a capacitors can or cannot do.</p><p>In today&#8217;s episode, let&#8217;s continue down that path and consider an even more perplexing example: a switched capacitor lowpass filter. The usual way to design an analog lowpass filter is to combine a resistor with a capacitor, as shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iz67!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F476c1f12-196e-483d-85cc-16b7ff349981_1450x750.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iz67!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F476c1f12-196e-483d-85cc-16b7ff349981_1450x750.jpeg 424w, https://substackcdn.com/image/fetch/$s_!iz67!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F476c1f12-196e-483d-85cc-16b7ff349981_1450x750.jpeg 848w, https://substackcdn.com/image/fetch/$s_!iz67!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F476c1f12-196e-483d-85cc-16b7ff349981_1450x750.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!iz67!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F476c1f12-196e-483d-85cc-16b7ff349981_1450x750.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iz67!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F476c1f12-196e-483d-85cc-16b7ff349981_1450x750.jpeg" width="1450" height="750" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/476c1f12-196e-483d-85cc-16b7ff349981_1450x750.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:750,&quot;width&quot;:1450,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:175371,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/180619026?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F476c1f12-196e-483d-85cc-16b7ff349981_1450x750.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!iz67!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F476c1f12-196e-483d-85cc-16b7ff349981_1450x750.jpeg 424w, https://substackcdn.com/image/fetch/$s_!iz67!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F476c1f12-196e-483d-85cc-16b7ff349981_1450x750.jpeg 848w, https://substackcdn.com/image/fetch/$s_!iz67!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F476c1f12-196e-483d-85cc-16b7ff349981_1450x750.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!iz67!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F476c1f12-196e-483d-85cc-16b7ff349981_1450x750.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A standard R-C lowpass filter.</em></figcaption></figure></div><p>The filter can be thought of as a voltage divider in which R is constant and C begins to conduct better as the sine-wave frequency of the input signal increases. This frequency-dependent resistor-like behavior of a capacitor is known as reactance and is described by the following formula:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;X_C = {1 \\over 2 \\pi f C}&quot;,&quot;id&quot;:&quot;FHVAQYRSBO&quot;}" data-component-name="LatexBlockToDOM"></div><p>Most sources give this equation without explaining where it comes from, but it can be derived with basic trigonometry; if you&#8217;re unfamiliar with its origins, you might enjoy <a href="https://lcamtuf.substack.com/p/primer-core-concepts-in-electronic">this foundational article</a> posted here back in 2023.</p><p>In an R-C lowpass circuit, the reactance is initially much larger than the value of R, so up to a certain frequency, the capacitor can be ignored and the input voltage is more or less equal to the output voltage. Past a certain point, however, the reactance of the capacitor becomes low enough so that the signal is markedly pulled toward the ground, attenuating it and producing a filter response plot similar to the following:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9A2j!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8301ee3d-9f01-4e4c-ae1a-413c6423d3b8_2813x1875.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9A2j!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8301ee3d-9f01-4e4c-ae1a-413c6423d3b8_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!9A2j!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8301ee3d-9f01-4e4c-ae1a-413c6423d3b8_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!9A2j!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8301ee3d-9f01-4e4c-ae1a-413c6423d3b8_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!9A2j!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8301ee3d-9f01-4e4c-ae1a-413c6423d3b8_2813x1875.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9A2j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8301ee3d-9f01-4e4c-ae1a-413c6423d3b8_2813x1875.png" width="1456" height="970" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8301ee3d-9f01-4e4c-ae1a-413c6423d3b8_2813x1875.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:970,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:68925,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/180619026?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8301ee3d-9f01-4e4c-ae1a-413c6423d3b8_2813x1875.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!9A2j!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8301ee3d-9f01-4e4c-ae1a-413c6423d3b8_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!9A2j!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8301ee3d-9f01-4e4c-ae1a-413c6423d3b8_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!9A2j!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8301ee3d-9f01-4e4c-ae1a-413c6423d3b8_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!9A2j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8301ee3d-9f01-4e4c-ae1a-413c6423d3b8_2813x1875.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>R-C lowpass filter behavior for R = 100 k&#937; and C = 10 nF.</em></figcaption></figure></div><p>It&#8217;s easy to find the frequency at which R = X<sub>C</sub>. The solution corresponds to the &#8220;knee&#8221; in the logarithmic plot shown before:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;f_{knee} = {1 \\over 2 \\pi R C}&quot;,&quot;id&quot;:&quot;WSCFZLDZCB&quot;}" data-component-name="LatexBlockToDOM"></div><p>This is basic analog electronics, and something we <a href="https://lcamtuf.substack.com/p/the-101-of-analog-signal-filtering">covered on the blog before</a>. But did you know that you can construct a perfectly good lowpass filter with a pair of capacitors and a toggle switch? The architecture is shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!f7x0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6149a4c-416c-4596-9d2b-6e1ed43309ac_2000x781.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!f7x0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6149a4c-416c-4596-9d2b-6e1ed43309ac_2000x781.jpeg 424w, https://substackcdn.com/image/fetch/$s_!f7x0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6149a4c-416c-4596-9d2b-6e1ed43309ac_2000x781.jpeg 848w, https://substackcdn.com/image/fetch/$s_!f7x0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6149a4c-416c-4596-9d2b-6e1ed43309ac_2000x781.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!f7x0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6149a4c-416c-4596-9d2b-6e1ed43309ac_2000x781.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!f7x0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6149a4c-416c-4596-9d2b-6e1ed43309ac_2000x781.jpeg" width="1456" height="569" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a6149a4c-416c-4596-9d2b-6e1ed43309ac_2000x781.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:569,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:154953,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/180619026?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6149a4c-416c-4596-9d2b-6e1ed43309ac_2000x781.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!f7x0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6149a4c-416c-4596-9d2b-6e1ed43309ac_2000x781.jpeg 424w, https://substackcdn.com/image/fetch/$s_!f7x0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6149a4c-416c-4596-9d2b-6e1ed43309ac_2000x781.jpeg 848w, https://substackcdn.com/image/fetch/$s_!f7x0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6149a4c-416c-4596-9d2b-6e1ed43309ac_2000x781.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!f7x0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6149a4c-416c-4596-9d2b-6e1ed43309ac_2000x781.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A conceptual illustration of a switched capacitor lowpass filter.</em></figcaption></figure></div><p>In practical circuits, the &#8220;switch&#8221; would be a pair of MOSFETs driven by a timing signal, but nothing stops us from using a real switch or an electromechanical relay to experiment with this topology on a breadboard.</p><p>In the first half of the timing cycle, the switch is in position A. This connects a small input capacitor, <em>C<sub>in</sub></em>, to the input terminal. As soon as the connection is made, the capacitor charges to a voltage equal to the momentary level of the input waveform, which we can denote as <em>V<sub>A</sub></em>.</p><p>In the second half of the cycle, the two-way switch is moved to position B. This causes the voltages across <em>C<sub>in</sub></em> and <em>C<sub>out </sub></em>to equalize. We don&#8217;t need to calculate the relative shifts in their terminal voltages; we&#8217;ll approach it symbolically and just say that <em>C<sub>in</sub></em> started at <em>V<sub>A</sub></em><sub> </sub>and ended up at <em>V<sub>B</sub></em>.</p><p>With this in mind, we can apply a a form of the <a href="https://lcamtuf.substack.com/p/primer-core-concepts-in-electronic">fundamental capacitor equation</a> (<em>I = C&#183;&#916;v/t</em>) to find the average current that must have flowed out of <em>C<sub>in</sub></em> to shift its voltage from <em>V<sub>A</sub></em> to <em>V<sub>B </sub></em>in time <em>t:</em></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;I_B = {(V_A - V_B) \\ \\cdot \\ C_{in} \\over t}&quot;,&quot;id&quot;:&quot;XXQLUVARLT&quot;}" data-component-name="LatexBlockToDOM"></div><p>The overall duration of the charge transfer cycle (<em>t</em>)<em> </em>is the reciprocal of the switch-toggling frequency <em>f<sub>s</sub></em>, so we can also restate this as <em>I<sub>B</sub> = (V<sub>A</sub> - V<sub>B</sub>) &#183; C<sub>in</sub> &#183; f<sub>s</sub></em>. </p><p>The formulas tell us that the average current is proportional to to the voltage present across the A and B terminals of the switch, multiplied by a constant proportional to the switching frequency and the capacitor value. The actual current is pulsed, but it depends on a voltage differential in a manner similar to the behavior of a series resistor (<em>I = V/R</em>). In fact, from Ohm&#8217;s law, we can find the equivalent input resistance that would deliver the same current to <em>C<sub>out</sub></em>:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;R_{in} =  {V_{switch} \\over I_{switch}} = {V_A - V_B \\over I_B} = {1 \\over C_{in} \\cdot f_s}&quot;,&quot;id&quot;:&quot;EYVGUEGLMF&quot;}" data-component-name="LatexBlockToDOM"></div><p>If the circuit can be modeled as a series resistor feeding a shunt capacitor, we&#8217;re essentially looking at a bog-standard lowpass R-C architecture. The knee frequency of this R-C filter can be written as:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;f_{knee} = {1 \\over {2 \\pi \\cdot R_{in} \\cdot C_{out}}} = {C_{in} \\over { C_{out} }} \\, \\cdot \\, {f_s \\over { 2 \\pi }}&quot;,&quot;id&quot;:&quot;PHHHDFOVDD&quot;}" data-component-name="LatexBlockToDOM"></div><p>The math might seem improbable, but the circuit works in practice. The following oscilloscope traces show a filter constructed with <em>C<sub>in</sub> = 100 </em>nF and<em> C<sub>out</sub> = 1 </em>&#181;F<em>, </em>toggled at <em>f<sub>s </sub></em>= 50 Hz. This corresponds to <em>f<sub>knee </sub></em>&#8776; 0.8 Hz &#8212; and indeed, we see some attenuation for a 1 Hz input sine, and a lot more for a 5 Hz one:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sh8a!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98716a2e-f716-4c71-a9ec-74040c8f505f_2813x1875.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sh8a!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98716a2e-f716-4c71-a9ec-74040c8f505f_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!sh8a!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98716a2e-f716-4c71-a9ec-74040c8f505f_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!sh8a!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98716a2e-f716-4c71-a9ec-74040c8f505f_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!sh8a!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98716a2e-f716-4c71-a9ec-74040c8f505f_2813x1875.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sh8a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98716a2e-f716-4c71-a9ec-74040c8f505f_2813x1875.png" width="1456" height="970" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/98716a2e-f716-4c71-a9ec-74040c8f505f_2813x1875.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:970,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:141756,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/180619026?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98716a2e-f716-4c71-a9ec-74040c8f505f_2813x1875.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sh8a!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98716a2e-f716-4c71-a9ec-74040c8f505f_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!sh8a!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98716a2e-f716-4c71-a9ec-74040c8f505f_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!sh8a!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98716a2e-f716-4c71-a9ec-74040c8f505f_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!sh8a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98716a2e-f716-4c71-a9ec-74040c8f505f_2813x1875.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A switched capacitor lowpass filter, showing variable attenuation.</em></figcaption></figure></div><p>The plot also offers an intuitive interpretation of the math: in each clock cycle, only a certain amount of charge can move between the capacitors; this corresponds to the maximum height of a single step in the output waveform, proportional to the relative sizing of the caps (i.e., the ratio of <em>C<sub>in</sub> </em>to <em>C<sub>out</sub></em>). The larger the vertical step, the easier it is for the output waveform to track a fast-moving input signal.</p><p>The switching frequency <em>f<sub>s </sub></em>controls how many charge transfers occur per second, which gives us another method of controlling the filter&#8217;s center frequency: to shift it, we can simply speed up or slow down the supplied clock. That&#8217;s a major boon for digitally-controlled analog signal processing.</p><p>In practice, to minimize the stairstep pattern, we tend choose the switching frequency <em>f<sub>s </sub></em>to be about two orders of magnitude higher than the filter&#8217;s intended center frequency. To achieve this, from the earlier <em>f<sub>knee  </sub></em>formula, we need to aim for <em>C<sub>out </sub></em>&#8776; 16 &#183; <em>C<sub>in</sub></em>.</p><h1 style="text-align: center;"><strong>&#128214;</strong></h1><p style="text-align: center;">If you liked the article, you&#8217;ll enjoy <em><a href="https://lcamtuf.coredump.cx/electronics/">The Secret Life of Circuits</a></em>. It&#8217;s a richly illustrated, lucid introduction to electronics &#8212; from the physics of conduction to embedded system programming. It features 290+ color diagrams, 420+ pages of original content, and zero AI.</p><div><hr></div><p><em>&#128073; For further articles about electronics, <a href="https://lcamtuf.substack.com/p/electronics-curriculum">click here</a>. In particular, you might enjoy:</em></p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;eb35418a-58ca-4335-bd2c-5d286d5dfad0&quot;,&quot;caption&quot;:&quot;In the spring of 2023, when this Substack had only a handful of subscribers, I posted a primer on voltage adjustment in electronic circuits. The article opened with a brief discussion of linear regulators, and then promptly threw them under the bus in favor of more efficient charge pumps and inductor-based topologies.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Cursed circuits: charge pump voltage halver&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-12-02T00:00:03.420Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/$s_!dYf0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/cursed-circuits-charge-pump-voltage&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:180429933,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:24,&quot;comment_count&quot;:0,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;4a6e81f3-cd9f-4331-b2af-d46dbc4efe74&quot;,&quot;caption&quot;:&quot;In the previous installments of Cursed Circuits, we looked at two switched capacitor circuits: the voltage halver and the capacitor lowpass filter.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Cursed circuits #3: true mathematics&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-12-22T02:38:09.425Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a8dee63b-328f-463b-87d2-20659ab0b41e_1280x720.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/cursed-circuits-3-true-mathematics&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:182245394,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:20,&quot;comment_count&quot;:15,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;acbfed7a-8291-4bf3-887b-276c29278380&quot;,&quot;caption&quot;:&quot;Welcome to another installment of Cursed Circuits. My goal for the series is to highlight a small collection of common yet mind-bending circuits that must&#8217;ve taken a stroke of genius to invent, but that are usually presented on the internet without explaining how or why they work.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Cursed circuits #4: PLL frequency multiplier&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-12-26T17:47:58.312Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/$s_!nqfK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ec45e92-4453-4adc-9873-ffd4ae9ed319_2813x1875.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/cursed-circuits-4-pll-frequency-multiplier&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:182613637,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:21,&quot;comment_count&quot;:1,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p><em>I write well-researched, original articles about geek culture, electronic circuit design, algorithms, and more. If you like the content, please subscribe.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item><item><title><![CDATA[Cursed circuits: charge pump voltage halver]]></title><description><![CDATA[There's plenty of circuits that are hard to understand because they're complicated. And some that are hard to make sense of because they seem too simple.]]></description><link>https://lcamtuf.substack.com/p/cursed-circuits-charge-pump-voltage</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/cursed-circuits-charge-pump-voltage</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Tue, 02 Dec 2025 00:00:03 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!dYf0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the spring of 2023, when this Substack had only a handful of subscribers, I posted a primer on <a href="https://lcamtuf.substack.com/p/the-magic-of-dc-dc-voltage-conversion">voltage adjustment in electronic circuits</a>. The article opened with a brief discussion of linear regulators, and then promptly threw them under the bus in favor of more efficient charge pumps and inductor-based topologies.</p><p>The basic charge pump architecture &#8212; a voltage doubler &#8212; is quite elegant and easy to understand. It&#8217;s also far more common than many people suspect: the circuit can be constructed directly on a silicon die, so it shows up inside quite a few digital chips, from modern op-amps to MCUs. If you weren&#8217;t a subscriber back in 2023, or if you don&#8217;t have a photographic memory for random blog articles, a conceptual diagram of the pump is shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!VjWb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6e0977d-78b6-4aac-a6cc-3c03a3e9bd8f_2000x850.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VjWb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6e0977d-78b6-4aac-a6cc-3c03a3e9bd8f_2000x850.jpeg 424w, https://substackcdn.com/image/fetch/$s_!VjWb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6e0977d-78b6-4aac-a6cc-3c03a3e9bd8f_2000x850.jpeg 848w, https://substackcdn.com/image/fetch/$s_!VjWb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6e0977d-78b6-4aac-a6cc-3c03a3e9bd8f_2000x850.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!VjWb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6e0977d-78b6-4aac-a6cc-3c03a3e9bd8f_2000x850.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!VjWb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6e0977d-78b6-4aac-a6cc-3c03a3e9bd8f_2000x850.jpeg" width="1456" height="619" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c6e0977d-78b6-4aac-a6cc-3c03a3e9bd8f_2000x850.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:619,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:201335,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/180429933?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6e0977d-78b6-4aac-a6cc-3c03a3e9bd8f_2000x850.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!VjWb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6e0977d-78b6-4aac-a6cc-3c03a3e9bd8f_2000x850.jpeg 424w, https://substackcdn.com/image/fetch/$s_!VjWb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6e0977d-78b6-4aac-a6cc-3c03a3e9bd8f_2000x850.jpeg 848w, https://substackcdn.com/image/fetch/$s_!VjWb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6e0977d-78b6-4aac-a6cc-3c03a3e9bd8f_2000x850.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!VjWb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6e0977d-78b6-4aac-a6cc-3c03a3e9bd8f_2000x850.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>The operation of a rudimentary charge pump.</em></figcaption></figure></div><p>In the panel on the left, we see a <em>Cout</em> capacitor that&#8217;s perched on top of the positive rail while a &#8220;flying&#8221; capacitance <em>Cf</em> is charging from the power supply. The charging process produces a voltage that&#8217;s internal to the component: we can unplug <em>Cf</em>, put it in our pocket, and then hook it up to another circuit to power it for a brief while.</p><p>In the second panel (right), we see the second part of the cycle: <em>Cf</em> is disconnected from the supply and then hooked up to the terminals of <em>Cout</em>. This action transfers some of the charge from <em>Cf</em> to <em>Cout,</em> up until the voltages across the terminals of the capacitors are equalized. After several of these<em> </em>roundtrips, <em>V<sub>AB</sub></em> should approach <em>Vsupply</em>. Of course, <em>V<sub>BC</sub></em> is also equal to <em>Vsupply</em>; it follows that the voltage between A and C must be the sum of the two, or<sub> </sub>2 &#183; <em>Vsupply</em>.</p><p>In other words, the circuit is a voltage doubler; the repeated motion of <em>Cf</em> ensures that the charge in <em>Cout</em> is continually replenished if we connect any load between the points A and C. There will be a bit of voltage ripple, but the amount can be controlled by sizing the capacitors and choosing the operating frequency to match the intended load.</p><p>Naturally, practical charge pumps don&#8217;t mechanically move a capacitor around. Instead, they use transistors configured as switches to alternately connect <em>Cf</em> to to the supply and to the output cap, an architecture that can be sketched the following way:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0YGi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5db94a5f-4269-451f-b84c-d88157a25d7a_2000x813.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0YGi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5db94a5f-4269-451f-b84c-d88157a25d7a_2000x813.jpeg 424w, https://substackcdn.com/image/fetch/$s_!0YGi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5db94a5f-4269-451f-b84c-d88157a25d7a_2000x813.jpeg 848w, https://substackcdn.com/image/fetch/$s_!0YGi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5db94a5f-4269-451f-b84c-d88157a25d7a_2000x813.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!0YGi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5db94a5f-4269-451f-b84c-d88157a25d7a_2000x813.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0YGi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5db94a5f-4269-451f-b84c-d88157a25d7a_2000x813.jpeg" width="1456" height="592" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5db94a5f-4269-451f-b84c-d88157a25d7a_2000x813.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:592,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:187931,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/180429933?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5db94a5f-4269-451f-b84c-d88157a25d7a_2000x813.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!0YGi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5db94a5f-4269-451f-b84c-d88157a25d7a_2000x813.jpeg 424w, https://substackcdn.com/image/fetch/$s_!0YGi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5db94a5f-4269-451f-b84c-d88157a25d7a_2000x813.jpeg 848w, https://substackcdn.com/image/fetch/$s_!0YGi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5db94a5f-4269-451f-b84c-d88157a25d7a_2000x813.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!0YGi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5db94a5f-4269-451f-b84c-d88157a25d7a_2000x813.jpeg 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A more practical outline of a charge pump voltage doubler.</em></figcaption></figure></div><p>The transistors themselves can be driven by a simple <a href="https://lcamtuf.substack.com/p/its-hard-to-build-an-oscillator">relaxation oscillator</a> or by a programmable digital chip.</p><p>A similar circuit can be used to produce negative voltages: we do this simply by dangling <em>Cout</em> from the negative supply rail instead of perching it on top of the positive one. This modification effectively places the capacitor&#8217;s bottom terminal at <em>-Vsupply.</em></p><p>So far, so good. But this brings us to a more perplexing flavor of the charge pump &#8212; the voltage-halving topology shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dYf0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dYf0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg 424w, https://substackcdn.com/image/fetch/$s_!dYf0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg 848w, https://substackcdn.com/image/fetch/$s_!dYf0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!dYf0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dYf0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg" width="1456" height="756" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:756,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:239310,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/180429933?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!dYf0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg 424w, https://substackcdn.com/image/fetch/$s_!dYf0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg 848w, https://substackcdn.com/image/fetch/$s_!dYf0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!dYf0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A mildly cursed &#8220;voltage halver&#8221;.</em></figcaption></figure></div><p>What&#8217;s that, you might ask &#8212; a capacitor-based voltage divider? Well, yes and no. Capacitors <em>can</em> be used as voltage dividers for AC signals: they exhibit a <a href="https://lcamtuf.substack.com/p/primer-core-concepts-in-electronic">resistance-like effect known as reactance</a>, so if you have an alternating sinusoidal waveform, you can attenuate it that way. That said, the divider doesn&#8217;t really work for DC voltages, because at 0 Hz, the reactance approaches infinity.</p><p>To grasp the design, ignore <em>Cf</em> and the attached load. Let&#8217;s focus just on the pair of series capacitors: <em>C1</em> and <em>C2</em>. When these two capacitors are first connected to the power supply, they can be analyzed as a single composite capacitance, with some common charging current that will briefly flow through this circuit branch. In particular, if <em>C1 = C2</em>, the common current will produce roughly the same charge state for each capacitor, resulting in <em>V<sub>AB</sub> &#8776; V<sub>BC</sub> &#8776; Vsupply / 2.</em></p><p>This sounds like the outcome we&#8217;re after, but once the common charging current ceases, there&#8217;s nothing to keep the voltages the same.  In particular, if we connect a resistive load across terminals B and C, the bottom capacitor will discharge to 0 V; the reduction in the voltage at point B will also allow the upper capacitor to charge in a way that makes up the difference. A momentary current will flow, but the end state is <em>V<sub>AB</sub></em> = <em>Vsupply</em>, <em>V<sub>BC</sub></em> = 0 V, and <em>Iout</em> = 0 A.</p><p>This sounds useless, but that&#8217;s where the flying capacitor &#8212; <em>Cf</em> &#8212; comes into play. If it&#8217;s moved back and forth between <em>C1</em> and <em>C2</em>, it will charge from the capacitor that sits at a higher voltage and then discharge into the one that&#8217;s at a lower voltage; in our example, it will continually replenish the charge in <em>C2</em>, allowing a steady current to flow through the load.</p><p>The stable equilibrium for this charge transfer process is reached when <em>V<sub>AB</sub></em> &#8776; <em>V<sub>BC</sub></em> &#8776; <em>Vsupply</em> / 2 &#8212; so in contrast to conventional voltage dividers, the output voltage is always at the midpoint between the supply rails, with no dependency on the relative values of <em>C1</em> and <em>C2</em>. Pretty neat!</p><div><hr></div><p><em>&#128073; For further articles about electronics, <a href="https://lcamtuf.substack.com/p/electronics-curriculum">click here</a>. In particular, you might enjoy:</em></p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;691c2310-dc17-43aa-b32d-9ea62fd07fdc&quot;,&quot;caption&quot;:&quot;In the previous post on this Substack, we looked at charge pump circuits and the mildly cursed example of a capacitor-based voltage halver. I find these topologies interesting because they are very simple, yet they subvert the usual way of thinking about what a capacitors can or cannot do.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Cursed circuits #2: switched capacitor lowpass&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-12-04T00:00:03.419Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4e0e7351-7d4f-4efd-be70-22f3ae8dc7fd_855x790.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/cursed-circuits-2-switched-capacitor&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:180619026,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:16,&quot;comment_count&quot;:1,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;5881c49c-38a6-407c-8c73-657289a229cc&quot;,&quot;caption&quot;:&quot;In the previous installments of Cursed Circuits, we looked at two switched capacitor circuits: the voltage halver and the capacitor lowpass filter.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Cursed circuits #3: true mathematics&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-12-22T02:38:09.425Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a8dee63b-328f-463b-87d2-20659ab0b41e_1280x720.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/cursed-circuits-3-true-mathematics&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:182245394,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:20,&quot;comment_count&quot;:15,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;b1485e60-30ce-4ae4-b95e-498d778fd6bb&quot;,&quot;caption&quot;:&quot;Welcome to another installment of Cursed Circuits. My goal for the series is to highlight a small collection of common yet mind-bending circuits that must&#8217;ve taken a stroke of genius to invent, but that are usually presented on the internet without explaining how or why they work.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Cursed circuits #4: PLL frequency multiplier&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-12-26T17:47:58.312Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/$s_!nqfK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ec45e92-4453-4adc-9873-ffd4ae9ed319_2813x1875.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/cursed-circuits-4-pll-frequency-multiplier&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:182613637,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:21,&quot;comment_count&quot;:1,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p><em>I write well-researched, original articles about geek culture, electronic circuit design, algorithms, and more. If you like the content, please subscribe.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item><item><title><![CDATA[It's hard to build an oscillator]]></title><description><![CDATA[Especially if you want it to work.]]></description><link>https://lcamtuf.substack.com/p/its-hard-to-build-an-oscillator</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/its-hard-to-build-an-oscillator</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Fri, 21 Nov 2025 01:21:27 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/d45de4a0-859e-48d5-aa6b-4cb46ac07da2_800x450.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>There&#8217;s an old electronics joke that if you want to build an oscillator, you should try building an amplifier. One of the fundamental criteria for oscillation is the presence of signal gain; without it, any oscillation is bound to decay, just like a swing that&#8217;s no longer being pushed must eventually come to a stop.</p><p>In reality, circuits with gain can occasionally oscillate by accident, but it&#8217;s rather difficult to build a good analog oscillator from scratch. The most common category of oscillators you can find on the internet are circuits that don&#8217;t work reliably. This is followed by approaches that require exotic components, such as center-tapped inductors or incandescent lightbulbs. The final group are the layouts you can copy, but probably won&#8217;t be able to explain to a friend who doesn&#8217;t have an EE degree.</p><p>In today&#8217;s article, I wanted to approach the problem in a different way. I&#8217;ll assume that you&#8217;re up-to-date on some of the key lessons from earlier articles: that you <a href="https://lcamtuf.substack.com/p/primer-core-concepts-in-electronic">can tell the difference between voltage and current</a>, have a <a href="https://lcamtuf.substack.com/p/how-do-transistors-work-anyway">basic grasp of transistors</a>, and know what happens when a <a href="https://lcamtuf.substack.com/p/the-101-of-analog-signal-filtering">capacitor is charged through a resistor</a>. With this in mind, let&#8217;s try to construct an oscillator that&#8217;s easy to understand, runs well, and has a predictable operating frequency. Further, let&#8217;s do it without peeking at someone else&#8217;s homework.</p><h3>Swing&#8230; and miss</h3><p>The simplest form of an oscillator is a device that uses negative feedback to cycle back and forth between two unstable states. To illustrate, think of a machine equipped with a light sensor and a robotic arm. In the dark, the machine is compelled to stroll over to the wall switch and flip it on. If it detects light, another part of its programming takes over and toggles the switch off. The machine is doomed to an endless cycle of switch-flipping at a frequency dictated by how quickly it can process information and react.</p><p>At first blush, we should be able to replicate this operating principle with a single n-channel MOSFET. After all, a transistor can be used as an electronically-operated switch:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!DQA9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2af6d34-c814-485d-810b-326783e8748a_2000x1000.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!DQA9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2af6d34-c814-485d-810b-326783e8748a_2000x1000.jpeg 424w, https://substackcdn.com/image/fetch/$s_!DQA9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2af6d34-c814-485d-810b-326783e8748a_2000x1000.jpeg 848w, https://substackcdn.com/image/fetch/$s_!DQA9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2af6d34-c814-485d-810b-326783e8748a_2000x1000.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!DQA9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2af6d34-c814-485d-810b-326783e8748a_2000x1000.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!DQA9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2af6d34-c814-485d-810b-326783e8748a_2000x1000.jpeg" width="1456" height="728" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b2af6d34-c814-485d-810b-326783e8748a_2000x1000.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:728,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:699444,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/179419876?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2af6d34-c814-485d-810b-326783e8748a_2000x1000.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!DQA9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2af6d34-c814-485d-810b-326783e8748a_2000x1000.jpeg 424w, https://substackcdn.com/image/fetch/$s_!DQA9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2af6d34-c814-485d-810b-326783e8748a_2000x1000.jpeg 848w, https://substackcdn.com/image/fetch/$s_!DQA9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2af6d34-c814-485d-810b-326783e8748a_2000x1000.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!DQA9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2af6d34-c814-485d-810b-326783e8748a_2000x1000.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A wannabe oscillator.</em></figcaption></figure></div><p>The transistor turns on when the voltage between its gate terminal and the source leg (<em>Vgs</em>) exceeds a certain threshold, usually around 2 V. When the power supply first ramps up, the transistor is not conducting. With no current flowing through, there&#8217;s no voltage drop across the resistor, so <em>Vgs</em> is pulled toward the positive supply rail. Once this voltage crosses about 2 V, the transistor begins to admit current. It stands to reason that the process shorts the bottom terminal of the resistor to the ground and causes <em>Vgs </em>will plunge to 0 V. If so, that would restart the cycle and produce a square wave on the output leg.</p><p>In practice, this is not the behavior you&#8217;ll see. For a MOSFET, the relationship between <em>Vgs</em> and the admitted current (<em>Id</em>) is steep, but the device is not a binary switch:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qmcl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8ca161-e0c8-44a4-99ac-3be2fbfd8c06_2344x1563.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qmcl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8ca161-e0c8-44a4-99ac-3be2fbfd8c06_2344x1563.png 424w, https://substackcdn.com/image/fetch/$s_!qmcl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8ca161-e0c8-44a4-99ac-3be2fbfd8c06_2344x1563.png 848w, https://substackcdn.com/image/fetch/$s_!qmcl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8ca161-e0c8-44a4-99ac-3be2fbfd8c06_2344x1563.png 1272w, https://substackcdn.com/image/fetch/$s_!qmcl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8ca161-e0c8-44a4-99ac-3be2fbfd8c06_2344x1563.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qmcl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8ca161-e0c8-44a4-99ac-3be2fbfd8c06_2344x1563.png" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3b8ca161-e0c8-44a4-99ac-3be2fbfd8c06_2344x1563.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:71986,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/179419876?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8ca161-e0c8-44a4-99ac-3be2fbfd8c06_2344x1563.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qmcl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8ca161-e0c8-44a4-99ac-3be2fbfd8c06_2344x1563.png 424w, https://substackcdn.com/image/fetch/$s_!qmcl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8ca161-e0c8-44a4-99ac-3be2fbfd8c06_2344x1563.png 848w, https://substackcdn.com/image/fetch/$s_!qmcl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8ca161-e0c8-44a4-99ac-3be2fbfd8c06_2344x1563.png 1272w, https://substackcdn.com/image/fetch/$s_!qmcl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8ca161-e0c8-44a4-99ac-3be2fbfd8c06_2344x1563.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>BS170 Vgs-Id curve for Vds = 1 V. Captured by author.</em></figcaption></figure></div><p>In particular, there is a certain point on that curve, somewhere in the vicinity of 2 V, that corresponds to the transistor only admitting a current of about 300 &#181;A. From Ohm&#8217;s law, this current flowing through a 10 k&#937; resistor will produce a voltage drop of 3 V. In a 5 V circuit, this puts <em>Vgs</em> at 5 V - 3 V = 2 V. In other words, there exists a stable equilibrium that prevents oscillation. It&#8217;s akin to our robot-operated light switch being half-on.</p><h3>Trigger warning</h3><p>To fix this issue, we need to build an electronic switch that has no stable midpoint. This is known as <em>Schmitt trigger</em> and its simple implementation is shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ovGn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93356957-2e59-4401-8044-95c2524dc151_2000x1450.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ovGn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93356957-2e59-4401-8044-95c2524dc151_2000x1450.jpeg 424w, https://substackcdn.com/image/fetch/$s_!ovGn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93356957-2e59-4401-8044-95c2524dc151_2000x1450.jpeg 848w, https://substackcdn.com/image/fetch/$s_!ovGn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93356957-2e59-4401-8044-95c2524dc151_2000x1450.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!ovGn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93356957-2e59-4401-8044-95c2524dc151_2000x1450.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ovGn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93356957-2e59-4401-8044-95c2524dc151_2000x1450.jpeg" width="1456" height="1056" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/93356957-2e59-4401-8044-95c2524dc151_2000x1450.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1056,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:356830,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/179419876?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93356957-2e59-4401-8044-95c2524dc151_2000x1450.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ovGn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93356957-2e59-4401-8044-95c2524dc151_2000x1450.jpeg 424w, https://substackcdn.com/image/fetch/$s_!ovGn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93356957-2e59-4401-8044-95c2524dc151_2000x1450.jpeg 848w, https://substackcdn.com/image/fetch/$s_!ovGn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93356957-2e59-4401-8044-95c2524dc151_2000x1450.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!ovGn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93356957-2e59-4401-8044-95c2524dc151_2000x1450.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A discrete-transistor Schmitt trigger.</em></figcaption></figure></div><p>To analyze the design, let&#8217;s assume the circuit is running off <em>Vsupply = 5 </em>V. If the input signal supplied on the gate of the left transistor is 0 V, this transistor will not be not conducting, which pulls <em>Vgs</em> for the other MOSFET all the way to 5 V. That input allows nearly arbitrary currents to flow through the right branch of the circuit, making that current path more or less equivalent to a two-resistor a voltage divider. We can calculate the midpoint voltage of the divider, as marked with an arrow on the schematic:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;V_{S\\textrm{ (input low)}} \\approx V_{supply} \\cdot { R_{comm} \\over { R_{comm} + R2} } \\approx 450 \\textrm{ mV}&quot;,&quot;id&quot;:&quot;GXGHOEWPLC&quot;}" data-component-name="LatexBlockToDOM"></div><p>This voltage also appears on the source terminal of the input transistor on the left. The actual <em>Vth</em> for the <a href="https://www.onsemi.com/download/data-sheet/pdf/mmbf170-d.pdf">BS170</a> transistors in my possession is about 2.15 V, so in this scenario, for the input-side transistor to turn on, the supplied signal will need to exceed <em>Vs + Vth &#8776;</em> 2.6 V. Once that happens, a large voltage drop will appear across R1, reducing the <em>Vgs</em> of the output-side transistor below the threshold of conduction, and choking off the current in the right branch.</p><p>At this point, there&#8217;s still current flowing through the common resistor on the bottom, but it&#8217;s increasingly sourced via the left branch. The left branch forms a new voltage divider; because R1<sub> </sub>has a higher resistance than R2, <em>Vs</em> is gradually reduced, effectively bumping up the gate-to-source differential<em> </em>for the left transistor and thus knocking it more firmly into conduction even if the input voltage remains constant. This is a positive feedback that gives the circuit no option to linger in a half-on state. </p><p>Once the transition is complete, the voltage drop across the bottom resistor is down from 450 mV to about 50 mV. This means that although the left transistor first turned on when the input signal crossed 2.6 V in reference to the ground, it will not turn off until the voltage drops all the way to 2.2 V &#8212; a 400 mV gap.</p><h3>Triumph of the switch-flipping bot</h3><p>This circuit lets us build what&#8217;s known as a <em>relaxation oscillator</em>. To do so, we only need to make two small tweaks. First, we need to loop an inverted output signal back onto the input; the most intuitive way of doing this is to add another transistor in a switch-like configuration similar to the failed design of a single-transistor oscillator mentioned earlier on. This building block, marked on the left, outputs <em>Vsupply</em> when the signal routed to the gate terminal is 0 V, and produces roughly 0 V when the input is near <em>Vsupply</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!V78O!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F680bce61-8b33-4afd-8a9c-e8c2147a788a_2000x1103.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!V78O!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F680bce61-8b33-4afd-8a9c-e8c2147a788a_2000x1103.jpeg 424w, https://substackcdn.com/image/fetch/$s_!V78O!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F680bce61-8b33-4afd-8a9c-e8c2147a788a_2000x1103.jpeg 848w, https://substackcdn.com/image/fetch/$s_!V78O!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F680bce61-8b33-4afd-8a9c-e8c2147a788a_2000x1103.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!V78O!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F680bce61-8b33-4afd-8a9c-e8c2147a788a_2000x1103.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!V78O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F680bce61-8b33-4afd-8a9c-e8c2147a788a_2000x1103.jpeg" width="1456" height="803" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/680bce61-8b33-4afd-8a9c-e8c2147a788a_2000x1103.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:803,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:317973,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/179419876?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F680bce61-8b33-4afd-8a9c-e8c2147a788a_2000x1103.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!V78O!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F680bce61-8b33-4afd-8a9c-e8c2147a788a_2000x1103.jpeg 424w, https://substackcdn.com/image/fetch/$s_!V78O!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F680bce61-8b33-4afd-8a9c-e8c2147a788a_2000x1103.jpeg 848w, https://substackcdn.com/image/fetch/$s_!V78O!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F680bce61-8b33-4afd-8a9c-e8c2147a788a_2000x1103.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!V78O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F680bce61-8b33-4afd-8a9c-e8c2147a788a_2000x1103.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A Schmitt trigger oscillator.</em></figcaption></figure></div><p>Next, to set a sensible oscillation speed, we need to add a time delay, which can be accomplished by charging a capacitor through a resistor (middle section). The resistor needs to be large enough not to overload the inverter stage.</p><p>For the component values shown in the schematic, the circuit should oscillate at a frequency of almost exactly 3 kHz when supplied with 5 V:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!VY3r!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fade8f556-7691-446d-b6f5-9d45acc2e737_2813x1875.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VY3r!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fade8f556-7691-446d-b6f5-9d45acc2e737_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!VY3r!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fade8f556-7691-446d-b6f5-9d45acc2e737_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!VY3r!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fade8f556-7691-446d-b6f5-9d45acc2e737_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!VY3r!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fade8f556-7691-446d-b6f5-9d45acc2e737_2813x1875.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!VY3r!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fade8f556-7691-446d-b6f5-9d45acc2e737_2813x1875.png" width="1456" height="970" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ade8f556-7691-446d-b6f5-9d45acc2e737_2813x1875.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:970,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:103611,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/179419876?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fade8f556-7691-446d-b6f5-9d45acc2e737_2813x1875.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!VY3r!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fade8f556-7691-446d-b6f5-9d45acc2e737_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!VY3r!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fade8f556-7691-446d-b6f5-9d45acc2e737_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!VY3r!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fade8f556-7691-446d-b6f5-9d45acc2e737_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!VY3r!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fade8f556-7691-446d-b6f5-9d45acc2e737_2813x1875.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>An oscilloscope trace for the circuit, by author.</em></figcaption></figure></div><p>The frequency is governed by how long it takes for the capacitor to move <em>&#916;v = </em>400 mV between the two Schmitt thresholds voltages:<em> </em>the &#8220;off&#8221; point at 2.2 V and the &#8220;on&#8221; point at 2.6 V.</p><p>Because the overall variation in capacitor voltage is small, the we can squint our eyes and say that the voltage across the 100 k&#937; resistor is nearly constant in every charge cycle. When the resistor is connected to the positive rail, <em>V<sub>R</sub></em> &#8776; 5 V &#8211; 2.4 V &#8776; 2.6 V. Conversely, when the resistor is connected to the ground, we get <em>V<sub>R</sub></em>  &#8776; 2.4 V. If the voltages across the resistor are nearly constant, so are the resulting capacitor currents:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{c}\nI_{C \\textrm{ (charging)}} \\approx {2.6 \\textrm{ V} \\over 100 \\textrm{ k&#937;}} \\approx 26 \\textrm{ &#181;A} \\\\\nI_{C \\textrm{ (discharging)}} \\approx {2.4 \\textrm{ V} \\over 100 \\textrm{ k&#937;}} \\approx 24 \\textrm{ &#181;A}\n\n\\end{array}\n\n&quot;,&quot;id&quot;:&quot;EBZQQUALIT&quot;}" data-component-name="LatexBlockToDOM"></div><p>From the <a href="https://lcamtuf.substack.com/p/primer-core-concepts-in-electronic">fundamental capacitor equation</a> (<em>&#916;v = I &#183; t/C</em>), we can solve for the charging time needed to move the voltage by <em>&#916;v</em> = 400 mV; the result is about 154 &#181;s for the charging period and 167 &#181;s for the discharging period. The sum is 321 &#181;s, corresponding to a frequency of about 3.1 kHz &#8211; pretty close to real life.</p><h3>Three transistors? I&#8217;m not made out of money!</h3><p>The circuit can be simplified to two transistors at the expense of readability, but if you need an analog oscillator with a lower component count, an <a href="https://lcamtuf.substack.com/p/the-basics-of-signal-amplification">operational amplifier</a> is your best bet.</p><p>If you&#8217;re rusty on op-amps, I suggest pausing to review the article linked in the preceding paragraph. That said, to understand the next circuit, all you need to know is that an op-amp compares two input voltages and that <em>Vout</em> swings toward the positive rail if <em>Vin+ </em>&#8811;<em> Vin-</em> or toward the negative rail if <em>Vin+ </em>&#8810;<em> Vin-</em>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wgXY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09212a80-6559-465c-a33a-f5970c707800_2000x1450.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wgXY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09212a80-6559-465c-a33a-f5970c707800_2000x1450.jpeg 424w, https://substackcdn.com/image/fetch/$s_!wgXY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09212a80-6559-465c-a33a-f5970c707800_2000x1450.jpeg 848w, https://substackcdn.com/image/fetch/$s_!wgXY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09212a80-6559-465c-a33a-f5970c707800_2000x1450.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!wgXY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09212a80-6559-465c-a33a-f5970c707800_2000x1450.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wgXY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09212a80-6559-465c-a33a-f5970c707800_2000x1450.jpeg" width="1456" height="1056" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/09212a80-6559-465c-a33a-f5970c707800_2000x1450.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1056,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:282920,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/179419876?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09212a80-6559-465c-a33a-f5970c707800_2000x1450.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wgXY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09212a80-6559-465c-a33a-f5970c707800_2000x1450.jpeg 424w, https://substackcdn.com/image/fetch/$s_!wgXY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09212a80-6559-465c-a33a-f5970c707800_2000x1450.jpeg 848w, https://substackcdn.com/image/fetch/$s_!wgXY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09212a80-6559-465c-a33a-f5970c707800_2000x1450.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!wgXY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09212a80-6559-465c-a33a-f5970c707800_2000x1450.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>An op-amp relaxation oscillator.</em></figcaption></figure></div><p>For simplicity, let&#8217;s choose R1 = R2 = R3 and then look at the non-inverting (<em>Vin+</em>) input of the chip. What we have here is a three-way voltage divider: the signal on the non-inverting input is simple average of three voltages: <em>Vsupply</em> (5 V), ground (0 V), and <em>Vout</em>. We don&#8217;t know the value of <em>Vout</em> just yet, but it can only vary from 0 V to <em>Vsupply</em>, so the <em>V<sub>in+</sub></em> signal will always stay between &#8531; &#183; <em>Vsupply</em> and &#8532; &#183;<em> Vsupply.</em></p><p>Next, let&#8217;s have a look at the inverting input (<em>Vin-</em>). When the circuit is first powered on, the capacitor C isn&#8217;t charged, so <em>Vin-</em> sits at 0 V. Since the voltage on the non-inverting input can&#8217;t be lower than &#8531; &#183; <em>Vsupply</em>, this means that on power-on, <em>Vin+ </em>&#8811;<em> Vin-</em>, sending the output voltage toward the positive rail. When <em>Vout</em> shoots up, it also bumps the <em>Vin+</em> average to &#8532; &#183; <em>Vsupply.</em></p><p>Because <em>Vout</em> is now high, this starts the process of charging the capacitor through the bottom resistor (R<sub>cap</sub>). After a while, the capacitor voltage is bound to exceed &#8532; &#183; <em>Vsupply</em>. The capacitor voltage is also hooked up to the amplifier&#8217;s inverting input, and at that point, <em>Vin-</em> begins to exceed <em>Vin+</em>, nudging the output voltage lower. Stable equilibrium is not possible because this output voltage drop is immediately reflected in the three-way average present on the <em>Vin+</em> leg, pulling it down and causing the difference between <em>Vin-</em> and <em>Vin+</em> to widen. This positive feedback loop puts the amplifier firmly into the <em>Vin+ </em>&#8810;<em> Vin-<sub> </sub></em>territory.</p><p>At that point, <em>Vout</em> must drop to 0 V, thus lowering the voltage on the non-inverting leg to &#8531; &#183; <em>Vsupply</em>. With <em>Vout</em> low, the capacitor starts discharging through R<sub>cap</sub>,. It needs to travel from the current charge state of &#8532; &#183; <em>Vsupply</em> all the way to &#8531; &#183; <em>Vsupply</em> before <em>Vin-</em> becomes lower than <em>Vin+</em> and the cycle is allowed to restart.</p><p>The continued charging and discharging of the capacitor between &#8531; &#183; <em>Vsupply</em> and &#8532; &#183; <em>Vsupply</em> results in periodic oscillation. The circuit produces a square wave signal with a period dictated by the value of C and R<sub>cap</sub>. The frequency of these oscillations can be approximated analogously to what we&#8217;ve done for the discrete-transistor variant earlier on. In a 5 V circuit with R1 = R2 = R3, the capacitor charges and discharges by <em>&#916;v &#8776;</em> 1.67 V. If R<sub>cap</sub> = 10 k&#937;, then the quasi-constant capacitor charging current is <em>I</em> <em>&#8776;</em> 2.5 V / 10 k&#937; <em>&#8776;</em> 250 &#181;A.</p><p>Knowing <em>&#916;v</em> and <em>I</em>, and assuming C = 1 &#181;F, we can tap into the capacitor equation (<em>&#916;v = I &#183; t/C</em>) to solve for <em>t</em>. The result is 6.67 ms. This puts the charge-discharge roundtrip at 13.34 ms, suggesting a frequency of 75 Hz. The actual measurement is shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!p0Ga!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa737b851-73ed-4611-8591-63ee7e7b82c6_2813x1875.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!p0Ga!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa737b851-73ed-4611-8591-63ee7e7b82c6_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!p0Ga!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa737b851-73ed-4611-8591-63ee7e7b82c6_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!p0Ga!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa737b851-73ed-4611-8591-63ee7e7b82c6_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!p0Ga!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa737b851-73ed-4611-8591-63ee7e7b82c6_2813x1875.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!p0Ga!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa737b851-73ed-4611-8591-63ee7e7b82c6_2813x1875.png" width="1456" height="970" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a737b851-73ed-4611-8591-63ee7e7b82c6_2813x1875.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:970,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:112168,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/179419876?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa737b851-73ed-4611-8591-63ee7e7b82c6_2813x1875.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!p0Ga!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa737b851-73ed-4611-8591-63ee7e7b82c6_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!p0Ga!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa737b851-73ed-4611-8591-63ee7e7b82c6_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!p0Ga!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa737b851-73ed-4611-8591-63ee7e7b82c6_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!p0Ga!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa737b851-73ed-4611-8591-63ee7e7b82c6_2813x1875.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Oscilloscope trace for the relaxation oscillator. By author.</em></figcaption></figure></div><p>The observed frequency is about 7% lower than predicted: 70 instead of 75 Hz. Although I could pin this on component tolerances, a more honest explanation is that at <em>&#916;v &#8776;</em> 1.67 V, the constant-current approximation of the capacitor charging process is stretched thin; the segments in the bottom oscilloscope trace diverge quite a bit from a straight line.</p><p>Short of reducing R3 to bring down <em>&#916;v</em> and thus reduce the variations in current, the way to develop a better formula is to tap into the equation for a capacitor charged by a constant voltage via a resistor, as derived <a href="https://lcamtuf.substack.com/p/the-101-of-analog-signal-filtering">here</a>:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;V_{cap} = V_{in} \\cdot (1 - e^{-t \\over RC})&quot;,&quot;id&quot;:&quot;HFCETYVRJQ&quot;}" data-component-name="LatexBlockToDOM"></div><p>To make the math simple, we can use &#8531; &#183; <em>Vsupply</em> as the reference point for the calculation, because that&#8217;s the starting voltage for the charging process and the capacitor never discharges below that level. In this view, the &#8220;virtual&#8221; supply voltage is <em>Vin =</em> &#8532; &#183; <em>Vsupply </em>(because we took away the unused bottom &#8531; of the range) and the capacitor is charging to <em>50%</em> of that value.</p><p>To find the charging time, we just need to rearrange the R-C formula for the <em>Vcap/Vin</em> ratio, and then solve for <em>t</em> at which the ratio works out to 50% (0.5):</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;0.5 = {V_{cap} \\over V_{in}} = 1 - e^{-t \\over RC}&quot;,&quot;id&quot;:&quot;SQWARXJZNB&quot;}" data-component-name="LatexBlockToDOM"></div><p>After moving 1 to the left and flipping signs, the equation simplifies to:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;0.5 = e^{-t \\over RC}&quot;,&quot;id&quot;:&quot;IGNZZMCPTD&quot;}" data-component-name="LatexBlockToDOM"></div><p>From there, we can take a natural logarithm of both sides:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;ln(0.5) = { -t \\over RC }&quot;,&quot;id&quot;:&quot;RCJTTIVSTD&quot;}" data-component-name="LatexBlockToDOM"></div><p>&#8230;and solve for <em>t:</em></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;t = \\underbrace{-ln(0.5)}_{=\\ ln(2)} \\cdot RC&quot;,&quot;id&quot;:&quot;DNQXQXGUZV&quot;}" data-component-name="LatexBlockToDOM"></div><p>In this particular case, the charging resistor is called <em>Rcap</em>, so the equation should be restated as:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;t = ln(2) \\cdot R_{cap} \\cdot C \\approx 0.693 \\cdot R_{cap} \\cdot C&quot;,&quot;id&quot;:&quot;EMQZBYUGFY&quot;}" data-component-name="LatexBlockToDOM"></div><p>The value of <em>t</em> can be used to find the oscillation frequency:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;f _{osc} = {1 \\over 2 \\cdot t} \\approx {1 \\over 1.386 \\cdot R_{cap} \\cdot C} \\approx {0.721 \\over R_{cap} \\cdot C }&quot;,&quot;id&quot;:&quot;STMEULHQBU&quot;}" data-component-name="LatexBlockToDOM"></div><p>If we plug 1 &#181;F and 10 k&#937; into the equation, the value works out to 72 Hz, which is within 3% of the observed behavior, comfortably within the tolerances of standard passive components.</p><p>As an aside, it&#8217;s worth noting that if we revise the circuit to connect the top terminal of <em>R1</em> to a lower positive reference voltage, or if we connect the bottom terminal of <em>R2</em> to a higher voltage, it will have the effect of reducing the distance between circuit&#8217;s Schmitt trigger voltages while still allowing the capacitor to charge from <em>Vsupply</em>. Reducing this distance has the effect of increasing the oscillation frequency; this makes for a rudimentary <em>voltage-controlled oscillator</em> (VCO), which has a number of uses &#8212; from musical instruments, to radios, to <a href="https://lcamtuf.substack.com/p/cursed-circuits-4-pll-frequency-multiplier">digital clock multipliers</a>.</p><h3>The phase-shift approach</h3><p>The method outlined earlier on is not the only conceptual approach to build oscillators. Another way is to produce resonance. We can do this by taking a standard op-amp voltage follower which uses negative feedback to control the output &#8212; and then mess with the feedback loop in a particular way.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8fnM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f096927-c524-43cb-b679-f8435a620f28_2000x800.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8fnM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f096927-c524-43cb-b679-f8435a620f28_2000x800.jpeg 424w, https://substackcdn.com/image/fetch/$s_!8fnM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f096927-c524-43cb-b679-f8435a620f28_2000x800.jpeg 848w, https://substackcdn.com/image/fetch/$s_!8fnM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f096927-c524-43cb-b679-f8435a620f28_2000x800.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!8fnM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f096927-c524-43cb-b679-f8435a620f28_2000x800.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8fnM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f096927-c524-43cb-b679-f8435a620f28_2000x800.jpeg" width="1456" height="582" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8f096927-c524-43cb-b679-f8435a620f28_2000x800.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:582,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:586742,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/179419876?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f096927-c524-43cb-b679-f8435a620f28_2000x800.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8fnM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f096927-c524-43cb-b679-f8435a620f28_2000x800.jpeg 424w, https://substackcdn.com/image/fetch/$s_!8fnM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f096927-c524-43cb-b679-f8435a620f28_2000x800.jpeg 848w, https://substackcdn.com/image/fetch/$s_!8fnM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f096927-c524-43cb-b679-f8435a620f28_2000x800.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!8fnM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f096927-c524-43cb-b679-f8435a620f28_2000x800.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>An op-amp voltage follower.</em></figcaption></figure></div><p>In the basic voltage follower configuration, the op-amp reaches a stable equilibrium when <em>Vin+</em> &#8776; <em>Vin-</em> &#8776; <em>Vout</em>. Again, the circuit works only because of the negative feedback loop; in its absence, <em>Vin- </em>would diverge from <em>Vin+</em> and the output voltage would swing toward one of the supply rails.</p><p>To turn this circuit into an oscillator, we can build a feedback loop that normally provides negative feedback, but that inverts the waveform at a particular sine-wave frequency. This turns negative feedback into positive feedback; instead of stabilizing the output voltage, it produces increasing swings, but only at the frequency at which the inversion takes place.</p><p>Such a selective waveform inversion sounds complicated, but we can achieve it a familiar building block: an R-C lowpass filter. The mechanics of these filters are discussed in <a href="https://lcamtuf.substack.com/p/the-101-of-analog-signal-filtering">this article</a>; in a nutshell, the arrangement produces a frequency-dependent phase shift of 0&#176; (at DC) to -90&#176; (as the frequency approaches infinity). If we cascade a couple of these R-C stages, we can achieve a -180&#176; phase shift at some chosen frequency, which is the same as flipping the waveform.</p><p>A minimalistic but well-behaved op-amp solution is shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BkK7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ac0ed4c-2eb0-4317-aac1-d8f5dd886f72_2000x1250.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BkK7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ac0ed4c-2eb0-4317-aac1-d8f5dd886f72_2000x1250.jpeg 424w, https://substackcdn.com/image/fetch/$s_!BkK7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ac0ed4c-2eb0-4317-aac1-d8f5dd886f72_2000x1250.jpeg 848w, https://substackcdn.com/image/fetch/$s_!BkK7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ac0ed4c-2eb0-4317-aac1-d8f5dd886f72_2000x1250.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!BkK7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ac0ed4c-2eb0-4317-aac1-d8f5dd886f72_2000x1250.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BkK7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ac0ed4c-2eb0-4317-aac1-d8f5dd886f72_2000x1250.jpeg" width="1456" height="910" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8ac0ed4c-2eb0-4317-aac1-d8f5dd886f72_2000x1250.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:910,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:279125,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/179419876?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ac0ed4c-2eb0-4317-aac1-d8f5dd886f72_2000x1250.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!BkK7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ac0ed4c-2eb0-4317-aac1-d8f5dd886f72_2000x1250.jpeg 424w, https://substackcdn.com/image/fetch/$s_!BkK7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ac0ed4c-2eb0-4317-aac1-d8f5dd886f72_2000x1250.jpeg 848w, https://substackcdn.com/image/fetch/$s_!BkK7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ac0ed4c-2eb0-4317-aac1-d8f5dd886f72_2000x1250.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!BkK7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ac0ed4c-2eb0-4317-aac1-d8f5dd886f72_2000x1250.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A rudimentary phase-shift oscillator.</em></figcaption></figure></div><p>In this particular circuit, an overall -180&#176; shift happens when each of the R-C stages adds its own -60&#176;. It&#8217;s easy to find the frequency at which this occurs. In the aforementioned article on signal filtering, we came up with the following formula describing the shift associated with the filter:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\theta = -arctan( 2 \\pi f R C )&quot;,&quot;id&quot;:&quot;YMNFWWHREK&quot;}" data-component-name="LatexBlockToDOM"></div><p>Arctangent is the inverse of the tangent function. In a right triangle, the tangent function describes the ratio of lengths of the opposite to the adjacent for a particular angle; the arctangent goes the other way round, giving us an angle for a particular ratio. In other words, if <em>x</em> = <em>tan(&#945;)</em> then <em>&#945; </em>= <em>arctan(x).</em> This allows us to rewrite the equation as:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;2 \\pi f R C = -tan(\\theta)&quot;,&quot;id&quot;:&quot;KHQUPQIRMH&quot;}" data-component-name="LatexBlockToDOM"></div><p>We&#8217;re trying to solve for <em>f</em> at which <em>&#952;</em> = -60&#176;; the value of <em>-tan(-60&#176;)</em> is roughly 1.73, so we can plug that into the equation and then move everything except <em>f </em>to the right. Throwing in the component values for the first R-C stage in the schematic, we obtain:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;f_{osc} \\approx {1.73 \\over {2 \\pi R C}} \\approx {1.73 \\over {2 \\pi \\cdot 1 \\textrm{ k&#937;} \\cdot 100 \\textrm{ nF}}} \\approx 2.75 \\textrm{ kHz}\n\n&quot;,&quot;id&quot;:&quot;IKOJUTYWJN&quot;}" data-component-name="LatexBlockToDOM"></div><p>You&#8217;ll notice that the result is the same for the other two stages: they have higher resistances but proportionally lower capacitances, so the denominator of the fraction doesn&#8217;t change.</p><p>Oscilloscope traces for the circuit are shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0H2m!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3c9efcc-3be6-4309-8d43-92e565c15c91_2813x1875.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0H2m!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3c9efcc-3be6-4309-8d43-92e565c15c91_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!0H2m!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3c9efcc-3be6-4309-8d43-92e565c15c91_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!0H2m!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3c9efcc-3be6-4309-8d43-92e565c15c91_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!0H2m!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3c9efcc-3be6-4309-8d43-92e565c15c91_2813x1875.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0H2m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3c9efcc-3be6-4309-8d43-92e565c15c91_2813x1875.png" width="1456" height="970" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e3c9efcc-3be6-4309-8d43-92e565c15c91_2813x1875.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:970,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:173849,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/179419876?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3c9efcc-3be6-4309-8d43-92e565c15c91_2813x1875.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!0H2m!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3c9efcc-3be6-4309-8d43-92e565c15c91_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!0H2m!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3c9efcc-3be6-4309-8d43-92e565c15c91_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!0H2m!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3c9efcc-3be6-4309-8d43-92e565c15c91_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!0H2m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3c9efcc-3be6-4309-8d43-92e565c15c91_2813x1875.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Traces for the three R-C stages.</em></figcaption></figure></div><p>Because the amplifier&#8217;s gain isn&#8217;t constrained in any way, the output waveform is a square wave. Nevertheless, in a lowpass circuit with these characteristics, the waveforms produced by the R-C stages in response to a square-wave input are close enough to sinusoids that the sine-wave model approximates the behavior nearly perfectly. We can run a discrete-time simulation to show that the sine-wave behavior of these three R-C stages (gray) aligns pretty well with the square-wave case (blue):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ffXM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13556ade-ffe1-42d1-8508-d35cc30ab114_2813x1875.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ffXM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13556ade-ffe1-42d1-8508-d35cc30ab114_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!ffXM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13556ade-ffe1-42d1-8508-d35cc30ab114_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!ffXM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13556ade-ffe1-42d1-8508-d35cc30ab114_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!ffXM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13556ade-ffe1-42d1-8508-d35cc30ab114_2813x1875.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ffXM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13556ade-ffe1-42d1-8508-d35cc30ab114_2813x1875.png" width="1456" height="970" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/13556ade-ffe1-42d1-8508-d35cc30ab114_2813x1875.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:970,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:145695,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/179419876?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13556ade-ffe1-42d1-8508-d35cc30ab114_2813x1875.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ffXM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13556ade-ffe1-42d1-8508-d35cc30ab114_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!ffXM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13556ade-ffe1-42d1-8508-d35cc30ab114_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!ffXM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13556ade-ffe1-42d1-8508-d35cc30ab114_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!ffXM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13556ade-ffe1-42d1-8508-d35cc30ab114_2813x1875.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A simulation of a square &amp; sine wave passing through three R-C filters.</em></figcaption></figure></div><p>To make the output a sine wave, it&#8217;s possible to tinker with with the feedback loop to lower the circuit&#8217;s gain, but it&#8217;s hard to get it right; insufficient gain prevents oscillation while excess gain produces distortion. A simpler trick is to tap into the signal on the non-inverting leg (bottom oscilloscope trace) and use the other part of a dual op-amp IC to amplify this signal to your heart&#8217;s desire.</p><p>Some readers might be wondering why I designed the stages so that each of them has an impedance ten times larger than the stage before it. This is to prevent the filters from appreciably loading each other. If all the impedances were in the same ballpark, the middle filter could source currents from the left as easily as it could from the right. In that situation, finding the point of -180&#176; phase shift with decent accuracy would require calculating the transfer function for the entire six-component Franken-filter; the task is doable but &#8212; to use a mathematical term &#8212; <a href="https://lcamtuf.substack.com/p/analog-filters-part-2-let-it-ring">rather unpleasant</a>.</p><p><em>Footnote: in the literature, the circuit is more often constructed using highpass stages and a discrete transistor as an amplifier. I&#8217;d wager that most authors who present the discrete-transistor solution have not actually tried it in practice; otherwise, they would have found it to be quite finicky. The version presented in this article is discussed <a href="https://www.electronicdesign.com/technologies/analog/article/21806012/simple-generator-provides-very-low-frequency-distortion-sine-and-square-waves">here</a>.</em></p><h1 style="text-align: center;">&#128214;</h1><p style="text-align: center;">If you liked the article, you&#8217;ll enjoy <em><a href="https://lcamtuf.coredump.cx/electronics/">The Secret Life of Circuits</a></em>. It&#8217;s a richly illustrated, lucid introduction to electronics &#8212; from the physics of conduction to embedded system programming. It features 290+ color diagrams, 420+ pages of original content, and zero AI.</p><div><hr></div><p><em>&#128073;  For further articles about electronics, <a href="https://lcamtuf.substack.com/p/electronics-curriculum">click here</a>. In particular, you might enjoy:</em></p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;2605a7c8-130b-44df-9be3-d6552a886426&quot;,&quot;caption&quot;:&quot;Radio communications play a key role in modern electronics, but to a hobbyist, the underlying theory is hard to parse. We get the general idea, of course: we know about frequencies and can probably explain the difference between amplitude modulation and frequency modulation. Yet, most of us find it difficult to articulate what makes a good antenna, or h&#8230;&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Radios, how do they work?&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2024-03-25T07:03:57.440Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe941fc1d-74d6-4765-bce5-0d95b7145975_1800x1016.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/radios-how-do-they-work&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:142762684,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:104,&quot;comment_count&quot;:13,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;ad1450c5-5de2-4e6e-b9dc-fcbb25e4f0d7&quot;,&quot;caption&quot;:&quot;Every other consumer electronic device on the market performs some form of DC voltage conversion. The reason is simple: the voltage you get out of a typical battery or a cheap wall wart is seldom right for every part of the circuit &#8212; from motors, to LCD backlights, to latest-generation digital chips.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;The magic of DC-DC voltage conversion&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-04-22T16:48:09.800Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b5f279ba-2314-4017-a703-ba682c912762_1631x943.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/the-magic-of-dc-dc-voltage-conversion&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:116183658,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:44,&quot;comment_count&quot;:9,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;ed4a9fd1-d177-4af6-9916-83d1c061167f&quot;,&quot;caption&quot;:&quot;The diode might be the most neglected component in the electronics curriculum today. Pages upon pages have been written about the mechanics of resistors, capacitors, and inductors; on this blog alone, we covered the components&#8217; fundamental equations, the model of&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Things you can do with diodes&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-11-02T19:39:54.712Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/03297fe4-2aef-4b79-9d7b-496d9b7978e7_1186x1027.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/things-you-can-do-with-diodes&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:177769958,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:38,&quot;comment_count&quot;:4,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p><em>I write well-researched, original articles about geek culture, electronic circuit design, algorithms, and more. If you like the content, please subscribe.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item><item><title><![CDATA[When it comes to writing, LLMs have won]]></title><description><![CDATA[As a middling author, I find it fairly easy to sniff out LLM-generated articles.]]></description><link>https://lcamtuf.substack.com/p/when-it-comes-to-writing-llms-have</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/when-it-comes-to-writing-llms-have</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Thu, 13 Nov 2025 23:13:09 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/4d31be35-ac9e-49b1-8c1e-ae1972f5b830_1196x800.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As a middling author, I find it fairly easy to sniff out LLM-generated articles. I see such content almost daily on Hacker News &#8212; and mind you, that&#8217;s the home of a fairly discerning, tech-savvy crowd; the proportion of generative AI on my other social media is higher than that. I understand the economics of it and I know the output is good enough for most readers. Still, from the perspective of a writer, it stings to see that the robots are winning the zero-sum contest for human attention on the internet.</p><p>There are some activists who try to stigmatize the use of generative AI for content creation, but they often end up chasing ghosts; so far, I had two people accuse me of using AI on this blog, and I&#8217;m sure there&#8217;s more to come. The controversy around em dashes (&#8212;) is instructive. I think it&#8217;s important to realize that language model output doesn&#8217;t differ from human writing <em>per se</em>; there&#8217;s just no single tell. What&#8217;s true, however, is that if you go to <em>chatgpt.com</em> and ask for an essay, it will by default assume a certain writer persona. All articles written by that persona will have similarities, just as all articles written by the same human would.</p><p>The quirks start with basic formatting. For example, the current crop of chatbots has a preference for book-style capitalization of section headings (<em>&#8220;Status in Academic Departments&#8221;</em>) versus the more common Wikipedia style (<em>&#8220;Status in academic departments&#8221;</em>); in the same vein, LLMs opt for bolded text instead of italics for emphasis. The models also overuse various stylistic cliches, including negative parallelisms (<em>&#8220;not only &#8230; but &#8230;&#8221;, &#8220;not &#8230;, not &#8230;, just &#8230;&#8221;</em>), vague appeals to significance (<em>&#8220;illustrates lasting influence&#8221;,</em> <em>&#8220;emphasizes the importance of &#8230;&#8221;</em>), and superfluous outline and summary paragraphs.</p><p>Again, there&#8217;s no single bulletproof indicator, but contrary to some nerd lore, the totality of these statistical patterns can be detected with automated tools: if Pangram flags something as LLM output, you probably shouldn&#8217;t dismiss the finding out of hand. At the same time, such tests are not enough. First, there&#8217;s a relatively small proportion of people who also write that way; it&#8217;s not good prose, but it&#8217;s also not a reason to burn them at the stake. Second, a clever user can prompt an LLM to use a different voice. Ask a chatbot to write as a grizzled sailor &#8212; a man of few words who&#8217;s still grieving the loss of his wife and only child &#8212; and the mathematics get out of whack.</p><p>Because of these gotchas, I tend to lean on three additional, higher-level heuristics. First, on the topic of style, I ask myself if the author&#8217;s works exhibit any <em>unusual</em> yet consistent writing traits. Every person has some: a preference for overly long sentences, a tendency to overuse semicolons, a propensity for colorful asides or dry wit, or maybe a recurring odd idiom or a mixed metaphor. If a given pattern isn&#8217;t common in the training data, the chatbot won&#8217;t replicate it unless given an oddly specific prompt (e.g., <em>&#8220;always hyphenate the word &#8216;co-worker&#8217;&#8220;</em>). If you go through several pages of writing and can&#8217;t identify any rare traits, it&#8217;s a reason for concern.</p><p>Another good question to ponder is why the article exists in the first place. Long-form text takes effort and time. Setting aside compelled writing such as school essays, we write when we have something interesting to say. On an online blog, you should be able to discern the author&#8217;s interests and pet peeves. The path of the reverse engineer is to ask what&#8217;s the shortest LLM prompt the article could be compressed into. If the prompt is vague and aimless &#8212; <em>&#8220;generate an article about the importance of Immanuel Kant in the age of AI&#8221;</em> &#8212; something might be amiss.</p><p>The final experiment is to plug this hypothetical prompt into an LLM of your choice. If the model produces something functionally similar to the original article &#8212; the same outline, the same metaphors, the same conclusions &#8212; it&#8217;s a fairly clear sign of LLM chicanery.</p><p>All this leads to a more fundamental question: is it even useful to know? I have my misgivings about the origins of the tech: years of my hard work ended up getting pulled into the training datasets without any acknowledgment, let alone consent. I&#8217;m sure this is also the fate of any future books I publish and web articles I write, no matter the license or the contents of <em>robots.txt</em>. At the same time, the ship has sailed: most people don&#8217;t enjoy the writing process and see a &#8220;get it done&#8221; button as a godsend. No one cares about the hurt feelings of bloggers who refuse to get with the times.</p><p>In the end, if you employ a chatbot as a copyeditor but stand by the result, I&#8217;m happy for you. Conversely, if the article you&#8217;re posting on the internet doesn&#8217;t represent any real cognitive effort and has no discernible goal, then something&#8217;s broken &#8212; but that&#8217;s true no matter if the text is LLM-generated or not.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item><item><title><![CDATA[What's the deal with Euler's identity?]]></title><description><![CDATA[Untangling a cursed formula from 1748.]]></description><link>https://lcamtuf.substack.com/p/whats-the-deal-with-eulers-identity</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/whats-the-deal-with-eulers-identity</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Sat, 08 Nov 2025 22:15:52 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/766c885b-d0b4-4d18-a739-604f0ebb4031_1015x580.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Perhaps the most famous equation in pop mathematics is Euler&#8217;s identity:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;e^{i \\pi} + 1 = 0&quot;,&quot;id&quot;:&quot;KYBWBTAMXN&quot;}" data-component-name="LatexBlockToDOM"></div><p>The equation is deemed profound because it combines not one, not two, but five &#8220;special&#8221; mathematical constants: <em>e</em>, <em>&#960;</em>, 0, 1, and the imaginary unit<em> i.</em></p><p>The identity is a special case of an equation known as Euler&#8217;s formula:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;e^{i \\alpha} = cos(\\alpha) + i \\cdot sin(\\alpha)&quot;,&quot;id&quot;:&quot;GHCUXMMHFF&quot;}" data-component-name="LatexBlockToDOM"></div><p>The identity form is what you get if you choose an angle of <em>&#945;</em> = <em>&#960;</em> in radians (180&#176;). This makes the cosine expression equal to -1 and the sine part equal to zero, so the final result of the substitution is:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;e^{i \\pi} = -1&quot;,&quot;id&quot;:&quot;VOAKDRQOMX&quot;}" data-component-name="LatexBlockToDOM"></div><p>Now, four &#8220;special&#8221; values is still weak sauce, so we move -1 to the left to increase the profoundness factor by another 25%.</p><p>There are multiple &#8220;easy&#8221; proofs of Euler&#8217;s formula you can find on YouTube, but they all involve sleight of hand: they make unobvious assertions about infinite series and function derivatives, or rely on a circular definition of complex numbers. I don&#8217;t have a proof that will fit on a napkin, but I think there&#8217;s a reasonably intuitive way to reason about what the equation does.</p><h3>A geometric view of complex numbers</h3><p>Imagine a point in a Cartesian coordinate system that lies on the horizontal axis at a distance <em>l </em>from the center. If you wish to rotate this point by an angle <em>&#945;</em> in radians, you can calculate the new <em>(x, y) </em>coordinates using simple trigonometry:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{align}\nx_{rotated} = l \\cdot cos(\\alpha) \\\\\ny_{rotated} = l \\cdot sin(\\alpha) \n\\end{align}&quot;,&quot;id&quot;:&quot;KKSARJVIDW&quot;}" data-component-name="LatexBlockToDOM"></div><p>Less obviously, there is also a way to rotate points without trigonometric functions. If we take point <em>(x, y)</em> and flip the signs of the individual coordinates &#8212; <em>(-x, -y)</em> &#8212; we always achieve what looks like a rotation by 180&#176;:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!btR-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42608eb5-2b73-47c5-986f-6f2caa78f2dd_2000x1300.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!btR-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42608eb5-2b73-47c5-986f-6f2caa78f2dd_2000x1300.jpeg 424w, https://substackcdn.com/image/fetch/$s_!btR-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42608eb5-2b73-47c5-986f-6f2caa78f2dd_2000x1300.jpeg 848w, https://substackcdn.com/image/fetch/$s_!btR-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42608eb5-2b73-47c5-986f-6f2caa78f2dd_2000x1300.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!btR-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42608eb5-2b73-47c5-986f-6f2caa78f2dd_2000x1300.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!btR-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42608eb5-2b73-47c5-986f-6f2caa78f2dd_2000x1300.jpeg" width="1456" height="946" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/42608eb5-2b73-47c5-986f-6f2caa78f2dd_2000x1300.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:946,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:398412,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/178365616?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42608eb5-2b73-47c5-986f-6f2caa78f2dd_2000x1300.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!btR-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42608eb5-2b73-47c5-986f-6f2caa78f2dd_2000x1300.jpeg 424w, https://substackcdn.com/image/fetch/$s_!btR-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42608eb5-2b73-47c5-986f-6f2caa78f2dd_2000x1300.jpeg 848w, https://substackcdn.com/image/fetch/$s_!btR-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42608eb5-2b73-47c5-986f-6f2caa78f2dd_2000x1300.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!btR-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42608eb5-2b73-47c5-986f-6f2caa78f2dd_2000x1300.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>180&#176; rotation by multiplying coordinates by -1.</em></figcaption></figure></div><p>The sign-flipping operation is equivalent to multiplication by -1. Changing the magnitude of the negative multiplier doesn&#8217;t result in a different rotation angle; it&#8217;s the &#8220;negative unit" itself (-1) that appears to be doing the hard work. If we want to achieve a rotation by 360&#176;, we need to multiply the coordinates by -1 twice; the pattern extends in a pretty obvious way:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{align}\n(x, y) \\cdot (-1)^0 &amp;\\rightarrow 0^\\circ \\\\\n(x, y) \\cdot (-1)^1 &amp;\\rightarrow 180^\\circ \\\\\n(x, y) \\cdot  (-1)^2 &amp;\\rightarrow 360^\\circ \\\\\n(x, y) \\cdot  (-1)^3 &amp;\\rightarrow 540^\\circ \\\\\n(x, y) \\cdot  (-1)^4 &amp;\\rightarrow 720^\\circ \\\\\n... \\\\\n(x, y) \\cdot  (-1)^m &amp;\\rightarrow 180^\\circ \\cdot m \\\\\n\n\n\\end{align}&quot;,&quot;id&quot;:&quot;KJSCFLZUFX&quot;}" data-component-name="LatexBlockToDOM"></div><p>This leads to a peculiar realization: it would appear that to achieve rotations of less than 180&#176;, we could raise -1 to a fractional power. In particular, to obtain 90&#176;, we seemingly need an exponent halfway between (-1)<sup>0</sup> and (-1)<sup>1</sup>. In other words, we need to multiply the coordinates by (-1)<sup>&#189;</sup>. This multiplier, known as <em>i,</em> can be also written as &#8730;(-1).</p><p>The number<em> i </em>is not a real. That&#8217;s not to say that it doesn&#8217;t exist; it just isn&#8217;t a member of the set of real numbers, &#8477;. The construct lets us represent the coordinates of any point (<em>x, y</em>) as a single compound (&#8220;complex&#8221;) number:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;z = x + iy&quot;,&quot;id&quot;:&quot;XDLBASWRVA&quot;}" data-component-name="LatexBlockToDOM"></div><p>The first part corresponds to the distance along the horizontal axis. The second (<em>i-</em>coupled) value is a number that&#8217;s evidently &#8220;rotated&#8221; by 90&#176; &#8212; i.e., it represents the distance along the vertical axis.</p><p>This might sound unhinged, but the result is a coherent model of 2D geometry, and standard algebra extends to this <em>i</em>-containing realm in a pretty straightforward way. For the most part, you just work on the two halves of a complex number separately, keeping in mind that <em>i &#183; i = -1.</em></p><p>With the <em>z = x + iy</em> construction in tow, let&#8217;s go back to the earlier method of rotating a segment of length <em>l </em>by an angle <em>&#945;:</em></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{align}\nx_{rotated} = l \\cdot cos(\\alpha) \\\\\ny_{rotated} = l \\cdot sin(\\alpha) \n\\end{align}&quot;,&quot;id&quot;:&quot;KBBMBRENQT&quot;}" data-component-name="LatexBlockToDOM"></div><p>Nothing stops us from combining these coordinates into a single complex number <em>z</em> that represents the <em>x</em> and <em>y</em> coordinates of the rotated point:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;z = \\underbrace{l \\cdot cos(\\alpha)}_{\\substack{\\textrm{horizontal} \\\\ \\textrm{distance}}} + i \\cdot \\underbrace{l \\cdot sin(\\alpha)}_{\\substack{\\textrm{vertical} \\\\ \\textrm{distance}}}&quot;,&quot;id&quot;:&quot;QGCLVRRPKS&quot;}" data-component-name="LatexBlockToDOM"></div><p>Equivalently, as discussed earlier on, we can express rotation by <em>m</em> &#183; 90&#176; by multiplying the starting length <em>l</em> by the correct power of <em>i</em>:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;z = l \\cdot i^m&quot;,&quot;id&quot;:&quot;PDEDIURACI&quot;}" data-component-name="LatexBlockToDOM"></div><p>In the first equation, the angle of rotation (<em>&#945;) </em>is expressed in radians, so a full 360&#176; turn is achieved when <em>&#945; = 2&#960;</em>. In the second version, it&#8217;s expressed in 90&#176; increments, so a full rotation is <em>m =</em> 4. To reconcile these equations, we need to toss in the appropriate scaling factor. If we do it on the <em>i<sup>m</sup></em><sup> </sup>side to settle on radians, we get:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;l \\cdot i^{2/ \\pi \\cdot \\alpha} = l \\cdot [ cos(\\alpha) + i \\cdot  sin(\\alpha) ]&quot;,&quot;id&quot;:&quot;WFRZXVCUQT&quot;}" data-component-name="LatexBlockToDOM"></div><p>This can be further simplified by choosing <em>l</em> = 1, essentially building a model of a point moving along a unit circle with a radius of one:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;i^{2/ \\pi \\cdot \\alpha} = cos(\\alpha) + i \\cdot sin(\\alpha)&quot;,&quot;id&quot;:&quot;XWZCYRMZJP&quot;}" data-component-name="LatexBlockToDOM"></div><p>The equation is already in the same ballpark as Euler&#8217;s formula, but we&#8217;re not quite done yet.</p><h3>Imaginary bases and exponents</h3><p>In the realm of real numbers, exponentiation that uses one positive base other than 1 can be rewritten in another base simply by tossing in an appropriate scaling factor in the exponent. For example, we can write the following:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;8^x = 2^{3 \\cdot x}&quot;,&quot;id&quot;:&quot;PEKVNMAMYD&quot;}" data-component-name="LatexBlockToDOM"></div><p>The scaling factor is just the logarithm of the old base in the new base: <em>log<sub>2</sub>(8)</em> = 3.</p><p>Logarithms can be seamlessly extended to complex numbers, allowing us to move between real and imaginary bases in exponentiation. As a trivial example, if <em>(-1)<sup>&#189; </sup>= i</em>, we can infer that <em>log<sub>-1</sub>(i)</em> <em>= &#189;</em>. Knowing this, we can apply the earlier rule to convert between an imaginary base <em>i </em>and a real base -1, with unsurprising results:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;i^x = (-1)^{x/2}&quot;,&quot;id&quot;:&quot;OAJGSMTIVO&quot;}" data-component-name="LatexBlockToDOM"></div><p>In the same vein, there exists a logarithm that nets us a scaling factor to move from base <em>i </em>to base 10<em>:</em></p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;i^x = 10^{log_{10}(i) \\cdot x}&quot;,&quot;id&quot;:&quot;COFBUDMHNJ&quot;}" data-component-name="LatexBlockToDOM"></div><p>The value of <em>log<sub>10</sub>(i) </em>can&#8217;t be a real number because if we choose <em>x = </em>2, the left-hand side works out to -1, and there&#8217;s no real <em>c </em>for which 10<em><sup>c</sup></em><sup> </sup>is negative. That said, we can make this equivalence work with imaginary-number solutions, netting us a coherent algebra without any overt contradictions.</p><p>In that system, the value of <em>log<sub>10</sub>(i)</em> would need to work out to roughly 0.682&#183;<em>i</em>, but we don&#8217;t need to know how to calculate it just yet. The point is just that the two earlier forms &#8212; <em>i<sup>x </sup></em>and 10<em><sup>&lt;some i-containing constant&gt;&#183;x </sup></em>&#8212; can be considered equivalent. They both represent rotation by a chosen angle<em> </em>in a two-dimensional space.</p><h3>&#9835; You spin me &#8216;round (like a record)</h3><p>Before the segue into the properties of exponentiation, we established the following formula that equated two methods of rotating a point:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;i^{2/ \\pi \\cdot \\alpha} = cos(\\alpha) + i \\cdot sin(\\alpha)&quot;,&quot;id&quot;:&quot;HCPRRBXPNL&quot;}" data-component-name="LatexBlockToDOM"></div><p>On the left side of the equation, we needed to toss in a 2/<em>&#960;</em> scaling factor to convert from 90&#176; increments to radians. It would be nice to switch to a different, real-number base <em>n</em> that naturally has the same rotation speed as the <em>cos + sin</em> expression. This would let us simplify the formula to:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;n^{i \\alpha} = cos(\\alpha) + i \\cdot sin(\\alpha)&quot;,&quot;id&quot;:&quot;YJJTWRADKP&quot;}" data-component-name="LatexBlockToDOM"></div><p>The <em>cos + sin </em>expression is drawing a circle with a radius of 1, completing one rotation every <em>2&#960; </em>radians. The circumference of the unit circle is <em>2&#960;</em>, so there is a 1:1 correspondence between the parameter of the expression (&#945;) and the distance traveled by the moving point.</p><p>Again, we&#8217;d like to meet that rotation on the left side of the equation by choosing the right <em>n </em>so that there is a 1:1 relationship between the increment in &#945; and the travel of the coordinate produced by exponentiation (<em>n<sup>i&#945;</sup></em>).</p><p>As luck would have it, there is a well-known real base for which there is a 1:1 correspondence between the increment of <em>n<sup>x</sup></em> and the increment of the exponent near <em>x = 0</em>. It is, by definition, the mathematical constant <em>e</em>. If you&#8217;re unfamiliar with this property, it&#8217;s easy to show it numerically; if we choose a small &#916;<em>x </em>= 0.0001 and calculate the rate of change near <em>x</em> = 0, we get:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\begin{array}{r l}\nn = 2: &amp; {{2^{\\Delta x} - 2^0} \\over \\Delta x} \\approx 0.69 \\\\\nn = e: &amp; {{e^{\\Delta x} - e^0} \\over \\Delta x} \\approx 1.00 \\\\\nn = 4: &amp; {{4^{\\Delta x} - 4^0} \\over \\Delta x} \\approx 1.39 \\\\\n\\end{array}&quot;,&quot;id&quot;:&quot;KLVSMUCNSU&quot;}" data-component-name="LatexBlockToDOM"></div><p>We can also illustrate this on a plot of <em>y</em> = <em>e<sup>x</sup></em>. The slope of the resulting curve is 45&#176; near <em>x = </em>0, suggesting that the function briefly behaves the same as <em>y = x:</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xYrI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb37641-fb45-41ef-8359-4c067b256465_2500x1329.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xYrI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb37641-fb45-41ef-8359-4c067b256465_2500x1329.png 424w, https://substackcdn.com/image/fetch/$s_!xYrI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb37641-fb45-41ef-8359-4c067b256465_2500x1329.png 848w, https://substackcdn.com/image/fetch/$s_!xYrI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb37641-fb45-41ef-8359-4c067b256465_2500x1329.png 1272w, https://substackcdn.com/image/fetch/$s_!xYrI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb37641-fb45-41ef-8359-4c067b256465_2500x1329.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xYrI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb37641-fb45-41ef-8359-4c067b256465_2500x1329.png" width="1456" height="774" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6fb37641-fb45-41ef-8359-4c067b256465_2500x1329.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:774,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:66687,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/178365616?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb37641-fb45-41ef-8359-4c067b256465_2500x1329.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!xYrI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb37641-fb45-41ef-8359-4c067b256465_2500x1329.png 424w, https://substackcdn.com/image/fetch/$s_!xYrI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb37641-fb45-41ef-8359-4c067b256465_2500x1329.png 848w, https://substackcdn.com/image/fetch/$s_!xYrI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb37641-fb45-41ef-8359-4c067b256465_2500x1329.png 1272w, https://substackcdn.com/image/fetch/$s_!xYrI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fb37641-fb45-41ef-8359-4c067b256465_2500x1329.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>The plot of y = e<sup>x</sup></em>.</figcaption></figure></div><p>In the domain of real numbers, the rate of change of e<em><sup>x </sup></em>increases in tandem with the value of <em>x</em>; that&#8217;s the nature of exponential growth. But in the realm of complex numbers, we have already asserted that a real value raised<em> </em>to an imaginary power results in constant-speed rotation, not runaway growth. We must conclude that the rate of change is dialed in solely by the real part of the exponent, which is always zero in the formula we&#8217;re trying to build.</p><p>This means that the scaling-factor-free solution we&#8217;re looking for is just:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;e^{i \\alpha} = cos(\\alpha) + i \\cdot sin(\\alpha)&quot;,&quot;id&quot;:&quot;LKEQYJSDPF&quot;}" data-component-name="LatexBlockToDOM"></div><p>The observation also gives us the value of <em>log<sub>e</sub>(i) = ln(i)</em>. Per the earlier discussion, switching from <em>i</em> to base <em>e </em>entails multiplying the exponent by <em>log<sub>e</sub>(i). </em>In this instance, the multiplication evidently cancels out the 2/<em>&#960; </em>factor associated with the original base, so <em>ln(i) </em>must be<em> &#960;/2 &#183; i</em>, or about<em> 1.571 &#183; i.</em></p><p>That&#8217;s it. Again, it&#8217;s not a real proof: the argument contains a couple of appeals to intuition. That said, I like this chain of thought better than the usual explanations found on the internet.</p><p>As to why all these constants come together, the basic answer is that complex numbers are a two-dimensional geometry &#8212; and that radians, i, <em>e, </em>and <em>&#960;</em> describe similar things.</p><div><hr></div><p><em>&#128073; For more articles about math, <a href="https://lcamtuf.substack.com/p/algorithms-and-math-trivia">visit this page</a>. In particular, you might enjoy:</em></p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;a401f81e-81a3-450c-a023-fbfb1ec638c6&quot;,&quot;caption&quot;:&quot;In a couple of earlier articles on this site, I brought up complex numbers. They are a fairly abstract construct that reeks of higher math, but that is hard to avoid in the context of analog electronics, signal processing, computer graphics, and more.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;A 20-minute intro to complex numbers&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-05-16T18:24:26.911Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b9640599-c4f0-42ce-bca4-e023c4149952_582x606.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/a-20-minute-intro-to-complex-numbers&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:163599741,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:42,&quot;comment_count&quot;:7,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;68cb77e9-5397-4e40-b3ad-ca31290de38d&quot;,&quot;caption&quot;:&quot;Several days ago, I posted a brief introduction to complex numbers. My goal was to explain the concept better than usual; I wanted to show that the imaginary unit of i = &#8730;-1 is not just a whimsical separator between two unrelated variables. Instead, it encodes a deliberate and important relationship between the real and imaginary part.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Complex numbers #2: a world in 3D&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-05-19T01:16:27.275Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d90cab2f-6547-4fe0-85a1-dc0d80716c6c_728x410.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/complex-numbers-2-a-world-in-3d&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:163868937,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:16,&quot;comment_count&quot;:10,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;85d099a5-a02b-4982-b12c-4cc4c1fde847&quot;,&quot;caption&quot;:&quot;If you&#8217;re a nerd, you probably have encountered visualizations of a tesseract: a four-dimensional equivalent of a cube. Heck, various representations of the shape have made it into blockbuster sci-fi films, music videos, and more.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;You gotta think outside the hypercube&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2026-01-26T23:05:38.271Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/$s_!Punz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73d9c28a-f287-4b29-abc2-40d701fcdf60_1409x1012.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/you-gotta-think-outside-the-hypercube&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:185802725,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:24,&quot;comment_count&quot;:5,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;92ffa9d9-1716-4978-8e20-76cafcdbb7f2&quot;,&quot;caption&quot;:&quot;In the previous article, I talked about one of my favorite mathematical constructs: the Buddhabrot fractal that&#8217;s hiding in the shadow of its better-known cousin, the Mandelbrot set. Both of these sets are described by the same formula:&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Fractals #2: understanding Mandelbrot&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2024-04-12T19:09:51.661Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ecd030d8-61fa-4313-93b9-67b7653cf0ff_1688x1687.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/fractals-2-revenge-of-the-mandel&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:143505082,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:21,&quot;comment_count&quot;:5,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p><em>I write well-researched, original articles about geek culture, electronic circuit design, algorithms, and more. If you like the content, please subscribe.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[Things you can do with diodes]]></title><description><![CDATA[Paying homage to the component we usually don't think about.]]></description><link>https://lcamtuf.substack.com/p/things-you-can-do-with-diodes</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/things-you-can-do-with-diodes</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Sun, 02 Nov 2025 19:39:54 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/03297fe4-2aef-4b79-9d7b-496d9b7978e7_1186x1027.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The diode might be the most neglected component in the electronics curriculum today. Pages upon pages have been written about the mechanics of resistors, capacitors, and inductors; on this blog alone, we covered the components&#8217; <a href="https://lcamtuf.substack.com/p/primer-core-concepts-in-electronic">fundamental equations</a>, the model of <a href="https://lcamtuf.substack.com/p/impedance-part-2-why-do-lcr-meters">complex impedance</a>, the behavior of <a href="https://lcamtuf.substack.com/p/the-101-of-analog-signal-filtering">R-C filters</a>, and more. As for semiconductors, the diode&#8217;s more useful sibling &#8212; the transistor &#8212; hogs the limelight.</p><p>The diode is given neither the mathematical rigor of linear circuits nor the red-carpet treatment of the transistor. To the extent that the component is marveled at all, it&#8217;s usually in the context of exotic inventions such as the Gunn diode or the tunnel diode &#8212; both of which are almost never encountered in real life.</p><p>Today, let&#8217;s pay the &#8220;normal&#8221; diode a small tribute.</p><h3>The mechanics of diodes</h3><p><em>If you&#8217;re rusty on concepts such as voltage, current, or impedance, I suggest reviewing <a href="https://lcamtuf.substack.com/p/primer-core-concepts-in-electronic">this article</a> first.</em></p><p>In an earlier post about the <a href="https://lcamtuf.substack.com/p/how-do-transistors-work-anyway">physics of semiconductors</a>, I noted that pure silicon is a poor conductor of electricity. This is because the material lacks long-lived, mobile charge carriers. Some conduction is still possible due to the short-lived thermal excitation of valence electrons that briefly pop into a higher-energy state, but these electrons can&#8217;t travel far before returning to a lower-energy level, so the effect is more or less negligible.</p><p>The conductivity of the material is improved by the addition of dopants. Some dopants contribute long-lived electrons that occupy higher energy levels with no lower-energy vacancies to return to; this is what&#8217;s called an n-type semiconductor. Other additives create easily-accessible valence band vacancies (&#8220;holes&#8221;); in such a p-type material, lower-energy electrons can slither around from atom to atom without needing to be knocked into a higher-energy state.</p><p>When an n-type material is brought into contact with a p-type semiconductor, higher-energy electrons from the n-side randomly diffuse to the p-side and then promptly fall into the abundant lower-energy holes. This produces a thermodynamic equilibrium with an internal electric field across the junction. There is a positive charge on the n-side and a negative charge on the p-side:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!V7h8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724e1e79-fa18-47b5-ad9c-3cb4343950ac_2000x944.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!V7h8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724e1e79-fa18-47b5-ad9c-3cb4343950ac_2000x944.jpeg 424w, https://substackcdn.com/image/fetch/$s_!V7h8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724e1e79-fa18-47b5-ad9c-3cb4343950ac_2000x944.jpeg 848w, https://substackcdn.com/image/fetch/$s_!V7h8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724e1e79-fa18-47b5-ad9c-3cb4343950ac_2000x944.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!V7h8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724e1e79-fa18-47b5-ad9c-3cb4343950ac_2000x944.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!V7h8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724e1e79-fa18-47b5-ad9c-3cb4343950ac_2000x944.jpeg" width="1456" height="687" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/724e1e79-fa18-47b5-ad9c-3cb4343950ac_2000x944.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:687,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:557155,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724e1e79-fa18-47b5-ad9c-3cb4343950ac_2000x944.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!V7h8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724e1e79-fa18-47b5-ad9c-3cb4343950ac_2000x944.jpeg 424w, https://substackcdn.com/image/fetch/$s_!V7h8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724e1e79-fa18-47b5-ad9c-3cb4343950ac_2000x944.jpeg 848w, https://substackcdn.com/image/fetch/$s_!V7h8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724e1e79-fa18-47b5-ad9c-3cb4343950ac_2000x944.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!V7h8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724e1e79-fa18-47b5-ad9c-3cb4343950ac_2000x944.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A simple illustration of a p-n junction.</em></figcaption></figure></div><p>The field pushes any mobile electrons that wander into the depletion region back to the n-side. The result is a thin, poorly conductive depletion region at the boundary.</p><p>The field of a p-n junction can be offset by an externally-applied voltage; if we make the p-side sufficiently more positive than the n-side, some current will flow. In the case of silicon, the junction becomes markedly conductive when the forward voltage reaches about 600 mV, although microamp-range currents will be flowing sooner than that.</p><p>A conventional diode is just a p-n junction. The component can be thought of as a rudimentary voltage-controlled gate: when the voltage is below a certain threshold, it presents itself as a very high resistance &#8212; typically in excess of 100 k&#937; &#8212; so virtually no current can flow. When the threshold is cleared, the diode begins to admit more substantial currents. The V-I curve is initially exponential, but before long, the inherent resistance of the material begins to dominate. From that point on, the current has a roughly linear relationship with the &#8220;excess&#8221; applied voltage:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!No7s!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c1e763a-bb4d-4a7f-9890-43929b97e56d_2969x1250.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!No7s!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c1e763a-bb4d-4a7f-9890-43929b97e56d_2969x1250.png 424w, https://substackcdn.com/image/fetch/$s_!No7s!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c1e763a-bb4d-4a7f-9890-43929b97e56d_2969x1250.png 848w, https://substackcdn.com/image/fetch/$s_!No7s!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c1e763a-bb4d-4a7f-9890-43929b97e56d_2969x1250.png 1272w, https://substackcdn.com/image/fetch/$s_!No7s!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c1e763a-bb4d-4a7f-9890-43929b97e56d_2969x1250.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!No7s!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c1e763a-bb4d-4a7f-9890-43929b97e56d_2969x1250.png" width="1456" height="613" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5c1e763a-bb4d-4a7f-9890-43929b97e56d_2969x1250.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:613,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:107816,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c1e763a-bb4d-4a7f-9890-43929b97e56d_2969x1250.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!No7s!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c1e763a-bb4d-4a7f-9890-43929b97e56d_2969x1250.png 424w, https://substackcdn.com/image/fetch/$s_!No7s!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c1e763a-bb4d-4a7f-9890-43929b97e56d_2969x1250.png 848w, https://substackcdn.com/image/fetch/$s_!No7s!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c1e763a-bb4d-4a7f-9890-43929b97e56d_2969x1250.png 1272w, https://substackcdn.com/image/fetch/$s_!No7s!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c1e763a-bb4d-4a7f-9890-43929b97e56d_2969x1250.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>The plot of voltage to current for a forward-biased 1N4148 diode. By author.</em></figcaption></figure></div><p>My assertion that the V-I curve isn&#8217;t <em>really</em> exponential may be at odds with the conventional wisdom of EE textbooks, but the discrepancy is pretty clear to see in the plot that uses log scale for current (right). An exponential relationship between current and voltage would produce a straight line. In reality, the plot curls markedly past perhaps 10 mA.</p><p>So far, we discussed a condition known as <em>forward bias</em>. If the diode is reverse-biased &#8212; that is, if the p-side is more negative than the n-side &#8212; the component notionally remains nonconductive. Well&#8230; up to a point.</p><p>One of the possible reverse-bias scenarios is that if the reverse voltage becomes high enough, the electric field can accelerate the odd charge carrier in the depletion region to a point where the particle knocks other electrons into conduction band, producing an avalanche-like effect. The abundance of these kinetically-generated charge carriers makes the junction unexpectedly conductive again.</p><p>Most diodes are designed to keep this reverse breakdown voltage well outside the device&#8217;s intended operating range. A special category of components &#8212; known as <em>Zener diodes</em> &#8212; is engineered to exhibit reverse breakdown at lower, carefully calibrated voltages. Either way, once the threshold is exceeded, a reverse-biased diode starts conducting just fine:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!z6tM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90100c9e-817d-40ae-aae7-e989724a0a70_2344x1563.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!z6tM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90100c9e-817d-40ae-aae7-e989724a0a70_2344x1563.png 424w, https://substackcdn.com/image/fetch/$s_!z6tM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90100c9e-817d-40ae-aae7-e989724a0a70_2344x1563.png 848w, https://substackcdn.com/image/fetch/$s_!z6tM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90100c9e-817d-40ae-aae7-e989724a0a70_2344x1563.png 1272w, https://substackcdn.com/image/fetch/$s_!z6tM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90100c9e-817d-40ae-aae7-e989724a0a70_2344x1563.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!z6tM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90100c9e-817d-40ae-aae7-e989724a0a70_2344x1563.png" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/90100c9e-817d-40ae-aae7-e989724a0a70_2344x1563.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:63088,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90100c9e-817d-40ae-aae7-e989724a0a70_2344x1563.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!z6tM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90100c9e-817d-40ae-aae7-e989724a0a70_2344x1563.png 424w, https://substackcdn.com/image/fetch/$s_!z6tM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90100c9e-817d-40ae-aae7-e989724a0a70_2344x1563.png 848w, https://substackcdn.com/image/fetch/$s_!z6tM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90100c9e-817d-40ae-aae7-e989724a0a70_2344x1563.png 1272w, https://substackcdn.com/image/fetch/$s_!z6tM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90100c9e-817d-40ae-aae7-e989724a0a70_2344x1563.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>1N4148 diode in reverse bias. By author.</em></figcaption></figure></div><p>Now that we have the basic theory laid out, we can have a look at some of the common uses of diodes.</p><h3>Circuit protection</h3><p>About the simplest application of diodes is circuit protection. Let&#8217;s start with the arrangement shown on the left:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hWyO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6bcc435-2f8b-43f1-a4ca-a08f7dc6e004_2000x1424.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hWyO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6bcc435-2f8b-43f1-a4ca-a08f7dc6e004_2000x1424.jpeg 424w, https://substackcdn.com/image/fetch/$s_!hWyO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6bcc435-2f8b-43f1-a4ca-a08f7dc6e004_2000x1424.jpeg 848w, https://substackcdn.com/image/fetch/$s_!hWyO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6bcc435-2f8b-43f1-a4ca-a08f7dc6e004_2000x1424.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!hWyO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6bcc435-2f8b-43f1-a4ca-a08f7dc6e004_2000x1424.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hWyO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6bcc435-2f8b-43f1-a4ca-a08f7dc6e004_2000x1424.jpeg" width="1456" height="1037" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b6bcc435-2f8b-43f1-a4ca-a08f7dc6e004_2000x1424.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1037,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:424059,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6bcc435-2f8b-43f1-a4ca-a08f7dc6e004_2000x1424.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hWyO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6bcc435-2f8b-43f1-a4ca-a08f7dc6e004_2000x1424.jpeg 424w, https://substackcdn.com/image/fetch/$s_!hWyO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6bcc435-2f8b-43f1-a4ca-a08f7dc6e004_2000x1424.jpeg 848w, https://substackcdn.com/image/fetch/$s_!hWyO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6bcc435-2f8b-43f1-a4ca-a08f7dc6e004_2000x1424.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!hWyO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6bcc435-2f8b-43f1-a4ca-a08f7dc6e004_2000x1424.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Several diode-based circuit protection schemes.</em></figcaption></figure></div><p>In the first circuit, a Zener-type diode is placed in reverse bias between a protected line and the ground. The diode remains non-conductive under normal operating conditions, but experiences electrical breakdown &#8212; and thus temporarily starts conducting &#8212; when the input voltage exceeds a safe limit. In effect, the diode acts as a crowbar that dissipates energy and protects more delicate components downstream. Diodes designed for this purpose are often marketed as <em>transient voltage suppressors</em> (TVS) and are particularly important for protecting semiconductors against static discharge. Another application is the suppression of voltage spikes that happen when we abruptly cut the current supplied to motors and other inductive loads.</p><p>A single diode can only be used to protect inputs where the input signal has a defined polarity &#8211; that is, where one rail is always more positive than the other. To provide overvoltage protection for AC signals with alternating polarity, we instead rely a two-diode arrangement shown on the right in the illustration above. This arrangement of components is also available in a single package known as a <em>bidirectional TVS</em>. </p><p>In the latter circuit, regardless of the polarity of the applied voltage, the &#8220;crowbar&#8221; path always consists of a forward-biased diode in series with a reverse-biased one. It follows that positive and negative conduction thresholds are the same: they&#8217;re equal to the diode&#8217;s reverse-bias breakdown voltage, plus roughly 600 mV.</p><p>Yet another protection technique is shown in the bottom panel. A regular forward-biased diode with a high reverse breakdown voltage is placed in series with the supply; this arrangement prevents damage to sensitive components if the polarity of the supply is accidentally reversed, for example if the batteries are inserted the wrong way. The trade-off is the inevitable voltage drop across the p-n junction, along with resistive heating if the current is high, so a transistor-based solution is typically preferred, especially in low-voltage circuits.</p><h3>Diodes as voltage references</h3><p>As mentioned earlier, most diodes are designed to withstand very high reverse-bias voltages, often in excess of -100 V; that said, a special category of products &#8212; Zener diodes &#8212; is designed to start conducting earlier than that.</p><p>When forward-biased, such a diode behaves the same as its conventional counterpart, becoming markedly conductive around 600 mV. When reverse-biased, it starts conducting at a higher voltage of manufacturer&#8217;s choice, with common options ranging from 1.8 V to 30 V.</p><p>The V-I plots shown earlier in the article tell us that once reverse breakdown begins, a small change in the applied voltage can produce a comparatively large swing in the current flowing through. We can also look at it another way: if the current through the diode is limited in some way, fluctuations in that current will have a comparatively minor effect on the voltage that develops across the diode&#8217;s terminals.</p><p>This observation lends itself to the use of diodes as voltage references. We take an unregulated power supply &#8212; for example, a battery &#8212; and in the simplest variant, use a resistor to roughly limit the current flowing through the diode. Depending on the voltage you want, you can use one or more forward-biased diodes, a reverse-biased Zener diode, or some combination thereof.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fTlS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e2e932-f55e-4aa1-9cf8-cb62afd70679_2000x1000.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fTlS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e2e932-f55e-4aa1-9cf8-cb62afd70679_2000x1000.jpeg 424w, https://substackcdn.com/image/fetch/$s_!fTlS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e2e932-f55e-4aa1-9cf8-cb62afd70679_2000x1000.jpeg 848w, https://substackcdn.com/image/fetch/$s_!fTlS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e2e932-f55e-4aa1-9cf8-cb62afd70679_2000x1000.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!fTlS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e2e932-f55e-4aa1-9cf8-cb62afd70679_2000x1000.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fTlS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e2e932-f55e-4aa1-9cf8-cb62afd70679_2000x1000.jpeg" width="1456" height="728" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/68e2e932-f55e-4aa1-9cf8-cb62afd70679_2000x1000.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:728,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:242217,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e2e932-f55e-4aa1-9cf8-cb62afd70679_2000x1000.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fTlS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e2e932-f55e-4aa1-9cf8-cb62afd70679_2000x1000.jpeg 424w, https://substackcdn.com/image/fetch/$s_!fTlS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e2e932-f55e-4aa1-9cf8-cb62afd70679_2000x1000.jpeg 848w, https://substackcdn.com/image/fetch/$s_!fTlS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e2e932-f55e-4aa1-9cf8-cb62afd70679_2000x1000.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!fTlS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e2e932-f55e-4aa1-9cf8-cb62afd70679_2000x1000.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A simple diode-based voltage reference.</em></figcaption></figure></div><p>From Ohm&#8217;s law, the current admitted by the resistor will change linearly with the supply voltage (I = V/R), but these current fluctuations affect the diode voltage to a much lower extent. Here&#8217;s an experimental plot for the circuit constructed with a <a href="https://www.onsemi.com/pdf/datasheet/1n4736at-d.pdf">1N4733</a> diode and a 100 &#937; resistor:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jdAk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fa22eab-3608-47aa-94c0-fc3da860abd3_2813x1875.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jdAk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fa22eab-3608-47aa-94c0-fc3da860abd3_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!jdAk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fa22eab-3608-47aa-94c0-fc3da860abd3_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!jdAk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fa22eab-3608-47aa-94c0-fc3da860abd3_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!jdAk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fa22eab-3608-47aa-94c0-fc3da860abd3_2813x1875.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jdAk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fa22eab-3608-47aa-94c0-fc3da860abd3_2813x1875.png" width="1456" height="970" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9fa22eab-3608-47aa-94c0-fc3da860abd3_2813x1875.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:970,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:99939,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fa22eab-3608-47aa-94c0-fc3da860abd3_2813x1875.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!jdAk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fa22eab-3608-47aa-94c0-fc3da860abd3_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!jdAk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fa22eab-3608-47aa-94c0-fc3da860abd3_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!jdAk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fa22eab-3608-47aa-94c0-fc3da860abd3_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!jdAk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fa22eab-3608-47aa-94c0-fc3da860abd3_2813x1875.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>The behavior of a voltage reference with a 1N4733 diode. By author.</em></figcaption></figure></div><p>The swing of the output voltage is under 5% of the fluctuations of the input signal: 45 mV versus 1 V. This figure might not sound particularly impressive, but the circuit can be cascaded: the output of one resistor-diode voltage reference can be used as the supply voltage for a second one. The effects stack up: 5% of 5% is equal to 0.25%.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zqkQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7aca00-0b13-4795-9afe-67762faae540_2000x1476.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zqkQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7aca00-0b13-4795-9afe-67762faae540_2000x1476.jpeg 424w, https://substackcdn.com/image/fetch/$s_!zqkQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7aca00-0b13-4795-9afe-67762faae540_2000x1476.jpeg 848w, https://substackcdn.com/image/fetch/$s_!zqkQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7aca00-0b13-4795-9afe-67762faae540_2000x1476.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!zqkQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7aca00-0b13-4795-9afe-67762faae540_2000x1476.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zqkQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7aca00-0b13-4795-9afe-67762faae540_2000x1476.jpeg" width="1456" height="1075" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0e7aca00-0b13-4795-9afe-67762faae540_2000x1476.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1075,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:431218,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7aca00-0b13-4795-9afe-67762faae540_2000x1476.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!zqkQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7aca00-0b13-4795-9afe-67762faae540_2000x1476.jpeg 424w, https://substackcdn.com/image/fetch/$s_!zqkQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7aca00-0b13-4795-9afe-67762faae540_2000x1476.jpeg 848w, https://substackcdn.com/image/fetch/$s_!zqkQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7aca00-0b13-4795-9afe-67762faae540_2000x1476.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!zqkQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7aca00-0b13-4795-9afe-67762faae540_2000x1476.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A cascaded voltage reference.</em></figcaption></figure></div><p>Of course, the Zener voltage of the first diode should be higher than the second one. Further, for the cascaded layout to behave correctly, we need to make sure that the current siphoned off by the second stage is much lower than the current flowing through the intended resistor-diode path. One way to ensure this property is to choose R1 &#8810; R2. Another solution is to separate the stages with a transistor circuit that mirrors the output voltage of stage 1 for use by stage 2; such voltage follower circuits are <a href="https://lcamtuf.substack.com/p/the-basics-of-signal-amplification">discussed here</a>.</p><p>Nowadays, more complex transistor-based circuits with temperature compensation are favored for precision applications. Nevertheless, a Zener diode still offers a viable a solution in a pinch.</p><h3>Rectifiers and envelope followers</h3><p>Let&#8217;s consider the circuit shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xCep!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd95bf337-c830-4ff0-b047-c2800b598ea9_2000x618.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xCep!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd95bf337-c830-4ff0-b047-c2800b598ea9_2000x618.jpeg 424w, https://substackcdn.com/image/fetch/$s_!xCep!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd95bf337-c830-4ff0-b047-c2800b598ea9_2000x618.jpeg 848w, https://substackcdn.com/image/fetch/$s_!xCep!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd95bf337-c830-4ff0-b047-c2800b598ea9_2000x618.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!xCep!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd95bf337-c830-4ff0-b047-c2800b598ea9_2000x618.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xCep!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd95bf337-c830-4ff0-b047-c2800b598ea9_2000x618.jpeg" width="1456" height="450" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d95bf337-c830-4ff0-b047-c2800b598ea9_2000x618.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:450,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:417670,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd95bf337-c830-4ff0-b047-c2800b598ea9_2000x618.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!xCep!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd95bf337-c830-4ff0-b047-c2800b598ea9_2000x618.jpeg 424w, https://substackcdn.com/image/fetch/$s_!xCep!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd95bf337-c830-4ff0-b047-c2800b598ea9_2000x618.jpeg 848w, https://substackcdn.com/image/fetch/$s_!xCep!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd95bf337-c830-4ff0-b047-c2800b598ea9_2000x618.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!xCep!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd95bf337-c830-4ff0-b047-c2800b598ea9_2000x618.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A simple rectifier.</em></figcaption></figure></div><p>This circuit is called a <em>half-wave rectifier. </em>The analysis is the easiest if we reference all circuit voltages to the bottom output leg marked as B, and then evaluate the positive half-cycle of the input AC waveform separately from the negative half-cycle:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YNma!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b046b4e-7d65-40ee-80f5-5678d9fc9e0c_2000x800.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YNma!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b046b4e-7d65-40ee-80f5-5678d9fc9e0c_2000x800.jpeg 424w, https://substackcdn.com/image/fetch/$s_!YNma!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b046b4e-7d65-40ee-80f5-5678d9fc9e0c_2000x800.jpeg 848w, https://substackcdn.com/image/fetch/$s_!YNma!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b046b4e-7d65-40ee-80f5-5678d9fc9e0c_2000x800.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!YNma!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b046b4e-7d65-40ee-80f5-5678d9fc9e0c_2000x800.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YNma!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b046b4e-7d65-40ee-80f5-5678d9fc9e0c_2000x800.jpeg" width="1456" height="582" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1b046b4e-7d65-40ee-80f5-5678d9fc9e0c_2000x800.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:582,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:233723,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b046b4e-7d65-40ee-80f5-5678d9fc9e0c_2000x800.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!YNma!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b046b4e-7d65-40ee-80f5-5678d9fc9e0c_2000x800.jpeg 424w, https://substackcdn.com/image/fetch/$s_!YNma!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b046b4e-7d65-40ee-80f5-5678d9fc9e0c_2000x800.jpeg 848w, https://substackcdn.com/image/fetch/$s_!YNma!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b046b4e-7d65-40ee-80f5-5678d9fc9e0c_2000x800.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!YNma!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b046b4e-7d65-40ee-80f5-5678d9fc9e0c_2000x800.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A simplified analysis of the half-wave rectifier (w/o diode voltage drops).</em></figcaption></figure></div><p>During the positive half-cycle of a sine wave &#8211; when the upper terminal of the supply sits at a higher voltage &#8211; the diode is initially forward-biased. Assuming a low-impedance signal source, this allows the capacitor to charge to a voltage equal to the peak amplitude of the input signal, minus some diode voltage drop. </p><p>When the polarity of the signal is reversed &#8211; making the upper supply terminal more negative &#8211; the diode becomes reverse-biased and doesn&#8217;t conduct, so the capacitor holds charge. The following is a discrete-time simulation of the process; I added a modest resistive load across the output terminals to discharge the capacitor slightly in between each positive peak:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5u6j!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1b521-3672-4749-825c-b7850f4da734_2813x1875.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5u6j!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1b521-3672-4749-825c-b7850f4da734_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!5u6j!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1b521-3672-4749-825c-b7850f4da734_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!5u6j!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1b521-3672-4749-825c-b7850f4da734_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!5u6j!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1b521-3672-4749-825c-b7850f4da734_2813x1875.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5u6j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1b521-3672-4749-825c-b7850f4da734_2813x1875.png" width="1456" height="970" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/72d1b521-3672-4749-825c-b7850f4da734_2813x1875.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:970,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:115534,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1b521-3672-4749-825c-b7850f4da734_2813x1875.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5u6j!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1b521-3672-4749-825c-b7850f4da734_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!5u6j!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1b521-3672-4749-825c-b7850f4da734_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!5u6j!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1b521-3672-4749-825c-b7850f4da734_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!5u6j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72d1b521-3672-4749-825c-b7850f4da734_2813x1875.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A simulation of a half-wave rectifier. By author.</em></figcaption></figure></div><p>If the load resistor is made a permanent part of the circuit and if it&#8217;s chosen so that the capacitor discharges quickly enough to keep up with the amplitude modulation of a carrier wave, we get a circuit known as the <em>envelope follower</em>. The circuit is a simple way to extract the approximate modulating waveform from the carrier signal in AM radio circuits:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WccL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6d1ca18-a8e2-48a1-b7cf-65f1c3c042c8_2813x1875.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WccL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6d1ca18-a8e2-48a1-b7cf-65f1c3c042c8_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!WccL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6d1ca18-a8e2-48a1-b7cf-65f1c3c042c8_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!WccL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6d1ca18-a8e2-48a1-b7cf-65f1c3c042c8_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!WccL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6d1ca18-a8e2-48a1-b7cf-65f1c3c042c8_2813x1875.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WccL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6d1ca18-a8e2-48a1-b7cf-65f1c3c042c8_2813x1875.png" width="1456" height="970" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f6d1ca18-a8e2-48a1-b7cf-65f1c3c042c8_2813x1875.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:970,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:197364,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6d1ca18-a8e2-48a1-b7cf-65f1c3c042c8_2813x1875.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WccL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6d1ca18-a8e2-48a1-b7cf-65f1c3c042c8_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!WccL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6d1ca18-a8e2-48a1-b7cf-65f1c3c042c8_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!WccL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6d1ca18-a8e2-48a1-b7cf-65f1c3c042c8_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!WccL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6d1ca18-a8e2-48a1-b7cf-65f1c3c042c8_2813x1875.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>A simulation of an envelope follower. By author.</em></figcaption></figure></div><p>The same principle can be used if we want to build a circuit that measures the approximate loudness of an audio signal, or more generally, hones in on the slow-changing component of any composite waveform.</p><p>The drawback of the half-wave rectifier is that the capacitor is only charged by the positive half-cycle of the sine wave; this is wasteful if the goal is to maximize the power delivered to a load. This deficiency can be addressed by constructing a <em>full-wave rectifier</em>, shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wFQo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ba4b808-4170-4b52-9e77-e08f373bfeb4_2000x900.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wFQo!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ba4b808-4170-4b52-9e77-e08f373bfeb4_2000x900.jpeg 424w, https://substackcdn.com/image/fetch/$s_!wFQo!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ba4b808-4170-4b52-9e77-e08f373bfeb4_2000x900.jpeg 848w, https://substackcdn.com/image/fetch/$s_!wFQo!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ba4b808-4170-4b52-9e77-e08f373bfeb4_2000x900.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!wFQo!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ba4b808-4170-4b52-9e77-e08f373bfeb4_2000x900.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wFQo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ba4b808-4170-4b52-9e77-e08f373bfeb4_2000x900.jpeg" width="1456" height="655" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5ba4b808-4170-4b52-9e77-e08f373bfeb4_2000x900.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:655,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:604668,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ba4b808-4170-4b52-9e77-e08f373bfeb4_2000x900.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wFQo!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ba4b808-4170-4b52-9e77-e08f373bfeb4_2000x900.jpeg 424w, https://substackcdn.com/image/fetch/$s_!wFQo!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ba4b808-4170-4b52-9e77-e08f373bfeb4_2000x900.jpeg 848w, https://substackcdn.com/image/fetch/$s_!wFQo!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ba4b808-4170-4b52-9e77-e08f373bfeb4_2000x900.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!wFQo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ba4b808-4170-4b52-9e77-e08f373bfeb4_2000x900.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Full-wave rectifier.</em></figcaption></figure></div><p>Once again, the analysis of the circuit is the simplest if we consider output B to be the reference point:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!n-oj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9df55c-f69e-4538-b13b-5d9e08c0ef56_2000x972.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!n-oj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9df55c-f69e-4538-b13b-5d9e08c0ef56_2000x972.jpeg 424w, https://substackcdn.com/image/fetch/$s_!n-oj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9df55c-f69e-4538-b13b-5d9e08c0ef56_2000x972.jpeg 848w, https://substackcdn.com/image/fetch/$s_!n-oj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9df55c-f69e-4538-b13b-5d9e08c0ef56_2000x972.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!n-oj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9df55c-f69e-4538-b13b-5d9e08c0ef56_2000x972.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!n-oj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9df55c-f69e-4538-b13b-5d9e08c0ef56_2000x972.jpeg" width="1456" height="708" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4d9df55c-f69e-4538-b13b-5d9e08c0ef56_2000x972.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:708,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:779246,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9df55c-f69e-4538-b13b-5d9e08c0ef56_2000x972.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!n-oj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9df55c-f69e-4538-b13b-5d9e08c0ef56_2000x972.jpeg 424w, https://substackcdn.com/image/fetch/$s_!n-oj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9df55c-f69e-4538-b13b-5d9e08c0ef56_2000x972.jpeg 848w, https://substackcdn.com/image/fetch/$s_!n-oj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9df55c-f69e-4538-b13b-5d9e08c0ef56_2000x972.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!n-oj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9df55c-f69e-4538-b13b-5d9e08c0ef56_2000x972.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Simplified analysis of the full-wave rectifier (w/o diode voltage drops).</em></figcaption></figure></div><p>During the positive half-cycle, diodes D1 and D2 are initially forward-biased; this allows the capacitor to charge to the AC peak voltage (minus the summed voltage drop of two diodes). During the negative half-cycle, diodes D3 and D4 become forward-biased, which connects the output B to the upper supply terminal. Meanwhile, the bottom supply terminal, which is currently at a higher voltage, is connected to point A. This allows the capacitor to continue charging in the same polarity as before.</p><p>A simulation of the process is shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!uFAm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F059f744e-57d4-4215-a7de-2c9ebe78f67f_2813x1875.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!uFAm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F059f744e-57d4-4215-a7de-2c9ebe78f67f_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!uFAm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F059f744e-57d4-4215-a7de-2c9ebe78f67f_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!uFAm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F059f744e-57d4-4215-a7de-2c9ebe78f67f_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!uFAm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F059f744e-57d4-4215-a7de-2c9ebe78f67f_2813x1875.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!uFAm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F059f744e-57d4-4215-a7de-2c9ebe78f67f_2813x1875.png" width="1456" height="970" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/059f744e-57d4-4215-a7de-2c9ebe78f67f_2813x1875.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:970,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:123337,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F059f744e-57d4-4215-a7de-2c9ebe78f67f_2813x1875.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!uFAm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F059f744e-57d4-4215-a7de-2c9ebe78f67f_2813x1875.png 424w, https://substackcdn.com/image/fetch/$s_!uFAm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F059f744e-57d4-4215-a7de-2c9ebe78f67f_2813x1875.png 848w, https://substackcdn.com/image/fetch/$s_!uFAm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F059f744e-57d4-4215-a7de-2c9ebe78f67f_2813x1875.png 1272w, https://substackcdn.com/image/fetch/$s_!uFAm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F059f744e-57d4-4215-a7de-2c9ebe78f67f_2813x1875.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>The behavior of a full-wave rectifier. By author.</em></figcaption></figure></div><h3>Voltage doublers</h3><p>The rectifier circuits outlined in the preceding section use diodes as voltage-controlled switches. Another application of the same principle is a circuit known as the <em>voltage doubler</em>.</p><p>There are many flavors of voltage doublers, but one particularly clean design is shown below. The circuit outputs a DC voltage that is equal to twice the peak amplitude of the zero-centered input waveform, minus the usual diode voltage drops. This in contrast to the rectifier circuits discussed earlier on, which only produce DC voltages in the vicinity of the peak amplitude:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!apiW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb56d71-e579-4152-8775-fff1d9c61424_2000x1776.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!apiW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb56d71-e579-4152-8775-fff1d9c61424_2000x1776.jpeg 424w, https://substackcdn.com/image/fetch/$s_!apiW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb56d71-e579-4152-8775-fff1d9c61424_2000x1776.jpeg 848w, https://substackcdn.com/image/fetch/$s_!apiW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb56d71-e579-4152-8775-fff1d9c61424_2000x1776.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!apiW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb56d71-e579-4152-8775-fff1d9c61424_2000x1776.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!apiW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb56d71-e579-4152-8775-fff1d9c61424_2000x1776.jpeg" width="1456" height="1293" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0cb56d71-e579-4152-8775-fff1d9c61424_2000x1776.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1293,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1230722,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb56d71-e579-4152-8775-fff1d9c61424_2000x1776.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!apiW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb56d71-e579-4152-8775-fff1d9c61424_2000x1776.jpeg 424w, https://substackcdn.com/image/fetch/$s_!apiW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb56d71-e579-4152-8775-fff1d9c61424_2000x1776.jpeg 848w, https://substackcdn.com/image/fetch/$s_!apiW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb56d71-e579-4152-8775-fff1d9c61424_2000x1776.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!apiW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0cb56d71-e579-4152-8775-fff1d9c61424_2000x1776.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Analysis of a voltage doubler (neglecting diode voltage drops).</em></figcaption></figure></div><p>This time, let&#8217;s use use the midpoint between the two capacitors as the reference point for voltage measurements. During the positive half-cycle of the AC signal (panel on the left), the upper diode (D1) can conduct to charge the top capacitor. This puts the output terminal A at a positive voltage in relation to the midpoint.</p><p>Next, let&#8217;s have a look at the negative half-cycle (right). In this scenario, the top diode is always reverse-biased, so it doesn&#8217;t conduct; C1 retains charge. At the same time, conduction is possible for the lower diode D2, which charges C2 so that the output terminal B ends up at a negative voltage in relation to the midpoint. In effect, we store the positive peak voltage of the input waveform in C1 and the negative maximum in C2. The total voltage between B and A is <em>V<sub>peak </sub></em>&#183; 2 (once again, minus the expected diode voltage drops).</p><p>This method of multiplying voltages with switched capacitors lives on, although modern circuits typically use digitally-controlled transistors instead of diodes; this avoids voltage drops and eliminates the need for an AC voltage supply. If you&#8217;re interested in such circuits, I have a separate article <a href="https://lcamtuf.substack.com/p/the-magic-of-dc-dc-voltage-conversion">here</a>.</p><h3>DC restorers</h3><p>Most of the time, alternating waveforms that are centered around zero volts are inconvenient to work with; in particular, it&#8217;s more challenging to build circuits that run off a single voltage supply but that are able to discern, amplify, or generate signals that extend below the negative supply rail.</p><p>This brings us to a somewhat mind-bending alternative approach. The circuit is known as a <em>clamper &#8211;</em> or, less cryptically, as a <em>DC restorer</em>. It takes an AC waveform and shifts it so that the negative peaks are at roughly zero volts, with no appreciable impact on signal amplitude:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SgSI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8f1ed7-8909-46fc-b6fc-5149daef7ad3_2000x2100.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SgSI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8f1ed7-8909-46fc-b6fc-5149daef7ad3_2000x2100.jpeg 424w, https://substackcdn.com/image/fetch/$s_!SgSI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8f1ed7-8909-46fc-b6fc-5149daef7ad3_2000x2100.jpeg 848w, https://substackcdn.com/image/fetch/$s_!SgSI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8f1ed7-8909-46fc-b6fc-5149daef7ad3_2000x2100.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!SgSI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8f1ed7-8909-46fc-b6fc-5149daef7ad3_2000x2100.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SgSI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8f1ed7-8909-46fc-b6fc-5149daef7ad3_2000x2100.jpeg" width="1456" height="1529" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9b8f1ed7-8909-46fc-b6fc-5149daef7ad3_2000x2100.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1529,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1376599,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8f1ed7-8909-46fc-b6fc-5149daef7ad3_2000x2100.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!SgSI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8f1ed7-8909-46fc-b6fc-5149daef7ad3_2000x2100.jpeg 424w, https://substackcdn.com/image/fetch/$s_!SgSI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8f1ed7-8909-46fc-b6fc-5149daef7ad3_2000x2100.jpeg 848w, https://substackcdn.com/image/fetch/$s_!SgSI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8f1ed7-8909-46fc-b6fc-5149daef7ad3_2000x2100.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!SgSI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8f1ed7-8909-46fc-b6fc-5149daef7ad3_2000x2100.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>An analysis of the clamper circuit (neglecting diode voltage drops).</em></figcaption></figure></div><p>For now, let&#8217;s ignore the optional resistor. We start with the first positive half-cycle of the input sine wave (top left). Initially, the capacitor is not charged (<em>V<sub>cap</sub></em> = 0 V); further, there&#8217;s no current path via the diode, so charging is not possible. To elaborate: for energy to be stored in a capacitor, there must be a symmetry in the motion of charges flowing onto and off the plates. This way, the resulting electrostatic fields &#8211; increasingly positive on one plate and increasingly negative on another &#8211; largely cancel out, allowing a non-trivial charge to be moved with the help of a modest voltage.</p><p>If one of the capacitor&#8217;s is left floating, the device can&#8217;t be charged or discharged; instead, its previous charge state persists as a voltage across its terminals. If we take a capacitor charged to 1 V and connect one of its legs to a 10 V supply, the other leg will read 11 V in reference to the ground. If we connect it to a -5 V supply, we&#8217;ll get a reading of -4 V. It&#8217;s no different from putting a battery in series with another voltage source. In our circuit, the initial <em>V<sub>cap</sub></em> = 0 V, so in the positive half-cycle, the capacitor adds nothing, and the voltage on the output leg A simply follows the input waveform.</p><p>In the following negative half-cycle, once the voltage at point A reaches about -600 mV, the diode starts to conduct (top right). This clamps the voltage at point A while simultaneously allowing the capacitor to charge so that its left terminal becomes negative in relation to the right terminal. If we measure <em>V<sub>cap</sub></em> left to right, the resulting voltage is positive and is equal to the peak amplitude of the supply signal (minus the diode voltage drop).</p><p>In the subsequent positive cycle, the diode becomes reverse-biased again, so the capacitor must hold its previous charge; this means that <em>V<sub>cap</sub></em> remains unchanged and that the voltage at point A is necessarily offset from the input waveform by that amount. If the input waveform runs -<em>V<sub>peak</sub></em> to +<em>V<sub>peak</sub></em>, the output will be now moving from roughly -600 mV to <em>V<sub>peak </sub></em>&#183; 2 &#8211; 600 mV.</p><p>The role of the optional load resistor is that it controls the circuit&#8217;s ability to respond to gradual shifts in signal amplitude. Without it, the circuit would theoretically be stuck forever at a voltage offset dictated by the largest encountered single-cycle swing in the input waveform. With a resistor, the capacitor can discharge over time, so the offset can change if the envelope of the waveform changes in some way.</p><p>In practice, the diode&#8217;s leakage current and the capacitor&#8217;s self-discharge rate are typically enough to make the circuit behave reasonably even without an output resistance. If you wish to play around with this layout, I recommend using a 10-100 &#181;F capacitor and either skipping the resistor or using a large one (1 M&#937;).</p><h3>Diode-based logic</h3><p>An OR gate is a circuit with two or more inputs that produces a positive voltage when any of the inputs is positive. An AND gate, in contrast, outputs a positive signal only if <em>all </em>the inputs are positive. Many readers are probably familiar with the application of this concept in computing, but more simply: a practical application of an OR gate might be a circuit that raises alarm if any of the door or window sensors are triggered. An application of an AND gate might be a system that illuminates a &#8220;PARKING FULL&#8221; sign when all the spots are occupied.</p><p>There are simple ways to implement this logic with diodes:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_AMD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b7c587-5212-4f78-8ff6-a2f5fd50174f_2000x850.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_AMD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b7c587-5212-4f78-8ff6-a2f5fd50174f_2000x850.jpeg 424w, https://substackcdn.com/image/fetch/$s_!_AMD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b7c587-5212-4f78-8ff6-a2f5fd50174f_2000x850.jpeg 848w, https://substackcdn.com/image/fetch/$s_!_AMD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b7c587-5212-4f78-8ff6-a2f5fd50174f_2000x850.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!_AMD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b7c587-5212-4f78-8ff6-a2f5fd50174f_2000x850.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_AMD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b7c587-5212-4f78-8ff6-a2f5fd50174f_2000x850.jpeg" width="1456" height="619" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/33b7c587-5212-4f78-8ff6-a2f5fd50174f_2000x850.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:619,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:666222,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b7c587-5212-4f78-8ff6-a2f5fd50174f_2000x850.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_AMD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b7c587-5212-4f78-8ff6-a2f5fd50174f_2000x850.jpeg 424w, https://substackcdn.com/image/fetch/$s_!_AMD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b7c587-5212-4f78-8ff6-a2f5fd50174f_2000x850.jpeg 848w, https://substackcdn.com/image/fetch/$s_!_AMD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b7c587-5212-4f78-8ff6-a2f5fd50174f_2000x850.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!_AMD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b7c587-5212-4f78-8ff6-a2f5fd50174f_2000x850.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Logic pseudo-gates constructed with diodes.</em></figcaption></figure></div><p>In the case of an OR circuit (left), if the positive supply rail is connected to any of the input terminals, this forward-biases the corresponding diode and causes a current to flow through a resistor. Because the impedance of a forward-biased diode is much lower than that of a 10 k&#937; resistor, the output voltage shoots up very close to the upper supply rail.</p><p>The AND circuit (right) essentially works in reverse: if any of the inputs is connected to the ground, this pulls the output voltage close to 0 V, so the output is positive only if both inputs are high (or are left floating).</p><p>The reason I put &#8220;gate&#8221; in scare quotes in the illustration is that the circuits are not readily composable to implement more complex digital logic; each of the gates requires current to flow through the input terminals, but it can&#8217;t necessarily deliver such currents on its output leg. A particularly troublesome situation is shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OMVS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d61c993-8575-485e-b971-3fce68430110_2000x1050.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OMVS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d61c993-8575-485e-b971-3fce68430110_2000x1050.jpeg 424w, https://substackcdn.com/image/fetch/$s_!OMVS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d61c993-8575-485e-b971-3fce68430110_2000x1050.jpeg 848w, https://substackcdn.com/image/fetch/$s_!OMVS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d61c993-8575-485e-b971-3fce68430110_2000x1050.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!OMVS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d61c993-8575-485e-b971-3fce68430110_2000x1050.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OMVS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d61c993-8575-485e-b971-3fce68430110_2000x1050.jpeg" width="1456" height="764" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6d61c993-8575-485e-b971-3fce68430110_2000x1050.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:764,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:761335,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/177769958?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d61c993-8575-485e-b971-3fce68430110_2000x1050.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OMVS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d61c993-8575-485e-b971-3fce68430110_2000x1050.jpeg 424w, https://substackcdn.com/image/fetch/$s_!OMVS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d61c993-8575-485e-b971-3fce68430110_2000x1050.jpeg 848w, https://substackcdn.com/image/fetch/$s_!OMVS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d61c993-8575-485e-b971-3fce68430110_2000x1050.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!OMVS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d61c993-8575-485e-b971-3fce68430110_2000x1050.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Trying to cascade diode-based gates.</em></figcaption></figure></div><p>With the input signals as indicated in the drawing, three out of four diodes are reverse-biased; the only current path is the series resistor-diode-resistor connection between the positive supply rail and the ground. The circuit is essentially a resistor-based voltage divider; instead of providing a binary output, it produces an ambiguous intermediate voltage.</p><p>In other words, the solution works for single-step logic; to build real computers, we&#8217;d need gates that can deliver output currents higher than what they demand as input of the gates upstream.</p><h1 style="text-align: center;">&#128214;</h1><p style="text-align: center;">If you liked the article, you&#8217;ll enjoy <em><a href="https://lcamtuf.coredump.cx/electronics/">The Secret Life of Circuits</a></em>. It&#8217;s a richly illustrated, lucid introduction to electronics &#8212; from the physics of conduction to embedded system programming. It features 290+ color diagrams, 420+ pages of original content, and zero AI.</p><div><hr></div><p><em>&#128073;  For further articles about electronics, <a href="https://lcamtuf.substack.com/p/electronics-curriculum">click here</a>. In particular, you might enjoy:</em></p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;0d2bcb0c-6d59-491c-88c5-3cebebe558be&quot;,&quot;caption&quot;:&quot;As a computer geek, I never had much trouble navigating the world of microcontrollers and logic gates. Analog circuitry proved to be a different animal. For a good while, I resigned myself to copying other people&#8217;s designs and going on wild-goose chases to procure long-obsolete parts that cropped up on the schematics.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;The basics of signal amplification&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-02-07T04:19:37.878Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5d90fe4d-706c-471d-b675-933c27cbcaa5_1600x900.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/the-basics-of-signal-amplification&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:100766694,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:30,&quot;comment_count&quot;:1,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;6e171983-1aae-4b4d-8a73-83f44875ccfa&quot;,&quot;caption&quot;:&quot;Signal filters are ubiquitous in electronics; on this blog alone, they cropped up in articles on digital-to-analog converters, radio receivers, audio amplifiers, and probably more.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;The 101 of analog signal filtering&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2024-07-12T06:03:10.737Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a762ad17-121b-4004-988d-91f06c17f21c_600x400.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/the-101-of-analog-signal-filtering&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:145747074,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:27,&quot;comment_count&quot;:6,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;2436339a-7faf-4fcf-8056-6c6b8816b136&quot;,&quot;caption&quot;:&quot;In the spring of 2023, when this Substack had only a handful of subscribers, I posted a primer on voltage adjustment in electronic circuits. The article opened with a brief discussion of linear regulators, and then promptly threw them under the bus in favor of more efficient charge pumps and inductor-based topologies.&quot;,&quot;cta&quot;:&quot;Read full story&quot;,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Cursed circuits: charge pump voltage halver&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:92541588,&quot;name&quot;:&quot;lcamtuf&quot;,&quot;bio&quot;:&quot;Recommended by 4 out of 5 dentists.&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/160026b1-f333-4244-b8dc-5ca8c437a0b4_400x400.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2025-12-02T00:00:03.420Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/$s_!dYf0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee204afd-e44f-4f24-ac6f-d387282f4a3f_2000x1038.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://lcamtuf.substack.com/p/cursed-circuits-charge-pump-voltage&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:180429933,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:24,&quot;comment_count&quot;:0,&quot;publication_id&quot;:1030211,&quot;publication_name&quot;:&quot;lcamtuf&#8217;s thing&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!WvGP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F57b73d90-d717-4de9-bfb7-30a0f2913607_400x400.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p><em>I write well-researched, original articles about geek culture, electronic circuit design, algorithms, and more. If you like the content, please subscribe.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[Weekend projects: Chicken Squisher 3000]]></title><description><![CDATA[If it clucks like a duck...]]></description><link>https://lcamtuf.substack.com/p/weekend-projects-chicken-squisher</link><guid isPermaLink="false">https://lcamtuf.substack.com/p/weekend-projects-chicken-squisher</guid><dc:creator><![CDATA[lcamtuf]]></dc:creator><pubDate>Tue, 14 Oct 2025 06:08:20 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!15vm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6094e9-0bdc-404b-b102-323ac5cc6c6b_2000x1334.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This summer, I built a relatively big, walk-in chicken coop. We <a href="https://lcamtuf.substack.com/p/dispatches-from-the-farm-upstate">live in a place</a> with grizzlies, mountain lions, and fairly harsh winters, so the structure is a bit overengineered. It has double walls, double-pane windows (built by my wife), four electric outlets, and an electric fence that surrounds the outer &#8220;run&#8221;, which would be otherwise protected only by some 19 gauge steel mesh:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fwjB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4490e32c-15bf-4278-be26-19b146dea3db_1800x1137.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fwjB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4490e32c-15bf-4278-be26-19b146dea3db_1800x1137.jpeg 424w, https://substackcdn.com/image/fetch/$s_!fwjB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4490e32c-15bf-4278-be26-19b146dea3db_1800x1137.jpeg 848w, https://substackcdn.com/image/fetch/$s_!fwjB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4490e32c-15bf-4278-be26-19b146dea3db_1800x1137.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!fwjB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4490e32c-15bf-4278-be26-19b146dea3db_1800x1137.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fwjB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4490e32c-15bf-4278-be26-19b146dea3db_1800x1137.jpeg" width="1456" height="920" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4490e32c-15bf-4278-be26-19b146dea3db_1800x1137.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:920,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:958347,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/176090309?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4490e32c-15bf-4278-be26-19b146dea3db_1800x1137.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fwjB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4490e32c-15bf-4278-be26-19b146dea3db_1800x1137.jpeg 424w, https://substackcdn.com/image/fetch/$s_!fwjB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4490e32c-15bf-4278-be26-19b146dea3db_1800x1137.jpeg 848w, https://substackcdn.com/image/fetch/$s_!fwjB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4490e32c-15bf-4278-be26-19b146dea3db_1800x1137.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!fwjB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4490e32c-15bf-4278-be26-19b146dea3db_1800x1137.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>The coop.</em></figcaption></figure></div><p>The feature we regretted not incorporating from the get go was an automatic inner door for the fully-enclosed box where the chickens nest and sleep at night. This would have allowed us to leave for a couple of days without needing anyone to stop by to let the chickens in an out.</p><p>There are some ready-made solutions for this, but they all require tearing out the existing hinged door and replacing it with a garage-door-style mechanism. Well, UNTIL NOW!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!15vm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6094e9-0bdc-404b-b102-323ac5cc6c6b_2000x1334.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!15vm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6094e9-0bdc-404b-b102-323ac5cc6c6b_2000x1334.jpeg 424w, https://substackcdn.com/image/fetch/$s_!15vm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6094e9-0bdc-404b-b102-323ac5cc6c6b_2000x1334.jpeg 848w, https://substackcdn.com/image/fetch/$s_!15vm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6094e9-0bdc-404b-b102-323ac5cc6c6b_2000x1334.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!15vm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6094e9-0bdc-404b-b102-323ac5cc6c6b_2000x1334.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!15vm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6094e9-0bdc-404b-b102-323ac5cc6c6b_2000x1334.jpeg" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/aa6094e9-0bdc-404b-b102-323ac5cc6c6b_2000x1334.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1191621,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/176090309?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6094e9-0bdc-404b-b102-323ac5cc6c6b_2000x1334.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!15vm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6094e9-0bdc-404b-b102-323ac5cc6c6b_2000x1334.jpeg 424w, https://substackcdn.com/image/fetch/$s_!15vm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6094e9-0bdc-404b-b102-323ac5cc6c6b_2000x1334.jpeg 848w, https://substackcdn.com/image/fetch/$s_!15vm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6094e9-0bdc-404b-b102-323ac5cc6c6b_2000x1334.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!15vm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6094e9-0bdc-404b-b102-323ac5cc6c6b_2000x1334.jpeg 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>The one, the only: Chicken Squisher 3000.</em></figcaption></figure></div><p>Here&#8217;s the device in action, with some added cat- and chicken-related comedy:</p><div id="vimeo-1126993569" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;1126993569&quot;,&quot;videoKey&quot;:&quot;5d55fe4e06&quot;,&quot;belowTheFold&quot;:false}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/1126993569?autoplay=0&amp;h=5d55fe4e06" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true"></iframe></div></div><p>In the video, I&#8217;m covering the front-facing light sensor for about a minute to simulate dusk and trigger the closing of the door.</p><p>What I liked about the project was not that it was challenging. Quite the opposite: modern technology made it much easier and faster than what would have been possible 2-3 decades ago.</p><p>I started with a relatively cheap but well-sealed and all-metal worm gear motor (<a href="https://www.amazon.com/dp/B07YBYBJ66">Amazon product link</a>). The motor needs 12 V, idles at 30 RPM, and delivers about 35 kg&#183;cm of stall torque. The output shaft is coupled to an 8 mm universal joint to make a 90&#176; turn. This angle locks the joint; it was just the easiest way to couple the motor to an 8 mm stainless steel rod without any welding or machining. The other end of the rod goes through a stainless rod-end bearing that&#8217;s screwed directly into the door. The total cost for the merchandise was around $35.</p><p>On the control side, the electronics are housed in a cast aluminum project box with a sticker made on a vinyl cutter and with several holes drilled for &#8220;emergency&#8221; manual operation buttons (<a href="https://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&amp;DocNm=IP68&amp;DocType=DS&amp;DocLang=English">TE PB6B2HS6M3CAL00</a>), along with a a waterproof power switch (CW industries CW246-ND). I also added a fitted acrylic window for a photoresistor secured with a glob of translucent silicone.</p><p>The control circuit is exceedingly simple:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!B-21!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F516915d2-8bfa-4b20-9e43-78e97ec5e682_5850x3600.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!B-21!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F516915d2-8bfa-4b20-9e43-78e97ec5e682_5850x3600.png 424w, https://substackcdn.com/image/fetch/$s_!B-21!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F516915d2-8bfa-4b20-9e43-78e97ec5e682_5850x3600.png 848w, https://substackcdn.com/image/fetch/$s_!B-21!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F516915d2-8bfa-4b20-9e43-78e97ec5e682_5850x3600.png 1272w, https://substackcdn.com/image/fetch/$s_!B-21!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F516915d2-8bfa-4b20-9e43-78e97ec5e682_5850x3600.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!B-21!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F516915d2-8bfa-4b20-9e43-78e97ec5e682_5850x3600.png" width="1456" height="896" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/516915d2-8bfa-4b20-9e43-78e97ec5e682_5850x3600.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:896,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:606617,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://lcamtuf.substack.com/i/176090309?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F516915d2-8bfa-4b20-9e43-78e97ec5e682_5850x3600.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!B-21!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F516915d2-8bfa-4b20-9e43-78e97ec5e682_5850x3600.png 424w, https://substackcdn.com/image/fetch/$s_!B-21!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F516915d2-8bfa-4b20-9e43-78e97ec5e682_5850x3600.png 848w, https://substackcdn.com/image/fetch/$s_!B-21!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F516915d2-8bfa-4b20-9e43-78e97ec5e682_5850x3600.png 1272w, https://substackcdn.com/image/fetch/$s_!B-21!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F516915d2-8bfa-4b20-9e43-78e97ec5e682_5850x3600.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><em>Chicken Squisher circuit schematics.</em></figcaption></figure></div><p>Power for the device is provided by a <a href="https://www.meanwell.com/Upload/PDF/APV-35/APV-35-SPEC.PDF">Meanwell APV-35-12</a> PSU ($7.50). This is housed in a separate electrical box, wired directly into the mains. The PSU outputs 12 V DC at up to 3 A; this is then converted once more to 5 V for the ICs. For that last task, I used a <a href="https://www.belfuse.com/media/datasheets/products/power-supplies/PXO78-500-S.pdf">PXO7805-500-S</a> switcher because I happened to have one in the drawer; that said, almost any linear or switching regulator should do.</p><p>Supply decoupling is done in a standard way, with a bulk electrolytic cap and a high-speed MLCC on both sides of the regulator, and one MLCC physically close to the main logic chip. Also note the use of a <a href="https://www.we-online.com/components/products/datasheet/74275043.pdf">Wurth 74275043</a> ferrite bead to isolate the supply of 12 V to the motor; it&#8217;s probably an overkill, but it contains high-frequency spikes to that portion of the circuit much better than a capacitor could.</p><p>The main light-sensing element is <a href="https://www.advancedphotonix.com/media/pages/our-products/light-dependent-resistor-ldr/nsl-a6014/16ed38b6da-1744813497/ds-nsl-a601-series.pdf">Advanced Photonix NSL-A6009</a>, a fairly standard cadmium selenide (CdS) photoresistor with a resistance specified at 4-11 k&#937; for 10 lux; in practice, it reads 10 k&#937; right around sunrise and 400 k&#937; just as the night falls. This element is connected to the ADC input of a <a href="https://lcamtuf.substack.com/p/psa-if-youre-a-fan-of-atmega-try">Microchip AVR Dx</a> series 8-bit microcontroller. A sub-$1 unit, such as AVR16DD14, should be more than enough.</p><p>Back in the day, a circuit like this would be implemented without programmable logic. That wouldn&#8217;t save us any money or time; further, we&#8217;d inevitably lose some flexibility with the operating plan. In my design, I rely on MCU pulse-width modulation to operate the motor at roughly 25% the speed and torque for the bulk of the movement; this avoids startling or pinching the chickens, but still lets me ramp it up to 100% for the final seal (when closing) or the initial pull (when opening). The scheme should hopefully make the device more reliable in the presence of dirt, snow, or ice.</p><p>The microcontroller is interfaced to a <a href="https://www.ti.com/lit/ds/symlink/drv8231.pdf">Texas Instruments DRV8231</a> motor driver; this is a yet another $1 part that takes place of wear-prone relays or a more complicated, multi-component H-bridge control circuit of the old. The chip uses current sensing and internal PWM to further limit stall current. The potentiometer that sets the current can be adjusted to avoid crushing the chickens even if all other safeties fail.</p><p>The program running on the MCU is even simpler than the circuitry. Source code can be found <a href="https://lcamtuf.coredump.cx/soft/embedded/chicken.c">here</a>; in a nutshell, it configures the ADC for 10-bit single-ended operation and then accumulates 10 measurements in a bit over a minute to decide if it&#8217;s day or night. At dawn, the voltage at the midpoint of the resistor ladder formed by the LDR and a series 100 k&#937; resistor is:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\frac{10k\\Omega}{(10k\\Omega + 100k\\Omega)} \\cdot 5 \\textrm{V} \\approx 0.45 \\textrm{V}&quot;,&quot;id&quot;:&quot;XENAAJQSCK&quot;}" data-component-name="LatexBlockToDOM"></div><p>&#8230;which corresponds to an ADC reading around 90/1024. If the measured resistance is lower, the system assumes it&#8217;s daytime and opens the door.</p><p>After dusk, the voltage is:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\frac{400k\\Omega}{(400k\\Omega + 100k\\Omega)} \\cdot 5 \\textrm{V} = 4 \\textrm{V}&quot;,&quot;id&quot;:&quot;YDADLBLJXK&quot;}" data-component-name="LatexBlockToDOM"></div><p>This corresponds to an ADC reading in the vicinity of 800/1024. If the reading is higher than that, the system assumes night and shuts the coop door. The hysteresis afforded by the wide spacing of the &#8220;open&#8221; and &#8220;close&#8221; conditions prevents erratic behavior if the illumination level fluctuates a bit.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://lcamtuf.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://lcamtuf.substack.com/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item></channel></rss>