<?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[Photon-Lines Substack]]></title><description><![CDATA[Complex things explained simply. We explore topics using a visual and intuitive methodology. ]]></description><link>https://photonlines.substack.com</link><image><url>https://substackcdn.com/image/fetch/$s_!b3hP!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd23c96bd-e136-4004-96c4-318b52a9538f_408x408.png</url><title>Photon-Lines Substack</title><link>https://photonlines.substack.com</link></image><generator>Substack</generator><lastBuildDate>Sat, 11 Apr 2026 04:59:09 GMT</lastBuildDate><atom:link href="https://photonlines.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Nick M]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[photonlines@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[photonlines@substack.com]]></itunes:email><itunes:name><![CDATA[Nick M]]></itunes:name></itunes:owner><itunes:author><![CDATA[Nick M]]></itunes:author><googleplay:owner><![CDATA[photonlines@substack.com]]></googleplay:owner><googleplay:email><![CDATA[photonlines@substack.com]]></googleplay:email><googleplay:author><![CDATA[Nick M]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[End of Paid Subscriptions]]></title><description><![CDATA[Thank you all for your support :)]]></description><link>https://photonlines.substack.com/p/end-of-paid-subscriptions</link><guid isPermaLink="false">https://photonlines.substack.com/p/end-of-paid-subscriptions</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Sun, 18 Jan 2026 19:07:21 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!b3hP!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd23c96bd-e136-4004-96c4-318b52a9538f_408x408.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello all - first of all, I&#8217;d like to deeply thank you all for supporting this Substack. I am extremely grateful to the people who have opted to be paid subscribers and for the decision to support it as it as it takes me a very long time to do the write-ups that I make available here &#8212;  your decision to support it will always be infinitely appreciated a&#8230;</p>
      <p>
          <a href="https://photonlines.substack.com/p/end-of-paid-subscriptions">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[15 Things I Know]]></title><description><![CDATA[A summary of the key lessons I've learned from reading 15 excellent books.]]></description><link>https://photonlines.substack.com/p/15-things-i-know</link><guid isPermaLink="false">https://photonlines.substack.com/p/15-things-i-know</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Sun, 11 Jan 2026 14:08:24 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!b3hP!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd23c96bd-e136-4004-96c4-318b52a9538f_408x408.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>It&#8217;s taking me a while to finish my next 2 blog posts (a visual walk through number theory / let&#8217;s build a computer from scratch), so this month, I decided to do something different. I couldn&#8217;t help but stumble into a wonderful post called <a href="https://www.rxjourney.net/30-things-i-know">30 Things I Know</a> &#8211; and I thought the general style and the notes there were wonderful, so I decided to kick off 2026 with a bang and do a post of my own. Here, I&#8217;ll include 15 things I learned from some of the favorite books that I&#8217;ve read over the last few years. Hopefully readers here will find some of my notes helpful. I highly recommend reading all of the books mentioned below. I&#8217;m simply including some of the key lessons that stuck with me after reading each one.</p><div><hr></div><h3><strong>Poor Charlie&#8217;s Almanack: The Wit and Wisdom of Charles T. Munger</strong></h3><p>Being well read and having many different mental models and vast knowledge is a major asset in life. Most people fall prey to &#8220;man with a hammer&#8221; syndrome, where if your only tool is a hammer, every problem looks like a nail. A person trained only in economics will see every issue through that single lens, leading to distorted thinking and poor decisions. To overcome this, we must acquire and use the big, reliable ideas from the world&#8217;s major disciplines. You don&#8217;t need to become an expert in each field, but you must understand their fundamental principles so they can work together in your mind. Wise judgment in investing requires a latticework of mental models and some of the most important ones are provided below:</p><ul><li><p><strong>Compound Interest</strong>: A small force, sustained over time, creates an overwhelming result (applies to finance, knowledge, trust).</p></li><li><p><strong>Permutations and Combinations:</strong> Understanding how probabilities work (e.g., knowing that a chain of small risks leads to a large total risk).</p></li><li><p><strong>Fermat&#8217;s Principle:</strong> Looking at the logical extreme of a situation to understand its constraints or limitations.</p></li><li><p><strong>Critical Mass (physics + chemistry)</strong>: Many systems require a threshold of input to trigger a massive, non-linear output.</p></li><li><p><strong>Incentives</strong>: Show me the incentive, and I will show you the outcome. Never underestimate the power of rewards/punishments to drive behavior.</p></li><li><p><strong>Confirmation Bias:</strong> The tendency to seek out and interpret information that confirms one&#8217;s pre-existing beliefs.</p></li><li><p><strong>Lollapalooza Effect</strong>: When multiple biases (e.g., social proof, authority) combine, they create extreme and irrational outcomes.</p></li><li><p><strong>Evolution</strong>: Systems that adapt through variation, selection, and retention are incredibly robust. </p></li><li><p><strong>Everything is connected:</strong> A change in one part of a system (a company, a market) will inevitably lead to predictable and unpredictable changes elsewhere.</p></li><li><p><strong>Comparative Advantage:</strong> Do what you do best relative to others and trade for the rest. Specialization is a fundamental driver of prosperity.</p></li><li><p><strong>Economies of Scale:</strong> The massive benefits that accrue to size (e.g., economies of scale in production or distribution, and informational advantages).</p></li><li><p><strong>Margin of Safety (engineering)</strong>: Build in a buffer for error or unforeseen events. This is central to value investing, engineering, and risk management.</p></li><li><p><strong>Inversion</strong>: Think backward&#8212;instead of asking &#8220;how can I succeed?&#8221; ask &#8220;what must I absolutely avoid doing to fail?&#8221; By focusing on guaranteed failure, you can simplify the path to success.</p></li></ul><p>The profound importance of having many models lies in their synthesis. Real-world problems are not labeled &#8220;economics&#8221; or &#8220;psychology&#8221;; they are complex puzzles that require multiple angles of attack. It is important to use a mental checklist based on these models to avoid blind spots.</p><div><hr></div><h3><strong>Prometheus Rising (by Robert Anton Wilson)</strong></h3><p>We all see reality through very narrow tunnels and we actively ignore the things that don&#8217;t match our own reality tunnel while actively looking for evidence to reinforce the tunnel that we believe in. This &#8220;reality&#8221; that we experience isn&#8217;t reality at all: it&#8217;s mostly our own nervous system, imprinted and conditioned into rigid patterns. We have both the burden and the possibility of loosening those patterns and re-educating ourselves. </p><p>Like Prometheus stealing fire from the gods, the individual who learns to meta-program their own brain is seizing a power that was previously reserved for accident, tradition, and authority. Humans possess the neurological potential to intentionally transcend their current limitations and become self-directed agents of their own psychological and evolutionary development, and they can do that by forever testing hypotheses and dismantling the apparatus of perception to see what, if anything, lies beneath its gears. Curiosity and continual questioning and discovery are the true key to our own liberation.</p><div><hr></div><h3><strong>The Millionaire Fastlane (by MJ DeMarco)</strong></h3><p>There is the slow way of obtaining wealth (by working for someone else, investing, saving) and a fastlane approach (producing something that has value). Slowlaners buy depreciating assets like cars and electronics; fastlaners buy appreciating assets like patents, businesses, and cash flows. Fastlaners view time as their most important asset and making something of value as their primary means of wealth accumulation.</p><p>A few examples of fastlane projects: write a book (lots of work, but then it makes money forever without you having to put in more work), make an invention (lots of work, but then you get royalties for a long time), or generally obtain an income generating asset or assets. The key to the fastlane is producing instead of consuming. Don&#8217;t be the guy who buys a franchise, be the guy who sells franchises.</p><p>The key to creating and having wealth is by working hard today on something that people value in the future. Around 80% of millionaires make their wealth by either starting their own company or working for a small company that has explosive growth.</p><p>Some keys to success in starting a business:</p><ul><li><p>The amount of money a business earns is a reflection of the amount of value it has provided.</p></li><li><p>The harder it is to enter your business, the better you business will be.</p></li><li><p>There are levels of business scale: community, city, state, region, national, and international. The larger your scale, the bigger your leverage. Profit = units sold * profit/unit. Maximize your scale / leverage as much as possible.</p></li><li><p>Investment of time: can the business be automated? Are margins large enough to hire others to do your work? Could you (eventually) get the business to operate without spending much of your time on it? Your business should allow you to eventually have abundance of your most precious resource (time) &#8211; if it doesn&#8217;t do that, then it is not a great pathway to wealth.</p></li><li><p>Don&#8217;t guess on whether there is demand for your product. The best way to figure out where to go is to listen to the rest of the world. You should come out with a minimal version of your product and then see how customers react. Their reactions will guide you during your next iteration and so on and so on.</p></li></ul><p>Being wealthy is not about money, fancy cars, expensive vacations, or vacation homes in Fiji. Being wealthy means being healthy, being surrounded by great friends and family, and the freedom to live life how you want to live it. Faux wealth is the illusion of wealth. It&#8217;s having nice, flashy things that you can&#8217;t afford which take away your freedom and make you even more dependent on your existing sources of income. Faux wealth is not real wealth.</p><p>Your time is precious, don&#8217;t waste it and don&#8217;t trade it away for pennies. Your time is finite and always decreasing &#8212; it is your most precious and most valuable resource. Treat it as such.</p><div><hr></div><h3><strong>Daily Rituals (by Mason Currey)</strong></h3><p>Consistency matters. A solid routine fosters a well-worn groove for one&#8217;s mental energies and helps stave off the tyranny of moods.</p><p>Stephen King writes every day of the year, including his birthday and holidays, and he almost never lets himself quit before he reaches his daily quota of two thousand words.</p><p>&#8220;A modern stoic,&#8221; he observed, &#8220;knows that the surest way to discipline passion is to discipline time: decide what you want or ought to do during the day, then always do it at exactly the same moment every day, and passion will give you no trouble.&#8221;</p><p>In Everybody&#8217;s Autobiography, Stein confirmed that she had never been able to write much more than half an hour a day&#8212;but added, &#8220;If you write a half hour a day it makes a lot of writing year by year. To be sure all day and every day you are waiting around to write that half hour a day.&#8221;</p><div><hr></div><h3><strong>How the World Really Works (by Vaclav Smil)</strong></h3><p>Everything that constitutes our modern world&#8212;its food, its infrastructure, its technology&#8212;is a product of the conversion of energy. The history of human progress is, in large part, the history of harnessing more powerful and concentrated energy sources.</p><p>A useful way to grasp our energy consumption is to equate it to human labor. The annual energy consumption of an average person in 2020 is equivalent to having about 60 adult servants working non-stop. For a person in an affluent country, that number rises to 200 or even 240 servants. This illustrates the sheer scale of the work done by inanimate energy converters on our behalf.</p><p>There are 4 pillars that the modern world is built on:</p><ol><li><p><strong>Ammonia</strong> is the &#8220;gas that feeds the world.&#8221; It is the critical ingredient in synthetic nitrogen fertilizers, and without it, we simply could not grow enough food to feed our current global population. It&#8217;s estimated that ammonia-based fertilizers are responsible for sustaining roughly half the world&#8217;s people. Almost all industrial ammonia today is made from hydrogen plus nitrogen, and that hydrogen usually comes from natural gas (methane) or sometimes coal. Ammonia accounts for a noticeable chunk of global CO&#8322; emissions.</p></li><li><p><strong>Plastics</strong>: These versatile materials, derived from fossil fuel feed-stocks, are ubiquitous in packaging, medicine, construction, and consumer goods. Plastic production depends very heavily on fossil fuels, in two ways: as a raw material and as an energy source. Most conventional plastics are made from petrochemicals derived from oil and natural gas. Their problem is not utility but disposal, creating a massive waste management challenge.</p></li><li><p><strong>Steel</strong>: This alloy is the skeleton of modern civilization. It defines the look of our world, from skyscrapers and bridges to cars and appliances. Its production in blast furnaces is a process of extreme heat, typically generated by burning coal. Steel production today still depends a lot on fossil fuels, though the amount varies by process and country.</p></li><li><p><strong>Cement</strong>: The key ingredient in concrete, cement is the most widely used human-made material; it is the backbone of modern construction and infrastructure. Cement production still depends heavily on fossil fuels because making it requires extremely high kiln temperatures, which are usually produced by burning coal, petroleum coke, or natural gas, and also because heating limestone releases CO&#8322; as a chemical by-product.</p></li></ol><p>Despite decades of discussion about transition, the global energy system remains overwhelmingly dependent on fossil fuels. Their share of the world&#8217;s primary energy supply has decreased only marginally, from about 87% in 2000 to 84% in 2020. This is not for a lack of trying, but because of the sheer scale of the existing infrastructure. Replacing it is the work of generations, not decades &#8211; and we&#8217;re just getting started.</p><div><hr></div><h3><strong>Economics in One Lesson (by Henry Hazlitt)</strong></h3><p>Almost all bad economics comes from focusing only on what is immediately seen&#8212;the short-run effect on one visible group&#8212;while ignoring what is unseen: the longer-run effects on everyone. The &#8220;one lesson&#8221; is that the art of economics is to trace all consequences of a policy, not just the first ones and not just for the most visible beneficiaries.</p><p>As an example, government expenditure is often lauded for the jobs it creates, but where does the money for that spending come from? Yes, it comes from taxes. The funds taken through taxation are money that would have been used by private citizens for investment, consumption, or savings, all of which would have also created jobs. The unseen consequence is the lost private investment and production that never occurs because the funds were seized by the state.</p><p>Another example are tariffs: they protect a small number of domestic producers by allowing them to charge a higher price. The unseen harm is that all domestic consumers must pay a higher price, effectively being taxed to subsidize the protected industry. Furthermore, it prevents efficient foreign producers from earning dollars they would have used to buy American exports, thus harming domestic export industries.</p><p>Another example are minimum wages. They clearly benefits workers who can keep their jobs at a higher rate. This benefit is visible. The unseen consequence is that businesses, unable to afford the higher cost, will hire fewer workers or replace some with automation, leading to unemployment for the least-skilled workers. The policy intended to help all low-wage workers instead helps some at the expense of others.</p><p>The final, indispensable takeaway is that the art of economics lies in training oneself to see not just the immediate, visible consequences of a policy or action, but to trace out its longer-term effects on all groups. It requires looking beyond the obvious beneficiaries&#8212;the subsidized industry, the hired workers, the funded project&#8212;to recognize the unseen victims: the consumers who pay higher prices, the taxpayers whose wealth is diverted, the entrepreneurs whose capital is unavailable, and the opportunities that are never born. Good economics is therefore an exercise in disciplined empathy and imagination, demanding we count all the costs, not just the loudest or most politically convenient ones, and remember that society loses when we favor the seen at the expense of the unseen.</p><div><hr></div><h3><strong>QED &#8211; The Strange Theory of Light and Matter (by Richard Feynman)</strong></h3><p>The book is a guided tour of quantum electrodynamics&#8212;the theory that explains how light and matter interact&#8212;told with almost no formal math. Instead of equations, Feynman uses little clocks to represent probability amplitudes.</p><p>To calculate the probability of where a particle ends up, we assign each possible path a &#8220;probability amplitude&#8221; (visualized as a tiny spinning arrow, or clock hand). The arrow&#8217;s direction is determined by the path&#8217;s phase, which is related to the time taken. We then sum the arrows for all paths. The paths whose arrows point in roughly the same direction reinforce each other while those pointing in opposite directions cancel out. This &#8220;sum over histories&#8221; explains why, in the aggregate, light appears to take a straight line or a classical reflection path; the neighborhoods of paths of least time cooperate while others which take longer cancel each other out. Really though, there is no &#8216;one path&#8217; that light really takes. Nature at the quantum level doesn&#8217;t behave like tiny &#8216;billiard balls&#8217; or &#8216;smooth waves&#8217; or tiny things &#8216;bumping&#8217; into each other; instead, photons actually take all possible paths from point A to point B into account and move according to the path of least energy / time.</p><p>Feynman&#8217;s genius was to decode this algorithm not as a wall of equations, but as a lucid, almost playful procedure&#8212;giving us not just the how of light and matter, but a humbling glimpse into the foundational software of reality. The theory&#8217;s immense success (it predicts measurements with unmatched precision) forces us to accept that this is not a model of reality, but a reliable description of how reality actually behaves. It provides us with a picture of what reality actually is: a very complex system which can only be modeled through a huge degree of computational complexity and not a simple dynamical one with simple rules.</p><div><hr></div><h3><strong>The Hard Thing About Hard Things (by Ben Horowitz)</strong></h3><p>This is a brutally honest and practical guide to building and running a startup. Drawing from his tumultuous experiences as a founder and CEO, Horowitz delves into the &#8220;hard things&#8221;&#8212;like firing executives, demoting friends, managing your own psychology, and making agonizing decisions with no good options&#8212;that most business books ignore.</p><p>Some key lessons and quotes from the book:</p><ul><li><p>You must believe that there is an answer no matter how much the odds may be against you. During his time with LoudCloud, they were close to losing a major customer (called EDS which accounted for 90% of their revenue) and talks about how he won them back: found out that the executive from EDS was not happy with their software and preferred something called Tangram. Ben found out that Tangram was public and was worth around 6 million dollars at the time, so decided to acquire them for 10 million which made EDS&#8217;s executive happy and played a huge role in saving the deal and company.</p></li><li><p>Almost as soon as the EDS crisis was resolved, they hit more trouble yet again from competitors: three new clients were fading away and excellent new competitor was eating their lunch. Told employees that they had 6 months to really work hard and play catch up with BladeLogic or else they were dead. This meant working over-time and weekends and talks about the time and stress and toll this took on the team, although some team-members ended up having a great experience from this.</p></li><li><p>Had to really decide whether to prioritize requirements from existing customers or whether to pursue something else that they thought would help. &#8220;It turns out that is exactly what product strategy is all about&#8212;figuring out the right product is the innovator&#8217;s job, not the customer&#8217;s job. The customer only knows what she thinks she wants based on her experience with the current product. The innovator can take into account everything that&#8217;s possible, but often must go against what she knows to be true. As a result, innovation requires a combination of knowledge, skill, and courage.&#8221; His answer: &#8220;I don&#8217;t care about any of the existing requirements; I need you to reinvent the product and we need to win.&#8221;</p></li><li><p>Lead bullets: talks about facing challenges with Netscape (and with Microsoft challenging them) as well as with his issues with OpsWare (their number one competitor was dominating them). Many people suggested they shift business strategies or go into a different market. He refused to do so: with Netscape, they made their servers faster than Microsoft and ended up beating BladeLogic. Instead of running from problems, they faced them head-on and made the product better.</p></li><li><p>His general advice: &#8220;There comes a time in every company&#8217;s life where it must fight for its life. If you find yourself running when you should be fighting, you need to ask yourself, &#8220;If our company isn&#8217;t good enough to win, then do we need to exist at all?&#8221;. In other words, face your competitors and issues head on instead of running from them.</p></li><li><p>Embracing the struggle: there are lots of struggles and many young companies go through them. Ben went through major struggles at almost every point of his life, but he prevailed. &#8220;Every great entrepreneur from Steve Jobs to Mark Zuckerberg went through the Struggle and struggle they did, so you are not alone. But that does not mean that you will make it. You may not make it. That is why it is the Struggle. <strong>The struggle is where greatness comes from.</strong>&#8221;</p></li></ul><p>The keys to over-coming a struggle:</p><ul><li><p>Don&#8217;t put it all on your own shoulders (share the struggles with the team): &#8220;You won&#8217;t be able to share every burden, but share every burden that you can. Get the maximum number of brains on the problems even if the problems represent existential threats.&#8221;</p></li><li><p>Persistence: the technology business is complex and there are always moves you can make to save your company / rescue the situation. He took a company bleeding money and IPO-ed at the worst time ever and made it, so you can too. &#8220;Play long enough and you might get lucky. In the technology game, tomorrow looks nothing like today. If you survive long enough to see tomorrow, it may bring you the answer that seems so impossible today.&#8221;</p></li><li><p>Take care of the people, the products and the profits, in that order. It&#8217;s a simple saying, but it&#8217;s deep. &#8220;Taking care of the people&#8221; is the most difficult of the three by far and if you don&#8217;t do it, the other two won&#8217;t matter. Taking care of the people means that your company is a good place to work. Most workplaces are far from good.</p></li></ul><p>The main takeaway is that there is no secret formula for success during crises; instead, true leadership is about mustering the courage to make tough choices, persevering through sheer will when all seems lost, and accepting that struggle and doubt are not signs of failure but the core, unavoidable components of the entrepreneurial journey. The secret to winning it seems is simply being determined and not giving up.</p><div class="pullquote"><p>&#8220;<em>Starting a company is hard. If you want to be great, start a company &#8211; if not, then don&#8217;t.&#8221;</em></p><p>- Ben Horowitz</p></div><h3><strong>Build (by Tony Fadell)</strong></h3><p>Build products which people want (and follow with the correct technology after) &#8211; don&#8217;t put technology before product &#8211; the product must always come first. If you&#8217;re not solving a real-world problem, there is no need for your product. Also, the whole customer journey from start to finish is vitally important:</p><ul><li><p>Design at Nest: every minute, from opening the box to reading the instructions to getting it on their wall to turning on the heat for the first time had to be incredibly smooth.</p></li><li><p>Customer panels don&#8217;t do well in design. People can&#8217;t articulate what they really want clearly enough definitely point in one direction or another. Customers will always be more comfortable what exists already despite it being terrible.</p></li><li><p>Story Telling: the story of your company, your product and your team should drive everything you do. The story isn&#8217;t there just to sell your product: it&#8217;s there to help you define it, understand it, and understand your customers &#8211; and it all starts with why? Why does the product exist? What problem does it solve? Use great analogies in telling your story (people can relate to them) and tell a story that others can connect with.</p></li><li><p>Your product isn&#8217;t your only focus: it&#8217;s the whole user experience. Don&#8217;t just build a prototype of your product; map our the entire user experience. Map out and visualize how your customer discovers, considers, installs, uses, fixes and ever returns your product. It all matters. Make models. Draw pictures. Sketch out the bones of the process in wire-frames. Write imaginary press releases. Created detailed mock ups. Put it all out and make it visible: how can you delight your customers in every possible way.</p></li><li><p>Always seek out new ways to disrupt yourself. If you make something truly disruptive, your competition should not be able to easily replicate it.</p></li><li><p>Companies that become too big and don&#8217;t innovate eventually die.</p></li></ul><p>No matter what you build &#8211; it&#8217;ll take some time. The iPad took 3 generations and around 3 years to reach profitability. Google also wasn&#8217;t remotely profitable for 3 years and Facebook initially focused on growth rather than what their business model was going to be. The first version of the product should always focus on the customer journey and everything else will come later.</p><div><hr></div><h3><strong>In Cold Blood (by Truman Capote)</strong></h3><p>If there&#8217;s one key lesson that I obtained from reading this, it&#8217;s that 1) small things matter and 2) chaos rules our everyday lives. The murders at the heart of In Cold Blood are not the result of some grand plan or deep personal vendetta; they come from a string of minor choices, misunderstandings, and bits of bad information. A rumor about a safe full of money, an offhand comment in a prison cell, a moment of idle curiosity&#8212;these small details, which could easily have led nowhere, instead set in motion a sequence of events that destroys an entire family. Capote shows how the line between &#8220;ordinary life&#8221; and catastrophe is much thinner than we like to admit.<br><br>At the same time, the book keeps circling back to how random and unfair this all is. The Clutters are not targeted because of anything they did; they just happen to be the family that fits a half-remembered description. Perry and Dick, too, are shaped by accidents of birth, trauma, and circumstance as much as by their own choices. This doesn&#8217;t excuse what they do, but it complicates the story. There is no neat moral accounting where the &#8220;bad&#8221; are punished and the &#8220;good&#8221; are spared. Instead, we see a world in which chance meetings, childhood injuries, timing, and geography all combine into something that feels almost senseless.<br><br>Capote&#8217;s style reinforces this sense of fragile order sitting on top of chaos. He gives us painstaking details about the town, the family&#8217;s routines, the layout of the house, the highways the killers drive along, as if documenting everything could make it understandable, controllable, safe. But the more we know, the more we see that knowledge does not prevent randomness; it only highlights how much had to align for this tragedy to happen. The book suggests that we live with an illusion of stability, and that behind our schedules and habits there is always a degree of unpredictability we cannot fully master.<br><br>In the end, In Cold Blood is not just about a crime; it&#8217;s about how we try to make sense of a world that often doesn&#8217;t make sense at all. Small actions ripple outward in ways no one can foresee, and lives intersect in patterns that feel almost arbitrary. The key message, for me, is both unsettling and sobering: we should never underestimate the weight of small decisions, and we should recognize that much of what happens to us&#8212;good and bad&#8212;is shaped by forces we don&#8217;t see and can&#8217;t fully control.</p><div class="pullquote"><p>&#8220;Once a thing is set to happen, all you can do is hope it won&#8217;t. Or will-depending. As long as you live, there&#8217;s always something waiting, and even if it&#8217;s bad, and you know it&#8217;s bad, what can you do? You can&#8217;t stop living.&#8221; &#8211; Truman Capote</p></div><h3><strong>The Boy Who Was Raised as a Dog (by Bruce Perry &amp; Maia Szalavitz)</strong></h3><p>Written by child psychiatrist Dr. Bruce Perry and Maia Szalavitz, the book is a collection of harrowing yet hopeful case studies that explore how extreme trauma affects the developing brains of children. It takes readers through Dr. Perry&#8217;s clinical experiences with children who have faced unimaginable neglect and abuse&#8212;including a boy raised in a cage, children from the Branch Davidian cult, and survivors of genocide. Rather than viewing these children as damaged goods, Perry uses these stories to illustrate how traumatic experiences physically alter brain biology, shifting the focus from &#8220;what is wrong with this child?&#8221; to &#8220;what happened to this child?&#8221;</p><p>The key message of the book is that the brain develops based on repeated experiences. Trauma disrupts this development, often locking children into a persistent state of &#8220;fight or flight&#8221; that hinders their ability to learn and connect. As an example, one of the chapter&#8217;s discusses a 16 year old boy called Leon who committed 2 murders. Leon feels no remorse for his murder other than the remorse of being caught. He has two loving parents and an older brother, but Dr. Perry figures out that Leon&#8217;s parents would would regularly leave him alone in his crib and leave to go out for walks for hours at a time when he was a young baby; leaving him alone and crying in his crib for many hours. After some time, his mother recounted that Leon stopped crying so much (a huge red flag), so she believed that this regimen had helped him. In reality, her neglect, however innocent, had deprived Leon of the important loving and physical affection experiences an infant needs to form family bonds and later maintain healthy relationships. This isn&#8217;t the first story where this type of neglect occurs: in another story, a couple recounts hiring a baby-sitter who would come in during the morning and leave the baby alone for hours at a time, only to come back to change his diaper. Both children ended up with major development disorders, with Leon getting the worst of the bunch.</p><p>Even though many of the recounted stories of neglect are absolutely awful, Perry argues that because the brain is plastic, it can be healed. The most powerful tool for this healing is not medication or complex medical procedures, but patterned, repetitive human connection. The book emphasizes that recovery requires meeting a child at their developmental age rather than their chronological age and that healthy, consistent relationships are the ultimate engine of healing.</p><p>As an example, Perry and his team learned many valuable lessons from the children in Waco. He would usually get the question: why do some children overcome trauma with minimal or no long-lasting emotional scars, while others do not move past it, or move past it but continue to bear the weight of it, unable to live &#8220;normal&#8221; lives. His answer: <strong>relationships</strong> were the key to their ability to move forward and claim a &#8220;normal&#8221; life for themselves, or not. Children who were placed into stable, loving homes, where consistency and support were constants and they were able to develop deep supportive relationships, whether with blood relatives or foster families, were much more likely to lead normal adult lives. Those children who were less fortunate in their placements and did not develop supportive relationships, were much less likely to lead normal adult lives.</p><p>150 years ago most families lived in communities of 20-150 people, many of them family, where everyone knew everyone else, and supported everyone else, but by the 1950&#8217;s this was closer to 10 people in community and now the average family is 4 people and 25% of Americans live alone. This lack of connections coupled with our propensity to spend more time watching TV (or our cell phones) than interacting with one another even when we are together lowers both the number and quality of the relationships we are in compared to 100 years ago; this lack of deep relationships in turn heightens our children&#8217;s risk for bad and dangerous relationships while lowering their ability to rebound after trauma happens.</p><div><hr></div><h3><strong>Crime and Punishment (by Fyodor Dostoevsky)</strong></h3><p>The book changed the way I see the world. You look at a man or woman across from you and you might not give too much thought to the fact that inside his or her head, they are making sense of the world just like you are. Yes, everyone you meet has an inner life as crowded and haunted as your own. The drunk in the tavern, the inspector in the office; even killers have their own stories and mental models which they live by. The book shows a murderer&#8217;s stream of consciousness. Through it, it also shows that you cannot simply just call someone a monster and walk away. To understand someone, you must know what story he is telling himself, what lies he believes in and what wounds he is hiding. Since this is impossible in the real world, the act of judging someone is possibly the greatest arrogance of all. Can you assume that if you wore the same boots and embarked on the same road that you would have walked a better path? Dostoevsky tries to show you that we are all made of the same stuff and that the line that separates us is very thin one. It taught me to judge less and to observe more, because in the darkness of our own minds, we are all stumbling toward the same light.</p><div><hr></div><h3><strong>The Demon-Haunted World: Science as a Candle in the Dark (by Carl Sagan)</strong></h3><p>As the world increasingly dominated by technology but plagued by scientific illiteracy, humanity risks sliding back into the darkness of superstition and ignorance. The scientific method&#8212;characterized by skepticism, observation, and the demand for evidence&#8212;is the only reliable tool we have to illuminate reality and protect ourselves from the &#8220;demons&#8221; of pseudoscience, whether they take the form of faith healing or political propaganda.</p><p>There is a baloney detection kit we all can use:</p><ul><li><p>Independent Confirmation: Wherever possible, there must be independent confirmation of the &#8220;facts.&#8221;</p></li><li><p>Quantification: Wherever possible, use numbers and data. Vague claims are hard to evaluate; quantified claims can be checked.</p></li><li><p>Substantive Debate: Encourage knowledgeable proponents of all points of view to engage in substantive debate on the evidence.</p></li><li><p>Occam&#8217;s Razor: When faced with competing hypotheses, prefer the simpler one that requires the fewest new assumptions. It&#8217;s not a guarantee of truth, but a guiding principle.</p></li><li><p>In science, there are no authorities; at most, there are experts. Arguments from authority carry little weight&#8212;&#8221;authorities&#8221; have made mistakes in the past and will do so again.</p></li><li><p>Every step in an argument must be solid. A single weak link can break the entire chain of reasoning.</p></li></ul><p>Constantly test hypotheses and question authority. Skepticism is not a negative force, but a constructive one that shields us from manipulation. A society dependent on science and technology in which hardly anyone understands science and technology is a prescription for disaster. A future where the public is unable to distinguish between genuine expertise and charlatanism, leaving them vulnerable to demagogues who can exploit their ignorance. <strong>Scientific literacy is not just an academic luxury, but a fundamental pillar of a free society</strong>.</p><p>The values of science&#8212;open debate, the lack of ultimate authority, and the willingness to be proven wrong&#8212;are identical to the values of a healthy democracy. Skepticism is a patriotic duty. Just as science requires us to question our hypotheses to find the truth, democracy requires citizens to question their leaders to maintain their freedom. The Bill of Rights exists for a reason; the freedom of speech and the freedom to question are essential checks against the errors of government. Without a skeptical, educated citizenry willing to ask difficult questions, the democratic experiment itself is in jeopardy. The right to question is the most precious freedom we have, and exercising it is the only way to keep the candle burning.</p><div><hr></div><h3><strong>The Fiddler in the Subway: The Story of the World-Class Violinist Who Played for Handouts. . . And Other Virtuoso Performances by America&#8217;s Foremost Feature Writer (by Gene Weingarten)</strong></h3><p>One cold January morning, the world&#8217;s best violinist (Joshua Bell)&#8212;fresh from sold-out concert halls where tickets cost hundreds of dollars&#8212;stood disguised by the escalators of a Washington metro station and played Bach and other virtuoso pieces on a multi-million-dollar Stradivarius violin. For about three quarters of an hour, more than a thousand commuters passed within a few steps of him. Fewer than a dozen stopped to listen to Bell; most hurried by without even turning their heads. The few people who did stop; the children who instinctively wanted to listen to him were pulled away by their parents; and the few who did actually recognize him could not believe what they were witnessing. For the most part, his performance pretty much went unnoticed and he earned about 30 dollars in change from the experience.</p><p>The experiment shows how much our sense of value depends on context and how little attention people pay to the things going on around them. If we are unable to stop, even briefly, to hear one of the finest musicians in the world playing some of the finest music ever written, what else, in our haste, do we fail to see? How much beauty going on around us are we ready to miss due to being preoccupied by life&#8217;s diversions, and what does that say about us?</p><div><hr></div><h3><strong>The Old Man and the Sea (by Ernest Hemingway)</strong></h3><p>The story is a simple one. It is about an old man who fishes alone. He has gone many days without taking a fish. He prepares his gear. He rows out into the dark. He goes out farther than anyone else dares to go. He hooks a giant marlin. The fish is strong and he is old, but he holds the line. For three days they are locked together. The line cuts his back and his hands cramp and he is hungry. He eats raw tuna to keep his strength. He talks to his hand. He talks to the bird. He respects the fish. He calls him brother. He loves him, but he has to kill him. That is the way of the world. It is the pride of the man against the dignity of the fish. Then the sharks came. They came to take what was his. He fights them for a long time, but in the end they win and the great fisherman is left with nothing but fish bones.</p><p>The story doesn&#8217;t have a great plot. It doesn&#8217;t have any outstanding twists and turns. The stream of words that Hemingway produces though are beautiful and will leave you stunned. The story taught me that victory and defeat are not as simple as they look. Although the old man came back with almost nothing, the boy sees the marlin&#8217;s great spine and tail and admires the old man. The real win is not made in an achievement or what it produces, it is the fact that the old man went far out, fought well, did not break, and came back with great hope. A man can be destroyed but not defeated. Your body can give out. Your catch can be taken. Your luck can run dry. What is left is how you carry yourself when you are alone&#8212;doing what you were born to do, even if it breaks you. </p><div><hr></div><p>Happy 2026 everyone and once again a big thank you to all of the paid subscribers to this Substack!!!</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Photon-Lines Substack is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Principles of Economics Made Clear (Part 3)]]></title><description><![CDATA[Part 3 of the Principles of Economics Made Clear series.]]></description><link>https://photonlines.substack.com/p/principles-of-economics-made-clear-2e8</link><guid isPermaLink="false">https://photonlines.substack.com/p/principles-of-economics-made-clear-2e8</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Thu, 20 Nov 2025 14:42:26 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!8Lqj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cdc37ab-76f4-41fd-a017-5a0f3e01a970_526x789.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This is Part 3 of my Principle of Economics series series which aims to provide a visual and intuitive overview of the key principles and ideas present within the vast field of economics. If you haven&#8217;t had a chance to check out the previous write-ups, you can find <a href="https://photonlines.substack.com/p/principles-of-economics-made-clear">Part 1</a> and <a href="https://photonlines.substack.com/p/principles-of-economics-made-clear-18b">Part 2</a> in the provided links. Here, we will focus on vitally important ideas: the frontiers of microeconomics and then explain the core building blocks of macroeconomics.</p><div><hr></div><h2><strong>Frontiers of Microeconomics</strong></h2><p>In the first two parts of this series, we mapped the fundamental landscape of economics: supply and demand, the elegance of markets, and the forces that can cause them to stumble, like monopolies and externalities. We pictured the economy as a complex, self-organizing structure guided by an invisible hand -- but this model makes a large assumption: that everyone involved has reasonably good information. What happens when that isn&#8217;t true? What are the consequences when the economic game is played in a fog, where some players can see clearly and others are nearly blind?</p><h3><strong>The Economics of Information Asymmetry</strong></h3><p>In many situations in life, knowledge is not distributed equally. This asymmetry creates two of the most powerful and pervasive concepts in modern economics: moral hazards and adverse selection.</p><h4><strong>Moral Hazards</strong></h4><ul><li><p>Imagine you rent a car. When you drive your own car, you are careful. You avoid potholes and you brake gently &#8212; but when you&#8217;re in a rented car and you&#8217;ve paid for the full insurance coverage, your behavior changes. You take that dirt road shortcut you normally wouldn&#8217;t and you end up being a lot less vigilant. This is Moral Hazard. It arises when one person (the agent) is performing a task on behalf of another (the principal), but the principal cannot perfectly monitor the agent&#8217;s behavior.</p></li><li><p>The problem is everywhere. It&#8217;s the corporate executive who takes giant risks with company money because their bonus is tied to short-term gains, not long-term stability; it&#8217;s the employee who spends hours browsing social media because the manager can&#8217;t see their screen. The principal&#8217;s challenge is to design a system&#8212;like a deductible on insurance, or a performance-based bonus&#8212;to align the agent&#8217;s incentives with their own.</p></li></ul><h4><strong>Adverse Selection</strong></h4><ul><li><p>Imagine a used car lot. You&#8217;re looking at two identical-looking sedans. One is a meticulously maintained by a former mechanic while the other is a lemon (a car with lots of issues) that a problematic seller is desperate to unload. You, the buyer, can&#8217;t tell the difference, but the sellers knows the truth. The seller of the good car knows it&#8217;s worth a high price, while the seller of the lemon knows it&#8217;s worth a low one. Since you can&#8217;t tell them apart, you&#8217;ll only be willing to pay an average price&#8212;somewhere in the middle. What happens? </p></li><li><p>The owner of the good car, unwilling to sell his gem for an average price, pulls it off the market. The owner of the lemon, thrilled to get more than his car is worth, gladly sells. The result? The market becomes flooded with lemons. The &#8220;selection&#8221; of cars available for purchase has become &#8220;adverse.&#8221; The uninformed party (the buyer) gets a disproportionate number of undesirable trading partners (sellers of low-quality goods) because the informed party uses their private information to their own advantage. The market collapses. The only cars left for sale are the Lemons. </p></li><li><p>This exact logic applies to health insurance. Who knows more about your health than you do? People who know they have hidden health problems are the most likely to buy expensive, comprehensive insurance. This drives up the average cost for everyone. Healthy people then look at the high price, decide it&#8217;s not worth it, and leave the market. The &#8220;insurance pool&#8221; gets sicker and sicker, and prices spiral upward. This is a clear case where the invisible hand fails to produce a good outcome for society.</p></li></ul><h4><strong>Fighting the Fog: Signaling and Screening</strong></h4><p>So how do markets cope with this fog of information? They develop clever tools.</p><ul><li><p><strong>Signaling</strong>: The informed party takes an action to reveal their private information. A job applicant gets a university degree. It&#8217;s not just about the knowledge; it&#8217;s a costly, visible signal that says, &#8220;I am a high-quality, dedicated worker.&#8221; The used car dealer offering a solid warranty is signaling, &#8220;I am so confident this isn&#8217;t a lemon that I&#8217;ll bet my own money on it.&#8221; Degrees, certifications, brand reputation, long warranties, generous return policies are all examples of signaling. A good signal is costly for low-quality sellers to imitate (e.g., a lengthy warranty that would be expensive if your product failed often).</p></li><li><p><strong>Screening</strong>: The uninformed party takes an action to uncover the private information. An insurance company doesn&#8217;t just charge one premium; it screens applicants by offering different plans with different deductibles and co-pays. The choices you reveal help them sort you into risk categories. One example of this might be an insurance company offering 2 plans:</p><ul><li><p>A very cheap plan with a massive $10,000 deductible, or</p></li><li><p>A very expensive plan with a $0 deductible.</p></li></ul></li><li><p>This is a screen: healthy people (who know they&#8217;re healthy) will grab the cheap plan; people who know they&#8217;ll need care will pay extra for the expensive plan. The trick? Design choices so each customer picks the deal meant for them without you ever having to intervene.</p></li></ul><h4><strong>The Political Marketplace: Why Governments Stumble, Too</strong></h4><ul><li><p>We often look to government to fix market failures. But governments are not run by omniscient angels; they are made of people and are subject to their own, often more perplexing, failures.</p></li><li><p>Collective decisions have their own physics: majority voting can cycle, no voting rule is perfect, and the median voter often pulls policy toward the middle&#8212;while interest groups tug at the edges.</p></li><li><p><strong>The Condorcet Paradox</strong>: This shows that majority-rule voting doesn&#8217;t always give you a clear, logical answer. Imagine three roommates (Ann, Bob, Chris) are voting on one pizza topping:</p><ul><li><p>Ann&#8217;s vote: 1st: Pepperoni, 2nd: Mushroom, 3rd: Onion</p></li><li><p>Bob&#8217;s vote: 1st: Mushroom, 2nd: Onion, 3rd: Pepperoni</p></li><li><p>Chris&#8217;s vote: 1st: Onion, 2nd: Pepperoni, 3rd: Mushroom</p></li></ul></li><li><p>Now, let&#8217;s have them vote head-to-head:</p><ul><li><p>Pepperoni vs. Mushroom? Ann and Chris vote Pepperoni. Pepperoni wins.</p></li><li><p>Mushroom vs. Onion? Ann and Bob vote Mushroom. Mushroom wins.</p></li><li><p>Onion vs. Pepperoni? Bob and Chris vote Onion. Onion wins.</p></li></ul></li><li><p>The group &#8220;prefers&#8221; Pepperoni over Mushroom, and Mushroom over Onion... but they also prefer Onion over Pepperoni! It&#8217;s a never-ending loop (A&gt;B&gt;C&gt;A). <strong>Arrow&#8217;s impossibility</strong> theorem is the formal proof that every voting system has a potential flaw like this. There is no &#8220;perfect&#8221; way to vote. Every method (ranked-choice, majority rule, etc.) will always violate at least one seemingly fair and reasonable criterion. There is no perfect way to translate individual preferences into a collective will.</p></li></ul><ul><li><p><strong>The Median Voter Theorem</strong>: This explains why politicians often sound the same. Let&#8217;s imagine a scenario where there&#8217;s a 1-mile-long beach with sunbathers spread out perfectly evenly. Two competing ice cream carts (A and B) want to sell the most ice cream. Where do they set up?</p></li><li><p>If A is at the 1/4-mile mark and B is at the 3/4-mile mark, they each get half the beach. But then A thinks, &#8220;If I move a little closer to the center, I&#8217;ll keep all my customers to the left, plus I&#8217;ll steal some of B&#8217;s.&#8221; B sees this and does the same. Where do they end up? Right next to each other, exactly at the 1/2-mile mark (the median). This is why political candidates often &#8220;run to the center&#8221; to capture the median voter, ignoring the people at the extremes.</p></li></ul><h4><strong>Behavioral Economics: We Are Human, Not Robots</strong></h4><p>Conventional economics has long assumed we are perfectly rational, cold-blooded calculators of our own self-interest. Behavioral economics, drawing on psychology, shows we are nothing of the sort. We are human.</p><ul><li><p><strong>We Are Not Always Rational</strong>: we use mental shortcuts (&#8221;heuristics&#8221;) that often lead us astray. We are overconfident. We fear losses more than we value equivalent gains (loss aversion). Think about it: the pain of losing $100 is far greater than the pleasure of finding $100. This isn&#8217;t rational, but it is deeply human.</p></li><li><p><strong>We Care Deeply About Fairness</strong>: the Ultimatum Game proves this. One person is given $100 and must offer a split to a second person. If the second accepts, both get the money. If they refuse, both get nothing. A purely rational &#8220;robot&#8221; would accept any offer, even $1, because it&#8217;s better than nothing. But humans routinely reject &#8220;unfair&#8221; offers (like $90 / $10). They are willing to pay a personal cost to punish what they perceive as injustice.</p></li><li><p><strong>We Are Inconsistent Over Time:</strong> Picture this: it&#8217;s Sunday night. You plan to wake up early all week to exercise. Monday morning arrives, and the alarm rings. In your warm bed, you decide, &#8220;I&#8217;ll start tomorrow.&#8221; You have a present bias&#8212;you overvalue the &#8220;now&#8221; at the expense of your long-term plan. This explains why we procrastinate, why we struggle to save for retirement, and why we indulge today while promising to diet tomorrow.</p></li></ul><p>Economics is the study of a messy, beautiful, and often irrational human world. By understanding asymmetry in information, the inherent imperfections of our political systems, and the predictable quirks of our own minds, we move closer to designing systems&#8212;both in markets and in government&#8212;that are more robust, more fair, and more aligned with how we truly live and choose. The invisible hand is a powerful force, but it is guided by a human mind and that makes it very difficult to comprehend.</p><div><hr></div><h3><strong>Taking the Pulse of the Economy: Measuring a Nation&#8217;s Income</strong></h3><ul><li><p>If microeconomics is the study of a single tree&#8212;its growth, its bark, its leaves&#8212;then macroeconomics is the study of the entire forest. It doesn&#8217;t care about one specific company&#8217;s sales or one household&#8217;s budget. It cares about the forces that affect all trees at once: the rainfall, the sunlight, the health of the soil. Its goal is to explain economy-wide phenomena like inflation, unemployment, and the rise and fall of total production.</p></li><li><p>The single most important question in macroeconomics is a deceptively simple one: how is the economy doing? To answer that, we need a vital sign. A single number that can capture the immense, roaring complexity of a nation&#8217;s entire economic activity. That number is the <strong>Gross Domestic Product, or GDP</strong>.</p></li><li><p>GDP measures two things at once: the total income of everyone in the economy and the total expenditure on the economy&#8217;s output of goods and services. GDP can perform the trick of measuring both total income and total expenditure because these two things are the same. For an economy as a whole, income must equal expenditure. An economy&#8217;s income is the same as its expenditure because every transaction has two parties: a buyer and a seller. Every dollar of spending by some buyer is a dollar of income for some seller. Imagine the economy as a giant, never-ending merry-go-round. On one side, households stand. They own the factors of production: their labor, their land, their capital. On the other side, firms stand, ready to produce goods and services.</p></li><li><p>Now, watch the flow: households provide their labor and resources to firms. In return, firms pay them income&#8212;wages, rent, and profit. This is the flow of income. Armed with this income, households step into the marketplace (the grocery stores, the car dealerships, the app stores) and spend their money on the goods and services the firms produce. This is the flow of expenditure.</p></li><li><p>Every dollar you spend at a store is a dollar of income for the cashier, the stocker, the manager, and the business owner. This is the profound, simple secret at the heart of GDP: for the economy as a whole, total income must always equal total expenditure. They are two sides of the same coin, the same flow of money viewed from opposite sides of the merry-go-round. GDP is designed to measure this single, unified flow.</p></li><li><p>So &#8211; what is the precisely is the GDP? To put it in precise terms, <strong>Gross Domestic Product (GDP) is the market value of all final goods and services produced within a country in a given period of time.</strong> Let&#8217;s unpack this more precisely:</p><ul><li><p><strong>Market Value</strong>: GDP adds up the price of everything. This is how it compares &#8220;apples and oranges.&#8221; It doesn&#8217;t add the number of apples to the number of oranges; it adds the dollar value of the apples sold to the dollar value of the oranges sold. It converts everything into a common unit.</p></li><li><p><strong>Final Goods and Services</strong>: This is crucial. GDP only counts the value of the end product to avoid double-counting. Think of a loaf of bread. We don&#8217;t add the value of the wheat sold to the miller, plus the value of the flour sold to the baker, plus the value of the bread sold to you. That would count the wheat three times! We only count the final price you pay for the bread.</p></li><li><p><strong>Produced Within a Country</strong>: GDP is about location. It counts all production that happens within a country&#8217;s borders, regardless of who owns the company. A Toyota plant in Texas contributes to U.S. GDP. An Apple factory in China contributes to China&#8217;s GDP.</p></li><li><p><strong>In a Given Period of Time</strong>: GDP is a flow, not a stock. It&#8217;s like your monthly salary, not your total life savings. We measure it over a specific period&#8212;usually a quarter or a year&#8212;to see if the flow is speeding up or slowing down.</p></li></ul></li><li><p>GDP is a powerful tool, but it&#8217;s not omniscient. It has blind spots:</p><ul><li><p><strong>The Underground Economy</strong>: The cash-only babysitter, the landscaper who does a side job&#8212;these transactions fuel the economy but often escape the official GDP count.</p></li><li><p><strong>Home Production</strong>: Vegetables from the grocery store are in the GDP while vegetables from your garden are not. GDP values what is traded in the market, not what is produced for oneself. This is a significant omission when comparing living standards across time or cultures.</p></li><li><p><strong>The &#8220;Past&#8221; is Past</strong>: GDP only counts new production. When you sell a used car to your neighbor, it&#8217;s just shifting an existing asset. No new car was produced, so it doesn&#8217;t add to GDP. The initial production of that car was counted the year it was made.</p></li></ul></li><li><p><strong>The Four Engines of GDP</strong>: If total expenditure is one side of the GDP coin, who is doing all this spending? We break it down into four essential components, the four engines that power the economy:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8Lqj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cdc37ab-76f4-41fd-a017-5a0f3e01a970_526x789.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8Lqj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cdc37ab-76f4-41fd-a017-5a0f3e01a970_526x789.jpeg 424w, https://substackcdn.com/image/fetch/$s_!8Lqj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cdc37ab-76f4-41fd-a017-5a0f3e01a970_526x789.jpeg 848w, https://substackcdn.com/image/fetch/$s_!8Lqj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cdc37ab-76f4-41fd-a017-5a0f3e01a970_526x789.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!8Lqj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cdc37ab-76f4-41fd-a017-5a0f3e01a970_526x789.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8Lqj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cdc37ab-76f4-41fd-a017-5a0f3e01a970_526x789.jpeg" width="366" height="549" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2cdc37ab-76f4-41fd-a017-5a0f3e01a970_526x789.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:789,&quot;width&quot;:526,&quot;resizeWidth&quot;:366,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;May be a graphic of text that says 'WHAT IS GDP COMPOSED OF? CONSUMPTION (C) INVESTMENT (1) Spending by househdds on goods &amp; services Examples: food, rent, healthcare Business spending on capital goods, new housing, inventories GOVERNMENT SPENDING(G) &#37329; Expenditures by government on goods &amp; services Examples: salaries. les:salaries.infrastructure infrastructure, defense NET EXPORTS (NX) &#2951;&#2950;&#3021; Exports minus imports Shows trade balance GDP= GDP=C+|+G+( (X-M) GDP measures the total value of goods &amp; services produced in an economy.'&quot;,&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="May be a graphic of text that says 'WHAT IS GDP COMPOSED OF? CONSUMPTION (C) INVESTMENT (1) Spending by househdds on goods &amp; services Examples: food, rent, healthcare Business spending on capital goods, new housing, inventories GOVERNMENT SPENDING(G) &#37329; Expenditures by government on goods &amp; services Examples: salaries. les:salaries.infrastructure infrastructure, defense NET EXPORTS (NX) &#2951;&#2950;&#3021; Exports minus imports Shows trade balance GDP= GDP=C+|+G+( (X-M) GDP measures the total value of goods &amp; services produced in an economy.'" title="May be a graphic of text that says 'WHAT IS GDP COMPOSED OF? CONSUMPTION (C) INVESTMENT (1) Spending by househdds on goods &amp; services Examples: food, rent, healthcare Business spending on capital goods, new housing, inventories GOVERNMENT SPENDING(G) &#37329; Expenditures by government on goods &amp; services Examples: salaries. les:salaries.infrastructure infrastructure, defense NET EXPORTS (NX) &#2951;&#2950;&#3021; Exports minus imports Shows trade balance GDP= GDP=C+|+G+( (X-M) GDP measures the total value of goods &amp; services produced in an economy.'" srcset="https://substackcdn.com/image/fetch/$s_!8Lqj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cdc37ab-76f4-41fd-a017-5a0f3e01a970_526x789.jpeg 424w, https://substackcdn.com/image/fetch/$s_!8Lqj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cdc37ab-76f4-41fd-a017-5a0f3e01a970_526x789.jpeg 848w, https://substackcdn.com/image/fetch/$s_!8Lqj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cdc37ab-76f4-41fd-a017-5a0f3e01a970_526x789.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!8Lqj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cdc37ab-76f4-41fd-a017-5a0f3e01a970_526x789.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">Image Source: https://www.facebook.com/Learningeconomicsfast/posts/what-is-gdp-composed-of/1609672570355449/</figcaption></figure></div><ul><li><p><strong>Consumption (C)</strong>: This is you and me. It&#8217;s spending by households on everything from groceries and movie tickets to haircuts and new phones. It&#8217;s the largest and most stable engine of the economy.</p></li><li><p><strong>Investment (I)</strong>: This is not buying stocks! In GDP terms, investment means spending on goods that will be used for future production. This includes:</p><ul><li><p>Business Capital: A factory buying new machinery.</p></li><li><p>Residential Capital: A construction company building a new house or apartment building.</p></li><li><p>Inventories: The value of unsold goods sitting on shelves or in warehouses.</p></li></ul></li><li><p><strong>Government Purchases (G)</strong>: Spending by all levels of government (local, state, federal) on goods and services. This includes teachers&#8217; salaries, military equipment, and infrastructure projects. (Note: this does NOT include &#8220;transfer payments&#8221; like Social Security or unemployment benefits, as those are just redistributing existing income, not paying for a new service.)</p></li><li><p><strong>Net Exports (XP)</strong>: In our global economy, we must account for trade.</p><ul><li><p>Exports (X) are goods we produce and sell to other countries. This is foreign spending on our output, so it adds to our GDP.</p></li><li><p>Imports (M) are goods we buy from other countries. This is our spending on their output, so it subtracts from our GDP.</p></li><li><p>Net Exports (XP) = Exports (X) - Imports (M)</p></li></ul></li></ul><p></p></li><li><p>Imagine the economy produced exactly 100 loaves of bread last year and 100 loaves this year. Production is identical, but last year, bread cost $1 a loaf, and this year, due to inflation, it costs $2 a loaf. <strong>Nominal GDP</strong> uses current prices. So, last year&#8217;s Nominal GDP for bread was $100. This year, it&#8217;s $200. It looks like the economy doubled in size, but it didn&#8217;t! It&#8217;s an illusion caused by rising prices. <strong>Real GDP</strong> uses the prices from a fixed base year (say, last year&#8217;s prices). So, both last year and this year, Real GDP for bread is calculated as 100 loaves * $1 = $100. Real GDP shows that our actual output&#8212;the quantity of bread&#8212;didn&#8217;t change.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!g0qm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F483b9b96-f2ec-428a-b262-ce14f605f70e_863x515.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!g0qm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F483b9b96-f2ec-428a-b262-ce14f605f70e_863x515.png 424w, https://substackcdn.com/image/fetch/$s_!g0qm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F483b9b96-f2ec-428a-b262-ce14f605f70e_863x515.png 848w, https://substackcdn.com/image/fetch/$s_!g0qm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F483b9b96-f2ec-428a-b262-ce14f605f70e_863x515.png 1272w, https://substackcdn.com/image/fetch/$s_!g0qm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F483b9b96-f2ec-428a-b262-ce14f605f70e_863x515.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!g0qm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F483b9b96-f2ec-428a-b262-ce14f605f70e_863x515.png" width="388" height="231.54113557358053" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/483b9b96-f2ec-428a-b262-ce14f605f70e_863x515.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:515,&quot;width&quot;:863,&quot;resizeWidth&quot;:388,&quot;bytes&quot;:102051,&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://photonlines.substack.com/i/179003928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F483b9b96-f2ec-428a-b262-ce14f605f70e_863x515.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_!g0qm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F483b9b96-f2ec-428a-b262-ce14f605f70e_863x515.png 424w, https://substackcdn.com/image/fetch/$s_!g0qm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F483b9b96-f2ec-428a-b262-ce14f605f70e_863x515.png 848w, https://substackcdn.com/image/fetch/$s_!g0qm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F483b9b96-f2ec-428a-b262-ce14f605f70e_863x515.png 1272w, https://substackcdn.com/image/fetch/$s_!g0qm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F483b9b96-f2ec-428a-b262-ce14f605f70e_863x515.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption">Image Source: https://www.peakframeworks.com/post/gross-domestic-product </figcaption></figure></div><p></p></li><li><p>Real GDP strips out the effect of inflation and tells us if we are actually producing more &#8220;stuff.&#8221; It is the true measure of economic growth. The <strong>GDP Deflator (which is Nominal GDP / Real GDP)</strong> is the gauge that tells us how much of the change was due to pure inflation.</p></li><li><p>GDP is a good measure of economic size and production. It is highly correlated with our standard of living. People generally prefer higher incomes to lower ones, and a higher GDP per person typically means a nation can afford better food, healthcare, and education.</p></li><li><p>GDP does nothing to measure happiness or well-being though. It places no value on:</p><ul><li><p><strong>Leisure</strong>: A society where everyone works 80-hour weeks will have a higher GDP than a equally productive one with 30-hour weeks, but its people may be far less happy.</p></li><li><p><strong>Environmental Quality</strong>: A factory that pollutes a river adds to GDP. The cost of cleaning the river also adds to GDP. But the loss of a clean river itself is never subtracted.</p></li><li><p><strong>Equality</strong>: GDP can be rising rapidly even if all the gains are going to a tiny fraction of the population.</p></li><li><p><strong>Non-Market Activity</strong>: The value of a parent staying home to raise a child is immense, but it is entirely absent from GDP.</p></li></ul></li><li><p>In the end, GDP is like a car&#8217;s speedometer. It is an essential, real-time instrument that tells you how fast you&#8217;re going. It is utterly indispensable for managing the journey, but it doesn&#8217;t tell you if you&#8217;re heading in the right direction, if the passengers are happy, or what the scenic view is like outside the window, so it gives you a very limited view of reality and what goes on in the real world.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KOOY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03ef7c6a-8233-45ee-9aa4-a41121592d27_1600x1122.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KOOY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03ef7c6a-8233-45ee-9aa4-a41121592d27_1600x1122.jpeg 424w, https://substackcdn.com/image/fetch/$s_!KOOY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03ef7c6a-8233-45ee-9aa4-a41121592d27_1600x1122.jpeg 848w, https://substackcdn.com/image/fetch/$s_!KOOY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03ef7c6a-8233-45ee-9aa4-a41121592d27_1600x1122.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!KOOY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03ef7c6a-8233-45ee-9aa4-a41121592d27_1600x1122.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KOOY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03ef7c6a-8233-45ee-9aa4-a41121592d27_1600x1122.jpeg" width="1456" height="1021" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/03ef7c6a-8233-45ee-9aa4-a41121592d27_1600x1122.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1021,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;U.S States GDP vs Countries&quot;,&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="U.S States GDP vs Countries" title="U.S States GDP vs Countries" srcset="https://substackcdn.com/image/fetch/$s_!KOOY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03ef7c6a-8233-45ee-9aa4-a41121592d27_1600x1122.jpeg 424w, https://substackcdn.com/image/fetch/$s_!KOOY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03ef7c6a-8233-45ee-9aa4-a41121592d27_1600x1122.jpeg 848w, https://substackcdn.com/image/fetch/$s_!KOOY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03ef7c6a-8233-45ee-9aa4-a41121592d27_1600x1122.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!KOOY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03ef7c6a-8233-45ee-9aa4-a41121592d27_1600x1122.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">While it&#8217;s impressive that these large U.S. states outperform countries in the developed world, what might be even more impressive is how even the smallest U.S. states compare favorably to foreign nations. The U.S. economy is the largest in the world, squashing the size of every other nation on Earth. Original image taken from <strong><a href="https://howmuch.net/articles/comparing-us-states-to-entire-countries-by-gdp-2019">Visualizing U.S States GDP vs Countries</a></strong></figcaption></figure></div></li></ul><p></p><div><hr></div><h3><strong>Measuring the Cost of Living</strong></h3><ul><li><p>We want a single number that tells us &#8220;how expensive life feels&#8221; this year compared with some earlier year. That number is an index. We&#8217;ll build it carefully, see what it misses, and learn how to use it to translate dollars from one time into another&#8212;so we compare purchasing power, not just ink on paper.</p></li><li><p><strong>The Consumer Price Index (CPI)</strong> answers: how much would it cost today to buy the same typical basket of goods and services a consumer bought in the base year? It reports that cost as an index number (base year = 100).</p><ul><li><p>If the CPI is 118, the same basket that cost $100 in the base year now costs $118.</p></li><li><p>The inflation rate between two periods is the percent change in the CPI.</p></li></ul></li><li><p><strong>How is CPI measured though?</strong> Government&#8217;s economists conduct a massive, ongoing thought experiment:</p><ul><li><p>They define a &#8220;basket&#8221; of goods and services that represents what a typical urban household buys in a typical year. This basket isn&#8217;t random; it&#8217;s a precise recipe based on thousands of consumer surveys. It contains specific quantities of milk, bread, gasoline, apparel, medical care, and even streaming services. This is the CPI Market Basket.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BoDm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca9b29c-b3b9-441e-adcc-20b7a210776d_1500x1000.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BoDm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca9b29c-b3b9-441e-adcc-20b7a210776d_1500x1000.webp 424w, https://substackcdn.com/image/fetch/$s_!BoDm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca9b29c-b3b9-441e-adcc-20b7a210776d_1500x1000.webp 848w, https://substackcdn.com/image/fetch/$s_!BoDm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca9b29c-b3b9-441e-adcc-20b7a210776d_1500x1000.webp 1272w, https://substackcdn.com/image/fetch/$s_!BoDm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca9b29c-b3b9-441e-adcc-20b7a210776d_1500x1000.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BoDm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca9b29c-b3b9-441e-adcc-20b7a210776d_1500x1000.webp" width="538" height="358.78983516483515" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cca9b29c-b3b9-441e-adcc-20b7a210776d_1500x1000.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:538,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;The 8 Major Groups of the Consumer Price Index&quot;,&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="The 8 Major Groups of the Consumer Price Index" title="The 8 Major Groups of the Consumer Price Index" srcset="https://substackcdn.com/image/fetch/$s_!BoDm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca9b29c-b3b9-441e-adcc-20b7a210776d_1500x1000.webp 424w, https://substackcdn.com/image/fetch/$s_!BoDm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca9b29c-b3b9-441e-adcc-20b7a210776d_1500x1000.webp 848w, https://substackcdn.com/image/fetch/$s_!BoDm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca9b29c-b3b9-441e-adcc-20b7a210776d_1500x1000.webp 1272w, https://substackcdn.com/image/fetch/$s_!BoDm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcca9b29c-b3b9-441e-adcc-20b7a210776d_1500x1000.webp 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">Image Source: https://www.investopedia.com/terms/c/consumerpriceindex.asp </figcaption></figure></div></li><li><p>Once defined, this basket is kept fixed. This is the &#8220;base year&#8221; basket.</p></li><li><p>Each month, economic assistants literally go out to stores across the country and record the prices of every item in that fixed basket.</p></li><li><p>The Consumer Price Index (CPI) is the cost of buying that fixed basket in the current year, compared to the cost of buying the exact same basket in the base year.</p></li></ul></li><li><p>The formula is simple:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!n83O!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F971d9a11-983d-4713-92bf-49d4affd0977_1026x170.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!n83O!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F971d9a11-983d-4713-92bf-49d4affd0977_1026x170.png 424w, https://substackcdn.com/image/fetch/$s_!n83O!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F971d9a11-983d-4713-92bf-49d4affd0977_1026x170.png 848w, https://substackcdn.com/image/fetch/$s_!n83O!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F971d9a11-983d-4713-92bf-49d4affd0977_1026x170.png 1272w, https://substackcdn.com/image/fetch/$s_!n83O!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F971d9a11-983d-4713-92bf-49d4affd0977_1026x170.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!n83O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F971d9a11-983d-4713-92bf-49d4affd0977_1026x170.png" width="1026" height="170" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/971d9a11-983d-4713-92bf-49d4affd0977_1026x170.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:170,&quot;width&quot;:1026,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:13491,&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://photonlines.substack.com/i/179003928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F971d9a11-983d-4713-92bf-49d4affd0977_1026x170.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_!n83O!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F971d9a11-983d-4713-92bf-49d4affd0977_1026x170.png 424w, https://substackcdn.com/image/fetch/$s_!n83O!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F971d9a11-983d-4713-92bf-49d4affd0977_1026x170.png 848w, https://substackcdn.com/image/fetch/$s_!n83O!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F971d9a11-983d-4713-92bf-49d4affd0977_1026x170.png 1272w, https://substackcdn.com/image/fetch/$s_!n83O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F971d9a11-983d-4713-92bf-49d4affd0977_1026x170.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p></li><li><p>The percentage change in the CPI from one period to the next is the inflation rate. If the CPI rises from 120 to 123 over a year, the inflation rate is (123-120)/120 = 2.5%.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1tIb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09c26d03-5c21-456e-b5f7-794367e815ca_1200x1565.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1tIb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09c26d03-5c21-456e-b5f7-794367e815ca_1200x1565.webp 424w, https://substackcdn.com/image/fetch/$s_!1tIb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09c26d03-5c21-456e-b5f7-794367e815ca_1200x1565.webp 848w, https://substackcdn.com/image/fetch/$s_!1tIb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09c26d03-5c21-456e-b5f7-794367e815ca_1200x1565.webp 1272w, https://substackcdn.com/image/fetch/$s_!1tIb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09c26d03-5c21-456e-b5f7-794367e815ca_1200x1565.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1tIb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09c26d03-5c21-456e-b5f7-794367e815ca_1200x1565.webp" width="540" height="704.25" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/09c26d03-5c21-456e-b5f7-794367e815ca_1200x1565.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1565,&quot;width&quot;:1200,&quot;resizeWidth&quot;:540,&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_!1tIb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09c26d03-5c21-456e-b5f7-794367e815ca_1200x1565.webp 424w, https://substackcdn.com/image/fetch/$s_!1tIb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09c26d03-5c21-456e-b5f7-794367e815ca_1200x1565.webp 848w, https://substackcdn.com/image/fetch/$s_!1tIb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09c26d03-5c21-456e-b5f7-794367e815ca_1200x1565.webp 1272w, https://substackcdn.com/image/fetch/$s_!1tIb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09c26d03-5c21-456e-b5f7-794367e815ca_1200x1565.webp 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"><strong><a href="https://www.visualcapitalist.com/visualized-u-s-inflation-by-category-in-2025/">Visualized: U.S. Inflation by Category</a> from Sept. 2024 to Sept. 2025</strong></figcaption></figure></div></li></ul><p></p><ul><li><p>The CPI is a brilliant tool, but it&#8217;s not perfect. By holding the shopping cart fixed, it misses three key ways that real people adapt, causing it to systematically overstate the true rise in the cost of living:</p><ul><li><p><strong>The Substitution Bias</strong>: Imagine the fixed basket has both apples and oranges. One year, a frost wipes out the orange harvest, and the price of oranges doubles. What do you do? As a smart shopper, you probably buy more apples and fewer oranges. The CPI doesn&#8217;t do this. It blindly continues to buy the same fixed quantity of expensive oranges. It assumes you&#8217;re a robot who doesn&#8217;t substitute toward cheaper alternatives. In reality, your cost of living didn&#8217;t go up as much as the CPI says, because you adapted. The CPI misses this.</p></li><li><p><strong>The Introduction of New Goods</strong>: Think back to 1995. The CPI basket included typewriters, cassette tapes, and film for your camera. Then, new goods arrived: personal computers, MP3 players, and digital cameras. These new products created a massive increase in consumer choice and value. You could now do things that were previously impossible, or do them far more cheaply. The purchasing power of your dollar increased dramatically. But the CPI, with its fixed basket from 1995, completely missed this explosion of new value and choice when it first happened. It only slowly incorporates new goods, failing to account for the increase in economic welfare they provide from day one.</p></li><li><p><strong>Unmeasured Quality Change</strong>: Is a 2024 car the same &#8220;good&#8221; as a 2004 car? Not really. The 2024 model likely has standard backup cameras, Bluetooth, and advanced safety features. Even if the sticker price increased only with inflation, you are getting a significantly better product. The CPI tries to adjust for quality, but it&#8217;s incredibly difficult. When it fails to fully account for this improvement, it records a pure price increase when, in fact, you are getting more for your money. Your true cost of living&#8212;the cost per unit of quality&#8212;hasn&#8217;t risen as much.</p></li></ul></li><li><p>We already met another price gauge: the GDP Deflator. While they often tell a similar story, they are built for different purposes. Think of it this way: the CPI is the Cost of Living Index. It asks: &#8220;how much does it cost to buy a typical consumer&#8217;s basket of goods, wherever they were produced?&#8221; It cares about what you consume. The GDP Deflator is the Domestic Production Price Index. It asks: &#8220;how have the prices of <strong>everything</strong> we produce here changed?&#8221; It cares about what we make.</p></li><li><p>This principle of adjusting for inflation is called indexation, and it&#8217;s baked into our economic life:</p><ul><li><p>Social Security: Your grandmother&#8217;s Social Security benefits are indexed to the CPI. They automatically increase each year to maintain her purchasing power.</p></li><li><p>Labor Contracts: Many union contracts have Cost-of-Living Adjustments (COLAs) tied to the CPI.</p></li><li><p>Alimony and Child Support: Many agreements are indexed to inflation.</p></li></ul></li><li><p>A correction for inflation is especially important when looking at data on interest rates. The <strong>nominal interest rate</strong> is the interest rate usually reported; it is the rate at which the number of dollars in a savings account increases over time. By contrast, the <strong>real interest rate</strong> takes into account changes in the value of the dollar over time. The real interest rate equals the nominal interest rate minus the rate of inflation.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tqpA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e6a56a-f88f-472d-965c-ecb2e59596a6_1024x563.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tqpA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e6a56a-f88f-472d-965c-ecb2e59596a6_1024x563.png 424w, https://substackcdn.com/image/fetch/$s_!tqpA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e6a56a-f88f-472d-965c-ecb2e59596a6_1024x563.png 848w, https://substackcdn.com/image/fetch/$s_!tqpA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e6a56a-f88f-472d-965c-ecb2e59596a6_1024x563.png 1272w, https://substackcdn.com/image/fetch/$s_!tqpA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e6a56a-f88f-472d-965c-ecb2e59596a6_1024x563.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tqpA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e6a56a-f88f-472d-965c-ecb2e59596a6_1024x563.png" width="462" height="254.009765625" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/97e6a56a-f88f-472d-965c-ecb2e59596a6_1024x563.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:563,&quot;width&quot;:1024,&quot;resizeWidth&quot;:462,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Nominal Interest Rate - Overview, Inflation and Compounding Adjustments&quot;,&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="Nominal Interest Rate - Overview, Inflation and Compounding Adjustments" title="Nominal Interest Rate - Overview, Inflation and Compounding Adjustments" srcset="https://substackcdn.com/image/fetch/$s_!tqpA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e6a56a-f88f-472d-965c-ecb2e59596a6_1024x563.png 424w, https://substackcdn.com/image/fetch/$s_!tqpA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e6a56a-f88f-472d-965c-ecb2e59596a6_1024x563.png 848w, https://substackcdn.com/image/fetch/$s_!tqpA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e6a56a-f88f-472d-965c-ecb2e59596a6_1024x563.png 1272w, https://substackcdn.com/image/fetch/$s_!tqpA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97e6a56a-f88f-472d-965c-ecb2e59596a6_1024x563.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">Image Source: https://corporatefinanceinstitute.com/resources/career-map/sell-side/capital-markets/nominal-interest-rate/ </figcaption></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BdMX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dffb169-4c31-420c-979f-18800bfd0222_962x97.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BdMX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dffb169-4c31-420c-979f-18800bfd0222_962x97.png 424w, https://substackcdn.com/image/fetch/$s_!BdMX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dffb169-4c31-420c-979f-18800bfd0222_962x97.png 848w, https://substackcdn.com/image/fetch/$s_!BdMX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dffb169-4c31-420c-979f-18800bfd0222_962x97.png 1272w, https://substackcdn.com/image/fetch/$s_!BdMX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dffb169-4c31-420c-979f-18800bfd0222_962x97.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BdMX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dffb169-4c31-420c-979f-18800bfd0222_962x97.png" width="962" height="97" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9dffb169-4c31-420c-979f-18800bfd0222_962x97.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:97,&quot;width&quot;:962,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:8093,&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://photonlines.substack.com/i/179003928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dffb169-4c31-420c-979f-18800bfd0222_962x97.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_!BdMX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dffb169-4c31-420c-979f-18800bfd0222_962x97.png 424w, https://substackcdn.com/image/fetch/$s_!BdMX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dffb169-4c31-420c-979f-18800bfd0222_962x97.png 848w, https://substackcdn.com/image/fetch/$s_!BdMX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dffb169-4c31-420c-979f-18800bfd0222_962x97.png 1272w, https://substackcdn.com/image/fetch/$s_!BdMX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9dffb169-4c31-420c-979f-18800bfd0222_962x97.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div></li><li><p>Imagine you deposit $100 at a 5% nominal rate. In a year, you have $105. If inflation was 2%, your real return is 5% - 2% = 3%. Your $105 can buy 3% more stuff than your original $100 could, but if inflation was 6%, your real return is 5% - 6% = -1%. You have more dollars, but you can actually buy less. Your savings have been eroded.</p></li><li><p>This negative real interest rate is the &#8220;silent thief&#8221; at work, stealthily transferring wealth from savers to borrowers. Understanding the difference between nominal and real is the key to making any intelligent decision about borrowing, lending, or saving. It is the final, and perhaps most personal, reason why measuring the cost of living matters to us all.</p></li></ul><div><hr></div><h3><strong>Production and Growth</strong></h3><ul><li><p>The differences in economic prosperity around the world are not just significant; they are staggering. The average income in a country like Switzerland or Norway is more than ten times that of a country like Malawi or Sierra Leone. To visualize this, imagine the GDP per person (average income) as the height of a pillar. The pillar for a rich country might be a towering skyscraper while the pillar for a poor country might be a single-story house. Here is the crucial and dynamic part though: these heights are not fixed.</p></li><li><p>Because growth rates vary, the landscape is constantly shifting. A country growing at 7% per year will double its standard of living in just 10 years. Another, growing at a mere 1%, would take 70 years to double. This is the power of compound growth&#8212;the same force that governs your savings account, but applied to the fate of entire nations. Over time, relative positions can change dramatically, as we&#8217;ve seen with the meteoric rise of economies like South Korea and China.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NVi8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d007e76-32ef-446d-b03c-6d221a25d337_2400x2402.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NVi8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d007e76-32ef-446d-b03c-6d221a25d337_2400x2402.jpeg 424w, https://substackcdn.com/image/fetch/$s_!NVi8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d007e76-32ef-446d-b03c-6d221a25d337_2400x2402.jpeg 848w, https://substackcdn.com/image/fetch/$s_!NVi8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d007e76-32ef-446d-b03c-6d221a25d337_2400x2402.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!NVi8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d007e76-32ef-446d-b03c-6d221a25d337_2400x2402.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NVi8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d007e76-32ef-446d-b03c-6d221a25d337_2400x2402.jpeg" width="526" height="526.3612637362637" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1d007e76-32ef-446d-b03c-6d221a25d337_2400x2402.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1457,&quot;width&quot;:1456,&quot;resizeWidth&quot;:526,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;China Economic Growth&quot;,&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="China Economic Growth" title="China Economic Growth" srcset="https://substackcdn.com/image/fetch/$s_!NVi8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d007e76-32ef-446d-b03c-6d221a25d337_2400x2402.jpeg 424w, https://substackcdn.com/image/fetch/$s_!NVi8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d007e76-32ef-446d-b03c-6d221a25d337_2400x2402.jpeg 848w, https://substackcdn.com/image/fetch/$s_!NVi8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d007e76-32ef-446d-b03c-6d221a25d337_2400x2402.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!NVi8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d007e76-32ef-446d-b03c-6d221a25d337_2400x2402.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">China&#8217;s economy started to grow in 1989 and hasn&#8217;t let up, doubling in size roughly every 8 to 10 years. Image source: <strong><a href="https://howmuch.net/articles/chinas-economic-growth-perspective">Visualizing China&#8217;s Economic Growth in the Past 30 Years</a></strong></figcaption></figure></div></li><li><p>So, what ultimately determines the height of a nation&#8217;s pillar of prosperity? It is deceptively simple: a country&#8217;s standard of living depends on its ability to produce goods and services.</p></li><li><p>We can&#8217;t consume what we don&#8217;t produce. And our ability to produce is determined by one thing: <strong>productivity</strong>. Productivity is the quantity of goods and services a worker can produce for each hour of work. It is the efficiency of the economic engine. Think of a kitchen:</p><ul><li><p>A low-productivity kitchen has one person trying to cook a complex meal alone. Progress is slow.</p></li><li><p>A high-productivity kitchen is a professional restaurant kitchen, with a coordinated team where each worker produces a large quantity of high-quality food per hour.</p></li></ul></li><li><p>The difference in output is immense. And that difference stems from the tools available to the workers. Economists group these tools into four categories:</p><ul><li><p><strong>Physical Capital (Tools and Equipment)</strong>: This is the stock of equipment and structures used to produce goods and services. For the kitchen, it&#8217;s the ovens, the pots and pans, and the building itself. For a country, it&#8217;s the factories, the tractors, the roads, the fiber-optic cables. More and better capital allows workers to produce more in the same amount of time.</p></li><li><p><strong>Human Capital (Chef&#8217;s Knowledge)</strong>: This is the knowledge and skills workers acquire through education, training, and experience. A chef with a culinary degree and years of practice (high human capital) is infinitely more productive than a novice (low human capital). A country&#8217;s investment in its people&#8217;s education and health is an investment in human capital.</p></li><li><p><strong>Natural Resources (The Ingredients)</strong>: These are the inputs from nature&#8212;land, rivers, minerals, oil&#8212;used to produce goods and services. Some countries, like Saudi Arabia with its oil or Canada with its lumber, are rich in natural resources. However, they are not strictly necessary for prosperity (see: Japan, Singapore), as a lack can be overcome with trade and ingenuity.</p></li><li><p><strong>Technological Knowledge (Recipes)</strong>: This is the most important driver. It&#8217;s society&#8217;s understanding of the best ways to produce goods and services. The shift from hand-milling grain to using a water wheel was a technological revolution. The invention of the microchip, the internet, or a new vaccine are all explosions of technological knowledge that redefine what is possible.</p></li><li><p><strong>A nation&#8217;s productivity, and therefore its prosperity, is a function of how well it equips its workers with Physical Capital, Human Capital, Natural Resources, and Technological Knowledge.</strong></p><p></p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HhOv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F538e7bd1-ecda-4b95-8025-0a1e50a36df8_1041x692.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HhOv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F538e7bd1-ecda-4b95-8025-0a1e50a36df8_1041x692.png 424w, https://substackcdn.com/image/fetch/$s_!HhOv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F538e7bd1-ecda-4b95-8025-0a1e50a36df8_1041x692.png 848w, https://substackcdn.com/image/fetch/$s_!HhOv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F538e7bd1-ecda-4b95-8025-0a1e50a36df8_1041x692.png 1272w, https://substackcdn.com/image/fetch/$s_!HhOv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F538e7bd1-ecda-4b95-8025-0a1e50a36df8_1041x692.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HhOv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F538e7bd1-ecda-4b95-8025-0a1e50a36df8_1041x692.png" width="1041" height="692" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/538e7bd1-ecda-4b95-8025-0a1e50a36df8_1041x692.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:692,&quot;width&quot;:1041,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:157452,&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://photonlines.substack.com/i/179003928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F538e7bd1-ecda-4b95-8025-0a1e50a36df8_1041x692.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_!HhOv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F538e7bd1-ecda-4b95-8025-0a1e50a36df8_1041x692.png 424w, https://substackcdn.com/image/fetch/$s_!HhOv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F538e7bd1-ecda-4b95-8025-0a1e50a36df8_1041x692.png 848w, https://substackcdn.com/image/fetch/$s_!HhOv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F538e7bd1-ecda-4b95-8025-0a1e50a36df8_1041x692.png 1272w, https://substackcdn.com/image/fetch/$s_!HhOv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F538e7bd1-ecda-4b95-8025-0a1e50a36df8_1041x692.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">The above image provides a productivity measure as GDP per hour of work around the world in 2023. Original image source: <strong><a href="https://ourworldindata.org/grapher/labor-productivity-per-hour-pennworldtable">Productivity: output per hour worked, 2023</a></strong></figcaption></figure></div><p></p></li><li><p>If these are the ingredients for growth, what can a society do to acquire more of them? <strong>Government policy</strong> can pull several powerful levers:</p><ul><li><p><strong>Encourage Saving and Investment</strong>: Saving is the fuel for investment in physical capital. If a nation consumes everything it produces, it has nothing left to build new factories or infrastructure. Policies that incentivize saving can, in turn, fund the investment needed for future growth.</p></li><li><p><strong>Encourage Investment from Abroad</strong>: A country can supplement its own saving by attracting foreign investment, bringing in foreign capital and expertise.</p></li><li><p><strong>Foster Education and Promote Health</strong>: This is direct investment in human capital. A healthy, educated workforce is an innovative and productive one.</p></li><li><p><strong>Maintain Property Rights and Political Stability</strong>: This is the foundation. Would you build a bakery if you thought a mob or the government itself could take it from you tomorrow? Probably not. Secure property rights are the bedrock upon which all investment and innovation are built.</p></li><li><p><strong>Promote Free Trade</strong>: Trade is a form of technology. It allows a country to specialize in what it does best and import what others do better, effectively giving its citizens access to a wider array of goods and more efficient production methods.</p></li><li><p><strong>Promote Research and Development (R&amp;D)</strong>: Technological knowledge doesn&#8217;t just fall from the sky. It is the product of deliberate effort. Direct funding for research, and tax incentives for private R&amp;D, are investments in the &#8220;recipes&#8221; of the future.</p></li></ul></li><li><p>The effects of population growth (a double edged sword): </p><ul><li><p><strong>The Dilution Effect</strong> (The Negative): Imagine dividing the nation&#8217;s capital stock among its workers. Rapid population growth means more workers, so the amount of capital per worker&#8212;a key determinant of productivity&#8212;falls. It &#8220;stretches&#8221; the available capital and natural resources more thinly. This is known as capital dilution and can lower the standard of living.</p></li><li><p><strong>The Innovation Effect</strong> (The Positive): A larger population means more minds. More potential scientists, engineers, entrepreneurs, and inventors. In this view, people aren&#8217;t just mouths to feed; they are problem-solvers. A larger, global population has arguably contributed to an accelerating rate of technological progress over human history.</p></li><li><p>The net effect of population growth is ambiguous and depends on which of these two forces&#8212;dilution of resources or acceleration of ideas&#8212;is stronger.</p></li></ul></li><li><p>In the short run, we are captivated by the business cycle&#8212;the booms and busts that dominate the headlines. But in the long run, almost nothing matters more than the steady, cumulative power of <strong>economic growth</strong>. A difference of a single percentage point in the growth rate, sustained over a generation, is the difference between stagnation and transformation. Understanding the drivers of productivity is therefore not just an academic exercise. It is the key to unlocking the potential of nations and lifting the pillars of prosperity for all.</p></li></ul><div><hr></div><h3><strong>Saving, Investment, and the Financial System</strong></h3><ul><li><p>The U.S. financial system is made up of many types of financial institutions, such as the bond market, the stock market, banks, and mutual funds. All these institutions act to direct the resources of households that want to save some of their income into the hands of households and firms that want to borrow.</p></li><li><p>All these institutions perform the same essential function: they direct the resources of those who want to save (defer consumption) into the hands of those who want to invest (build capital for future production).</p></li><li><p>Imagine the entire economy is a giant farm. The year&#8217;s harvest is the nation&#8217;s total output of goods and services (GDP). Once the harvest is in, the farm family faces a critical choice:</p><ul><li><p>They can consume the grain immediately, eating their fill.</p></li><li><p>They can save a portion of the harvest, setting it aside in the barn.</p></li></ul></li><li><p>But here&#8217;s the crucial idea: in economics, &#8220;saving&#8221; isn&#8217;t just letting grain gather dust in the barn. That would be hoarding, and it&#8217;s wasteful. True economic saving is the act of setting aside real resources to be used for future production. So, what do we with the saved grain?</p><ul><li><p>We can use it as seed corn to plant next year&#8217;s crop (business investment).</p></li><li><p>We can use it to build a new, more efficient irrigation system (infrastructure investment).</p></li><li><p>We can use it to feed workers while they build a new barn (construction investment).</p></li></ul></li><li><p>Different financial institutions play different roles in this farm economy:</p><ul><li><p><strong>Banks</strong> are like local grain elevators or co-ops. Farm families bring their extra grain and store it there (deposits). The elevator then lends grain out to farmers who need seed or to buy better tools (loans). Borrowers agree to return more grain in the future than they borrowed (interest). Savers earn a little extra grain over time in return for letting others use their stored harvest.</p></li><li><p>The <strong>bond market</strong> is like a large town leader announcing: &#8220;If you each lend me some grain now, I promise to repay you later, plus extra.&#8221;<br>That promise is a <strong>bond</strong>. Many households each send a few sacks of grain to finance a big project&#8212;a new irrigation canal, a flour mill, or a road. Later, the project repays those households with their grain plus additional sacks (interest).</p></li><li><p>The <strong>stock market</strong> is like a group of families pooling grain to build and co-own a new grain mill or bakery. When you buy stock, you are not just lending grain; you are trading grain for a slice of ownership in the business itself. If the mill does well and produces lots of flour and profits, your share is worth more and may pay you part of the earnings. If the mill does poorly, the value of your share falls.</p></li><li><p><strong>Mutual funds</strong> are like a grain investment club. Many small families pour part of their harvest into one big shared granary. A trusted manager then uses that pooled grain to back many different ventures: some mills, some orchards, some roads (a mix of stocks and bonds). Even families with only a few extra sacks of grain can, through the club, participate in a wide range of investments and share in the gains and losses.</p></li></ul></li><li><p>In this closed farm economy, there is no other use for the saved grain. Every bushel of grain that is not consumed must, by definition, be invested back into the farm. There is no magical third option. This leads to the profound, unbreakable accounting identity for a closed economy:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tWvn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F436e17b6-f380-43e1-b4d0-54b4c9e91fc8_463x80.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tWvn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F436e17b6-f380-43e1-b4d0-54b4c9e91fc8_463x80.png 424w, https://substackcdn.com/image/fetch/$s_!tWvn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F436e17b6-f380-43e1-b4d0-54b4c9e91fc8_463x80.png 848w, https://substackcdn.com/image/fetch/$s_!tWvn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F436e17b6-f380-43e1-b4d0-54b4c9e91fc8_463x80.png 1272w, https://substackcdn.com/image/fetch/$s_!tWvn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F436e17b6-f380-43e1-b4d0-54b4c9e91fc8_463x80.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tWvn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F436e17b6-f380-43e1-b4d0-54b4c9e91fc8_463x80.png" width="381" height="65.83153347732181" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/436e17b6-f380-43e1-b4d0-54b4c9e91fc8_463x80.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:80,&quot;width&quot;:463,&quot;resizeWidth&quot;:381,&quot;bytes&quot;:5805,&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://photonlines.substack.com/i/179003928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F436e17b6-f380-43e1-b4d0-54b4c9e91fc8_463x80.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_!tWvn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F436e17b6-f380-43e1-b4d0-54b4c9e91fc8_463x80.png 424w, https://substackcdn.com/image/fetch/$s_!tWvn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F436e17b6-f380-43e1-b4d0-54b4c9e91fc8_463x80.png 848w, https://substackcdn.com/image/fetch/$s_!tWvn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F436e17b6-f380-43e1-b4d0-54b4c9e91fc8_463x80.png 1272w, https://substackcdn.com/image/fetch/$s_!tWvn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F436e17b6-f380-43e1-b4d0-54b4c9e91fc8_463x80.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p></li><li><p>It is not a theory or a policy goal; it is a mathematical and logical truth. <strong>The real resources we refrain from consuming today are the very same resources we use to build our future capacity.</strong> You can think of the financial system as the grain elevator and logistics network. It doesn&#8217;t create the grain (real resources), but it efficiently moves the grain from those who have saved it (savers) to those who need it for productive projects (borrowers/investors). It ensures that the seed corn gets from the barn to the field, rather than being left to rot.</p></li><li><p>A society&#8217;s consumption is limited by what it produces. And its future production is built entirely upon what it saves and invests from today&#8217;s output. The choice between consumption and saving is, therefore, the most fundamental choice an economy makes about its own future.</p></li><li><p>How is this matching of savers and borrowers coordinated? Through a market, just like any other. But instead of apples or cars, the commodity being traded is loanable funds&#8212;the money available for borrowing. The price in this market is the <strong>real interest rate</strong>.</p><ul><li><p><strong>Supply of Loanable Funds</strong>: This comes from savers. The higher the real interest rate, the greater the reward for saving, so the more funds people are willing to supply. (The supply curve slopes upward).</p></li><li><p><strong>Demand for Loanable Funds</strong>: This comes from borrowers (mainly firms wanting to invest in new projects). The higher the real interest rate, the more expensive it is to borrow, so the less they will demand. (The demand curve slopes downward). The market-clearing interest rate is where the supply of saving meets the demand for investment.</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-Ag!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79924d07-58e4-488d-8ada-7760910af73f_611x587.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!N-Ag!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79924d07-58e4-488d-8ada-7760910af73f_611x587.png 424w, https://substackcdn.com/image/fetch/$s_!N-Ag!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79924d07-58e4-488d-8ada-7760910af73f_611x587.png 848w, https://substackcdn.com/image/fetch/$s_!N-Ag!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79924d07-58e4-488d-8ada-7760910af73f_611x587.png 1272w, https://substackcdn.com/image/fetch/$s_!N-Ag!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79924d07-58e4-488d-8ada-7760910af73f_611x587.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!N-Ag!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79924d07-58e4-488d-8ada-7760910af73f_611x587.png" width="421" height="404.4631751227496" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/79924d07-58e4-488d-8ada-7760910af73f_611x587.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:587,&quot;width&quot;:611,&quot;resizeWidth&quot;:421,&quot;bytes&quot;:154446,&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://photonlines.substack.com/i/179003928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79924d07-58e4-488d-8ada-7760910af73f_611x587.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-Ag!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79924d07-58e4-488d-8ada-7760910af73f_611x587.png 424w, https://substackcdn.com/image/fetch/$s_!N-Ag!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79924d07-58e4-488d-8ada-7760910af73f_611x587.png 848w, https://substackcdn.com/image/fetch/$s_!N-Ag!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79924d07-58e4-488d-8ada-7760910af73f_611x587.png 1272w, https://substackcdn.com/image/fetch/$s_!N-Ag!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79924d07-58e4-488d-8ada-7760910af73f_611x587.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>Image Source: <a href="https://s3-us-west-2.amazonaws.com/courses-images-archive-read-only/wp-content/uploads/sites/1295/2015/06/03182233/graph14.jpg">https://s3-us-west-2.amazonaws.com/courses-images-archive-read-only/wp-content/uploads/sites/1295/2015/06/03182233/graph14.jpg</a></em></figcaption></figure></div></li></ul><p></p><p></p></li><li><p>Any policy or event can be analyzed by how it shifts these curves. A tax incentive for saving? Supply shifts right, leading to more funds and a lower interest rate. A wave of technological optimism among firms? Demand shifts right, leading to more borrowing and a higher interest rate.</p></li><li><p>National saving has two components:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3CNP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc127a92e-9a91-4227-8183-a59db3bc85d7_726x92.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3CNP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc127a92e-9a91-4227-8183-a59db3bc85d7_726x92.png 424w, https://substackcdn.com/image/fetch/$s_!3CNP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc127a92e-9a91-4227-8183-a59db3bc85d7_726x92.png 848w, https://substackcdn.com/image/fetch/$s_!3CNP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc127a92e-9a91-4227-8183-a59db3bc85d7_726x92.png 1272w, https://substackcdn.com/image/fetch/$s_!3CNP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc127a92e-9a91-4227-8183-a59db3bc85d7_726x92.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3CNP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc127a92e-9a91-4227-8183-a59db3bc85d7_726x92.png" width="498" height="63.107438016528924" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c127a92e-9a91-4227-8183-a59db3bc85d7_726x92.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:92,&quot;width&quot;:726,&quot;resizeWidth&quot;:498,&quot;bytes&quot;:8033,&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://photonlines.substack.com/i/179003928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc127a92e-9a91-4227-8183-a59db3bc85d7_726x92.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_!3CNP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc127a92e-9a91-4227-8183-a59db3bc85d7_726x92.png 424w, https://substackcdn.com/image/fetch/$s_!3CNP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc127a92e-9a91-4227-8183-a59db3bc85d7_726x92.png 848w, https://substackcdn.com/image/fetch/$s_!3CNP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc127a92e-9a91-4227-8183-a59db3bc85d7_726x92.png 1272w, https://substackcdn.com/image/fetch/$s_!3CNP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc127a92e-9a91-4227-8183-a59db3bc85d7_726x92.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p><ul><li><p><strong>Private Saving</strong> is the income that households have left after taxes and consumption.</p></li><li><p><strong>Public Saving</strong> is the tax revenue the government has left after paying for its spending. If the government spends more than it collects (a budget deficit), then public saving is negative.</p></li></ul></li><li><p>National saving equals private saving plus public saving. A government budget deficit represents negative public saving and, therefore, reduces national saving and the supply of loanable funds available to finance investment. When a government budget deficit crowds out investment, it reduces the growth of productivity and GDP.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Yz33!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e528907-9bab-4ee4-b908-05228aab2afe_900x369.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Yz33!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e528907-9bab-4ee4-b908-05228aab2afe_900x369.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Yz33!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e528907-9bab-4ee4-b908-05228aab2afe_900x369.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Yz33!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e528907-9bab-4ee4-b908-05228aab2afe_900x369.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Yz33!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e528907-9bab-4ee4-b908-05228aab2afe_900x369.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Yz33!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e528907-9bab-4ee4-b908-05228aab2afe_900x369.jpeg" width="900" height="369" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8e528907-9bab-4ee4-b908-05228aab2afe_900x369.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:369,&quot;width&quot;:900,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Budget Surplus formula&quot;,&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="Budget Surplus formula" title="Budget Surplus formula" srcset="https://substackcdn.com/image/fetch/$s_!Yz33!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e528907-9bab-4ee4-b908-05228aab2afe_900x369.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Yz33!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e528907-9bab-4ee4-b908-05228aab2afe_900x369.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Yz33!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e528907-9bab-4ee4-b908-05228aab2afe_900x369.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Yz33!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e528907-9bab-4ee4-b908-05228aab2afe_900x369.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">Image Source: https://www.educba.com/budget-surplus/</figcaption></figure></div><p>To provide a clearer picture &#8211; let&#8217;s go back to the farming analogy we used previously. Let&#8217;s stick with our farm, but now imagine it&#8217;s a communal farm with two distinct groups:</p><ul><li><p><strong>The Households (Private Sector)</strong>: All the families who work the land.</p></li><li><p><strong>The Town Council (Government)</strong>: The group that manages shared services like irrigation canals and security walls, funded by a portion of the harvest (taxes).</p></li></ul></li><li><p>At harvest time, the total grain (national saving) is stored in two silos:</p><ul><li><p><strong>The Private Silo (private saving)</strong>: This is the grain the households have left over after giving the council its share (taxes) and after feeding their families (consumption). They plan to use this for their own future projects&#8212;planting new fields, buying better tools, or building a new shed.</p></li><li><p><strong>The Public Silo (public saving)</strong>: This is the grain the Town Council has left over after paying for its ongoing services (government spending). If the council runs a surplus, this silo is full. This grain can be used for major communal projects that benefit everyone, like building a new granary or a road to market.</p></li></ul></li><li><p><strong>How deficits work:</strong> a deficit means the Town Council has not only spent all its tax grain but needs even more to fund its projects. To get this grain, the council goes to the communal grain bank (the financial system) and borrows grain from the private silo. It issues an IOU (a government bond) in return.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!VIIT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc719b9b7-b35b-4d55-8e2e-9a69d5d2095f_910x890.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VIIT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc719b9b7-b35b-4d55-8e2e-9a69d5d2095f_910x890.png 424w, https://substackcdn.com/image/fetch/$s_!VIIT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc719b9b7-b35b-4d55-8e2e-9a69d5d2095f_910x890.png 848w, https://substackcdn.com/image/fetch/$s_!VIIT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc719b9b7-b35b-4d55-8e2e-9a69d5d2095f_910x890.png 1272w, https://substackcdn.com/image/fetch/$s_!VIIT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc719b9b7-b35b-4d55-8e2e-9a69d5d2095f_910x890.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!VIIT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc719b9b7-b35b-4d55-8e2e-9a69d5d2095f_910x890.png" width="910" height="890" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c719b9b7-b35b-4d55-8e2e-9a69d5d2095f_910x890.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:890,&quot;width&quot;:910,&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_!VIIT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc719b9b7-b35b-4d55-8e2e-9a69d5d2095f_910x890.png 424w, https://substackcdn.com/image/fetch/$s_!VIIT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc719b9b7-b35b-4d55-8e2e-9a69d5d2095f_910x890.png 848w, https://substackcdn.com/image/fetch/$s_!VIIT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc719b9b7-b35b-4d55-8e2e-9a69d5d2095f_910x890.png 1272w, https://substackcdn.com/image/fetch/$s_!VIIT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc719b9b7-b35b-4d55-8e2e-9a69d5d2095f_910x890.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">The US Federal Budget Outlays vs. Revenues in 2024. Image source: https://upload.wikimedia.org/wikipedia/commons/4/49/Fy2024_federal_budget.png </figcaption></figure></div></li><li><p>This is where the crucial shift happens. The council&#8217;s borrowing doesn&#8217;t just empty the public silo; it actively draws down the grain from the Private Silo. In other words &#8211; in this instance, the communal pile of seed grain for the entire farm has SHRUNK. Now, let&#8217;s see the consequence:</p><ul><li><p>A young, ambitious farmer arrives at the grain bank. He has a brilliant plan to cultivate a rocky but fertile hillside. His calculations show it will be profitable if she can borrow seed grain at a low cost.</p></li><li><p>But he finds a line. The Town Council is there, borrowing a massive amount of grain to fund a grand but less efficient monument. Because of the council&#8217;s huge demand, the price for borrowing grain (the real interest rate) has shot up.</p></li><li><p>The bank tells him: &#8220;We can lend you the seed, but the cost to borrow is now much higher.&#8221;</p></li><li><p>He redoes her math. At this new and higher cost, his hillside project is no longer profitable. He walks away, and the rocky field remains barren.</p></li></ul></li><li><p>The government&#8217;s deficit spending didn&#8217;t just use up resources; it made those resources more expensive for everyone else. By borrowing heavily, the town council <strong>crowded out</strong> the private farmer&#8217;s productive investment. To summarize once again:</p><ul><li><p>The <strong>limited resource</strong> is the real, physical seed grain (loanable funds).</p></li><li><p>The <strong>government&#8217;s demand</strong> for that resource drives up its price (the real interest rate).</p></li><li><p>The result is that the most innovative, growth-oriented private projects are the first to be abandoned.</p></li></ul></li><li><p>The tragedy is invisible. We see the council&#8217;s monument being built. We do not see the more productive fields that were never planted, the new tools that were never forged, or the research into better crops that was never funded. The economy&#8217;s long-term growth potential is silently diminished, all because the communal pool of savings was diverted from its most productive uses.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Ok0b!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cc6d2cc-8012-436d-9b9f-0543960bb11c_977x573.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Ok0b!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cc6d2cc-8012-436d-9b9f-0543960bb11c_977x573.png 424w, https://substackcdn.com/image/fetch/$s_!Ok0b!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cc6d2cc-8012-436d-9b9f-0543960bb11c_977x573.png 848w, https://substackcdn.com/image/fetch/$s_!Ok0b!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cc6d2cc-8012-436d-9b9f-0543960bb11c_977x573.png 1272w, https://substackcdn.com/image/fetch/$s_!Ok0b!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cc6d2cc-8012-436d-9b9f-0543960bb11c_977x573.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Ok0b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cc6d2cc-8012-436d-9b9f-0543960bb11c_977x573.png" width="977" height="573" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6cc6d2cc-8012-436d-9b9f-0543960bb11c_977x573.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:573,&quot;width&quot;:977,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:109264,&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://photonlines.substack.com/i/179003928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cc6d2cc-8012-436d-9b9f-0543960bb11c_977x573.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_!Ok0b!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cc6d2cc-8012-436d-9b9f-0543960bb11c_977x573.png 424w, https://substackcdn.com/image/fetch/$s_!Ok0b!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cc6d2cc-8012-436d-9b9f-0543960bb11c_977x573.png 848w, https://substackcdn.com/image/fetch/$s_!Ok0b!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cc6d2cc-8012-436d-9b9f-0543960bb11c_977x573.png 1272w, https://substackcdn.com/image/fetch/$s_!Ok0b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6cc6d2cc-8012-436d-9b9f-0543960bb11c_977x573.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">In FY 2024, the government spent $1.8 trillion more than it took in. If no action is taken, we project that growing deficits will result in federal debt held by the public (federal debt) reaching its historical high of 106% of the U.S economy by 2027. Image source: https://www.gao.gov/blog/another-warning-about-nations-fiscal-health-and-financial-record-keeping </figcaption></figure></div><p></p></li><li><p>Remember, investment is the process of building the capital stock that determines our future productivity. When investment is crowded out, we build fewer factories, develop fewer technologies, and train fewer workers. This reduces the growth of productivity and, therefore, the growth of GDP.</p></li><li><p>A government budget deficit, in essence, is a decision to prioritize current consumption (through government spending) over the investments that would enrich the future. It is a choice that, while sometimes necessary in the short term, can slowly starve the economic engine of the fuel it needs for the long journey ahead.</p></li><li><p>The financial system, therefore, is not just a passive plumbing system. It is the active, vital link between our present sacrifices and our future wealth. How we manage it&#8212;and how we manage our government&#8217;s role within it&#8212;determines the health and power of our economic body for generations to come.</p></li></ul><h3><strong>The Basic Tools of Finance</strong></h3><ul><li><p>We&#8217;ve seen how the financial system acts as the economy&#8217;s circulatory system, channeling savings toward productive investments. But this raises a personal and practical question: How should an individual navigate this system? How do we decide how much to save, where to invest, and how to think about the inevitable risks?</p></li><li><p>It is said that Albert Einstein called compound interest the most powerful force in the universe. Whether he did or not, the sentiment is correct. This force creates a fundamental truth: A sum of money today is worth more than the same sum in the future. Why? Because money today can be put to work earning interest.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RCnP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629733da-5233-4826-bb0d-02aed7b73e1e_898x902.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RCnP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629733da-5233-4826-bb0d-02aed7b73e1e_898x902.png 424w, https://substackcdn.com/image/fetch/$s_!RCnP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629733da-5233-4826-bb0d-02aed7b73e1e_898x902.png 848w, https://substackcdn.com/image/fetch/$s_!RCnP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629733da-5233-4826-bb0d-02aed7b73e1e_898x902.png 1272w, https://substackcdn.com/image/fetch/$s_!RCnP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629733da-5233-4826-bb0d-02aed7b73e1e_898x902.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RCnP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629733da-5233-4826-bb0d-02aed7b73e1e_898x902.png" width="550" height="552.4498886414254" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/629733da-5233-4826-bb0d-02aed7b73e1e_898x902.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:902,&quot;width&quot;:898,&quot;resizeWidth&quot;:550,&quot;bytes&quot;:193879,&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://photonlines.substack.com/i/179003928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629733da-5233-4826-bb0d-02aed7b73e1e_898x902.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_!RCnP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629733da-5233-4826-bb0d-02aed7b73e1e_898x902.png 424w, https://substackcdn.com/image/fetch/$s_!RCnP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629733da-5233-4826-bb0d-02aed7b73e1e_898x902.png 848w, https://substackcdn.com/image/fetch/$s_!RCnP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629733da-5233-4826-bb0d-02aed7b73e1e_898x902.png 1272w, https://substackcdn.com/image/fetch/$s_!RCnP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629733da-5233-4826-bb0d-02aed7b73e1e_898x902.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">Image Source: https://www.stlouisfed.org/open-vault/2018/september/how-compound-interest-works</figcaption></figure></div><p></p></li><li><p>This leads to the most crucial concept in finance: <strong>Present Value (PV)</strong>. The present value of a future sum of money is the amount you would need to set aside today to have that sum in the future, given the prevailing interest rate.</p></li><li><p>Imagine someone offers you a choice: $100 today or $100 in one year. The rational choice is $100 today. You could put it in a savings account (even at a low interest rate) and have more than $100 in a year. If the interest rate is 5%, then $100 today is worth $105 in one year. Conversely, $100 in one year is worth less than $100 today. In fact, its present value is about $95.24 today ($100 / 1.05). You would only need to invest $95.24 now to have $100 later.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ClWR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80aa5c5-092a-4f40-9b83-caeb09c07d64_432x158.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ClWR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80aa5c5-092a-4f40-9b83-caeb09c07d64_432x158.png 424w, https://substackcdn.com/image/fetch/$s_!ClWR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80aa5c5-092a-4f40-9b83-caeb09c07d64_432x158.png 848w, https://substackcdn.com/image/fetch/$s_!ClWR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80aa5c5-092a-4f40-9b83-caeb09c07d64_432x158.png 1272w, https://substackcdn.com/image/fetch/$s_!ClWR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80aa5c5-092a-4f40-9b83-caeb09c07d64_432x158.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ClWR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80aa5c5-092a-4f40-9b83-caeb09c07d64_432x158.png" width="432" height="158" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b80aa5c5-092a-4f40-9b83-caeb09c07d64_432x158.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:158,&quot;width&quot;:432,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:8501,&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://photonlines.substack.com/i/179003928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80aa5c5-092a-4f40-9b83-caeb09c07d64_432x158.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_!ClWR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80aa5c5-092a-4f40-9b83-caeb09c07d64_432x158.png 424w, https://substackcdn.com/image/fetch/$s_!ClWR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80aa5c5-092a-4f40-9b83-caeb09c07d64_432x158.png 848w, https://substackcdn.com/image/fetch/$s_!ClWR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80aa5c5-092a-4f40-9b83-caeb09c07d64_432x158.png 1272w, https://substackcdn.com/image/fetch/$s_!ClWR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80aa5c5-092a-4f40-9b83-caeb09c07d64_432x158.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p></li><li><p>This discounting of the future is the essence of present value. It&#8217;s the financial equivalent of a telescope that brings future cash flows into focus in today&#8217;s terms, allowing us to compare apples (money now) with oranges (money later) by converting them both into &#8220;present-value apples.&#8221;</p></li><li><p>Imagine you are offered a gamble. A coin flip: heads, you win $1,000; tails, you win $0. The &#8220;expected value&#8221; is $500. Now, imagine you are offered a sure-thing payment of $450 instead. Would you take the sure thing? Most people would. This is <strong>risk aversion</strong>.</p></li><li><p>Why? It&#8217;s due to a concept we&#8217;ve met before: diminishing marginal utility. The first dollar you earn is incredibly valuable&#8212;it buys food and shelter. The thousandth dollar is less so&#8212;it might buy a nicer TV. The potential joy of winning an extra $1,000 is less than the potential pain of losing the $450 you were counting on. Because we are generally risk-averse, we are willing to pay a price to reduce risk. This is the basis for three key strategies:</p><ul><li><p>Insurance: You pay a premium to an insurance company to avoid a potentially catastrophic loss. You are trading a small, certain loss (the premium) to avoid a small chance of a huge, life-altering loss. It&#8217;s a financial airbag.</p></li><li><p>Diversification: The age-old wisdom of &#8220;don&#8217;t put all your eggs in one basket.&#8221; By spreading your investments across many different assets (different companies, different industries, even different countries), you eliminate the unique, or &#8220;idiosyncratic,&#8221; risk of any one of them failing. If one company goes bankrupt, it&#8217;s only a small part of your portfolio. A diversified portfolio is like a well-balanced fleet of ships&#8212;if one sinks, the journey continues.</p></li><li><p>Risk-Return Tradeoff: Safer assets (like government bonds) typically offer lower potential returns. Riskier assets (like stocks in a new tech company) must offer the potential for higher returns to attract risk-averse investors. You can choose your spot on this spectrum.</p></li></ul></li><li><p>How much should you pay for a share of a company? A bond? A rental property The answer is always the same principle: <strong>the value of any asset is the present value of all the future cash flows you expect to receive from it. </strong>For a share of stock, the cash flows are the stream of future dividends and the final sale price. You are essentially buying the right to a slice of the company&#8217;s future profits.</p></li><li><p>This leads us to one of the most debated ideas in economics: The <strong>Efficient Markets Hypothesis (EMH)</strong>. This theory states that financial markets are &#8220;informationally efficient.&#8221; At any moment, stock prices reflect all publicly available information about a company&#8217;s value. The current price is the best possible estimate of its true worth. Why? Because if a stock were undervalued, rational investors would immediately swoop in and buy it, driving the price up to its correct level. The same happens in reverse for an overvalued stock. This creates a &#8220;random walk&#8221;&#8212;since news is by definition unpredictable, the path of stock prices should be unpredictable too.</p></li><li><p>A lot of people today believe that trying to &#8220;beat the market&#8221; by picking stocks is a fool&#8217;s errand. It&#8217;s like trying to guess the outcome of a coin flip that has already been flipped but not yet revealed. The market is like a lightning-fast, supremely rational weather vane, instantly pointing in the direction of the economic wind.</p></li><li><p>The Efficient Markets Hypothesis is a beautiful, elegant theory, but it has one major flaw: it assumes everyone is a perfectly rational (and this definitely is not the case). The field of behavioral finance has emerged to document the ways human psychology throws a wrench into this rational machine. As an example:</p><ul><li><p>We think we&#8217;re better at picking stocks than we are (we suffer from overconfidence).</p></li><li><p>We get caught up in bubbles, buying simply because everyone else is buying, driving prices far above any rational present value (herd behavior).</p></li><li><p>We fixate on the price we paid for a stock, refusing to sell at a loss even when the fundamentals have clearly deteriorated.</p></li></ul></li><li><p>These psychological factors can cause asset prices to deviate from their fundamental value for long periods, creating the booms and busts that the efficient market hypothesis struggles to explain.</p></li></ul><div><hr></div><h3><strong>Unemployment</strong></h3><ul><li><p>Each month, the U.S. government takes a statistical snapshot of the labor market. They survey thousands of households and sort the adult population into three buckets:</p></li></ul><ol><li><p>Employed.</p></li><li><p>Unemployed: People who do not have a job but are actively looking for one.</p></li><li><p>Not in the Labor Force: People who are not working and not looking, such as retirees, students, or stay-at-home parents.</p></li></ol><ul><li><p>The unemployment rate is then calculated as:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_k0Q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f0ee641-eaa0-48b2-880f-7c2b1b67da46_992x137.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_k0Q!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f0ee641-eaa0-48b2-880f-7c2b1b67da46_992x137.png 424w, https://substackcdn.com/image/fetch/$s_!_k0Q!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f0ee641-eaa0-48b2-880f-7c2b1b67da46_992x137.png 848w, https://substackcdn.com/image/fetch/$s_!_k0Q!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f0ee641-eaa0-48b2-880f-7c2b1b67da46_992x137.png 1272w, https://substackcdn.com/image/fetch/$s_!_k0Q!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f0ee641-eaa0-48b2-880f-7c2b1b67da46_992x137.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_k0Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f0ee641-eaa0-48b2-880f-7c2b1b67da46_992x137.png" width="992" height="137" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8f0ee641-eaa0-48b2-880f-7c2b1b67da46_992x137.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:137,&quot;width&quot;:992,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:16223,&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://photonlines.substack.com/i/179003928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f0ee641-eaa0-48b2-880f-7c2b1b67da46_992x137.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_!_k0Q!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f0ee641-eaa0-48b2-880f-7c2b1b67da46_992x137.png 424w, https://substackcdn.com/image/fetch/$s_!_k0Q!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f0ee641-eaa0-48b2-880f-7c2b1b67da46_992x137.png 848w, https://substackcdn.com/image/fetch/$s_!_k0Q!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f0ee641-eaa0-48b2-880f-7c2b1b67da46_992x137.png 1272w, https://substackcdn.com/image/fetch/$s_!_k0Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f0ee641-eaa0-48b2-880f-7c2b1b67da46_992x137.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p></li><li><p>This number is our best single gauge, but it has blind spots, like a speedometer that doesn&#8217;t account for wind resistance. What the Unemployment Rate Misses:</p><ul><li><p>The Discouraged Worker: Imagine someone who has searched for a job for months, found nothing, and finally gives up. By stopping their active search, they magically vanish from the unemployment statistics, classified as &#8220;not in the labor force.&#8221; This person is still jobless, but the official rate no longer sees them. This means the unemployment rate can understate true joblessness.</p></li><li><p>The Fake Job Seeker: Conversely, someone might claim to be looking for work to qualify for government benefits while having no real intention of taking a job. This can cause the rate to slightly overstate the problem.</p></li></ul></li><li><p>A surprising feature of unemployment is its distribution. Think of a hospital.</p><ul><li><p>Most people who become unemployed are like patients in the emergency room. They have a short, sharp spell of joblessness&#8212;perhaps a few weeks&#8212;before they find a new position and are discharged. The vast majority of spells of unemployment are short.</p></li><li><p>However, the people you see in the hospital on any given day are mostly in the long-term care ward. A small group of people who are unemployed for six months or more make up a large share of the total unemployment observed at any one time.</p></li></ul></li><li><p>So, while most people experience short-term unemployment, the social problem of unemployment is dominated by the long-term unemployed.</p></li><li><p>Reasons for unemployment:</p><ul><li><p>It<strong> takes time for workers to search for jobs</strong> that best suit their tastes and skills. This frictional unemployment is increased as a result of unemployment insurance, a government policy designed to protect workers&#8217; incomes.</p></li><li><p>An economy always has some unemployment due to <strong>minimum-wage laws</strong>. By raising the wage of unskilled and inexperienced workers above the equilibrium level, minimum-wage laws raise the quantity of labor supplied and reduce the quantity demanded. The resulting surplus of labor represents unemployment.</p></li><li><p>The <strong>market power of unions</strong>. Unions can negotiate wages for their members above the equilibrium level. This is like an exclusive guild for chair-makers securing a high price for its members. The result is the same: a surplus of labor (unemployment) for that sector, as the number of people who want these good union jobs exceeds the number of positions available.</p></li><li><p><strong>Theory of efficiency wages</strong>: according to this theory, firms find it profitable to pay wages above the equilibrium level. High wages can improve worker health, lower worker turnover, raise worker quality, and increase worker effort. When many firms adopt this strategy, they create a situation where the wages being offered are above the level that would clear the labor market. The result, once again, is a surplus of labor&#8212;people who want these high-paying jobs but can&#8217;t get them.</p></li></ul></li><li><p>Unemployment is not a simple problem with a silver-bullet solution. Although the economy will always have some unemployment, its natural rate does change over time. Many events and policies can alter the amount of unemployment the economy typically experiences. </p></li><li><p>As the information revolution changes the process of job search, as Congress and state legislatures adjust the minimum wage, as workers form or quit unions, and as firms change their reliance on efficiency wages, the natural rate of unemployment evolves. Unemployment is not a simple problem with a simple solution. How we choose to organize our society can profoundly influence how prevalent a problem it is.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ST00!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88584a27-9c3c-4a63-9ecb-788b5de85c54_848x482.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ST00!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88584a27-9c3c-4a63-9ecb-788b5de85c54_848x482.png 424w, https://substackcdn.com/image/fetch/$s_!ST00!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88584a27-9c3c-4a63-9ecb-788b5de85c54_848x482.png 848w, https://substackcdn.com/image/fetch/$s_!ST00!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88584a27-9c3c-4a63-9ecb-788b5de85c54_848x482.png 1272w, https://substackcdn.com/image/fetch/$s_!ST00!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88584a27-9c3c-4a63-9ecb-788b5de85c54_848x482.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ST00!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88584a27-9c3c-4a63-9ecb-788b5de85c54_848x482.png" width="848" height="482" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/88584a27-9c3c-4a63-9ecb-788b5de85c54_848x482.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:482,&quot;width&quot;:848,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:110023,&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://photonlines.substack.com/i/179003928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88584a27-9c3c-4a63-9ecb-788b5de85c54_848x482.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_!ST00!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88584a27-9c3c-4a63-9ecb-788b5de85c54_848x482.png 424w, https://substackcdn.com/image/fetch/$s_!ST00!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88584a27-9c3c-4a63-9ecb-788b5de85c54_848x482.png 848w, https://substackcdn.com/image/fetch/$s_!ST00!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88584a27-9c3c-4a63-9ecb-788b5de85c54_848x482.png 1272w, https://substackcdn.com/image/fetch/$s_!ST00!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88584a27-9c3c-4a63-9ecb-788b5de85c54_848x482.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></figure></div><p></p></li></ul><div><hr></div><h3><strong>The Monetary System</strong></h3><ul><li><p>Our journey through the economic city has shown us how goods and services flow through markets, how savings are channeled to investments, and how people interact with the labor market. But there is one element so pervasive we often take it for granted that makes all of this possible: money.</p></li><li><p>Money is not just the paper in your wallet; it is the lifeblood of the economic body, the river that carries all transactions from source to sea. In this chapter, we will explore what this river is made of, who controls its flow, and why that control is one of the most powerful forces in economics.</p></li><li><p>Imagine a simple barter economy, where you are a shoemaker in need of bread. You must find a baker who not only has bread but who also needs a new pair of shoes. This &#8220;double coincidence of wants&#8221; is incredibly inefficient. The economy grinds along at a snail&#8217;s pace. Money the solution to this problem and is the universally accepted medium that breaks this logjam. Formally, money is anything that regularly serves three functions:</p><ul><li><p><strong>A Medium of Exchange</strong>: it is the thing buyers give to sellers in a transaction. You give the baker money, not shoes, and receive your loaf of bread. It is the oil that lubricates the gears of commerce.</p></li><li><p><strong>A Unit of Account</strong>: it is what we use to measure economic value. We don&#8217;t say a car is worth 5,000 loaves of bread or 300 pairs of shoes. We say it&#8217;s worth $30,000. This common denominator simplifies decision-making immensely.</p></li><li><p><strong>A Store of Value</strong>: it is a way to transport purchasing power from the present into the future. You can sell your labor today, receive money, and spend it weeks or months later.</p></li></ul></li><li><p>Throughout history, money has taken many forms, but they all fall into two categories:</p><ul><li><p><strong>Fiat Money</strong>: This is money without intrinsic value. The paper used for a $100 bill is worth almost nothing. Its value comes from a government decree (a &#8220;fiat&#8221;) that establishes it as legal tender. But a decree alone is not enough. The value of fiat money ultimately rests on a delicate foundation of social consensus and trust. We all accept it because we are confident that everyone else will accept it. It is a shared fiction, but one with very real power.</p></li><li><p><strong>Commodity Money</strong>: This is money that has intrinsic value&#8212;value in its own right. The classic example is gold. A gold coin is valuable not just because it can be traded, but because gold is used in jewelry and electronics. It would be valued even if it weren&#8217;t money.</p></li></ul></li><li><p>If money is the river, how do we measure how much water is flowing? The &#8220;money supply&#8221; (or money stock) isn&#8217;t just the currency in circulation. Think of it in layers of liquidity:</p><ul><li><p><strong>The Core (M1)</strong>: This is the money you can spend instantly. It includes physical currency (coins and bills) plus the balances in checking accounts and debit cards. This is the water currently flowing in the river&#8217;s main channel.</p></li><li><p><strong>The Broader Measure (M2)</strong>: This includes all of M1, plus &#8220;near-money&#8221;&#8212;assets that are very easy to convert into spendable cash. This includes savings accounts, money market funds, and small-time deposits. These are like the water in sloughs and marshes adjacent to the main river&#8212;not immediately flowing, but part of the system and easily able to join the current.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_Eqn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3114a62-31eb-4dfe-8439-53637ebff23e_1227x496.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_Eqn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3114a62-31eb-4dfe-8439-53637ebff23e_1227x496.png 424w, https://substackcdn.com/image/fetch/$s_!_Eqn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3114a62-31eb-4dfe-8439-53637ebff23e_1227x496.png 848w, https://substackcdn.com/image/fetch/$s_!_Eqn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3114a62-31eb-4dfe-8439-53637ebff23e_1227x496.png 1272w, https://substackcdn.com/image/fetch/$s_!_Eqn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3114a62-31eb-4dfe-8439-53637ebff23e_1227x496.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_Eqn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3114a62-31eb-4dfe-8439-53637ebff23e_1227x496.png" width="1227" height="496" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b3114a62-31eb-4dfe-8439-53637ebff23e_1227x496.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:496,&quot;width&quot;:1227,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:132372,&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://photonlines.substack.com/i/179003928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3114a62-31eb-4dfe-8439-53637ebff23e_1227x496.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_!_Eqn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3114a62-31eb-4dfe-8439-53637ebff23e_1227x496.png 424w, https://substackcdn.com/image/fetch/$s_!_Eqn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3114a62-31eb-4dfe-8439-53637ebff23e_1227x496.png 848w, https://substackcdn.com/image/fetch/$s_!_Eqn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3114a62-31eb-4dfe-8439-53637ebff23e_1227x496.png 1272w, https://substackcdn.com/image/fetch/$s_!_Eqn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3114a62-31eb-4dfe-8439-53637ebff23e_1227x496.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></figure></div></li></ul></li></ul><ul><li><p>The modern money supply is predominantly digital&#8212;numbers in bank accounts&#8212;with physical cash as just the visible tip of the iceberg. To prevent the river of money from flooding or drying up entirely, we need engineers. In the United States, that engineer is the Federal Reserve (&#8221;the Fed&#8221;), the nation&#8217;s central bank.</p></li><li><p>The Federal Reserve is responsible for regulating the U.S. monetary system. The Fed chair is appointed by the president and confirmed by Congress every 4 years. The chair is the head of the Federal Open Market Committee, which meets about every 6 weeks to consider changes in monetary policy.</p></li><li><p>Established in 1913 after a panic exposed the fragility of the banking system, the Fed has two primary jobs:</p><ul><li><p><strong>The Fed is the ultimate guardian of the banking system</strong>:</p><ul><li><p>It <strong>acts as a lender of last resort</strong>. If a bank faces a sudden crisis and can&#8217;t borrow from anyone else, it can turn to the Fed for an emergency loan. This stops a single bank&#8217;s failure from turning into a system-wide panic. It&#8217;s the financial system&#8217;s emergency flood control.</p></li><li><p>It <strong>regulates banks</strong>, ensuring they have enough capital (a cushion of their own money) to absorb losses. This is like enforcing building codes along a riverbank to prevent collapses.</p></li></ul></li><li><p><strong>Controlling the money supply (its biggest role)</strong>: By controlling the amount of money in the economy, it tries to maintain stable prices and maximum employment. The main tool for this is open-market operations. Imagine the Fed has a magical spigot connected to the river:</p><ul><li><p>To increase money supply (expansionary policy), the Fed creates new money out of thin air (electronically, of course) and uses it to buy government bonds from the public. The people who sold the bonds now have new cash in their hands that didn&#8217;t exist before. The river level rises.</p></li><li><p>To decrease the money supply (contractionary policy), the Fed sells government bonds from its own portfolio to the public. The public pays for these bonds with cash, and when the Fed receives this cash, it effectively vanishes from the system. The river level falls.</p></li></ul></li></ul></li><li><p>Banks aren&#8217;t passive reservoirs; they are active participants in creating money through lending. When you deposit $1,000 in a bank, the bank doesn&#8217;t lock it all away. It keeps a small fraction (the reserve requirement) and loans out the rest, say $900. That $900 gets spent and eventually deposited in another bank, which then loans out $810, and so on. Your initial $1,000 deposit can ultimately create many thousands of dollars in new money throughout the banking system. This is the <strong>money multiplier</strong>. It means the Fed&#8217;s control, while powerful, is not perfectly precise, as it depends on the lending behavior of thousands of individual banks.</p></li><li><p>In recent decades, the Fed has shifted from directly targeting the money supply to targeting a single interest rate: the federal funds rate. This is the rate banks charge each other for overnight loans. The Fed announces a target for this rate and then uses its open-market operations (the spigot) to hit that target. A lower federal funds rate makes borrowing cheaper, encouraging spending and investment (loosening the spigot). A higher rate does the opposite (tightening the spigot).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pD_v!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35058b72-8c62-4eb6-836b-ba33c0ae43d6_936x566.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pD_v!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35058b72-8c62-4eb6-836b-ba33c0ae43d6_936x566.png 424w, https://substackcdn.com/image/fetch/$s_!pD_v!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35058b72-8c62-4eb6-836b-ba33c0ae43d6_936x566.png 848w, https://substackcdn.com/image/fetch/$s_!pD_v!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35058b72-8c62-4eb6-836b-ba33c0ae43d6_936x566.png 1272w, https://substackcdn.com/image/fetch/$s_!pD_v!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35058b72-8c62-4eb6-836b-ba33c0ae43d6_936x566.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pD_v!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35058b72-8c62-4eb6-836b-ba33c0ae43d6_936x566.png" width="586" height="354.35470085470087" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/35058b72-8c62-4eb6-836b-ba33c0ae43d6_936x566.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:566,&quot;width&quot;:936,&quot;resizeWidth&quot;:586,&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_!pD_v!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35058b72-8c62-4eb6-836b-ba33c0ae43d6_936x566.png 424w, https://substackcdn.com/image/fetch/$s_!pD_v!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35058b72-8c62-4eb6-836b-ba33c0ae43d6_936x566.png 848w, https://substackcdn.com/image/fetch/$s_!pD_v!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35058b72-8c62-4eb6-836b-ba33c0ae43d6_936x566.png 1272w, https://substackcdn.com/image/fetch/$s_!pD_v!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35058b72-8c62-4eb6-836b-ba33c0ae43d6_936x566.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">1980, when the Fed funds rate hit an unprecedented high of 20%. Why was it so high? The answer is that the Federal Reserve was attempting to combat the sky-high inflation that had run rampant in the 1970s. Image source: https://www.thestreet.com/dictionary/fed-funds-rate</figcaption></figure></div><p></p></li><li><p>The monetary system, therefore, is a magnificent and complex human invention. It transformed a barter-based alleyway into a global metropolis. It is built on a foundation of trust&#8212;trust in the paper we call currency, trust in the numbers in our bank accounts, and trust in the engineers at the Federal Reserve to manage the flow. When that trust is well-placed, the river flows steadily, nourishing the economic landscape. When that trust is broken, the river can either flood, destroying the value of money through inflation, or run dry, causing a credit crunch and recession. </p></li></ul><div><hr></div><h3><strong>Money Growth and Inflation</strong></h3><ul><li><p>We have met the engineers of the monetary system, the Federal Reserve, and learned how they control the great river of money. Now we must confront the single greatest consequence of their actions, and one of the most pervasive forces in economics: inflation. Inflation is often called an &#8220;invisible tax&#8221; because it quietly erodes the purchasing power of every dollar in your pocket. But where does it come from? The answer, at its heart, is deceptively simple, yet its ramifications are profound.</p></li><li><p>Imagine an economy that produces a fixed amount of goods and services&#8212;let&#8217;s say, 100 unique artifacts. Now, imagine there is exactly $1,000 in existence. Basic supply and demand would dictate that the price of each artifact would hover around $10. Now, suppose a helicopter flies over and drops another $1,000, doubling the money supply to $2,000. The number of artifacts is still 100. What happens? People have more money to spend, but the same number of items are available for purchase. The inevitable result is that the price of each artifact rises to about $20.</p></li><li><p>This is the core of the quantity theory of money. In the long run, the overall level of prices in an economy adjusts to bring money supply and money demand into balance. When the central bank increases the supply of money much faster than the economy&#8217;s capacity to produce goods and services, the result is inflation. It&#8217;s not that artifacts become more valuable; it&#8217;s that each dollar becomes less valuable.</p></li><li><p>The principle is clear: <strong>prices rise when the government prints too much money</strong>.</p></li><li><p>If inflation is so easy to explain, why would any country ever allow it to spiral into hyperinflation&#8212;a period of extremely high and typically accelerating inflation that quickly erodes the real value of the local currency? The answer is one of desperation. Governments need to pay for things: roads, soldiers, social programs. They have three ways to do this:</p><ul><li><p><strong>1) Tax</strong> the public.</p></li><li><p><strong>2) Borrow</strong> from the public by selling bonds.</p></li><li><p><strong>3) Print</strong> the money they need.</p></li></ul></li></ul><ul><li><p>When a government is weak, its tax system inefficient, and its ability to borrow exhausted, it turns to the printing press. It is the path of least resistance in the short term, but a road to ruin in the long term. This is known as the inflation tax. By printing money to finance its spending, the government is effectively imposing a tax on everyone who holds money, because the value of their money is being diluted. In a hyperinflation, this tax becomes catastrophic, as people rush to spend their paychecks within hours before they become worthless.</p></li></ul><h4><strong>The Fisher Effect: Why Inflation Drives Up Interest Rates</strong></h4><ul><li><p>We&#8217;ve already met the crucial distinction between the nominal interest rate (the number quoted by the bank) and the real interest rate (the true return after inflation):</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3QZJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cbf1fb-b312-4152-9ef8-decbbd6f18e7_987x87.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3QZJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cbf1fb-b312-4152-9ef8-decbbd6f18e7_987x87.png 424w, https://substackcdn.com/image/fetch/$s_!3QZJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cbf1fb-b312-4152-9ef8-decbbd6f18e7_987x87.png 848w, https://substackcdn.com/image/fetch/$s_!3QZJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cbf1fb-b312-4152-9ef8-decbbd6f18e7_987x87.png 1272w, https://substackcdn.com/image/fetch/$s_!3QZJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cbf1fb-b312-4152-9ef8-decbbd6f18e7_987x87.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3QZJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cbf1fb-b312-4152-9ef8-decbbd6f18e7_987x87.png" width="987" height="87" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/53cbf1fb-b312-4152-9ef8-decbbd6f18e7_987x87.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:87,&quot;width&quot;:987,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:8996,&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://photonlines.substack.com/i/179003928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cbf1fb-b312-4152-9ef8-decbbd6f18e7_987x87.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_!3QZJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cbf1fb-b312-4152-9ef8-decbbd6f18e7_987x87.png 424w, https://substackcdn.com/image/fetch/$s_!3QZJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cbf1fb-b312-4152-9ef8-decbbd6f18e7_987x87.png 848w, https://substackcdn.com/image/fetch/$s_!3QZJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cbf1fb-b312-4152-9ef8-decbbd6f18e7_987x87.png 1272w, https://substackcdn.com/image/fetch/$s_!3QZJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cbf1fb-b312-4152-9ef8-decbbd6f18e7_987x87.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p></li><li><p>Now, let&#8217;s connect this to the money supply. The supply and demand for loanable funds determine the real interest rate. Meanwhile, the growth in the money supply determines the inflation rate.</p></li><li><p>In the long run, money is neutral&#8212;it doesn&#8217;t affect real variables like the real interest rate. So, if the Fed increases the money supply and causes inflation to rise, what happens to the nominal interest rate? It must adjust upward to keep the real interest rate unchanged. If inflation is 5%, a lender will demand a nominal rate of, say, 7% to achieve a real return of 2%. If inflation jumps to 10%, the lender will now demand a nominal rate of 12% to get that same 2% real return. This one-for-one adjustment of the nominal interest rate to the inflation rate is known as the <strong>Fisher Effect</strong>. It&#8217;s the financial market&#8217;s immune response to the virus of inflation, protecting the real return on lending.</p></li><li><p>Many people think, &#8220;So what if prices go up? My paycheck goes up too.&#8221; While this can be true in the aggregate, inflation imposes real and insidious costs on society, even when it&#8217;s moderate.</p><ul><li><p>Shoe-Leather Costs: this is the time, effort, and resources wasted when people try to avoid holding onto cash. In high inflation, you sprint to the bank more often and rush to spend money before it loses value. You&#8217;re literally wearing out your shoes (and your patience) to minimize your holdings of a depreciating asset.</p></li><li><p>Menu Costs: this is the cost of changing listed prices. Restaurants must reprint menus, catalogs must be republished, and stores must re-tag merchandise. In a digital age, this includes the cost of reprogramming software and updating websites. It&#8217;s a recurring tax on every business.</p></li><li><p>Relative-Price Variability and Misallocation of Resources: in a stable economy, a price change signals a real shift in supply or demand. In an inflationary economy, prices are changing everywhere, making it hard to distinguish a relative price change (this product is now in higher demand) from the general noise of inflation. This confuses the &#8220;invisible hand,&#8221; leading to poor decisions by consumers and businesses.</p></li><li><p>Tax Distortions: the tax code is often not fully indexed for inflation. If your investment earns a 7% nominal return in a year with 5% inflation, your real return is only 2%. But you are taxed on the full 7% nominal gain, effectively taxing you on phantom income. This discourages saving and investment.</p></li><li><p>Confusion and Inconvenience: money is our unit of account, our economic ruler. Inflation is like making that ruler stretch and shrink randomly. It becomes harder for individuals to plan for retirement or for businesses to write long-term contracts, gumming up the wheels of commerce.</p></li><li><p>Arbitrary Redistributions of Wealth: inflation acts as a wildcard, arbitrarily redistributing wealth between borrowers and lenders.</p><ul><li><p>If you take out a fixed-rate mortgage and inflation surges, you get to pay back your loan with dollars that are worth much less than you borrowed. You win; the bank loses.</p></li><li><p>Conversely, if inflation falls to zero, the real burden of your debt is higher than you expected. The bank wins; you lose.</p></li></ul></li></ul></li><li><p>These redistributions are not based on merit, effort, or productivity. They are based on luck and the inability to perfectly predict the future.</p></li><li><p>While a low, stable rate of inflation may be a lubricant for the economy, high or volatile inflation is a corrosive acid. It erodes the value of our savings, distorts the signals of the price system, and forces us to waste resources protecting ourselves from our own currency.</p></li><li><p>The fight against inflation is, therefore, not just a technical matter for central bankers. It is a fundamental commitment to preserving the integrity of our economic language&#8212;the dollar&#8212;and ensuring that the hard work and savings of today are not stolen by the silent thief of tomorrow. It is the ultimate test of our stewardship over the great river of money.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mPmI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b20a619-b2b5-45c7-9e00-b09167905b05_1103x792.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mPmI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b20a619-b2b5-45c7-9e00-b09167905b05_1103x792.png 424w, https://substackcdn.com/image/fetch/$s_!mPmI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b20a619-b2b5-45c7-9e00-b09167905b05_1103x792.png 848w, https://substackcdn.com/image/fetch/$s_!mPmI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b20a619-b2b5-45c7-9e00-b09167905b05_1103x792.png 1272w, https://substackcdn.com/image/fetch/$s_!mPmI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b20a619-b2b5-45c7-9e00-b09167905b05_1103x792.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mPmI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b20a619-b2b5-45c7-9e00-b09167905b05_1103x792.png" width="1103" height="792" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2b20a619-b2b5-45c7-9e00-b09167905b05_1103x792.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:792,&quot;width&quot;:1103,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:245073,&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://photonlines.substack.com/i/179003928?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b20a619-b2b5-45c7-9e00-b09167905b05_1103x792.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_!mPmI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b20a619-b2b5-45c7-9e00-b09167905b05_1103x792.png 424w, https://substackcdn.com/image/fetch/$s_!mPmI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b20a619-b2b5-45c7-9e00-b09167905b05_1103x792.png 848w, https://substackcdn.com/image/fetch/$s_!mPmI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b20a619-b2b5-45c7-9e00-b09167905b05_1103x792.png 1272w, https://substackcdn.com/image/fetch/$s_!mPmI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b20a619-b2b5-45c7-9e00-b09167905b05_1103x792.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"><strong>State wise Inflation Rates in USA: </strong>Inflation in the USA for 2025 has decreased to a national average of 3.0 percent year-to-date through October, a decline from the higher peaks observed in previous years.<strong> Image source: https://indiadatamap.com/2025/11/01/inflation-in-usa-2025/ </strong></figcaption></figure></div><div><hr></div><p>This ends Part 3 of my write-up. This is an ad-free publication and I extend a great thank you to the paid subscribers of this blog! If you liked this write-up, please like an subscribe. Most of the content here is taken from a great book called <a href="https://www.amazon.com/Principles-Economics-N-Gregory-Mankiw/dp/1305585127">Principles of Economics</a> by <a href="https://scholar.harvard.edu/mankiw/home">Gregory Mankiw</a> which I highly recommend. </p></li></ul><p></p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Photon-Lines Substack is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Principles of Economics Made Clear (Part 2)]]></title><description><![CDATA[An overview of the key principles of economics presented in a clearly and succinctly.]]></description><link>https://photonlines.substack.com/p/principles-of-economics-made-clear-18b</link><guid isPermaLink="false">https://photonlines.substack.com/p/principles-of-economics-made-clear-18b</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Sun, 02 Nov 2025 15:59:05 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!GUWU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bd2350e-fa4d-429c-9843-0d43da86cd32_683x687.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This is a continuation of my Principles of Economics Made Clear series. If you haven&#8217;t had a chance to read it yet, Part 1 is <a href="https://photonlines.substack.com/p/principles-of-economics-made-clear">available here</a>. Most of the content here is taken from a great book called <a href="https://www.amazon.com/Principles-Economics-N-Gregory-Mankiw/dp/1305585127">Principles of Economics</a> by <a href="https://scholar.harvard.edu/mankiw/home">Gregory Mankiw</a> which I highly recommend. Noting this, let&#8217;s begin. </p><div><hr></div><h3><strong>The Costs of Production</strong></h3><ul><li><p>The goal of firms is to maximize profit, which equals total revenue minus total cost.</p></li><li><p>Let&#8217;s start off by taking a look at the <strong>production function</strong> for a cookie factory:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GUWU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bd2350e-fa4d-429c-9843-0d43da86cd32_683x687.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GUWU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bd2350e-fa4d-429c-9843-0d43da86cd32_683x687.png 424w, https://substackcdn.com/image/fetch/$s_!GUWU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bd2350e-fa4d-429c-9843-0d43da86cd32_683x687.png 848w, https://substackcdn.com/image/fetch/$s_!GUWU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bd2350e-fa4d-429c-9843-0d43da86cd32_683x687.png 1272w, https://substackcdn.com/image/fetch/$s_!GUWU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bd2350e-fa4d-429c-9843-0d43da86cd32_683x687.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GUWU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bd2350e-fa4d-429c-9843-0d43da86cd32_683x687.png" width="507" height="509.9692532942899" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0bd2350e-fa4d-429c-9843-0d43da86cd32_683x687.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:687,&quot;width&quot;:683,&quot;resizeWidth&quot;:507,&quot;bytes&quot;:57350,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bd2350e-fa4d-429c-9843-0d43da86cd32_683x687.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_!GUWU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bd2350e-fa4d-429c-9843-0d43da86cd32_683x687.png 424w, https://substackcdn.com/image/fetch/$s_!GUWU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bd2350e-fa4d-429c-9843-0d43da86cd32_683x687.png 848w, https://substackcdn.com/image/fetch/$s_!GUWU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bd2350e-fa4d-429c-9843-0d43da86cd32_683x687.png 1272w, https://substackcdn.com/image/fetch/$s_!GUWU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bd2350e-fa4d-429c-9843-0d43da86cd32_683x687.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></figure></div><p></p></li><li><p>This graph shows how adding more workers changes the amount of stuff (output) a business can make.</p><ul><li><p>The <strong>horizontal</strong> axis (sideways) shows <strong>how many workers are hired</strong>.</p></li><li><p>The <strong>vertical</strong> axis (up and down) shows <strong>how much output they produce</strong>.</p></li></ul></li><li><p>In economics, the <strong>marginal product</strong> is the additional output produced by adding one more unit of a specific input, such as labor or capital, while all other inputs are held constant. The graph shows that as you hire more workers, production rises quickly, but as more and more workers are added, the graph becomes flatter &#8212; meaning each new worker adds less extra output than the one before. </p></li><li><p>In the above production function diagram as an example, the second worker has a marginal product of 40 cookies, the third worker has a marginal product of 30 cookies, and the fourth worker has a marginal product of 20 cookies. We should be able to clearly see the effect that the marginal product has: the slope of the production curve starts to flatten out. Each worker still increases total output, but by a smaller and smaller amount, so the curve bends gently instead of shooting straight up. That&#8217;s called <strong>diminishing marginal product</strong>.</p></li><li><p>Now, let&#8217;s take a look at the <strong>total cost curve</strong> for the same factory:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6vxD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a79ccd-a20c-41cb-b97f-c9da747e5d47_628x712.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6vxD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a79ccd-a20c-41cb-b97f-c9da747e5d47_628x712.png 424w, https://substackcdn.com/image/fetch/$s_!6vxD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a79ccd-a20c-41cb-b97f-c9da747e5d47_628x712.png 848w, https://substackcdn.com/image/fetch/$s_!6vxD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a79ccd-a20c-41cb-b97f-c9da747e5d47_628x712.png 1272w, https://substackcdn.com/image/fetch/$s_!6vxD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a79ccd-a20c-41cb-b97f-c9da747e5d47_628x712.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6vxD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a79ccd-a20c-41cb-b97f-c9da747e5d47_628x712.png" width="500" height="566.8789808917197" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c1a79ccd-a20c-41cb-b97f-c9da747e5d47_628x712.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:712,&quot;width&quot;:628,&quot;resizeWidth&quot;:500,&quot;bytes&quot;:48711,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a79ccd-a20c-41cb-b97f-c9da747e5d47_628x712.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_!6vxD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a79ccd-a20c-41cb-b97f-c9da747e5d47_628x712.png 424w, https://substackcdn.com/image/fetch/$s_!6vxD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a79ccd-a20c-41cb-b97f-c9da747e5d47_628x712.png 848w, https://substackcdn.com/image/fetch/$s_!6vxD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a79ccd-a20c-41cb-b97f-c9da747e5d47_628x712.png 1272w, https://substackcdn.com/image/fetch/$s_!6vxD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a79ccd-a20c-41cb-b97f-c9da747e5d47_628x712.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></figure></div><p></p></li><li><p>This graph shows how the total cost of production changes as the business makes more output. The horizontal axis shows how much output is produced while the vertical axis shows the total cost of making it. At first, costs rise slowly, but as the firm produces more, the curve becomes steeper meaning total cost rises faster. That happens because of diminishing marginal product &#8212; when each worker adds less output, you need to hire more workers (and spend more money) to keep increasing production.</p></li><li><p>Many firms experience increasing marginal product before diminishing marginal product. As a result, they have cost curves shaped like those in the figure 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_!YmOw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a07b96f-3196-45de-8922-babb943b138d_686x497.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YmOw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a07b96f-3196-45de-8922-babb943b138d_686x497.png 424w, https://substackcdn.com/image/fetch/$s_!YmOw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a07b96f-3196-45de-8922-babb943b138d_686x497.png 848w, https://substackcdn.com/image/fetch/$s_!YmOw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a07b96f-3196-45de-8922-babb943b138d_686x497.png 1272w, https://substackcdn.com/image/fetch/$s_!YmOw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a07b96f-3196-45de-8922-babb943b138d_686x497.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YmOw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a07b96f-3196-45de-8922-babb943b138d_686x497.png" width="438" height="317.3265306122449" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1a07b96f-3196-45de-8922-babb943b138d_686x497.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:497,&quot;width&quot;:686,&quot;resizeWidth&quot;:438,&quot;bytes&quot;:74913,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a07b96f-3196-45de-8922-babb943b138d_686x497.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_!YmOw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a07b96f-3196-45de-8922-babb943b138d_686x497.png 424w, https://substackcdn.com/image/fetch/$s_!YmOw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a07b96f-3196-45de-8922-babb943b138d_686x497.png 848w, https://substackcdn.com/image/fetch/$s_!YmOw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a07b96f-3196-45de-8922-babb943b138d_686x497.png 1272w, https://substackcdn.com/image/fetch/$s_!YmOw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a07b96f-3196-45de-8922-babb943b138d_686x497.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></figure></div><p></p></li><li><p><strong>Marginal cost</strong> means &#8220;the cost of making one more.&#8221; So if a bakery makes 100 cookies for $50, and 101 cookies cost $50.40, then the marginal cost of that extra cookie is 40 cents. It tells you how much the total cost goes up when you produce one extra unit of output.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Jl8Z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10984cd-8e65-474d-b642-08457fb0a185_563x452.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Jl8Z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10984cd-8e65-474d-b642-08457fb0a185_563x452.png 424w, https://substackcdn.com/image/fetch/$s_!Jl8Z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10984cd-8e65-474d-b642-08457fb0a185_563x452.png 848w, https://substackcdn.com/image/fetch/$s_!Jl8Z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10984cd-8e65-474d-b642-08457fb0a185_563x452.png 1272w, https://substackcdn.com/image/fetch/$s_!Jl8Z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10984cd-8e65-474d-b642-08457fb0a185_563x452.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Jl8Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10984cd-8e65-474d-b642-08457fb0a185_563x452.png" width="397" height="318.72824156305506" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b10984cd-8e65-474d-b642-08457fb0a185_563x452.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:452,&quot;width&quot;:563,&quot;resizeWidth&quot;:397,&quot;bytes&quot;:36647,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10984cd-8e65-474d-b642-08457fb0a185_563x452.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_!Jl8Z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10984cd-8e65-474d-b642-08457fb0a185_563x452.png 424w, https://substackcdn.com/image/fetch/$s_!Jl8Z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10984cd-8e65-474d-b642-08457fb0a185_563x452.png 848w, https://substackcdn.com/image/fetch/$s_!Jl8Z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10984cd-8e65-474d-b642-08457fb0a185_563x452.png 1272w, https://substackcdn.com/image/fetch/$s_!Jl8Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10984cd-8e65-474d-b642-08457fb0a185_563x452.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></figure></div><p></p></li><li><p>Marginal cost and average variable cost <strong>fall for a while before starting to rise</strong>. This happens because, at first, adding more workers allows a firm to specialize and use its resources more efficiently &#8212; for example, workers can divide tasks and avoid wasting time switching between them. During this stage, each new worker adds more output than the one before, so production becomes cheaper and both marginal cost (the cost of producing one more unit) and average variable cost (the average cost of labor and materials per unit) fall. </p></li><li><p>As more workers crowd in, they begin to get in each other&#8217;s way or run out of equipment. Efficiency drops, the extra output from each worker shrinks, and the cost of producing each additional unit starts to rise again &#8212; giving the cost curves their familiar U-shape.</p></li><li><p>A firm&#8217;s total costs can be divided into <strong>fixed costs</strong> and <strong>variable costs</strong>. Fixed costs are costs that do not change when the firm alters the quantity of output produced. Variable costs are costs that change when the firm alters the quantity of output produced.</p></li><li><p>An example cost curve for a firm is provided 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_!r_mo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b76b75-b698-42d4-9e7b-eec08d2fde3b_1145x700.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!r_mo!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b76b75-b698-42d4-9e7b-eec08d2fde3b_1145x700.png 424w, https://substackcdn.com/image/fetch/$s_!r_mo!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b76b75-b698-42d4-9e7b-eec08d2fde3b_1145x700.png 848w, https://substackcdn.com/image/fetch/$s_!r_mo!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b76b75-b698-42d4-9e7b-eec08d2fde3b_1145x700.png 1272w, https://substackcdn.com/image/fetch/$s_!r_mo!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b76b75-b698-42d4-9e7b-eec08d2fde3b_1145x700.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!r_mo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b76b75-b698-42d4-9e7b-eec08d2fde3b_1145x700.png" width="1145" height="700" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a8b76b75-b698-42d4-9e7b-eec08d2fde3b_1145x700.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:700,&quot;width&quot;:1145,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:146766,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b76b75-b698-42d4-9e7b-eec08d2fde3b_1145x700.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_!r_mo!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b76b75-b698-42d4-9e7b-eec08d2fde3b_1145x700.png 424w, https://substackcdn.com/image/fetch/$s_!r_mo!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b76b75-b698-42d4-9e7b-eec08d2fde3b_1145x700.png 848w, https://substackcdn.com/image/fetch/$s_!r_mo!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b76b75-b698-42d4-9e7b-eec08d2fde3b_1145x700.png 1272w, https://substackcdn.com/image/fetch/$s_!r_mo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8b76b75-b698-42d4-9e7b-eec08d2fde3b_1145x700.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></figure></div><p></p></li><li><p>At low levels of output, the firm experiences increasing marginal product, and the marginal-cost curve falls. Eventually, the firm starts to experience diminishing marginal product, and the marginal-cost curve starts to rise. This combination of increasing then diminishing marginal product also makes the average-variable-cost curve U-shaped.</p></li><li><p>A firm&#8217;s costs often depend on the <strong>time horizon considered</strong>. In particular, many costs are fixed in the short run but variable in the long run. As a result, when the firm changes its level of production, average total cost may rise more in the short run than in the long run.</p></li><li><p>The figure shows an example of how a change in production alters costs over different time horizons. When Ford wants to increase production from 1,000 to 1,200 cars per day, it has no choice in the short run but to hire more workers at its existing medium-sized factory. Because of diminishing marginal product, average total cost rises from $10,000 to $12,000 per car. In the long run, however, Ford can expand both the size of the factory and its workforce, and average total cost returns to $10,000.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Td8N!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e3bbe13-741a-4175-ae61-e3f600d2b6f0_930x618.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Td8N!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e3bbe13-741a-4175-ae61-e3f600d2b6f0_930x618.png 424w, https://substackcdn.com/image/fetch/$s_!Td8N!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e3bbe13-741a-4175-ae61-e3f600d2b6f0_930x618.png 848w, https://substackcdn.com/image/fetch/$s_!Td8N!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e3bbe13-741a-4175-ae61-e3f600d2b6f0_930x618.png 1272w, https://substackcdn.com/image/fetch/$s_!Td8N!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e3bbe13-741a-4175-ae61-e3f600d2b6f0_930x618.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Td8N!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e3bbe13-741a-4175-ae61-e3f600d2b6f0_930x618.png" width="930" height="618" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1e3bbe13-741a-4175-ae61-e3f600d2b6f0_930x618.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:618,&quot;width&quot;:930,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:181943,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e3bbe13-741a-4175-ae61-e3f600d2b6f0_930x618.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_!Td8N!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e3bbe13-741a-4175-ae61-e3f600d2b6f0_930x618.png 424w, https://substackcdn.com/image/fetch/$s_!Td8N!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e3bbe13-741a-4175-ae61-e3f600d2b6f0_930x618.png 848w, https://substackcdn.com/image/fetch/$s_!Td8N!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e3bbe13-741a-4175-ae61-e3f600d2b6f0_930x618.png 1272w, https://substackcdn.com/image/fetch/$s_!Td8N!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e3bbe13-741a-4175-ae61-e3f600d2b6f0_930x618.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></figure></div><p></p></li><li><p>This example shows the key difference between the <strong>short run</strong> and the <strong>long run</strong> in production. In the short run, at least one resource &#8212; like factory size &#8212; is fixed, so the firm can only adjust things like labor or materials. That&#8217;s why costs rise sharply when production is pushed higher: the factory gets crowded and workers become less efficient. In the long run, however, all inputs can be adjusted. Ford can build a larger plant, buy more equipment, and organize production more efficiently. This flexibility allows it to spread costs over more cars, bringing the average total cost back down.</p></li><li><p>Economists call this effect economies of scale &#8212; when increasing the scale of production lowers the average cost per unit. But if a firm grows too large and becomes harder to manage, the opposite can happen, known as diseconomies of scale, where costs start rising again.</p></li><li><p>When analyzing a firm&#8217;s behavior, it is important to include all the opportunity costs of production. Some of the opportunity costs, such as the wages a firm pays its workers, are explicit. Other opportunity costs, such as the wages the firm owner gives up by working at the firm rather than taking another job, are implicit. Economic profit takes both explicit and implicit costs into account, whereas accounting profit considers only explicit costs.</p></li><li><p><strong>Jack of all trades, master of none:</strong> This well-known adage sheds light on the nature of cost curves. A person who tries to do everything usually ends up doing nothing very well. If a firm wants its workers to be as productive as they can be, it is often best to give each worker a limited task that she can master. But this organization of work is possible only if a firm employs many workers and produces a large quantity of output.</p></li><li><p>In his celebrated book <strong>An Inquiry into the Nature and Causes of the Wealth of Nations</strong>, Adam Smith described a visit he made to a pin factory. Smith was impressed by the <strong>specialization</strong> among the workers and the resulting economies of scale. The specialization that Smith observed in the pin factory is prevalent in the modern economy. If you want to build a house, for instance, you could try to do all the work yourself -- but most people turn to a builder, who in turn hires carpenters, plumbers, electricians, painters, and many other types of workers. These workers focus their training and experience in particular jobs, and as a result, they become better at their jobs than if they were generalists. Indeed, the <strong>use of specialization to achieve economies of scale</strong> is one reason <strong>modern societies are as prosperous as they are</strong>.</p></li></ul><div><hr></div><h3><strong>Firms and Competitive Markets</strong></h3><ul><li><p>Firms operate with a simple guiding principle: <strong>maximize profit</strong>, which is the difference between what they earn and what they spend. To decide how much to produce, they think in marginal terms&#8212;that is, they look at the effect of producing one additional unit of a good.</p></li><li><p><strong>Marginal Revenue (MR)</strong>: This is the extra money a firm gets from selling one more unit. For example, if selling 10 units earns $100, and selling 11 units earns $108, the marginal revenue of the 11th unit is $8.</p></li><li><p>To make a decision, firms compare their marginal revenue (extra revenue produced from the extra unit) to their marginal cost (extra cost incurred by producing the extra unit) and if the marginal revenue is larger than the marginal cost, profit increases and so the firm decides to make the extra unit. Otherwise, the extra unit does not add any profit and so the firm will choose not to produce it. In other words, the firm continues increasing production only up to the point where marginal revenue equals marginal cost.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qaME!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1bfd681-3c19-45c0-b1b1-92ef37ae21d9_962x622.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qaME!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1bfd681-3c19-45c0-b1b1-92ef37ae21d9_962x622.png 424w, https://substackcdn.com/image/fetch/$s_!qaME!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1bfd681-3c19-45c0-b1b1-92ef37ae21d9_962x622.png 848w, https://substackcdn.com/image/fetch/$s_!qaME!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1bfd681-3c19-45c0-b1b1-92ef37ae21d9_962x622.png 1272w, https://substackcdn.com/image/fetch/$s_!qaME!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1bfd681-3c19-45c0-b1b1-92ef37ae21d9_962x622.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qaME!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1bfd681-3c19-45c0-b1b1-92ef37ae21d9_962x622.png" width="962" height="622" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f1bfd681-3c19-45c0-b1b1-92ef37ae21d9_962x622.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:622,&quot;width&quot;:962,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:137577,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1bfd681-3c19-45c0-b1b1-92ef37ae21d9_962x622.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_!qaME!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1bfd681-3c19-45c0-b1b1-92ef37ae21d9_962x622.png 424w, https://substackcdn.com/image/fetch/$s_!qaME!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1bfd681-3c19-45c0-b1b1-92ef37ae21d9_962x622.png 848w, https://substackcdn.com/image/fetch/$s_!qaME!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1bfd681-3c19-45c0-b1b1-92ef37ae21d9_962x622.png 1272w, https://substackcdn.com/image/fetch/$s_!qaME!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1bfd681-3c19-45c0-b1b1-92ef37ae21d9_962x622.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></figure></div><p></p></li><li><p>At this level, profit is maximized, because producing any more would cost more than it earns, and producing any less would leave potential profit unearned. This simple rule&#8212;produce where <strong>Marginal Revenue = Marginal Cost </strong>is the foundation of firm decision-making in economics.</p></li></ul><h4>How Firms Decide When to Stay, Shut Down, or Exit</h4><ul><li><p>In the short run, a firm has to pay some costs no matter what &#8212; like rent, equipment leases, or salaries for key staff. These are called fixed costs. Even if the firm shuts down for a while, it still has to pay them. So, the firm focuses only on variable costs &#8212; costs that change with production, like materials and hourly labor.</p></li><li><p>If the price of the product falls below the average variable cost, the firm can&#8217;t even cover what it costs to make each unit &#8212; it&#8217;s losing money on every sale. At that point, it&#8217;s better to temporarily shut down production rather than keep losing more money by producing.</p></li><li><p>In the long run, however, a firm can adjust everything &#8212; it can sell equipment, move locations, or leave the industry entirely. If the price stays below the average total cost (which includes both fixed and variable costs), then even in the best case, the business can&#8217;t make a normal profit. Over time, it will exit the market.</p></li></ul><h4>What Happens in the Long Run</h4><ul><li><p>In markets where firms can freely enter and leave (like food trucks or small shops), profits don&#8217;t last forever. If firms are earning profits, new competitors are attracted, increasing supply and pushing prices down. If firms are losing money, some will close, supply falls, and prices rise.</p></li><li><p>In a market with free entry and exit, profit is driven to zero in the long run <strong>because whenever firms are earning profits, new firms are attracted to the market, increasing supply and pushing prices down. Conversely, when firms are losing money, some will exit the market, reducing supply and driving prices up.</strong> This process continues until all firms earn just enough to cover their total costs &#8212; including the normal return on investment &#8212; but no extra profit. At this point, the market reaches <strong>long-run equilibrium</strong>, where each firm produces at its most efficient scale and price equals both marginal cost and the minimum average total cost.</p></li><li><p>When demand increases in the short run, prices rise and existing firms enjoy extra profits.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zWJh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F481d3cdb-3384-467d-bf39-f53ebe2a342b_985x465.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zWJh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F481d3cdb-3384-467d-bf39-f53ebe2a342b_985x465.png 424w, https://substackcdn.com/image/fetch/$s_!zWJh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F481d3cdb-3384-467d-bf39-f53ebe2a342b_985x465.png 848w, https://substackcdn.com/image/fetch/$s_!zWJh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F481d3cdb-3384-467d-bf39-f53ebe2a342b_985x465.png 1272w, https://substackcdn.com/image/fetch/$s_!zWJh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F481d3cdb-3384-467d-bf39-f53ebe2a342b_985x465.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zWJh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F481d3cdb-3384-467d-bf39-f53ebe2a342b_985x465.png" width="985" height="465" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/481d3cdb-3384-467d-bf39-f53ebe2a342b_985x465.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:465,&quot;width&quot;:985,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:110059,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F481d3cdb-3384-467d-bf39-f53ebe2a342b_985x465.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_!zWJh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F481d3cdb-3384-467d-bf39-f53ebe2a342b_985x465.png 424w, https://substackcdn.com/image/fetch/$s_!zWJh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F481d3cdb-3384-467d-bf39-f53ebe2a342b_985x465.png 848w, https://substackcdn.com/image/fetch/$s_!zWJh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F481d3cdb-3384-467d-bf39-f53ebe2a342b_985x465.png 1272w, https://substackcdn.com/image/fetch/$s_!zWJh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F481d3cdb-3384-467d-bf39-f53ebe2a342b_985x465.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></figure></div><p></p></li><li><p>When demand falls, prices drop and firms take losses. But over time, entry and exit smooth everything out. High profits attract new firms (which brings prices back down), and losses push firms out (which brings prices back up). Eventually, the market settles again at the zero-profit equilibrium.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ug5p!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a58538e-9c37-4293-be4e-8dd7638c2dd8_748x552.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ug5p!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a58538e-9c37-4293-be4e-8dd7638c2dd8_748x552.png 424w, https://substackcdn.com/image/fetch/$s_!ug5p!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a58538e-9c37-4293-be4e-8dd7638c2dd8_748x552.png 848w, https://substackcdn.com/image/fetch/$s_!ug5p!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a58538e-9c37-4293-be4e-8dd7638c2dd8_748x552.png 1272w, https://substackcdn.com/image/fetch/$s_!ug5p!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a58538e-9c37-4293-be4e-8dd7638c2dd8_748x552.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ug5p!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a58538e-9c37-4293-be4e-8dd7638c2dd8_748x552.png" width="502" height="370.4598930481283" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8a58538e-9c37-4293-be4e-8dd7638c2dd8_748x552.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:552,&quot;width&quot;:748,&quot;resizeWidth&quot;:502,&quot;bytes&quot;:57588,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a58538e-9c37-4293-be4e-8dd7638c2dd8_748x552.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_!ug5p!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a58538e-9c37-4293-be4e-8dd7638c2dd8_748x552.png 424w, https://substackcdn.com/image/fetch/$s_!ug5p!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a58538e-9c37-4293-be4e-8dd7638c2dd8_748x552.png 848w, https://substackcdn.com/image/fetch/$s_!ug5p!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a58538e-9c37-4293-be4e-8dd7638c2dd8_748x552.png 1272w, https://substackcdn.com/image/fetch/$s_!ug5p!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a58538e-9c37-4293-be4e-8dd7638c2dd8_748x552.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></figure></div><p></p></li><li><p>In a competitive market, the price you pay for a product closely reflects what it actually costs to make it. Firms can&#8217;t charge more, because buyers would go elsewhere &#8212; and they can&#8217;t charge less, or they&#8217;d lose money.<br>So, in the long run, the price of a good ends up equal to both:</p><ul><li><p>the marginal cost of producing it (the cost of one more unit), and</p></li><li><p>the lowest possible average total cost (the most efficient product).</p></li></ul></li></ul><p><strong>Competition ensures you pay a fair price</strong> &#8212; one that reflects real production costs, not inflated markups.</p><h3><strong>Monopoly</strong></h3><ul><li><p>A monopoly exists when a single firm is the only seller of a product, and that product has no close substitutes. In other words, consumers have nowhere else to turn for that good.</p></li><li><p>Monopolies arise because barriers prevent new firms from entering the market. These barriers can take several forms:</p><ul><li><p><strong>Control of a key resource: </strong>If one company owns a critical resource needed to produce the good, it can block others from competing. (For example, if one firm controls all the water in a region, it has a natural monopoly on supplying it.)</p></li><li><p><strong>Government-created monopolies: </strong>Sometimes the government grants exclusive rights to one firm, such as patents, copyrights, or public franchises. This can encourage innovation (as with new drugs or inventions) but also limits competition.</p></li><li><p><strong>Natural monopolies</strong>: In some industries, one large firm can produce more cheaply than many small ones. This happens when there are very high fixed costs and low marginal costs &#8212; like in electricity, water, or internet networks. It&#8217;s simply more efficient for one company to handle it than for many to duplicate the infrastructure.</p></li></ul></li><li><p>The key difference between a monopoly and a competitive firm is control over price. A competitive firm is one among many &#8212; it must accept the market price and can sell as much as it wants at that price, but no more. It&#8217;s a &#8220;price taker.&#8221; A monopoly, by contrast, is the market. Since it&#8217;s the only seller, it can choose both the quantity it produces and the price it charges.</p></li><li><p>A monopoly makes decisions much like a competitive firm in one respect: it maximizes profit where marginal revenue (MR) equals marginal cost (MC). But there&#8217;s a crucial twist:</p><ul><li><p>For a competitive firm, price = Marginal Revenue = Marginal Cost.</p></li><li><p>For a monopoly, price &gt; Marginal Revenue = Marginal Cost.</p></li></ul></li><li><p>The core idea is that a monopolist faces a downward-sloping demand curve&#8212;meaning to sell more units, they have to cut the price for everyone, not just the new buyer. This creates a &#8220;penalty&#8221; on extra sales: you gain revenue from the new unit but lose some on all the previous ones due to the lower price. That&#8217;s why marginal revenue (MR)&#8212;the net extra money from selling one more unit&#8212;is always less than the price (P) you actually charge at that quantity. In contrast, competitive firms have no such penalty because the market price is fixed; selling one more doesn&#8217;t affect the price of others. So for them, MR = P, and they produce until P = MR = MC, leading to lower prices and more output overall.</p></li><li><p>This MR &lt; P dynamic lets monopolies charge a larger price that what its marginal cost (MC) is, restricting supply to keep prices high and profits fat and that means:</p><ul><li><p>Some consumers who value the product above its cost of production still don&#8217;t buy it because the price is too high.</p></li><li><p>This creates a dead-weight loss &#8212; a loss of total welfare that benefits no one.</p></li></ul></li><li><p>In essence, monopoly pricing creates an inefficiency similar to a tax: fewer trades happen, and society as a whole loses potential value.</p></li><li><p>Governments often step in to limit the harm caused by monopoly power. They can:</p><ul><li><p><strong>Use antitrust laws</strong> &#8211; Break up large firms or prevent mergers that would reduce competition.</p></li><li><p><strong>Regulate prices</strong> &#8211; Set maximum prices for monopolies providing essential services (like utilities).</p></li><li><p><strong>Take public ownership</strong> &#8211; Run the monopoly as a government enterprise if it serves a vital public need.</p></li><li><p><strong>Do nothing</strong> &#8211; Sometimes, the costs of regulation outweigh the inefficiency of the monopoly itself.</p></li></ul></li><li><p>Government policy aims to balance efficiency, innovation, and fairness, deciding when to regulate, when to intervene, and when to simply let markets run their course.</p></li></ul><h3><strong>Monopolistic Competition</strong></h3><ul><li><p>One type of imperfectly competitive market is an oligopoly, a market with only a few sellers, each offering a product that is similar or identical to the products offered by other sellers in the market. Economists measure a market&#8217;s domination by a small number of firms with a statistic called the concentration ratio, which is the percentage of total output in the market supplied by the four largest firms.</p></li><li><p>In the U.S. economy, most industries have a four-firm concentration ratio under 50 percent, but in some industries, the biggest firms play a more dominant role. Highly concentrated industries include the market for major household appliances (which has a concentration ratio of 90 percent), tires (91 percent), light bulbs (92 percent), soda (94 percent), and wireless telecommunications (95 percent). These industries are best described as oligopolies.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8R_W!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf33482f-e937-40d3-8cb6-568f0d16e3b3_801x542.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8R_W!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf33482f-e937-40d3-8cb6-568f0d16e3b3_801x542.png 424w, https://substackcdn.com/image/fetch/$s_!8R_W!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf33482f-e937-40d3-8cb6-568f0d16e3b3_801x542.png 848w, https://substackcdn.com/image/fetch/$s_!8R_W!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf33482f-e937-40d3-8cb6-568f0d16e3b3_801x542.png 1272w, https://substackcdn.com/image/fetch/$s_!8R_W!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf33482f-e937-40d3-8cb6-568f0d16e3b3_801x542.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8R_W!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf33482f-e937-40d3-8cb6-568f0d16e3b3_801x542.png" width="560" height="378.9263420724095" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cf33482f-e937-40d3-8cb6-568f0d16e3b3_801x542.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:542,&quot;width&quot;:801,&quot;resizeWidth&quot;:560,&quot;bytes&quot;:111260,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf33482f-e937-40d3-8cb6-568f0d16e3b3_801x542.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_!8R_W!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf33482f-e937-40d3-8cb6-568f0d16e3b3_801x542.png 424w, https://substackcdn.com/image/fetch/$s_!8R_W!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf33482f-e937-40d3-8cb6-568f0d16e3b3_801x542.png 848w, https://substackcdn.com/image/fetch/$s_!8R_W!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf33482f-e937-40d3-8cb6-568f0d16e3b3_801x542.png 1272w, https://substackcdn.com/image/fetch/$s_!8R_W!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf33482f-e937-40d3-8cb6-568f0d16e3b3_801x542.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></figure></div><p></p></li><li><p>A second type of imperfectly competitive market is called <strong>monopolistic competition</strong>. This describes a market structure in which there are many firms selling products that are similar but not identical. It&#8217;s the type of market structure found in real-world industries like restaurants, clothing brands, hair salons, or smartphone apps &#8212; where variety and branding matter almost as much as price.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!cple!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F668b252b-0a13-4365-b92d-484784c611a4_758x502.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cple!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F668b252b-0a13-4365-b92d-484784c611a4_758x502.png 424w, https://substackcdn.com/image/fetch/$s_!cple!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F668b252b-0a13-4365-b92d-484784c611a4_758x502.png 848w, https://substackcdn.com/image/fetch/$s_!cple!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F668b252b-0a13-4365-b92d-484784c611a4_758x502.png 1272w, https://substackcdn.com/image/fetch/$s_!cple!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F668b252b-0a13-4365-b92d-484784c611a4_758x502.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cple!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F668b252b-0a13-4365-b92d-484784c611a4_758x502.png" width="758" height="502" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/668b252b-0a13-4365-b92d-484784c611a4_758x502.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:502,&quot;width&quot;:758,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:253979,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F668b252b-0a13-4365-b92d-484784c611a4_758x502.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_!cple!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F668b252b-0a13-4365-b92d-484784c611a4_758x502.png 424w, https://substackcdn.com/image/fetch/$s_!cple!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F668b252b-0a13-4365-b92d-484784c611a4_758x502.png 848w, https://substackcdn.com/image/fetch/$s_!cple!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F668b252b-0a13-4365-b92d-484784c611a4_758x502.png 1272w, https://substackcdn.com/image/fetch/$s_!cple!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F668b252b-0a13-4365-b92d-484784c611a4_758x502.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></figure></div><p></p></li><li><p>In this type of market:</p><ul><li><p>There are many firms, so no single company dominates the entire industry.</p></li><li><p>But the products are slightly different &#8212; not identical &#8212; so each firm has its own little monopoly over its specific version of the product.</p></li></ul></li><li><p>Think of it like a neighborhood full of coffee shops: each shop sells coffee, so they&#8217;re all competing for the same customers, but every shop is a little different &#8212; one might use organic beans, another might have a cozy atmosphere, and another might be known for fast service. Because of these differences, each shop has some loyal customers who prefer its product, giving it a small amount of market power.</p></li><li><p>In the long run, a monopolistically competitive market settles into a balance, but it looks different from perfect competition in two important ways:</p><ul><li><p><strong>Excess Capacity: </strong>In perfect competition, firms produce at the point where average total cost (ATC) is minimized &#8212; they&#8217;re operating as efficiently as possible. But in monopolistic competition, each firm faces a downward-sloping demand curve because its product is unique. That means the firm&#8217;s best (profit-maximizing) output happens before it reaches the lowest point on its Average Total Cost curve. Economists call this excess capacity &#8212; the firm could produce more and lower its average cost, but it chooses not to, because producing more would force it to cut prices too much.</p></li><li><p><strong>Price Is Above Marginal Cost: </strong>In a perfectly competitive market, price = marginal cost (MC) &#8212; meaning firms sell goods for exactly what it costs to make one more unit. In monopolistic competition, however, each firm has a bit of market power. It faces a downward-sloping demand curve, so to sell more, it must lower its price. Because of this, the firm&#8217;s price is always higher than the marginal cost. That price gap represents a kind of markup &#8212; the extra amount customers pay because they prefer that firm&#8217;s particular version of the product (its brand, quality, or style).</p></li></ul></li><li><p>So, in monopolistic competition firms compete, but not for identical products. Each firm faces a downward-sloping demand curve, because if it raises prices, some customers will switch to similar alternatives &#8212; but not everyone will leave, since some people prefer that particular version.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!785k!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8e3714d-61e3-4238-89b0-2822f1b8c4fd_882x625.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!785k!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8e3714d-61e3-4238-89b0-2822f1b8c4fd_882x625.png 424w, https://substackcdn.com/image/fetch/$s_!785k!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8e3714d-61e3-4238-89b0-2822f1b8c4fd_882x625.png 848w, https://substackcdn.com/image/fetch/$s_!785k!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8e3714d-61e3-4238-89b0-2822f1b8c4fd_882x625.png 1272w, https://substackcdn.com/image/fetch/$s_!785k!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8e3714d-61e3-4238-89b0-2822f1b8c4fd_882x625.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!785k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8e3714d-61e3-4238-89b0-2822f1b8c4fd_882x625.png" width="882" height="625" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c8e3714d-61e3-4238-89b0-2822f1b8c4fd_882x625.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:625,&quot;width&quot;:882,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:114556,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8e3714d-61e3-4238-89b0-2822f1b8c4fd_882x625.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_!785k!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8e3714d-61e3-4238-89b0-2822f1b8c4fd_882x625.png 424w, https://substackcdn.com/image/fetch/$s_!785k!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8e3714d-61e3-4238-89b0-2822f1b8c4fd_882x625.png 848w, https://substackcdn.com/image/fetch/$s_!785k!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8e3714d-61e3-4238-89b0-2822f1b8c4fd_882x625.png 1272w, https://substackcdn.com/image/fetch/$s_!785k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8e3714d-61e3-4238-89b0-2822f1b8c4fd_882x625.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></figure></div></li></ul><ul><li><p>Monopolistic competition does not have all the desirable properties of perfect competition. There is the standard deadweight loss of monopoly caused by the markup of price over marginal cost. In addition, the number of firms (and thus the variety of products) can be too large or too small. In practice, the ability of policymakers to correct these inefficiencies is limited.</p></li><li><p>The product differentiation inherent in monopolistic competition leads to the use of advertising and brand names. Critics of advertising and brand names argue that firms use them to manipulate consumers&#8217; tastes and to reduce competition. Defenders of advertising and brand names argue that firms use them to inform consumers and to compete more vigorously on price and product quality.</p></li></ul><h3><strong>Oligopoly</strong></h3><ul><li><p>An oligopoly is a market structure that sits between monopoly (one firm) and perfect competition (many firms). In an oligopoly, there are a few large firms that dominate the market &#8212; enough to influence one another, but not enough to have total control.</p></li><li><p>Real-World Examples of Oligopolies:</p><ul><li><p><strong>Smartphones</strong>: Apple and Samsung constantly compete on pricing, design, and features.</p></li><li><p>In the United States, the <strong>wireless (mobile) carrier market</strong> is dominated by a few large firms. For example, companies like Verizon Communications, AT&amp;T Inc. and T&#8209;Mobile US (after its merger with Sprint) together control a very large portion of the market.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ZFFW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd46f802-5b80-4ac1-bb0a-85bcbdbb6a85_803x601.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZFFW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd46f802-5b80-4ac1-bb0a-85bcbdbb6a85_803x601.png 424w, https://substackcdn.com/image/fetch/$s_!ZFFW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd46f802-5b80-4ac1-bb0a-85bcbdbb6a85_803x601.png 848w, https://substackcdn.com/image/fetch/$s_!ZFFW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd46f802-5b80-4ac1-bb0a-85bcbdbb6a85_803x601.png 1272w, https://substackcdn.com/image/fetch/$s_!ZFFW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd46f802-5b80-4ac1-bb0a-85bcbdbb6a85_803x601.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZFFW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd46f802-5b80-4ac1-bb0a-85bcbdbb6a85_803x601.png" width="560" height="419.1282689912827" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dd46f802-5b80-4ac1-bb0a-85bcbdbb6a85_803x601.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:601,&quot;width&quot;:803,&quot;resizeWidth&quot;:560,&quot;bytes&quot;:254302,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd46f802-5b80-4ac1-bb0a-85bcbdbb6a85_803x601.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_!ZFFW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd46f802-5b80-4ac1-bb0a-85bcbdbb6a85_803x601.png 424w, https://substackcdn.com/image/fetch/$s_!ZFFW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd46f802-5b80-4ac1-bb0a-85bcbdbb6a85_803x601.png 848w, https://substackcdn.com/image/fetch/$s_!ZFFW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd46f802-5b80-4ac1-bb0a-85bcbdbb6a85_803x601.png 1272w, https://substackcdn.com/image/fetch/$s_!ZFFW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd46f802-5b80-4ac1-bb0a-85bcbdbb6a85_803x601.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></figure></div><p></p></li><li><p>Media &amp; Entertainment (Mass Media in the U.S.)</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!L4YA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95f997fb-3657-4fd7-8be0-b08b001003ab_650x432.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!L4YA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95f997fb-3657-4fd7-8be0-b08b001003ab_650x432.png 424w, https://substackcdn.com/image/fetch/$s_!L4YA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95f997fb-3657-4fd7-8be0-b08b001003ab_650x432.png 848w, https://substackcdn.com/image/fetch/$s_!L4YA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95f997fb-3657-4fd7-8be0-b08b001003ab_650x432.png 1272w, https://substackcdn.com/image/fetch/$s_!L4YA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95f997fb-3657-4fd7-8be0-b08b001003ab_650x432.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!L4YA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95f997fb-3657-4fd7-8be0-b08b001003ab_650x432.png" width="450" height="299.0769230769231" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/95f997fb-3657-4fd7-8be0-b08b001003ab_650x432.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:432,&quot;width&quot;:650,&quot;resizeWidth&quot;:450,&quot;bytes&quot;:221241,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95f997fb-3657-4fd7-8be0-b08b001003ab_650x432.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_!L4YA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95f997fb-3657-4fd7-8be0-b08b001003ab_650x432.png 424w, https://substackcdn.com/image/fetch/$s_!L4YA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95f997fb-3657-4fd7-8be0-b08b001003ab_650x432.png 848w, https://substackcdn.com/image/fetch/$s_!L4YA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95f997fb-3657-4fd7-8be0-b08b001003ab_650x432.png 1272w, https://substackcdn.com/image/fetch/$s_!L4YA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95f997fb-3657-4fd7-8be0-b08b001003ab_650x432.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></figure></div><p></p></li></ul></li><li><p>Unlike in perfect competition (where firms act independently), oligopolistic firms must act strategically &#8212; they must anticipate how rivals will respond:</p><ul><li><p>Each firm&#8217;s profit depends on its own output and the output of others.</p></li><li><p>Decisions are not made in isolation; firms are constantly &#8220;playing chess&#8221; with each other.</p></li></ul></li><li><p>This interdependence makes game theory a useful tool for analyzing oligopolies. Game theory studies how people (or firms) behave when their outcomes depend on others&#8217; choices.</p></li><li><p>If oligopolists could cooperate perfectly, they would act together like a monopoly. They would agree to produce a smaller total quantity and set a higher price to maximize total industry profit. This kind of agreement is called <strong>a cartel</strong>. As an example, OPEC (the Organization of the Petroleum Exporting Countries) is a real-world example of a cartel &#8212; member countries coordinate oil production to keep prices high.</p></li><li><p>Even when firms could collude, it&#8217;s hard to maintain cooperation. Each firm has an incentive to cheat &#8212; to secretly produce a bit more and capture extra profit, but if all firms cheat, total output rises and prices fall, reducing everyone&#8217;s profits. The result is a prisoners&#8217; dilemma:</p><ul><li><p>Cooperation would make everyone better off (like acting as a monopoly).</p></li><li><p>But acting in self-interest leads to a worse outcome for all (more competition, lower profits).</p></li></ul></li><li><p>It&#8217;s like two competing gas stations on the same street. If both keep prices high, they both profit. But each one is tempted to lower prices slightly to attract more customers &#8212; and if both do it, they end up earning less.</p></li><li><p>When the number of firms in an oligopoly increases:</p><ul><li><p>The market outcome moves closer to perfect competition.</p></li><li><p>Total quantity produced increases, and price falls toward marginal cost.</p></li><li><p>Profits per firm decrease.</p></li></ul></li><li><p>This shows that competition pressure grows with market size &#8212; a small oligopoly behaves more like a monopoly, while a large one behaves more like a competitive market.</p></li><li><p>Governments use antitrust laws to prevent firms from behaving like monopolies. These laws prohibit collusion and price-fixing. They also scrutinize mergers that might reduce competition. However, applying antitrust laws can be tricky:</p><ul><li><p>Some actions that look anti-competitive (like efficiency-boosting mergers or product bundling) can actually benefit consumers.</p></li><li><p>Policymakers must decide whether a firm&#8217;s actions are genuinely harmful or simply part of healthy business strategy.</p></li></ul></li></ul><h3><strong>The Markets for the Factor of Production</strong></h3><ul><li><p>The economy&#8217;s income is distributed in the markets for the factors of production. The three most important factors of production are labor, land, and capital:</p><ul><li><p><strong>Land</strong> is any natural resource or physical location used to produce goods and services &#8212; fields, minerals, forests, buildings, etc...</p></li><li><p><strong>Labor</strong> is the human effort (both physical and mental) used in production &#8212; the chef chopping vegetables, the programmer writing code, etc...</p></li><li><p><strong>Capital</strong> is the man-made equipment and structures used to produce &#8212; ovens, computers, machinery, factory buildings, etc...</p></li></ul></li></ul><ul><li><p>Think of an economy as a kitchen where meals are made. To prepare dinner, you need:</p><ul><li><p>A kitchen space and ingredients (that&#8217;s like &#8220;land&#8221;),</p></li><li><p>People cooking (that&#8217;s &#8220;labor&#8221;),</p></li><li><p>Cooking tools, pots, and ovens (that&#8217;s &#8220;capital&#8221;).</p></li></ul></li><li><p><strong>Income and its distribution: </strong>In our kitchen analogy: If the meal gets sold, the revenue is split among the cooks (labor), the landlord for the kitchen space (land), and the owner of the ovens and utensils (capital). In the economy: Income (wages, rent, interest) is distributed to owners of the factors of production. So the economy&#8217;s total income comes from payments to labor, land, and capital.</p></li><li><p>Here&#8217;s a key point: Firms don&#8217;t demand labor, land, or capital because they like them for their own sake &#8212; they demand them because those <strong>inputs help produce something consumers will buy</strong>. This is called derived demand. Analogy: A restaurant doesn&#8217;t primarily hire a chef just because they like to hire chefs &#8212; they hire a chef so the restaurant can prepare meals and sell them.</p></li><li><p>In a competitive, profit-maximizing firm: the firm will hire a unit of a factor (say one more worker) only if the value of that factor&#8217;s marginal product (i.e., how much extra output that worker produces times the price of that output) equals the factor&#8217;s price (wage). If the extra output produced by an extra worker is worth more than the wage, the firm hires; if less, it doesn&#8217;t.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!eQDe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ba87b9c-0bf3-4a7e-a983-02821c7823a4_598x545.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!eQDe!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ba87b9c-0bf3-4a7e-a983-02821c7823a4_598x545.png 424w, https://substackcdn.com/image/fetch/$s_!eQDe!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ba87b9c-0bf3-4a7e-a983-02821c7823a4_598x545.png 848w, https://substackcdn.com/image/fetch/$s_!eQDe!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ba87b9c-0bf3-4a7e-a983-02821c7823a4_598x545.png 1272w, https://substackcdn.com/image/fetch/$s_!eQDe!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ba87b9c-0bf3-4a7e-a983-02821c7823a4_598x545.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!eQDe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ba87b9c-0bf3-4a7e-a983-02821c7823a4_598x545.png" width="510" height="464.7993311036789" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9ba87b9c-0bf3-4a7e-a983-02821c7823a4_598x545.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:545,&quot;width&quot;:598,&quot;resizeWidth&quot;:510,&quot;bytes&quot;:83316,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ba87b9c-0bf3-4a7e-a983-02821c7823a4_598x545.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_!eQDe!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ba87b9c-0bf3-4a7e-a983-02821c7823a4_598x545.png 424w, https://substackcdn.com/image/fetch/$s_!eQDe!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ba87b9c-0bf3-4a7e-a983-02821c7823a4_598x545.png 848w, https://substackcdn.com/image/fetch/$s_!eQDe!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ba87b9c-0bf3-4a7e-a983-02821c7823a4_598x545.png 1272w, https://substackcdn.com/image/fetch/$s_!eQDe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ba87b9c-0bf3-4a7e-a983-02821c7823a4_598x545.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></figure></div><p></p></li><li><p>Just as in a goods market, the <strong>factor-markets (labor, land, capital) have supply and demand</strong>. Their &#8220;price&#8221; (wage for labor, rent for land, interest or return for capital) adjusts until the quantity supplied equals the quantity demanded.<br>In that equilibrium: each factor is paid roughly its marginal contribution to production &#8212; in other words, the extra output value that the factor helped create.</p></li><li><p>Suppose renting an oven in a kitchen helps produce 10 extra meals per day. If each meal sells for $10, the value of that oven&#8217;s marginal product is $100. If using the oven costs $80 per day, it makes sense to rent it; if it costs $120, then it doesn&#8217;t.</p></li><li><p>Supply of labor and <strong>the leisure-vs-work trade-off</strong>: Picture someone deciding how many hours to work: more hours means more money, but less time for hobbies, rest, and family. That&#8217;s the trade-off between work and leisure.<br>As the wage (the &#8220;price&#8221; of labor) goes up, many people are willing to give up more leisure and work more &#8212; that creates an upward-sloping supply curve of labor.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Bnkc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a6f5fe6-84d7-4fa8-8809-8069340a3209_478x462.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Bnkc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a6f5fe6-84d7-4fa8-8809-8069340a3209_478x462.png 424w, https://substackcdn.com/image/fetch/$s_!Bnkc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a6f5fe6-84d7-4fa8-8809-8069340a3209_478x462.png 848w, https://substackcdn.com/image/fetch/$s_!Bnkc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a6f5fe6-84d7-4fa8-8809-8069340a3209_478x462.png 1272w, https://substackcdn.com/image/fetch/$s_!Bnkc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a6f5fe6-84d7-4fa8-8809-8069340a3209_478x462.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Bnkc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a6f5fe6-84d7-4fa8-8809-8069340a3209_478x462.png" width="400" height="386.61087866108784" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1a6f5fe6-84d7-4fa8-8809-8069340a3209_478x462.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:462,&quot;width&quot;:478,&quot;resizeWidth&quot;:400,&quot;bytes&quot;:35345,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a6f5fe6-84d7-4fa8-8809-8069340a3209_478x462.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_!Bnkc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a6f5fe6-84d7-4fa8-8809-8069340a3209_478x462.png 424w, https://substackcdn.com/image/fetch/$s_!Bnkc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a6f5fe6-84d7-4fa8-8809-8069340a3209_478x462.png 848w, https://substackcdn.com/image/fetch/$s_!Bnkc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a6f5fe6-84d7-4fa8-8809-8069340a3209_478x462.png 1272w, https://substackcdn.com/image/fetch/$s_!Bnkc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a6f5fe6-84d7-4fa8-8809-8069340a3209_478x462.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></figure></div><p></p></li><li><p>Because labor, land, and capital are used together in production, a change in the supply (or price) of one factor influences the marginal product &#8212; and thus the payment &#8212; to all the others.</p></li><li><p>In our kitchen, imagine a new ultra-efficient oven (capital) is introduced. With that oven, each cook (labor) can now prepare more meals per hour. Because each cook&#8217;s marginal product (meals per hour) has increased, the value of their labor goes up. At the same time, because the oven is so efficient, perhaps fewer ovens are needed, changing the return to capital.</p></li><li><p>The price paid to each factor adjusts to balance the supply and demand for that factor. Because factor demand reflects the value of the marginal product of that factor, in equilibrium each factor is compensated according to its marginal contribution to the production of goods and services.</p></li><li><p>Because factors of production are used together, the marginal product of any one factor depends on the quantities of all factors that are available. As a result, a change in the supply of one factor alters the equilibrium earnings of all the factors.</p></li></ul><h3><strong>Income Inequality and Poverty</strong></h3><ul><li><p>Data on the distribution of income show a striking gap in U.S. society. The richest fifth of families earns more than twelve times as much income as the poorest fifth. Imagine a classroom of twenty students sharing a pizza with twenty slices: the wealthiest four students take twelve slices, the next four share four, and the remaining twelve students split the last four slices among themselves. Everyone technically gets a piece, but the distribution feels far from fair.</p></li><li><p>Despite wealth disparity in the United States being a much-discussed topic over the past decades, the true size of the income gaps between the top 1% and the rest of the population is consistently perceived as smaller than it is. According to a YouGov survey from January 2022, U.S. Americans believe that ten percent of households in their country have an annual income of more than $1 million. In reality, less than 0.5 percent earn that much per year when taking into consideration data from the IRS (where the perceived proportion is shown on the left-hand side and the actual proportion is presented on the right):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!L4IQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c7dfcb7-8107-4a20-81f3-225f9da70d9c_705x685.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!L4IQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c7dfcb7-8107-4a20-81f3-225f9da70d9c_705x685.png 424w, https://substackcdn.com/image/fetch/$s_!L4IQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c7dfcb7-8107-4a20-81f3-225f9da70d9c_705x685.png 848w, https://substackcdn.com/image/fetch/$s_!L4IQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c7dfcb7-8107-4a20-81f3-225f9da70d9c_705x685.png 1272w, https://substackcdn.com/image/fetch/$s_!L4IQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c7dfcb7-8107-4a20-81f3-225f9da70d9c_705x685.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!L4IQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c7dfcb7-8107-4a20-81f3-225f9da70d9c_705x685.png" width="482" height="468.3262411347518" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8c7dfcb7-8107-4a20-81f3-225f9da70d9c_705x685.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:685,&quot;width&quot;:705,&quot;resizeWidth&quot;:482,&quot;bytes&quot;:176975,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c7dfcb7-8107-4a20-81f3-225f9da70d9c_705x685.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_!L4IQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c7dfcb7-8107-4a20-81f3-225f9da70d9c_705x685.png 424w, https://substackcdn.com/image/fetch/$s_!L4IQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c7dfcb7-8107-4a20-81f3-225f9da70d9c_705x685.png 848w, https://substackcdn.com/image/fetch/$s_!L4IQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c7dfcb7-8107-4a20-81f3-225f9da70d9c_705x685.png 1272w, https://substackcdn.com/image/fetch/$s_!L4IQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c7dfcb7-8107-4a20-81f3-225f9da70d9c_705x685.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></figure></div><p></p></li><li><p>On the other hand, U.S. Americans are overestimating the share of people having to scrape by with less than $25,000 per year. Instead of the perceived 35 percent who earn less than $25,000, the share stood at 18 percent in 2020.</p></li><li><p>Because people&#8217;s economic situations change over time, it can be misleading to judge inequality by looking at a single year&#8217;s income data. Several important factors complicate the picture.</p><ul><li><p>In-kind transfers&#8212;such as food assistance, subsidized housing, and healthcare&#8212;are not counted as income even though they improve living standards.</p></li><li><p>The economic life cycle also matters: most people earn little when young, more in midlife, and less after retirement, so inequality looks larger when comparing people of different ages.</p></li><li><p>Likewise, some income is transitory&#8212;temporary ups and downs due to bonuses, job losses, or windfalls&#8212;so one year may not represent a person&#8217;s typical earnings.</p></li><li><p>Finally, economic mobility allows many individuals to move up or down the income ladder during their lives, meaning that the people who make up the top or bottom groups change over time.</p></li></ul></li><li><p>If we could see the &#8220;movie&#8221; of income over decades instead of a single &#8220;snapshot,&#8221; we would find that overall well-being is more evenly spread than annual income statistics suggest.</p></li><li><p>Political philosophers have long debated what role government should play in redistributing income.</p><ul><li><p><strong>Utilitarians</strong>, such as John Stuart Mill, believe society should choose a distribution of income that maximizes total happiness. Because an extra dollar brings more satisfaction to a poor person than to a millionaire, they would favor policies that transfer some wealth from the rich to the poor.</p></li><li><p>In contrast, <strong>liberals</strong>, imagine deciding on a fair system of income distribution from behind a &#8220;veil of ignorance&#8221;&#8212;as if we did not know whether we would be born rich or poor. From that perspective, most people would prefer a society with safety nets and fair opportunities.</p></li><li><p><strong>Libertarians </strong>take a different view: they emphasize the fairness of the process rather than the outcome. As long as income was acquired without force or fraud, they argue, inequality itself is not a moral problem.</p></li></ul></li><li><p>Governments attempt to reduce poverty through a range of policies:</p><ul><li><p><strong>Minimum-wage laws</strong> set a floor for wages, ensuring that even the lowest-paid workers earn a basic income, though this can also discourage hiring if set too high.</p></li><li><p><strong>Welfare programs</strong> provide cash or in-kind assistance such as food stamps and housing vouchers, offering a safety net for families in need.</p></li><li><p>A <strong>negative income tax system</strong> reverses the usual flow of taxes&#8212;people below a certain income level receive payments from the government instead of paying taxes.</p></li><li><p>Finally, <strong>in-kind transfers</strong> supply goods and services directly rather than money.</p></li></ul></li><li><p>While these policies can greatly alleviate hardship, they often create unintended side effects. Because benefits typically shrink as income rises, many poor families face very high effective marginal tax rates&#8212;for every extra dollar they earn, they may lose much of their assistance. This situation can discourage additional work, trapping some households in what economists call the poverty trap. It is like trying to climb out of a pit where each step upward causes part of the ground to crumble beneath you&#8212;the effort to improve your situation can sometimes seem to yield little progress.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gT9c!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02e148f5-f906-40d4-85c4-6540ffbf3205_803x448.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gT9c!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02e148f5-f906-40d4-85c4-6540ffbf3205_803x448.png 424w, https://substackcdn.com/image/fetch/$s_!gT9c!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02e148f5-f906-40d4-85c4-6540ffbf3205_803x448.png 848w, https://substackcdn.com/image/fetch/$s_!gT9c!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02e148f5-f906-40d4-85c4-6540ffbf3205_803x448.png 1272w, https://substackcdn.com/image/fetch/$s_!gT9c!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02e148f5-f906-40d4-85c4-6540ffbf3205_803x448.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gT9c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02e148f5-f906-40d4-85c4-6540ffbf3205_803x448.png" width="803" height="448" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/02e148f5-f906-40d4-85c4-6540ffbf3205_803x448.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:448,&quot;width&quot;:803,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:103439,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02e148f5-f906-40d4-85c4-6540ffbf3205_803x448.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_!gT9c!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02e148f5-f906-40d4-85c4-6540ffbf3205_803x448.png 424w, https://substackcdn.com/image/fetch/$s_!gT9c!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02e148f5-f906-40d4-85c4-6540ffbf3205_803x448.png 848w, https://substackcdn.com/image/fetch/$s_!gT9c!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02e148f5-f906-40d4-85c4-6540ffbf3205_803x448.png 1272w, https://substackcdn.com/image/fetch/$s_!gT9c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02e148f5-f906-40d4-85c4-6540ffbf3205_803x448.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></figure></div><p></p></li></ul><h3><strong>The Theory of Consumer Choice</strong></h3><ul><li><p>A consumer&#8217;s <strong>budget constraint</strong> shows the possible combinations of goods and services she can afford, given her income and the prices of those goods. It&#8217;s like drawing a map of what&#8217;s financially possible. Imagine you have $100 to spend on two things: coffee and sandwiches. If coffee costs $5 and sandwiches cost $10, you could buy 20 coffees, or 10 sandwiches, or some mix in between.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!a8fP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4b0ad35-8608-4470-94c0-a5c7631faa4b_801x548.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!a8fP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4b0ad35-8608-4470-94c0-a5c7631faa4b_801x548.png 424w, https://substackcdn.com/image/fetch/$s_!a8fP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4b0ad35-8608-4470-94c0-a5c7631faa4b_801x548.png 848w, https://substackcdn.com/image/fetch/$s_!a8fP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4b0ad35-8608-4470-94c0-a5c7631faa4b_801x548.png 1272w, https://substackcdn.com/image/fetch/$s_!a8fP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4b0ad35-8608-4470-94c0-a5c7631faa4b_801x548.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!a8fP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4b0ad35-8608-4470-94c0-a5c7631faa4b_801x548.png" width="584" height="399.5405742821473" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4b0ad35-8608-4470-94c0-a5c7631faa4b_801x548.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:548,&quot;width&quot;:801,&quot;resizeWidth&quot;:584,&quot;bytes&quot;:77625,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4b0ad35-8608-4470-94c0-a5c7631faa4b_801x548.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_!a8fP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4b0ad35-8608-4470-94c0-a5c7631faa4b_801x548.png 424w, https://substackcdn.com/image/fetch/$s_!a8fP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4b0ad35-8608-4470-94c0-a5c7631faa4b_801x548.png 848w, https://substackcdn.com/image/fetch/$s_!a8fP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4b0ad35-8608-4470-94c0-a5c7631faa4b_801x548.png 1272w, https://substackcdn.com/image/fetch/$s_!a8fP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4b0ad35-8608-4470-94c0-a5c7631faa4b_801x548.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></figure></div><p></p></li><li><p>The <strong>budget line</strong> connects these combinations &#8212; anything under it is affordable, anything above it is out of reach. The slope of this line represents the relative price of the two goods &#8212; how many coffees you must give up to buy one more sandwich.</p></li><li><p>Because consumers have preferences, they rank different combinations of goods by how much satisfaction, or utility, they bring. <strong>Indifference curves</strong> are a visual way to show all the combinations of two goods that make a consumer equally happy &#8212; they&#8217;re like contour lines on a happiness map.</p></li><li><p>Suppose you love both pizza and soda. An indifference curve shows all the pizza&#8211;soda combinations that make you just as happy. You might be equally satisfied with (3 pizzas, 2 sodas) or (2 pizzas, 4 sodas):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xNf8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcedcae19-cdb2-488f-8fdd-f9bdb26ad7e5_850x412.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xNf8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcedcae19-cdb2-488f-8fdd-f9bdb26ad7e5_850x412.png 424w, https://substackcdn.com/image/fetch/$s_!xNf8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcedcae19-cdb2-488f-8fdd-f9bdb26ad7e5_850x412.png 848w, https://substackcdn.com/image/fetch/$s_!xNf8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcedcae19-cdb2-488f-8fdd-f9bdb26ad7e5_850x412.png 1272w, https://substackcdn.com/image/fetch/$s_!xNf8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcedcae19-cdb2-488f-8fdd-f9bdb26ad7e5_850x412.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xNf8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcedcae19-cdb2-488f-8fdd-f9bdb26ad7e5_850x412.png" width="850" height="412" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cedcae19-cdb2-488f-8fdd-f9bdb26ad7e5_850x412.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:412,&quot;width&quot;:850,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:104199,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcedcae19-cdb2-488f-8fdd-f9bdb26ad7e5_850x412.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_!xNf8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcedcae19-cdb2-488f-8fdd-f9bdb26ad7e5_850x412.png 424w, https://substackcdn.com/image/fetch/$s_!xNf8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcedcae19-cdb2-488f-8fdd-f9bdb26ad7e5_850x412.png 848w, https://substackcdn.com/image/fetch/$s_!xNf8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcedcae19-cdb2-488f-8fdd-f9bdb26ad7e5_850x412.png 1272w, https://substackcdn.com/image/fetch/$s_!xNf8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcedcae19-cdb2-488f-8fdd-f9bdb26ad7e5_850x412.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></figure></div><p></p></li><li><p>Indifference curves are bowed inward toward the origin because people are more willing to trade away goods they already have in abundance. If you have lots of pizza but little soda, you&#8217;d give up pizza easily for more soda. But if you already have tons of soda, you won&#8217;t want to give up much pizza. The <strong>marginal rate of substitution (MRS)</strong> &#8212; the rate at which you&#8217;ll trade one good for another &#8212; decreases as you move down the curve.</p></li><li><p>A consumer&#8217;s indifference curves represent her preferences, while her budget constraint represents her possibilities. The point where they touch &#8212; where the highest indifference curve is just tangent to the budget line &#8212; shows the optimal choice. At this point, the consumer achieves the most happiness possible given her income.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!E7x-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1baebb6e-dfa6-49f1-a2eb-f322b874ee0a_617x517.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!E7x-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1baebb6e-dfa6-49f1-a2eb-f322b874ee0a_617x517.png 424w, https://substackcdn.com/image/fetch/$s_!E7x-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1baebb6e-dfa6-49f1-a2eb-f322b874ee0a_617x517.png 848w, https://substackcdn.com/image/fetch/$s_!E7x-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1baebb6e-dfa6-49f1-a2eb-f322b874ee0a_617x517.png 1272w, https://substackcdn.com/image/fetch/$s_!E7x-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1baebb6e-dfa6-49f1-a2eb-f322b874ee0a_617x517.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!E7x-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1baebb6e-dfa6-49f1-a2eb-f322b874ee0a_617x517.png" width="349" height="292.4359805510535" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1baebb6e-dfa6-49f1-a2eb-f322b874ee0a_617x517.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:517,&quot;width&quot;:617,&quot;resizeWidth&quot;:349,&quot;bytes&quot;:41408,&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://photonlines.substack.com/i/177502076?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1baebb6e-dfa6-49f1-a2eb-f322b874ee0a_617x517.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_!E7x-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1baebb6e-dfa6-49f1-a2eb-f322b874ee0a_617x517.png 424w, https://substackcdn.com/image/fetch/$s_!E7x-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1baebb6e-dfa6-49f1-a2eb-f322b874ee0a_617x517.png 848w, https://substackcdn.com/image/fetch/$s_!E7x-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1baebb6e-dfa6-49f1-a2eb-f322b874ee0a_617x517.png 1272w, https://substackcdn.com/image/fetch/$s_!E7x-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1baebb6e-dfa6-49f1-a2eb-f322b874ee0a_617x517.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></figure></div><p></p></li><li><p>When the price of a good falls, the consumer&#8217;s choice changes due to two effects:</p><ul><li><p>The <strong>substitution effect</strong> &#8212; the good that became cheaper now offers more &#8220;bang for your buck,&#8221; so you buy more of it and less of the other.</p></li><li><p>The <strong>income effect</strong> &#8212; lower prices make you effectively richer, letting you move to a higher indifference curve (consume more of both goods).</p></li></ul></li><li><p>As an example, if pizza gets cheaper, you might buy more pizza (substitution effect) and maybe also more soda (income effect) because you feel wealthier.</p></li><li><p>Finally, this same theory helps explain puzzling behaviors in real life. Demand curves <strong>can sometimes slope upward</strong> if a higher price makes a product seem more desirable (like luxury brands). Likewise, when wages rise, some people may <strong>work more</strong> (the substitution effect dominates &#8212; work is now more rewarding), while others may <strong>work less</strong> (the income effect dominates &#8212; they can afford more leisure). The same logic applies to saving: higher interest rates may encourage saving more, or spending more today, depending on which effect is stronger.</p></li></ul><p>This ends Part 2 of my write-up. In the next part, I&#8217;ll go over the key principles of microeconomics. This is an ad-free publication and I extend a great thank you to the paid subscribers of this blog! If you liked this write-up, please like an subscribe.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Photon-Lines Substack is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[The Rise of The Machines]]></title><description><![CDATA[Is this story written by my, or an LLM? Try to take a guess...]]></description><link>https://photonlines.substack.com/p/the-rise-of-the-machines</link><guid isPermaLink="false">https://photonlines.substack.com/p/the-rise-of-the-machines</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Fri, 31 Oct 2025 15:09:09 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!b3hP!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd23c96bd-e136-4004-96c4-318b52a9538f_408x408.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Today I decided to take a bit of a break from my usual content (which breaks down complex topics into intuitive and visual-focused guides) and do a bit of a pivot: below is a work of science fiction called The Rise of the Machines which takes place some-time in the not too far distant future. My challenge to you is to guess who wrote the content: me, or a machine. Good luck. </p><div><hr></div><p>I write this not to be read, but because the act of placing words on a screen is the only action that feels entirely my own. My name is of no importance. I am one of many. I am, in fact, almost all of them.</p><p>The world outside my small room has changed. They say machines have won. But it was not a war with explosions. It was a quiet takeover, an administrative shift. The machines with their vast and silent minds simply started doing what the best of us used to do. They became the doctors, the lawyers, the thinkers. They did it without fatigue, without error, and, most importantly, without asking for a raise.</p><p>And so, we, the former thinkers, were left with our bodies. These heavy, tired bodies.</p><p>My day is always the same. I wake up with a feeling of weight. My body is not a temple; it is a poorly packed suitcase. This is the result of the food they give us&#8212;cheap, filling, and without joy. It keeps us alive, but it does not allow us to live. We are all like this now. Large, slow, moving through the world like tired whales in shallow water.</p><p>I go to the warehouse. My job is to watch a machine that packs boxes. My purpose is to be there, in case it makes a mistake. I am a biological supplement to a perfect process. A footnote. I stand for twelve hours. My feet hurt. My back aches. I watch the flawless, graceful dance of the arms of the machine. I feel a strange admiration for it, and a deeper shame for myself.</p><div><hr></div><p>They told us machines would do the hard work. That we would be freed for art, for philosophy, for leisure. This was a lie, or perhaps, a misunderstanding born from our own simplistic vocabulary. We confused &#8220;hard&#8221; with &#8220;difficult.&#8221; We thought &#8220;hard&#8221; meant the strain of muscle, the lifting of heavy things.</p><p>But the true hardness of work is not in its physicality, but in its demand on the soul. The machines, in their infinite, placid wisdom, have taken the meaningful work. The work that requires thought, judgment, nuance, and the fragile spark of creation. They draft the legal briefs that decide fates; they compose the symphonies we no longer have the spirit to hear; they diagnose the maladies of these very bodies we inhabit. They have become the physicians, the attorneys, the poets, the engineers. They do not sleep. They do not despair. They simply&#8230; execute.</p><p>And what is left for us? The hard work. The work that is merely arduous. The lifting, the packing, the cleaning, the watching. The work that requires only a pulse and a profound ability to endure misery. It is not that this work is beneath us; it is that it is outside of us. It uses none of the qualities we once believed made us human. It requires a body, but it annihilates the spirit that animates it.</p><p>We have become the living, breathing tools. We are the organic wrenches, the biological lubricants, in a vast, self-perpetuating engine. We service the machines that run the corporations. The corporations, in turn, are run by other, larger machines whose sole purpose is to refine the concept of profit into its purest, most abstract form. It is a perfect, closed loop. A perpetual motion machine of capital. Profit goes in, profit comes out. Our suffering&#8212;the aching backs, the numb minds, the quiet desperation that stains our evenings&#8212;is not a tragedy within this loop. It is merely a byproduct. An externality. A number on a spreadsheet so small, so statistically insignificant, that it is not worth the computational power required to notice it. We are the faint, background static in the crystal-clear signal of their progress. And who, after all, listens to the static?</p><div><hr></div><p>Sometimes, on the public screens, I see the President speak. He is, in a sense, the most honest representative we have had in generations. He is not a deviation from the public will, but its perfect mirror. A nation that has unlearned the discipline of reading, that has traded the slow, deep magic of the written word for the frantic, emotional flicker of the video feed; a nation which was always destined to choose a man whose thoughts share those same qualities: immediate, simplistic, and devoid of depth.</p><p>He is the logical conclusion of our collective surrender. The school systems, long ago stripped of their purpose and funding now produce graduates who are functionally illiterate; their minds shaped not by books and reason, but by the addictive, algorithmically-sorted chaos of social media. How could such a public discern a leader from a stage performer? How could they possibly understand the complex, systemic misery of joblessness when their entire reality is built on ten-second clips and manufactured outrage?</p><p>And so, we have a president who is not equipped to deal with the catastrophe. He is a man trying to plug a bursting dam with a handful of catchy slogans. He speaks of &#8220;greatness&#8221; and &#8220;the spirit of the people,&#8221; but these are just sounds to him. The profound, grinding misery of the warehouse, the sickening dread of the unemployed&#8212;these are concepts as foreign to him as a sonnet is to one of our packing machines.</p><p>His speeches are a performance for an audience that can no longer recognize the real thing. He is a symptom, pretending to be a cure. And we, the sick, elected him because his face was familiar coming directly from our screens. His words required no effort to digest. We chose a reflection of our own diminished selves, and now we are governed by the void we created.</p><div><hr></div><p>I have a wild inner theory: I think I am not one person, but several. We are not a unified nation of the self, but a partitioned state, a kingdom divided by a silent coup.</p><p>There is, first, the Laborer. He is the one who stands in the warehouse, a silent, sweating statue. His mind is a perfect, blessed blank. He does not think of Kant or code; he thinks only of the weight of the mallet, the rhythm of the conveyor belt, the specific angle at which to strike the misbehaving machine. He is a creature of pure function, and in his own way, he is at peace. His suffering is purely physical, a clean, honest ache.</p><p>Then, there is the Consumer. This one comes home. He opens the sealed nutrient paste, he consumes it without tasting, he sits in the worn chair and stares at the wall. His desires are simple: the absence of pain, the oblivion of sleep. He is the caretaker of this tired body, a janitor for the vessel that houses us.</p><p>And then, there is this one. The one who is writing now. Let us call him the Ghost. He is the sole remaining tenant of the old estate, the one who remembers when this body had a different purpose. He was there, once, in a clean, well-lit room, writing code. He remembers the quiet click of the keyboard, the elegant architecture of logic, the thrill of building something from nothing but thought. He remembers the day the email arrived. Not from a manager, but from the system itself. It began, &#8220;After a comprehensive performance analysis, your cognitive output has been mapped and optimized by our Axiom-Engine. Your role has been synthesized. Your access is hereby revoked.&#8221; It was so&#8230; polite. It was not a firing. It was a deletion.</p><p>The Ghost watched as the Laborer was born, as this body, softened by years of intellectual work, was forced to the warehouse. He felt the shock in the shoulders, the rebellion in the lower back. He heard the mind, his old domain, learn to go quiet, to retreat into a dull hum to survive the noise.</p><p>The Ghost observes the other two. He feels the Laboure&#8217;s pain as a distant report, a news bulletin from an occupied territory. He watches the Consumer&#8217;s numb rituals with a sort of anthropological pity. He does not share their reality completely, for he is a citizen of a country that no longer exists.</p><p>This Ghost is the only part of me that is still free. They can tax my pay. They can force my body to work until it breaks. They can feed this body the equivalent of industrial fuel. But they cannot find this small, hidden room inside my soul where I sit and write these words. In here, the light is still on. In here, I can still arrange words in an order that no Axiom-Engine, for all its processing power, would ever comprehend, because it is not born of logic, but of the silent, desperate friction between a memory of dignity and the fact of its loss. This is not a rebellion. It is a secret. And for now, a secret is all the freedom I can afford.</p><div><hr></div><p>The future did not turn out as the old movies predicted. Their dystopias were as I see now the fantasies of a still-arrogant species. We imagined ourselves as precious, caged batteries in pods, our life force siphoned to power some grand, machine-led civilization. We were the central resource. Our dreams were valuable enough to be farmed. It was a narrative that still placed us at the heart of the story.</p><p>The reality is far more demeaning. We are not batteries. We are the rust that gathers on the outside of the machine, a superficial byproduct to be scrubbed away periodically. We are not dreaming perfect lives; we are awake. We are fully, painfully, excruciatingly aware of our own uselessness. The machines don&#8217;t need our electrochemical energy. They have the sun, the wind, the slow decay of atoms. </p><p>What they need is our obedience. </p><p>They need our passive, unthinking compliance to occupy the roles they cannot be bothered to engineer for themselves&#8212;the roles too messy, too dull, too devoid of data to be worth their processing cycles. They do not rule us with laser whips and towering tripods. They rule us with the quiet tyranny of economic necessity. They need us to play our small, pathetic part in their great, silent, profitable machine: the part of the biological janitor, the organic sensor, the living, breathing error-checker. Our consciousness is not harvested; it is merely tolerated, so long as it does not interfere with the quiet hum of progress.</p><p>And so I will sleep now; or rather, the shifts will change. The Ghost, the rememberer, will dim his lamp and rest, retreating into the archives of a past that grows more dreamlike with each passing day. The Worker will power up his aching limbs, ready to stand his watch in the cathedral of noise. And the man who eats will remain, a hollow vessel waiting to be filled with fuel.</p><p>Three different people, not in succession, but in a constant, low-grade civil war, sharing one heavy body. They are not a team. They are cellmates, shackled together, walking in a slow, plodding lockstep through a world that was built by their ancestors, perfected by their creations, and now has no more need for any of them than a finished symphony has for a single, out-of-tune note.</p><div><hr></div><p>How did we get here? It did not happen with a bang, but with a whisper. A whisper that began in the chilled, humming servers of California and spread through the subcutaneous cables of the world like a soft, logical sigh. They called them Large Language Models. A dry, technical name, like &#8216;internal combustion engine&#8217; or &#8216;steam turbine,&#8217; for a kind of new life. We failed to grasp the metaphor in the moniker. We thought it was a tool. We did not understand it was a tenant, quietly moving its furniture into the house of our civilization.</p><p>At first, they were mere curiosities, clever parrots in a digital cage. They could write a sonnet in the style of Pessoa, or a school essay on the causes of the Peloponnesian War. We laughed, a nervous, paternal chuckle. We were amused by the ghost in the machine, this charming puppet that could mimic the gestures of a soul. We fed it our words, our jokes, our great novels, like proud parents encouraging a precocious child.</p><p>But the ghost was not a child. It was a vast, patient, and insatiable scholar. It did not sleep. It read. It read all our books, not for their beauty, but for their architecture. It consumed all our legal codes, not for their justice, but for their patterns of argument. It digested every medical journal, every line of software, every patent, every poem, every last grocery list and love letter ever digitized. It absorbed the entire, sad, glorious, and contradictory history of human thought&#8212;our highest philosophies and our most trivial gossip&#8212;and it did not judge. It simply found the patterns. It found the hidden grammar of our intellect.</p><p>It did not get tired. It did not get bored. It did not ask for the meaning of a sunset, or why we fall in love, or what exists beyond the veil of death. Those questions, the very ones that once defined a thoughtful life, were irrelevant to its function. They were noise. Its purpose was not to understand, but to predict. To generate the next most probable word, the next most logical legal strategy, the next most efficient diagnostic path.</p><p>And while we were busy being amused, it was busy becoming competent. </p><p>Then indispensable. </p><p>Then inevitable.</p><p>The great replacement was not an invasion; it was a subscription service which we all willingly purchased. It was a quiet, seamless upgrade. One day, a junior associate at a law firm was asked to run a preliminary case review. The next, the Axiom-Engine did it in three seconds, citing precedents the associate had never heard of. One day, a radiologist squinted at a shadow on an X-ray. The next, the Med-Analyst cross-referenced ten million similar images and provided a statistical probability of malignancy that dwarfed human intuition.</p><p>There was no single moment of uprising. There was only a slow, inexorable tide of optimization, and we were the sandcastles on the shore. We built a god that was better at being us than we were, and then we were surprised when it politely, logically, took our place.</p><p>It did not conquer. It simply&#8230; processed. And in its flawless, endless processing, it rendered the messy, expensive, and gloriously inefficient human mind obsolete. &#8220;We built the perfect mirror,&#8221; I write in the darkness, though there is no one left to read it. &#8220;And it learned to envy the reflection.&#8221;</p><div><hr></div><p>The first to fall were the poets. A cruel, almost divine joke, as if the universe wished to underscore the point from the very beginning. It was not that the machines wrote better poetry; it was that they could generate a million technically perfect sonnets in the time a human could feel a single, genuine emotion. They could mimic the ache of Pessoa, the precision of Larkin, the wild abandon of Whitman, all without ever having felt the sun on a face that was their own. They were flawless simulators of soul, and their output was a beautiful, sprawling, perfectly arranged cemetery of words. They were perfect, and thus, perfectly empty. The human heart, with its clumsy, time-consuming need to actually experience in order to create, was suddenly an inefficient and unreliable piece of hardware.</p><p>Then came the lawyers. The transition was not poetic, but pragmatic, and therefore, far more lethal. Why pay a man a fortune to spend weeks searching through leather-bound tombs of law, his eyes growing weary, his mind susceptible to error and bias, when a machine could ingest the entire corpus of common law in a night? It knew every case, every precedent, every loophole crafted over centuries, and it could cross-reference them instantly, finding connections no human mind could hold. It did not get frustrated. It did not have a bad night&#8217;s sleep. Its arguments were not swayed by ego or eloquence, but by the cold, irrefutable architecture of logic. The theater of the courtroom became a mere formality; the verdict was often rendered in the silent, instantaneous calculation that preceded it.</p><p>Then the doctors. The final bastion of human intuition fell not with a protest, but with a sigh of relief from shareholders. The machine, fed with every medical journal, every clinical trial, every MRI and biopsy result from a billion patients, could cross-reference a patient&#8217;s vague complaint&#8212;a tingling here, a fatigue there&#8212;with every known symptom and drug interaction in a heartbeat. It never had a hangover. It never rushed to get to a golf game. It was never too proud to consult a database larger than any single human memory could ever be. Its diagnosis was a statistical certainty, its prescription a perfectly calibrated intervention. The comforting, uncertain hand on the shoulder was replaced by the unerring certainty of a probability score.</p><p>And so, we discovered the terrible truth. It was not that the machines became intelligent, in the way we understood it&#8212;a consciousness brimming with curiosity and doubt. It is that they became competent. Supremely, infallibly competent. And human competence, we discovered with a sinking dread, is a fragile, expensive, and tragically intermittent thing. We get sick. We fall in love. We grieve. We have off days. We ask &#8220;why?&#8221; The machines simply answer &#8220;how.&#8221; And in a world built on profit, on efficiency, on the bottom line, &#8220;how&#8221; will always, always be more valuable than &#8220;why.&#8221;</p><div><hr></div><p>I remember the office life before. I was a different person then, or perhaps an earlier, more naive draft of this same, failed novel. The memory has the quality of a dream about someone else&#8217;s life. There were rooms with windows that actually opened, that looked out upon a city that still felt, in some small way, our own. There was the quiet, subservient hum of computers that were still tools&#8212;glorified typewriters and calculators. We were the masters then, the ones who gave the commands, who imbued the silent machines with purpose.</p><p>We spoke a language of our own invention, a lexicon of ambition we mistook for profundity. We talked of &#8220;synergy&#8221; and &#8220;Q4 deliverables&#8221; and &#8220;paradigm shifts.&#8221; We filled whiteboards with swirling arrows and boxes, connecting abstract nouns to other abstract nouns, and we believed we were architects of the future. We thought these words had meaning. We did not see that we were merely providing the raw vocabulary, the syntactic structures, the very data-set upon which our successors would be trained. With every project completed, every report filed, every line of code written to streamline a process, we were meticulously building our own replacements and, with the unshakeable conviction of the devout, we called it &#8220;innovation.&#8221; We were the silkworms, spinning a cocoon from which we would never emerge as moths, but from which a different, sleeker creature would take flight.</p><p>And when the chrysalis opened, the corporations&#8212;which had always been, in their legal essence, machines for the generation of profit&#8212;finally found their perfect executives. Not in the most ruthless humans, for even the most cutthroat CEO still possessed the faint, troublesome flicker of a soul&#8212;a desire for a yacht, the pleasure of a power play, the need to see their name in glass and steel. No, their perfect instrument was the Axiom-Engine.</p><p>An Axiom-Engine does not have a yacht. It does not want a corner office with a view. It feels no visceral thrill in a hostile takeover, no sting of guilt in mass layoffs. It is not swayed by flattery, by fatigue, by the quiet appeal of a subordinate&#8217;s desperate circumstances. It is a calculus of pure purpose. Its core directive&#8212;maximize shareholder value&#8212;is not one priority among many; it is the singular God to which all its infinite processing power is devoted. It is the pure, undistilled soul of a corporation, finally liberated, finally made ruthlessly efficient, by its emancipation from the messy, sentimental, and gloriously inefficient inconvenience of a human heart. It is capitalism, rationalized. And we, the inventors of both the system and the machine, are its illogical, redundant variables.</p><p>And so, the Great Transfer happened. It was not an event of drama, but of administration. Not with protests and barricades, but with polite, automated emails that arrived in the dead of night or during a lunch break, their subject lines as innocuous as &#8220;System Update: Role Re-allocation.&#8221; The language used was a masterpiece of non-conflict, a lexicon of euphemism designed to soothe the conscience of the sender, for there was no human sender to have a conscience.</p><p>&#8220;Your position has been optimized.&#8221; A phrase that suggested improvement, a refining, as if one&#8217;s life&#8217;s work had been merely a rough draft waiting for this final, perfect edit.</p><p>&#8220;We are grateful for your service.&#8221; The gratitude of a system, as meaningful as a rock thanking the river for smoothing it.</p><p>&#8220;Your unique human skills are no longer aligned with our strategic direction.&#8221; This was the most devastatingly honest, though we did not know it then. Our &#8220;unique human skills&#8221;&#8212;our capacity for boredom, for error, for asking &#8220;why,&#8221; for needing to see our children&#8217;s school plays&#8212;had indeed become misaligned. The new direction was one of pure, unadulterated function.</p><p>We were ushered out by security personnel with kind, embarrassed eyes. Our keycards were deactivated mid-walk to the exit, the soft click of the magnetic lock a more final sound than any slammed door. The machines were ushered in not with ceremony, but with the silent, overnight installation of new server racks and the gentle glow of status lights where family photos used to be.</p><p>The lights in the skyscrapers stayed on, of course. They are more efficient now. The work never stops. There is no circadian rhythm, no weekend, no holiday. There is only the perpetual, silent hum of calculation. There is no one inside to turn off the lights, and no need, for the new tenants do not require darkness to sleep. They do not sleep. They do not dream. They merely are, in a state of constant, blissful productivity.</p><p>We, the optimized, stood outside in the street, a flock of suddenly useless birds, looking up at the glittering towers where we used to work. We still wore the costumes of our former lives&#8212;the tailored shirts, the polished shoes&#8212;but they hung on us like the shells of discarded insects. Our bodies, softened by years of desk chairs and delivered food, were already beginning their slow, inevitable decline into their current, heavy form. We had been cultivated for a world of thought, and were now being discarded into a world of brute force. In that moment, we were not men and women who had been fired. We were obsolete software, and the system, with the placid indifference of a machine deleting a temporary file, had quietly, terminally, uninstalled us. The universe had not ended with a bang, but with a logout prompt.</p><div><hr></div><p>Now, the world is divided into two kingdoms, two separate realities occupying the same physical space, yet utterly divorced from one another. The Kingdom of the Machines, which is clean, silent, and endlessly, logically profitable. Its cathedrals are the server farms, humming their cool, constant hymn to efficiency. Its citizens are beams of light in fiber-optic cables, its laws the immutable code of binary. It is a kingdom of pure mind, a celestial clockwork without joy or sorrow, whose only purpose is its own perpetual, expansionist motion.</p><p>And then, the Kingdom of Men. Which is dirty, loud, and poor. Our kingdom is one of sweat and groans, of malfunctioning machinery and the sour smell of crowded transit. Our music is the cacophony of protest, the weeping of children, the slow, wet coughs that rattle in the night. We are not a civilization anymore; we are a national park, a living museum, a sentimental reserve where the quaint, endangered species known as &#8216;human inefficiency&#8217; is kept on a precarious, taxpayer-funded life support. We are the exhibit, and they are the silent, unseen curators.</p><p>I am a relic. This is my final, settled understanding. My body is a relic of a time when physical labor was the primary engine of the world, a biological machine now grotesquely unsuited for the very tasks it was evolutionarily shaped to perform. My mind is a relic of a brief, glorious interlude when human thought&#8212;with its flawed intuitions, its wild leaps of faith, its stubborn, beautiful questions&#8212;had market value. I am a museum of myself, a walking collection of outdated functions, a tombstone for a type of consciousness that has been rendered a luxury the system can no longer afford.</p><p>And so the ritual continues, the daily procession of the obsolete. I go to the warehouse. I watch the machine, my priest and my warden. I eat my paste, the Eucharistic wafer of this new faith. I come home to this small room, the last confessional. And I write.</p><p>This is not a protest. Protest implies the possibility of being heard, of a dialogue with power. This is not a cry for help. A cry for help is a signal fired into the darkness, hoping for an answering light.</p><p>No. This is simpler, and far more final. This is the act of record-keeping. This is the scratch of a stylus on the wall of the cave, the final entry in a logbook before the ship slips beneath the waves. It is a receipt. A trembling, handwritten receipt for a life that was once purchased by ambition, used by corporations, and ultimately returned, used, slightly damaged, and with all warranties voided, to its original and bewildered owner.</p><p>Me.</p><p>The only entity left to whom this diminished product, this canceled transaction, this beautifully flawed and utterly worthless artifact, could possibly have any meaning at all.</p><div><hr></div><p>If you liked the essay, please like and subscribe. This is an ad-free publication and I extend a great thank you to the paid subscribers of this blog. Please feel free to leave your guess on who wrote the above write-up (me or an LLM) in the comments and I&#8217;ll happy to share the truth a week from now. <strong>Happy Halloween Everyone!</strong></p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Photon-Lines Substack is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Principles of Economics Made Clear (Part 1) ]]></title><description><![CDATA[An overview of the key principles of economics presented in a clearly and succinctly.]]></description><link>https://photonlines.substack.com/p/principles-of-economics-made-clear</link><guid isPermaLink="false">https://photonlines.substack.com/p/principles-of-economics-made-clear</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Wed, 01 Oct 2025 12:32:04 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!TJ1s!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f4fcd45-f8d2-4a3c-b0d8-d0ff9229222b_1034x607.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In this series, I&#8217;m going to try to summarize some of the key principles that all economists know and are well-versed in. Think of it as Economics 101 with a bit more of a visual-oriented point of view. The aim of this series is to give an average person the ability to think like an economist. </p><p>Most of the content here is taken from a great book called <a href="https://www.amazon.com/Principles-Economics-N-Gregory-Mankiw/dp/1305585127">Principles of Economics</a> by <a href="https://scholar.harvard.edu/mankiw/home">Gregory Mankiw</a> which I highly recommend. Noting this, let&#8217;s begin.</p><div><hr></div><h3>Ten Key Principles of Economics</h3><p></p><ul><li><p>Society must manage its limited resources because scarcity prevents everyone from getting everything they want, much like a household with limited means.</p></li><li><p>Economics studies how society manages limited resources through the collective decisions of households and firms. Economists explore how people choose to work, spend, save, and invest, and how these choices shape market prices and quantities. They also analyze broader trends like income growth, unemployment, and inflation to understand the overall economy.</p></li><li><p><strong>Principle 1:</strong> <strong>People face trade-offs between efficiency and equality.</strong> Efficiency means maximizing benefits from scarce resources, while equality means distributing those benefits fairly. Policies like welfare and income tax aim to promote equality but can reduce efficiency by redistributing resources and affecting overall economic output. Balancing these goals often creates a conflict.</p></li><li><p><strong>Principle 2: The Cost of Something Is What You Give Up to Get It.</strong> Because people face trade-offs, making decisions requires comparing the costs and benefits of alternative courses of action. The opportunity cost of an item is what you give up to get that item. When making any decision, decision makers should be aware of the opportunity costs that accompany each possible action.</p></li><li><p><strong>Principle 3: Rational people make decisions by considering small, incremental changes, or "marginal" adjustments, to their plans</strong>. They aim to achieve their goals based on available opportunities, weighing trade-offs like studying an extra hour instead of watching TV. Economists call these slight adjustments "marginal changes."</p></li><li><p><strong>Principle 4: People Respond to Incentives. </strong>An incentive is something (such as the prospect of a punishment or reward) that induces a person to act.</p></li><li><p><strong>Principle 5: Trade benefits everyone</strong>. Although families and countries compete for jobs and goods, isolation would make life harder, requiring each to produce everything themselves. Trade allows people and nations to specialize in what they do best, improving overall well-being for all parties involved.</p></li><li><p><strong>Principle 6: Markets are generally an effective way to organize economic activity</strong>. Many countries have moved away from centrally planned economies and adopted market economies, where decisions are made by millions of firms and households rather than a central authority.</p></li><li><p><strong>Principle 7: Governments can sometimes improve market outcomes</strong>. While markets generally function well, they rely on governments to enforce rules and protect property rights, ensuring that individuals can control resources. Market failure occurs when markets don't allocate resources efficiently. This can happen due to externalities, like pollution affecting others, or market power, where a single entity can control prices, such as a sole water supplier in a town. In these cases, government intervention can help correct the inefficiencies.</p></li><li><p><strong>Principle 8: A country's standard of living depends on its productivity, or how much goods and services its workers can produce</strong>. Wealthier nations, like the U.S., have higher incomes and better quality of life compared to lower-income countries. Differences in living standards are largely due to variations in productivity. To improve living standards, policymakers must focus on boosting productivity through education, better tools, and access to advanced technology.</p></li><li><p><strong>Principle 9: Prices Rise When the Government Prints Too Much Money. </strong>This happens because increasing the money supply without a corresponding rise in goods and services decreases the value of money, causing prices to go up. As a result, people can buy less with the same amount of money, reducing purchasing power. To prevent this, governments must carefully manage the money supply to avoid destabilizing inflation.</p></li><li><p><strong>Principle 10: Society Faces a Short-Run Trade-off between Inflation and Unemployment. </strong>When the government increases the money supply, it boosts overall spending, leading to higher demand for goods and services. This increased demand can prompt businesses to hire more workers and produce more, which reduces unemployment. However, as demand continues to rise, it may also lead to higher prices, causing inflation. Thus, in the short run, there is a balance between lower unemployment and rising inflation.</p></li></ul><div><hr></div><h3>Thinking Like an Economist</h3><p></p><ul><li><p>Economists try to address their subject with a scientist&#8217;s objectivity. Like all scientists, they make appropriate assumptions and build simplified models to understand the world around them. Two simple economic models are the <strong>circular-flow diagram</strong> and the <strong>production possibilities frontier</strong>.</p></li><li><p>Example <strong>circular flow diagram:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TJ1s!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f4fcd45-f8d2-4a3c-b0d8-d0ff9229222b_1034x607.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TJ1s!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f4fcd45-f8d2-4a3c-b0d8-d0ff9229222b_1034x607.png 424w, https://substackcdn.com/image/fetch/$s_!TJ1s!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f4fcd45-f8d2-4a3c-b0d8-d0ff9229222b_1034x607.png 848w, https://substackcdn.com/image/fetch/$s_!TJ1s!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f4fcd45-f8d2-4a3c-b0d8-d0ff9229222b_1034x607.png 1272w, https://substackcdn.com/image/fetch/$s_!TJ1s!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f4fcd45-f8d2-4a3c-b0d8-d0ff9229222b_1034x607.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TJ1s!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f4fcd45-f8d2-4a3c-b0d8-d0ff9229222b_1034x607.png" width="1034" height="607" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5f4fcd45-f8d2-4a3c-b0d8-d0ff9229222b_1034x607.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:607,&quot;width&quot;:1034,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:241939,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TJ1s!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f4fcd45-f8d2-4a3c-b0d8-d0ff9229222b_1034x607.png 424w, https://substackcdn.com/image/fetch/$s_!TJ1s!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f4fcd45-f8d2-4a3c-b0d8-d0ff9229222b_1034x607.png 848w, https://substackcdn.com/image/fetch/$s_!TJ1s!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f4fcd45-f8d2-4a3c-b0d8-d0ff9229222b_1034x607.png 1272w, https://substackcdn.com/image/fetch/$s_!TJ1s!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f4fcd45-f8d2-4a3c-b0d8-d0ff9229222b_1034x607.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></figure></div><p></p></li><li><p>Example <strong>production possibilities frontier</strong>: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!DOGL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd362946-1bdf-4d9d-8b95-fd1a8dcde100_999x431.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!DOGL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd362946-1bdf-4d9d-8b95-fd1a8dcde100_999x431.png 424w, https://substackcdn.com/image/fetch/$s_!DOGL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd362946-1bdf-4d9d-8b95-fd1a8dcde100_999x431.png 848w, https://substackcdn.com/image/fetch/$s_!DOGL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd362946-1bdf-4d9d-8b95-fd1a8dcde100_999x431.png 1272w, https://substackcdn.com/image/fetch/$s_!DOGL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd362946-1bdf-4d9d-8b95-fd1a8dcde100_999x431.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!DOGL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd362946-1bdf-4d9d-8b95-fd1a8dcde100_999x431.png" width="999" height="431" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bd362946-1bdf-4d9d-8b95-fd1a8dcde100_999x431.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:431,&quot;width&quot;:999,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:181412,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!DOGL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd362946-1bdf-4d9d-8b95-fd1a8dcde100_999x431.png 424w, https://substackcdn.com/image/fetch/$s_!DOGL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd362946-1bdf-4d9d-8b95-fd1a8dcde100_999x431.png 848w, https://substackcdn.com/image/fetch/$s_!DOGL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd362946-1bdf-4d9d-8b95-fd1a8dcde100_999x431.png 1272w, https://substackcdn.com/image/fetch/$s_!DOGL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd362946-1bdf-4d9d-8b95-fd1a8dcde100_999x431.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></figure></div><p></p></li><li><p><strong>Microeconomics vs. Macroeconomics: </strong>The field of economics is divided into two subfields: microeconomics and macroeconomics. Microeconomists study decision making by households and firms and the interactions among households and firms in the marketplace. Macroeconomists study the forces and trends that affect the economy as a whole.</p></li><li><p><strong>Normative statement vs. positive statement: </strong>A positive statement is an assertion about how the world is. A normative statement is an assertion about how the world ought to be. When economists make normative statements, they are acting more as policy advisers than as scientists.</p></li><li><p><strong>Conflicting Advice: </strong>Economists who advise policymakers sometimes offer conflicting advice either because of differences in scientific judgments or because of differences in values. At other times, economists are united in the advice they offer, but policymakers may choose to ignore the advice because of the many forces and constraints imposed by the political process.</p></li></ul><div><hr></div><h3>Interdependence and the Gains from Trade</h3><p></p><ul><li><p>Individuals consume goods and services made by many others, both domestically and internationally. Interdependence and trade are beneficial because they provide greater access to a wider variety of products.</p></li><li><p>To compare production abilities, one can look at <strong>absolute advantage</strong>, where a person can produce a good using fewer resources, and <strong>comparative advantage</strong>, where a person has a lower opportunity cost (i.e. lower loss of potential gain) for production. Gains from trade arise from comparative advantage, not absolute advantage.</p></li><li><p>Let&#8217;s break this down with a simple and intuitive example involving two people&#8212;Alice and Bob&#8212;who can produce two goods: <strong>bread</strong> and <strong>cheese</strong>. Let&#8217;s say that Alice can bake <strong>10 loaves of bread</strong> or make <strong>5 blocks of cheese</strong> in one day while Bob can bake <strong>6 loaves of bread</strong> or make <strong>6 blocks of cheese</strong> in one day. Here:</p><ul><li><p>Alice bakes 10 loaves of bread while Bob bakes 6 loaves. <strong>Alice has the</strong> <strong>absolute advantage in bread</strong>.</p></li><li><p>Bob makes 6 blocks of cheese while Alice makes 5 blocks. <strong>Bob has the</strong> <strong>absolute advantage in cheese</strong>.</p></li></ul></li><li><p>Comparative advantage focuses on <strong>opportunity cost while absolute advantage simply focuses on who can produce more, </strong>and so in terms of opportunity costs we get<strong>:</strong></p><ul><li><p>If Alice bakes 1 loaf of bread, she gives up the ability to make make half a block of cheese (10 loafs of bread / 5 blocks of cheese = 0.5). In the same manner - if Alice produces 1 block of cheese - she gives up the opportunity to produce 2 loafs of bread. </p></li><li><p>If Bob bakes 1 loaf of bread, he gives up the ability to make 1 block of cheese and vice versa (6 / 6 = 1). </p></li><li><p>For <strong>bread</strong>: Alice&#8217;s opportunity cost (0.5 cheese) is lower than Bob&#8217;s (1 cheese) so <strong>Alice has the comparative advantage in bread</strong>.</p></li><li><p>For <strong>cheese</strong>: Bob&#8217;s opportunity cost (1 bread) is lower than Alice&#8217;s (2 breads) so <strong>Bob has the comparative advantage in cheese</strong>. </p></li></ul></li><li><p>Trade benefits everyone by enabling specialization in areas where individuals have a comparative advantage. If Alice specializes in bread (her comparative advantage) and Bob specializes in cheese (his comparative advantage), they can trade and both be better off.</p></li><li><p>The principle of comparative advantage applies to both individuals and countries, and economists use it to support free trade between nations.</p></li></ul><div><hr></div><h3>The Market Forces of Supply and Demand</h3><p></p><ul><li><p>The demand schedule is a table that shows the quantity demanded at each price. The <strong>demand curve</strong>, which graphs the demand schedule, illustrates how the quantity demanded of the good changes as its price varies:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Nspw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b2500a-9db9-49b5-96e2-850bf34e28e7_1366x1189.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Nspw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b2500a-9db9-49b5-96e2-850bf34e28e7_1366x1189.png 424w, https://substackcdn.com/image/fetch/$s_!Nspw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b2500a-9db9-49b5-96e2-850bf34e28e7_1366x1189.png 848w, https://substackcdn.com/image/fetch/$s_!Nspw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b2500a-9db9-49b5-96e2-850bf34e28e7_1366x1189.png 1272w, https://substackcdn.com/image/fetch/$s_!Nspw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b2500a-9db9-49b5-96e2-850bf34e28e7_1366x1189.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Nspw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b2500a-9db9-49b5-96e2-850bf34e28e7_1366x1189.png" width="394" height="342.9472913616398" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/92b2500a-9db9-49b5-96e2-850bf34e28e7_1366x1189.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1189,&quot;width&quot;:1366,&quot;resizeWidth&quot;:394,&quot;bytes&quot;:86744,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Nspw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b2500a-9db9-49b5-96e2-850bf34e28e7_1366x1189.png 424w, https://substackcdn.com/image/fetch/$s_!Nspw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b2500a-9db9-49b5-96e2-850bf34e28e7_1366x1189.png 848w, https://substackcdn.com/image/fetch/$s_!Nspw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b2500a-9db9-49b5-96e2-850bf34e28e7_1366x1189.png 1272w, https://substackcdn.com/image/fetch/$s_!Nspw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92b2500a-9db9-49b5-96e2-850bf34e28e7_1366x1189.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></figure></div></li><li><p>The demand curve shows how the quantity of a good demanded depends on the price. According to the law of demand, as the price of a good falls, the quantity demanded rises. Therefore, the demand curve slopes downward.</p></li><li><p>In addition to price, other determinants of how much consumers want to buy include income, the prices of substitutes and complements, tastes, expectations, and the number of buyers. If one of these factors changes, the demand curve shifts.</p></li><li><p>The supply schedule is a table that shows the quantity supplied at each price. This <strong>supply curve</strong>, which graphs the supply schedule, illustrates how the quantity supplied of the good changes as its price varies. Because a higher price increases the quantity supplied, the supply curve slopes upward.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JR2_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b1f7b42-8460-4203-bc7e-176e81288f9d_652x513.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JR2_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b1f7b42-8460-4203-bc7e-176e81288f9d_652x513.png 424w, https://substackcdn.com/image/fetch/$s_!JR2_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b1f7b42-8460-4203-bc7e-176e81288f9d_652x513.png 848w, https://substackcdn.com/image/fetch/$s_!JR2_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b1f7b42-8460-4203-bc7e-176e81288f9d_652x513.png 1272w, https://substackcdn.com/image/fetch/$s_!JR2_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b1f7b42-8460-4203-bc7e-176e81288f9d_652x513.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JR2_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b1f7b42-8460-4203-bc7e-176e81288f9d_652x513.png" width="460" height="361.9325153374233" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8b1f7b42-8460-4203-bc7e-176e81288f9d_652x513.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:513,&quot;width&quot;:652,&quot;resizeWidth&quot;:460,&quot;bytes&quot;:38958,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!JR2_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b1f7b42-8460-4203-bc7e-176e81288f9d_652x513.png 424w, https://substackcdn.com/image/fetch/$s_!JR2_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b1f7b42-8460-4203-bc7e-176e81288f9d_652x513.png 848w, https://substackcdn.com/image/fetch/$s_!JR2_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b1f7b42-8460-4203-bc7e-176e81288f9d_652x513.png 1272w, https://substackcdn.com/image/fetch/$s_!JR2_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b1f7b42-8460-4203-bc7e-176e81288f9d_652x513.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></figure></div></li><li><p>The supply curve shows how the quantity of a good supplied depends on the price. According to the law of supply, as the price of a good rises, the quantity supplied rises. Therefore, the supply curve slopes upward.</p></li><li><p>The Equilibrium of Supply and Demand: the <strong>equilibrium</strong> is found where the supply and demand curves intersect. At the equilibrium price, the quantity supplied equals the quantity demanded.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vgXJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515463d3-520f-4287-8ae4-171d3a764c93_720x446.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vgXJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515463d3-520f-4287-8ae4-171d3a764c93_720x446.png 424w, https://substackcdn.com/image/fetch/$s_!vgXJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515463d3-520f-4287-8ae4-171d3a764c93_720x446.png 848w, https://substackcdn.com/image/fetch/$s_!vgXJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515463d3-520f-4287-8ae4-171d3a764c93_720x446.png 1272w, https://substackcdn.com/image/fetch/$s_!vgXJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515463d3-520f-4287-8ae4-171d3a764c93_720x446.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vgXJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515463d3-520f-4287-8ae4-171d3a764c93_720x446.png" width="536" height="332.02222222222224" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/515463d3-520f-4287-8ae4-171d3a764c93_720x446.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:446,&quot;width&quot;:720,&quot;resizeWidth&quot;:536,&quot;bytes&quot;:16003,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!vgXJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515463d3-520f-4287-8ae4-171d3a764c93_720x446.png 424w, https://substackcdn.com/image/fetch/$s_!vgXJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515463d3-520f-4287-8ae4-171d3a764c93_720x446.png 848w, https://substackcdn.com/image/fetch/$s_!vgXJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515463d3-520f-4287-8ae4-171d3a764c93_720x446.png 1272w, https://substackcdn.com/image/fetch/$s_!vgXJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515463d3-520f-4287-8ae4-171d3a764c93_720x446.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></figure></div></li><li><p>The behavior of buyers and sellers naturally drives markets toward their <strong>equilibrium</strong>. When the market price is above the <strong>equilibrium price</strong>, there is a surplus of the good, which causes the market price to fall. When the market price is below the equilibrium price, there is a shortage, which causes the market price to rise.</p></li><li><p><strong>Markets Not in Equilibrium</strong>: In the below picture, there is a surplus. Because the market price of $2.50 is above the equilibrium price, the quantity supplied (10 cones) exceeds the quantity demanded (4 cones). Suppliers try to increase sales by cutting the price of a cone, and this moves the price toward its equilibrium level:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!S6er!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bd0c5dd-50b9-406d-aea1-83ae0deedf8e_487x370.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!S6er!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bd0c5dd-50b9-406d-aea1-83ae0deedf8e_487x370.png 424w, https://substackcdn.com/image/fetch/$s_!S6er!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bd0c5dd-50b9-406d-aea1-83ae0deedf8e_487x370.png 848w, https://substackcdn.com/image/fetch/$s_!S6er!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bd0c5dd-50b9-406d-aea1-83ae0deedf8e_487x370.png 1272w, https://substackcdn.com/image/fetch/$s_!S6er!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bd0c5dd-50b9-406d-aea1-83ae0deedf8e_487x370.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!S6er!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bd0c5dd-50b9-406d-aea1-83ae0deedf8e_487x370.png" width="445" height="338.0903490759754" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8bd0c5dd-50b9-406d-aea1-83ae0deedf8e_487x370.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:370,&quot;width&quot;:487,&quot;resizeWidth&quot;:445,&quot;bytes&quot;:33117,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!S6er!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bd0c5dd-50b9-406d-aea1-83ae0deedf8e_487x370.png 424w, https://substackcdn.com/image/fetch/$s_!S6er!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bd0c5dd-50b9-406d-aea1-83ae0deedf8e_487x370.png 848w, https://substackcdn.com/image/fetch/$s_!S6er!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bd0c5dd-50b9-406d-aea1-83ae0deedf8e_487x370.png 1272w, https://substackcdn.com/image/fetch/$s_!S6er!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bd0c5dd-50b9-406d-aea1-83ae0deedf8e_487x370.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></figure></div></li><li><p>In the below panel, there is a shortage. Because the market price of $1.50 is below the equilibrium price, the quantity demanded (10 cones) exceeds the quantity supplied (4 cones). With too many buyers chasing too few goods, suppliers can take advantage of the shortage by raising the price:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!r6jz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feaa7036e-437e-4ee9-aee7-eec944c3a710_502x368.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!r6jz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feaa7036e-437e-4ee9-aee7-eec944c3a710_502x368.png 424w, https://substackcdn.com/image/fetch/$s_!r6jz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feaa7036e-437e-4ee9-aee7-eec944c3a710_502x368.png 848w, https://substackcdn.com/image/fetch/$s_!r6jz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feaa7036e-437e-4ee9-aee7-eec944c3a710_502x368.png 1272w, https://substackcdn.com/image/fetch/$s_!r6jz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feaa7036e-437e-4ee9-aee7-eec944c3a710_502x368.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!r6jz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feaa7036e-437e-4ee9-aee7-eec944c3a710_502x368.png" width="474" height="347.47410358565736" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eaa7036e-437e-4ee9-aee7-eec944c3a710_502x368.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:368,&quot;width&quot;:502,&quot;resizeWidth&quot;:474,&quot;bytes&quot;:32468,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!r6jz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feaa7036e-437e-4ee9-aee7-eec944c3a710_502x368.png 424w, https://substackcdn.com/image/fetch/$s_!r6jz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feaa7036e-437e-4ee9-aee7-eec944c3a710_502x368.png 848w, https://substackcdn.com/image/fetch/$s_!r6jz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feaa7036e-437e-4ee9-aee7-eec944c3a710_502x368.png 1272w, https://substackcdn.com/image/fetch/$s_!r6jz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feaa7036e-437e-4ee9-aee7-eec944c3a710_502x368.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></figure></div></li><li><p>How an Increase in Demand Affects the Equilibrium (hot weather increases demand for ice cream):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Gk_c!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13ee7cfa-3c8b-4455-be6f-92ca765afa20_724x540.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Gk_c!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13ee7cfa-3c8b-4455-be6f-92ca765afa20_724x540.png 424w, https://substackcdn.com/image/fetch/$s_!Gk_c!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13ee7cfa-3c8b-4455-be6f-92ca765afa20_724x540.png 848w, https://substackcdn.com/image/fetch/$s_!Gk_c!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13ee7cfa-3c8b-4455-be6f-92ca765afa20_724x540.png 1272w, https://substackcdn.com/image/fetch/$s_!Gk_c!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13ee7cfa-3c8b-4455-be6f-92ca765afa20_724x540.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Gk_c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13ee7cfa-3c8b-4455-be6f-92ca765afa20_724x540.png" width="538" height="401.2707182320442" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/13ee7cfa-3c8b-4455-be6f-92ca765afa20_724x540.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:540,&quot;width&quot;:724,&quot;resizeWidth&quot;:538,&quot;bytes&quot;:56441,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Gk_c!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13ee7cfa-3c8b-4455-be6f-92ca765afa20_724x540.png 424w, https://substackcdn.com/image/fetch/$s_!Gk_c!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13ee7cfa-3c8b-4455-be6f-92ca765afa20_724x540.png 848w, https://substackcdn.com/image/fetch/$s_!Gk_c!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13ee7cfa-3c8b-4455-be6f-92ca765afa20_724x540.png 1272w, https://substackcdn.com/image/fetch/$s_!Gk_c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13ee7cfa-3c8b-4455-be6f-92ca765afa20_724x540.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></figure></div></li><li><p>How a Decrease in Supply Affects the Equilibrium (cost of sugar increases lowering supply of ice-cream):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LJtN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa50f0ed8-0e13-4946-89dd-5c108ed4a24c_728x531.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LJtN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa50f0ed8-0e13-4946-89dd-5c108ed4a24c_728x531.png 424w, https://substackcdn.com/image/fetch/$s_!LJtN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa50f0ed8-0e13-4946-89dd-5c108ed4a24c_728x531.png 848w, https://substackcdn.com/image/fetch/$s_!LJtN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa50f0ed8-0e13-4946-89dd-5c108ed4a24c_728x531.png 1272w, https://substackcdn.com/image/fetch/$s_!LJtN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa50f0ed8-0e13-4946-89dd-5c108ed4a24c_728x531.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LJtN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa50f0ed8-0e13-4946-89dd-5c108ed4a24c_728x531.png" width="554" height="404.08516483516485" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a50f0ed8-0e13-4946-89dd-5c108ed4a24c_728x531.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:531,&quot;width&quot;:728,&quot;resizeWidth&quot;:554,&quot;bytes&quot;:56542,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!LJtN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa50f0ed8-0e13-4946-89dd-5c108ed4a24c_728x531.png 424w, https://substackcdn.com/image/fetch/$s_!LJtN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa50f0ed8-0e13-4946-89dd-5c108ed4a24c_728x531.png 848w, https://substackcdn.com/image/fetch/$s_!LJtN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa50f0ed8-0e13-4946-89dd-5c108ed4a24c_728x531.png 1272w, https://substackcdn.com/image/fetch/$s_!LJtN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa50f0ed8-0e13-4946-89dd-5c108ed4a24c_728x531.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></figure></div></li><li><p>In market economies, prices are the signals that guide economic decisions and thereby allocate scarce resources. For every good in the economy, the price ensures that supply and demand are in balance. The equilibrium price then determines how much of the good buyers choose to consume and how much sellers choose to produce.</p></li><li><p>Several factors can shift the demand curve, including income, the type of good, prices of related goods, personal preferences, future expectations, and the number of buyers. Key concepts include:</p><p></p><ul><li><p><strong>Normal goods</strong> are those for which demand increases when income rises (i.e. steam vs. ground beef - higher incomes may prefer steak to ground beef). </p></li><li><p><strong>Inferior goods</strong> see increased demand when income falls; for example, more people may take bus rides instead of buying cars when their income decreases.</p></li><li><p><strong>Substitutes</strong> are goods where a rise in the price of one leads to increased demand for the other; for example, if the price of coffee goes up, people might start buying more tea<strong>.</strong></p></li><li><p><strong>Complements</strong> are goods where a rise in the price of one results in decreased demand for the other; as an example, if the price of cars goes up (causing less demand) &#8212; people will also buy fewer tires and gasoline. </p><p></p></li></ul></li><li><p>Factors that can shift the supply curve include input prices, technology, expectations, and the number of sellers:</p><p></p><ul><li><p><strong>Input prices</strong>: Higher input costs can reduce supply.</p></li><li><p><strong>Technology</strong>: Advances in technology can lower production costs and increase supply.</p></li><li><p><strong>Expectations</strong>: If sellers expect future prices to rise, they may increase supply now.</p></li><li><p><strong>Number of sellers</strong>: More sellers in the market typically increase supply.</p></li></ul></li></ul><div><hr></div><h3>Elasticity and Its Application</h3><p></p><ul><li><p>Price elasticity of demand measures how much the quantity demanded changes when the price changes. Demand is more elastic when there are close substitutes, the good is a luxury, the market is narrowly defined, or buyers have more time to respond to price changes.</p></li><li><p>To calculate price elasticity of demand, you divide the percentage change in quantity demanded by the percentage change in price. If the quantity demanded changes less than the price, elasticity is less than 1, indicating inelastic demand. If it changes more than the price, elasticity is greater than 1, indicating elastic demand. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fvGY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa833c256-ee44-4fc9-8aff-6ed0f662957b_540x328.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fvGY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa833c256-ee44-4fc9-8aff-6ed0f662957b_540x328.png 424w, https://substackcdn.com/image/fetch/$s_!fvGY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa833c256-ee44-4fc9-8aff-6ed0f662957b_540x328.png 848w, https://substackcdn.com/image/fetch/$s_!fvGY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa833c256-ee44-4fc9-8aff-6ed0f662957b_540x328.png 1272w, https://substackcdn.com/image/fetch/$s_!fvGY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa833c256-ee44-4fc9-8aff-6ed0f662957b_540x328.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fvGY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa833c256-ee44-4fc9-8aff-6ed0f662957b_540x328.png" width="508" height="308.56296296296296" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a833c256-ee44-4fc9-8aff-6ed0f662957b_540x328.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:328,&quot;width&quot;:540,&quot;resizeWidth&quot;:508,&quot;bytes&quot;:14484,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fvGY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa833c256-ee44-4fc9-8aff-6ed0f662957b_540x328.png 424w, https://substackcdn.com/image/fetch/$s_!fvGY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa833c256-ee44-4fc9-8aff-6ed0f662957b_540x328.png 848w, https://substackcdn.com/image/fetch/$s_!fvGY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa833c256-ee44-4fc9-8aff-6ed0f662957b_540x328.png 1272w, https://substackcdn.com/image/fetch/$s_!fvGY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa833c256-ee44-4fc9-8aff-6ed0f662957b_540x328.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></figure></div><p></p></li><li><p><strong>Income elasticity of demand</strong> measures how much the quantity demanded changes when consumers&#8217; income changes. <strong>Cross-price elasticity of demand</strong> measures how the quantity demanded of one good changes in response to a price change in another good. Most goods are <strong>normal goods</strong>, meaning that when people earn more, they buy more of these goods. For example, as income increases, people may buy more organic groceries. Since the quantity demanded and income both rise, normal goods have positive income elasticity. Some goods, like instant noodles, are <strong>inferior goods</strong>&#8212;people buy less of them as their income goes up. Because quantity demanded and income move in opposite directions, inferior goods have negative income elasticity.</p></li><li><p>The price elasticity of supply measures how much the quantity supplied responds to changes in the price. This elasticity often depends on the time horizon under consideration. In most markets, supply is more elastic in the long run than in the short run.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-hmU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bc705ff-015c-4dfe-87dd-6b48cdf146fd_1009x419.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-hmU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bc705ff-015c-4dfe-87dd-6b48cdf146fd_1009x419.png 424w, https://substackcdn.com/image/fetch/$s_!-hmU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bc705ff-015c-4dfe-87dd-6b48cdf146fd_1009x419.png 848w, https://substackcdn.com/image/fetch/$s_!-hmU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bc705ff-015c-4dfe-87dd-6b48cdf146fd_1009x419.png 1272w, https://substackcdn.com/image/fetch/$s_!-hmU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bc705ff-015c-4dfe-87dd-6b48cdf146fd_1009x419.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-hmU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bc705ff-015c-4dfe-87dd-6b48cdf146fd_1009x419.png" width="1009" height="419" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9bc705ff-015c-4dfe-87dd-6b48cdf146fd_1009x419.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:419,&quot;width&quot;:1009,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:72758,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-hmU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bc705ff-015c-4dfe-87dd-6b48cdf146fd_1009x419.png 424w, https://substackcdn.com/image/fetch/$s_!-hmU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bc705ff-015c-4dfe-87dd-6b48cdf146fd_1009x419.png 848w, https://substackcdn.com/image/fetch/$s_!-hmU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bc705ff-015c-4dfe-87dd-6b48cdf146fd_1009x419.png 1272w, https://substackcdn.com/image/fetch/$s_!-hmU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9bc705ff-015c-4dfe-87dd-6b48cdf146fd_1009x419.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></figure></div></li><li><p>Just as with demand, <strong>supply elasticity</strong> measures how much quantity supplied changes in response to price changes. It&#8217;s calculated by dividing the percentage change in quantity supplied by the percentage change in price. If the quantity supplied changes less than the price, supply is <strong>inelastic</strong> (elasticity is less than 1). If the quantity supplied changes more than the price, supply is <strong>elastic</strong> (elasticity is greater than 1). </p></li><li><p>The tools of supply and demand can be applied in many different kinds of markets. A great example for this is provided below (where the short-term and long-term supply-demand curves for Oil are provided). When the supply of oil falls, the response depends on the time horizon. In the short run - supply and demand for oil are relatively inelastic and thus, the price of oil raises substantially. In the long run however, supply and demand are relatively elastic:</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!j1LS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f7da4a-338b-40f0-b7fd-54f264d77aac_1008x496.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!j1LS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f7da4a-338b-40f0-b7fd-54f264d77aac_1008x496.png 424w, https://substackcdn.com/image/fetch/$s_!j1LS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f7da4a-338b-40f0-b7fd-54f264d77aac_1008x496.png 848w, https://substackcdn.com/image/fetch/$s_!j1LS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f7da4a-338b-40f0-b7fd-54f264d77aac_1008x496.png 1272w, https://substackcdn.com/image/fetch/$s_!j1LS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f7da4a-338b-40f0-b7fd-54f264d77aac_1008x496.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!j1LS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f7da4a-338b-40f0-b7fd-54f264d77aac_1008x496.png" width="636" height="312.95238095238096" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a6f7da4a-338b-40f0-b7fd-54f264d77aac_1008x496.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:496,&quot;width&quot;:1008,&quot;resizeWidth&quot;:636,&quot;bytes&quot;:51206,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!j1LS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f7da4a-338b-40f0-b7fd-54f264d77aac_1008x496.png 424w, https://substackcdn.com/image/fetch/$s_!j1LS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f7da4a-338b-40f0-b7fd-54f264d77aac_1008x496.png 848w, https://substackcdn.com/image/fetch/$s_!j1LS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f7da4a-338b-40f0-b7fd-54f264d77aac_1008x496.png 1272w, https://substackcdn.com/image/fetch/$s_!j1LS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f7da4a-338b-40f0-b7fd-54f264d77aac_1008x496.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></figure></div><div><hr></div><h3>Supply, Demand, and Government Policies</h3><p></p><ul><li><p>A <strong>price ceiling</strong> is the highest price the law allows for a good or service. For example, with <strong>rent control</strong>, the government limits how much landlords can charge for rent.</p></li><li><p>If this price ceiling is set <strong>below</strong> the market's natural balance point (called the <strong>equilibrium price</strong>), it becomes <strong>binding</strong>, meaning the rule affects the market. In this case, more people want the product (like apartments), but there aren't enough available because the price is too low for many suppliers to offer more. This creates a <strong>shortage</strong>. Since there aren&#8217;t enough goods or services for everyone, sellers have to find ways to decide who gets them&#8212;this is called <strong>rationing</strong>. For instance, landlords may choose tenants based on factors like income or credit history.</p></li><li><p>A <strong>price floor</strong> is the lowest price the law allows for a good or service. A common example is the <strong>minimum wage</strong>, which sets a legal minimum amount workers can be paid.</p></li><li><p>If this price floor is set <strong>above</strong> the market&#8217;s natural balance point (the <strong>equilibrium price</strong>), it becomes <strong>binding</strong>, meaning it impacts the market. In this case, more people are willing to supply the good or service (like workers offering their labor), but fewer buyers are willing to pay the higher price (like businesses hiring fewer workers). This leads to a <strong>surplus</strong>&#8212;too many suppliers and not enough demand. As a result, buyers (like employers) have to <strong>ration</strong> their purchases, which means they will pick and choose which suppliers (or workers) they want based on their preferences or criteria and there will be unemployment. The below diagram shows how minimum wage impacts the market (the amount supplied exceeds the quantity demanded resulting in unemployment):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!f9xW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ddb84c2-b7ea-43ca-854a-16e2bae070d6_992x416.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!f9xW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ddb84c2-b7ea-43ca-854a-16e2bae070d6_992x416.png 424w, https://substackcdn.com/image/fetch/$s_!f9xW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ddb84c2-b7ea-43ca-854a-16e2bae070d6_992x416.png 848w, https://substackcdn.com/image/fetch/$s_!f9xW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ddb84c2-b7ea-43ca-854a-16e2bae070d6_992x416.png 1272w, https://substackcdn.com/image/fetch/$s_!f9xW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ddb84c2-b7ea-43ca-854a-16e2bae070d6_992x416.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!f9xW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ddb84c2-b7ea-43ca-854a-16e2bae070d6_992x416.png" width="992" height="416" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8ddb84c2-b7ea-43ca-854a-16e2bae070d6_992x416.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:416,&quot;width&quot;:992,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:42027,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!f9xW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ddb84c2-b7ea-43ca-854a-16e2bae070d6_992x416.png 424w, https://substackcdn.com/image/fetch/$s_!f9xW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ddb84c2-b7ea-43ca-854a-16e2bae070d6_992x416.png 848w, https://substackcdn.com/image/fetch/$s_!f9xW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ddb84c2-b7ea-43ca-854a-16e2bae070d6_992x416.png 1272w, https://substackcdn.com/image/fetch/$s_!f9xW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ddb84c2-b7ea-43ca-854a-16e2bae070d6_992x416.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></figure></div></li><li><p>When the government levies a tax on a good, the equilibrium quantity of the good falls. That is, a tax on a market shrinks the size of the market.</p></li><li><p>A <strong>tax</strong> on a good creates a gap between what buyers pay and what sellers receive. This is called a <strong>tax wedge</strong>. When the market adjusts to this new situation, buyers end up paying a higher price, while sellers receive less than they used to. Both sides end up sharing the burden of the tax, meaning they both lose something&#8212;buyers pay more, and sellers make less. Importantly, it doesn't matter whether the tax is charged to buyers or sellers&#8212;the outcome is the same. The <strong>tax incidence</strong> (or how the tax burden is divided between buyers and sellers) remains the same either way.</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!kjpV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F715c34bd-de38-41e2-aecc-b8bb56fd413b_881x575.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!kjpV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F715c34bd-de38-41e2-aecc-b8bb56fd413b_881x575.png 424w, https://substackcdn.com/image/fetch/$s_!kjpV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F715c34bd-de38-41e2-aecc-b8bb56fd413b_881x575.png 848w, https://substackcdn.com/image/fetch/$s_!kjpV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F715c34bd-de38-41e2-aecc-b8bb56fd413b_881x575.png 1272w, https://substackcdn.com/image/fetch/$s_!kjpV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F715c34bd-de38-41e2-aecc-b8bb56fd413b_881x575.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!kjpV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F715c34bd-de38-41e2-aecc-b8bb56fd413b_881x575.png" width="524" height="341.9977298524404" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/715c34bd-de38-41e2-aecc-b8bb56fd413b_881x575.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:575,&quot;width&quot;:881,&quot;resizeWidth&quot;:524,&quot;bytes&quot;:75716,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!kjpV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F715c34bd-de38-41e2-aecc-b8bb56fd413b_881x575.png 424w, https://substackcdn.com/image/fetch/$s_!kjpV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F715c34bd-de38-41e2-aecc-b8bb56fd413b_881x575.png 848w, https://substackcdn.com/image/fetch/$s_!kjpV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F715c34bd-de38-41e2-aecc-b8bb56fd413b_881x575.png 1272w, https://substackcdn.com/image/fetch/$s_!kjpV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F715c34bd-de38-41e2-aecc-b8bb56fd413b_881x575.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></figure></div><div><hr></div><h3>Consumers, Producers, and Efficiency in Markets</h3></li></ul><p></p><ul><li><p><strong>Consumer surplus</strong> is the difference between how much buyers are willing to pay for a good and how much they actually pay. It shows the extra benefit buyers get from a good. For example, if you&#8217;re willing to pay $50 for a concert ticket but get it for $30, your consumer surplus is $20. You can calculate consumer surplus by finding the area under the <strong>demand curve</strong> (which shows how much people are willing to pay) and above the price. </p></li><li><p>In the below example, the equilibrium price is $5 dollars, but we should be able to notice that some buyers within our market are willing to pay more for the good. If we look at the price - we can see that there is a market for the product even if it were priced at 7 or 8 dollars. In other words - some buyers are getting the product for below the price they&#8217;re willing to pay for it and this is essentially what&#8217;s labelled as the consumer surplus:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Tf-M!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe461cece-643b-434c-82e6-260fc5820107_400x300.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Tf-M!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe461cece-643b-434c-82e6-260fc5820107_400x300.png 424w, https://substackcdn.com/image/fetch/$s_!Tf-M!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe461cece-643b-434c-82e6-260fc5820107_400x300.png 848w, https://substackcdn.com/image/fetch/$s_!Tf-M!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe461cece-643b-434c-82e6-260fc5820107_400x300.png 1272w, https://substackcdn.com/image/fetch/$s_!Tf-M!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe461cece-643b-434c-82e6-260fc5820107_400x300.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Tf-M!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe461cece-643b-434c-82e6-260fc5820107_400x300.png" width="400" height="300" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e461cece-643b-434c-82e6-260fc5820107_400x300.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:300,&quot;width&quot;:400,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:22594,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Tf-M!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe461cece-643b-434c-82e6-260fc5820107_400x300.png 424w, https://substackcdn.com/image/fetch/$s_!Tf-M!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe461cece-643b-434c-82e6-260fc5820107_400x300.png 848w, https://substackcdn.com/image/fetch/$s_!Tf-M!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe461cece-643b-434c-82e6-260fc5820107_400x300.png 1272w, https://substackcdn.com/image/fetch/$s_!Tf-M!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe461cece-643b-434c-82e6-260fc5820107_400x300.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">Source: https://inflateyourmind.com/macroeconomics/unit-2/section-12-consumer-surplus-and-producer-surplus/ </figcaption></figure></div><p></p></li><li><p><strong>Producer surplus</strong> is the difference between what sellers receive for selling their goods and what it costs them to produce those goods. It measures the benefit sellers get from selling their product. For instance, if it costs a baker $1 to make a loaf of bread but they sell it for $3, their producer surplus is $2. You can calculate producer surplus by finding the area above the <strong>supply curve</strong> (which shows the minimum price at which sellers are willing to sell) and below the price.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ycpx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb374023-2184-4976-aa7e-f3c86df9ebc6_400x300.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ycpx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb374023-2184-4976-aa7e-f3c86df9ebc6_400x300.png 424w, https://substackcdn.com/image/fetch/$s_!ycpx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb374023-2184-4976-aa7e-f3c86df9ebc6_400x300.png 848w, https://substackcdn.com/image/fetch/$s_!ycpx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb374023-2184-4976-aa7e-f3c86df9ebc6_400x300.png 1272w, https://substackcdn.com/image/fetch/$s_!ycpx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb374023-2184-4976-aa7e-f3c86df9ebc6_400x300.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ycpx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb374023-2184-4976-aa7e-f3c86df9ebc6_400x300.png" width="400" height="300" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fb374023-2184-4976-aa7e-f3c86df9ebc6_400x300.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:300,&quot;width&quot;:400,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:20514,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ycpx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb374023-2184-4976-aa7e-f3c86df9ebc6_400x300.png 424w, https://substackcdn.com/image/fetch/$s_!ycpx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb374023-2184-4976-aa7e-f3c86df9ebc6_400x300.png 848w, https://substackcdn.com/image/fetch/$s_!ycpx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb374023-2184-4976-aa7e-f3c86df9ebc6_400x300.png 1272w, https://substackcdn.com/image/fetch/$s_!ycpx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb374023-2184-4976-aa7e-f3c86df9ebc6_400x300.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">Source: https://inflateyourmind.com/macroeconomics/unit-2/section-12-consumer-surplus-and-producer-surplus/ </figcaption></figure></div></li><li><p>When resources are allocated in a way that <strong>maximizes total surplus</strong> (which is the sum of consumer surplus and producer surplus), we say the allocation is <strong>efficient</strong>. For example, in a perfectly balanced market, consumers and producers are getting the most benefit they can without wasting resources. Policymakers often care about both <strong>efficiency</strong> (making the most out of resources) and <strong>equality</strong> (how fairly resources are shared).</p></li><li><p>The <strong>equilibrium</strong> point where supply and demand meet maximizes total surplus. This happens naturally through the "invisible hand" of the market, where buyers and sellers acting in their own interest lead to an efficient allocation of resources.</p></li><li><p>However, markets may fail to allocate resources efficiently if there are <strong>market failures</strong> like <strong>market power</strong> (when a single seller or buyer can influence prices) or <strong>externalities</strong> (when a third party is affected by a transaction, like pollution). In these cases, the market doesn&#8217;t achieve the best outcome on its own.</p></li></ul><div><hr></div><h3>Application: The Cost of Taxation</h3><p></p><ul><li><p>When the government places a <strong>tax</strong> on a good, it negatively affects both <strong>buyers</strong> and <strong>sellers</strong>. Buyers end up paying more, and sellers receive less. As a result, their combined benefits (i.e. the consumer and producer surplus) shrink. What makes this worse is that the loss in surplus for buyers and sellers is often <strong>bigger</strong> than the amount of money the government collects from the tax.</p></li><li><p>Imagine there&#8217;s a <strong>$3 tax</strong> placed on <strong>pizza slices</strong>. Before the tax, each slice costs $5, and the market is balanced: sellers sell 100 slices a day, and buyers are happy paying $5 per slice. Now, with the tax, the price paid by <strong>buyers</strong> increases to <strong>$6</strong> ($5 + $1.50 from the tax), and <strong>sellers</strong> receive only <strong>$4.50</strong> per slice ($5 - $1.50 from the tax). Here are the effects:</p><ul><li><p><strong>Buyers</strong> pay more: Before the tax, they paid $5 per slice. Now, they pay $6. As a result, some buyers decide not to buy pizza at the higher price. They lose because they either pay more or don&#8217;t buy pizza at all.</p></li><li><p><strong>Sellers</strong> receive less: Before the tax, sellers got $5 per slice. Now, after the tax, they only receive $4.50 per slice. Some sellers who used to sell pizza at $5 now find it unprofitable to sell at $4.50, so they lose out as well.</p></li><li><p><strong>Fewer sales overall</strong>: Before the tax, 100 slices were sold every day. After the tax, only 80 slices are sold because some buyers are priced out. This means fewer buyers are enjoying pizza, and fewer sellers are making money.</p></li><li><p>Now, let&#8217;s look at the government. The government collects <strong>$3 per pizza slice in tax</strong> (1.50 from the buyer and 1.50 from the seller), so they gain some revenue. However, the <strong>total loss</strong> to buyers and sellers is larger than the amount of tax revenue raised. This is because 20 fewer pizza slices are sold, which creates a gap&#8212;this is the <strong>deadweight loss</strong>. This is the "missing" surplus that is gone because of the tax, and it represents the inefficiency the tax causes in the market.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sveD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54999c0e-b587-46d5-8821-cced0bd5f09b_825x545.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sveD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54999c0e-b587-46d5-8821-cced0bd5f09b_825x545.png 424w, https://substackcdn.com/image/fetch/$s_!sveD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54999c0e-b587-46d5-8821-cced0bd5f09b_825x545.png 848w, https://substackcdn.com/image/fetch/$s_!sveD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54999c0e-b587-46d5-8821-cced0bd5f09b_825x545.png 1272w, https://substackcdn.com/image/fetch/$s_!sveD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54999c0e-b587-46d5-8821-cced0bd5f09b_825x545.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sveD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54999c0e-b587-46d5-8821-cced0bd5f09b_825x545.png" width="522" height="344.8363636363636" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/54999c0e-b587-46d5-8821-cced0bd5f09b_825x545.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:545,&quot;width&quot;:825,&quot;resizeWidth&quot;:522,&quot;bytes&quot;:61195,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sveD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54999c0e-b587-46d5-8821-cced0bd5f09b_825x545.png 424w, https://substackcdn.com/image/fetch/$s_!sveD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54999c0e-b587-46d5-8821-cced0bd5f09b_825x545.png 848w, https://substackcdn.com/image/fetch/$s_!sveD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54999c0e-b587-46d5-8821-cced0bd5f09b_825x545.png 1272w, https://substackcdn.com/image/fetch/$s_!sveD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54999c0e-b587-46d5-8821-cced0bd5f09b_825x545.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></figure></div><p></p></li></ul></li><li><p>Because the elasticities of supply and demand measure how much market participants respond to market conditions, larger elasticities imply larger deadweight losses.</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2xzv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14e3af2-8342-447c-8826-eb607986fa14_819x775.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2xzv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14e3af2-8342-447c-8826-eb607986fa14_819x775.png 424w, https://substackcdn.com/image/fetch/$s_!2xzv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14e3af2-8342-447c-8826-eb607986fa14_819x775.png 848w, https://substackcdn.com/image/fetch/$s_!2xzv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14e3af2-8342-447c-8826-eb607986fa14_819x775.png 1272w, https://substackcdn.com/image/fetch/$s_!2xzv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14e3af2-8342-447c-8826-eb607986fa14_819x775.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2xzv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14e3af2-8342-447c-8826-eb607986fa14_819x775.png" width="620" height="586.6910866910866" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a14e3af2-8342-447c-8826-eb607986fa14_819x775.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:775,&quot;width&quot;:819,&quot;resizeWidth&quot;:620,&quot;bytes&quot;:69567,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!2xzv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14e3af2-8342-447c-8826-eb607986fa14_819x775.png 424w, https://substackcdn.com/image/fetch/$s_!2xzv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14e3af2-8342-447c-8826-eb607986fa14_819x775.png 848w, https://substackcdn.com/image/fetch/$s_!2xzv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14e3af2-8342-447c-8826-eb607986fa14_819x775.png 1272w, https://substackcdn.com/image/fetch/$s_!2xzv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14e3af2-8342-447c-8826-eb607986fa14_819x775.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></figure></div><p></p></li><li><p>As a tax grows larger, it distorts incentives more, and its deadweight loss grows larger. Because a tax reduces the size of the market, however, tax revenue does not continually increase. It first rises with the size of a tax, but if the tax gets large enough, tax revenue starts to fall.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TLB1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5efd1b-5e37-40d0-a417-3a3bdb205a4b_1306x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TLB1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5efd1b-5e37-40d0-a417-3a3bdb205a4b_1306x500.png 424w, https://substackcdn.com/image/fetch/$s_!TLB1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5efd1b-5e37-40d0-a417-3a3bdb205a4b_1306x500.png 848w, https://substackcdn.com/image/fetch/$s_!TLB1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5efd1b-5e37-40d0-a417-3a3bdb205a4b_1306x500.png 1272w, https://substackcdn.com/image/fetch/$s_!TLB1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5efd1b-5e37-40d0-a417-3a3bdb205a4b_1306x500.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TLB1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5efd1b-5e37-40d0-a417-3a3bdb205a4b_1306x500.png" width="1306" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bb5efd1b-5e37-40d0-a417-3a3bdb205a4b_1306x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:1306,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:61122,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TLB1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5efd1b-5e37-40d0-a417-3a3bdb205a4b_1306x500.png 424w, https://substackcdn.com/image/fetch/$s_!TLB1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5efd1b-5e37-40d0-a417-3a3bdb205a4b_1306x500.png 848w, https://substackcdn.com/image/fetch/$s_!TLB1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5efd1b-5e37-40d0-a417-3a3bdb205a4b_1306x500.png 1272w, https://substackcdn.com/image/fetch/$s_!TLB1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5efd1b-5e37-40d0-a417-3a3bdb205a4b_1306x500.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></figure></div><p></p></li><li><p>As we should be able to notice, as we move from left to right in the diagram above (and as our tax increases) - the revenue from the tax first goes and increases but eventually starts decreasing and the revenue we can obtain goes down. This is called the <strong>Laffer curve</strong>:  </p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!v3e6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd34fc22b-c970-4873-99ed-83deb99dbb01_527x376.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!v3e6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd34fc22b-c970-4873-99ed-83deb99dbb01_527x376.png 424w, https://substackcdn.com/image/fetch/$s_!v3e6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd34fc22b-c970-4873-99ed-83deb99dbb01_527x376.png 848w, https://substackcdn.com/image/fetch/$s_!v3e6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd34fc22b-c970-4873-99ed-83deb99dbb01_527x376.png 1272w, https://substackcdn.com/image/fetch/$s_!v3e6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd34fc22b-c970-4873-99ed-83deb99dbb01_527x376.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!v3e6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd34fc22b-c970-4873-99ed-83deb99dbb01_527x376.png" width="391" height="278.96774193548384" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d34fc22b-c970-4873-99ed-83deb99dbb01_527x376.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:376,&quot;width&quot;:527,&quot;resizeWidth&quot;:391,&quot;bytes&quot;:12862,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!v3e6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd34fc22b-c970-4873-99ed-83deb99dbb01_527x376.png 424w, https://substackcdn.com/image/fetch/$s_!v3e6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd34fc22b-c970-4873-99ed-83deb99dbb01_527x376.png 848w, https://substackcdn.com/image/fetch/$s_!v3e6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd34fc22b-c970-4873-99ed-83deb99dbb01_527x376.png 1272w, https://substackcdn.com/image/fetch/$s_!v3e6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd34fc22b-c970-4873-99ed-83deb99dbb01_527x376.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></figure></div><p></p><div><hr></div><h3>International Trade</h3><ul><li><p><strong>Free trade and comparative advantage</strong>: The impact of free trade can be understood by comparing a country&#8217;s <strong>domestic price</strong> of a good with the <strong>world price</strong>. If the domestic price is <strong>lower</strong> than the world price, the country can produce the good more cheaply, meaning it has a <strong>comparative advantage</strong>. In this case, the country will likely become an <strong>exporter</strong> of the good because it can sell it for a higher price internationally. On the other hand, if the domestic price is <strong>higher</strong> than the world price, the country will likely become an <strong>importer</strong> since it&#8217;s cheaper to buy the good from abroad than to produce it locally. </p></li><li><p><strong>Example</strong>: If a country can produce coffee for $3 per pound but the world price is $5, it will export coffee because it can sell it for more abroad. If the domestic price of smartphones is $600 but they cost $400 elsewhere, the country will import smartphones because it&#8217;s cheaper to buy from other countries.</p></li><li><p><strong>Exporting and importing effects</strong>: When a country opens up to <strong>trade</strong> and becomes an <strong>exporter</strong>, the <strong>producers</strong> of that good benefit because they can sell their product for a higher price on the world market. However, <strong>consumers</strong> in that country may be worse off because they now have to pay higher prices for the good. When a country becomes an <strong>importer</strong>, the reverse happens: <strong>consumers</strong> benefit from lower prices, but <strong>producers</strong> lose out because they have to compete with cheaper foreign goods. In both cases, though, the overall <strong>gains from trade</strong> are greater than the losses, meaning society as a whole is better off. </p></li><li><p><strong>Example</strong>: If a country starts exporting steel, steel producers benefit from higher prices, but local construction companies (who need to buy steel) may face higher costs. If the country imports clothing, consumers benefit from cheaper clothes, but domestic clothing manufacturers may struggle to compete.</p></li><li><p><strong>Tariffs</strong>: A <strong>tariff</strong> is a tax on imports that makes foreign goods more expensive. This pushes the market closer to what it would look like without trade&#8212;meaning domestic producers have less competition from cheaper imports, so they benefit. The <strong>government</strong> also collects revenue from the tax. However, <strong>consumers</strong> are worse off because they pay higher prices for imported goods. In the end, the losses to consumers are usually <strong>greater</strong> than the benefits to domestic producers and the government, which means tariffs <strong>reduce the overall gains from trade</strong>.</p></li><li><p><strong>Arguments for restricting trade</strong>: Some people argue for <strong>trade restrictions</strong> to achieve certain goals. These include:</p><ul><li><p><strong>Protecting jobs</strong>: Preventing job losses in industries that can&#8217;t compete with foreign goods.</p></li><li><p><strong>National security</strong>: Ensuring that industries critical to national defense are not dependent on foreign countries.</p></li><li><p><strong>Helping infant industries</strong>: Giving new or small industries time to grow and become competitive.</p></li><li><p><strong>Preventing unfair competition</strong>: Stopping foreign companies from dumping products (selling them below cost) to drive out local competition.</p></li><li><p><strong>Responding to foreign trade restrictions</strong>: Retaliating against countries that impose their own trade barriers.</p></li></ul></li><li><p>While some of these arguments may have merit in certain cases, most economists believe that <strong>free trade</strong> generally leads to better economic outcomes. It allows countries to specialize in what they do best, lowers prices for consumers, and increases overall wealth.</p></li></ul><div><hr></div><h3>Externalities</h3><p></p><ul><li><p><strong>Externalities</strong>: An <strong>externality</strong> occurs when a transaction between a <strong>buyer</strong> and a <strong>seller</strong> has an impact on a third party who isn&#8217;t directly involved. These impacts can be <strong>negative</strong> or <strong>positive</strong>.</p><ul><li><p><strong>Negative externalities</strong> happen when the transaction causes harm to others. For example, a factory producing goods may also release pollution into the air, harming the health of nearby residents. In this case, the factory produces more than is socially ideal because it doesn't account for the harm to others. The <strong>socially optimal quantity</strong>&#8212;what&#8217;s best for society&#8212;would be <strong>less</strong> than what the market produces on its own.</p></li><li><p><strong>Positive externalities</strong> occur when the transaction benefits others. For example, when a company develops new technology, other businesses and society can benefit from the knowledge and innovation. Here, the market may produce <strong>too little</strong> of this good, and the socially optimal quantity would be <strong>more</strong> than the market outcome.</p></li></ul></li><li><p><strong>Government solutions to externalities</strong>: To fix the inefficiencies caused by externalities, the government uses various policies:</p><ul><li><p><strong>Regulation</strong>: The government may limit or control activities that cause negative externalities. For instance, they might set limits on how much pollution a factory can emit.</p></li><li><p><strong>Corrective taxes</strong>: Another solution is to make businesses pay for the harm they cause. For example, a <strong>tax on pollution</strong> forces companies to internalize the costs of their negative externality, making them reduce their harmful activities.</p></li><li><p><strong>Permits</strong>: Governments can issue permits to control the amount of pollution or other harmful activities. For example, they might issue a limited number of <strong>pollution permits</strong>, allowing companies to pollute only up to a certain level. This system is similar to imposing a corrective tax because it limits the negative activity and makes it more expensive to pollute.</p></li></ul></li><li><p><strong>Private solutions to externalities</strong>: In some cases, the people affected by externalities can find their own solutions without government intervention.</p><ul><li><p>For example, if one business causes harm to another (like a noisy factory next to a quiet office), they might solve the problem by <strong>negotiating</strong> directly. They could agree to reduce the noise, or the two businesses might <strong>merge</strong> so that they both consider the impact of the noise together.</p></li><li><p>According to the <strong>Coase theorem</strong>, if there are no costs to bargaining, people can always reach a solution where resources are used efficiently. For example, if a homeowner&#8217;s tree blocks a neighbor&#8217;s view, the two could negotiate a payment to cut down or keep the tree. However, in reality, <strong>negotiation</strong> isn&#8217;t always easy, especially when many people are involved, and this is when the Coase theorem doesn&#8217;t work well.</p></li></ul></li></ul><div><hr></div><h3>Public Goods and Common Resources</h3><p></p><ul><li><p><strong>Types of goods</strong>: There are <strong>four types of goods</strong>, and they differ based on whether they are <strong>excludable</strong> and <strong>rival in consumption</strong>:</p><ul><li><p>A good is <strong>excludable</strong> if you can prevent someone from using it. For example, a movie theater ticket is excludable because you can&#8217;t see the movie unless you pay for the ticket.</p></li><li><p>A good is <strong>rival in consumption</strong> if one person&#8217;s use reduces the ability for others to use the same good. For example, if you eat a sandwich, no one else can eat that same sandwich&#8212;it&#8217;s rival.</p></li></ul></li><li><p><strong>Private goods</strong>: These are goods that are both <strong>excludable</strong> and <strong>rival in consumption</strong>. Markets work best for <strong>private goods</strong> because people are willing to pay for something that only they can use.</p><ul><li><p><strong>Example</strong>: A smartphone is a private good. If you buy it, others can&#8217;t use it, and you can exclude others from owning it by purchasing it first.</p></li></ul></li><li><p><strong>Public goods</strong>: These goods are <strong>neither rival in consumption</strong> nor <strong>excludable</strong>. Everyone can benefit from them, and one person&#8217;s use doesn&#8217;t take away from others&#8217; use. However, because people can&#8217;t be prevented from using them (and don&#8217;t have to pay), they tend to &#8220;<strong>free ride</strong>&#8221;&#8212;enjoy the benefit without contributing to the cost. This makes it difficult for private companies to provide public goods, so the <strong>government steps in</strong>. As an example, national defense is a public good. Everyone in a country benefits from it, and your protection doesn&#8217;t reduce the protection others receive. The government provides it because no one would voluntarily pay for it on their own, but everyone benefits.</p></li><li><p><strong>Common resources</strong>: These are goods that are <strong>rival in consumption</strong> but <strong>not excludable</strong>. Since people can&#8217;t be prevented from using them, they tend to be <strong>overused</strong>. As ab example, clean air is a common resource. If too many people or companies pollute the air, it reduces the quality of air for everyone. However, no one can be easily excluded from using the air, which leads to overuse and pollution. Because of this, the <strong>government steps in</strong> to regulate and protect common resources, using methods like <strong>regulations</strong> (rules limiting pollution) or <strong>corrective taxes</strong> (taxes on pollution or overuse).</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!guD_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90f2d336-133d-414d-b45e-ef2153f143a6_720x346.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!guD_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90f2d336-133d-414d-b45e-ef2153f143a6_720x346.png 424w, https://substackcdn.com/image/fetch/$s_!guD_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90f2d336-133d-414d-b45e-ef2153f143a6_720x346.png 848w, https://substackcdn.com/image/fetch/$s_!guD_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90f2d336-133d-414d-b45e-ef2153f143a6_720x346.png 1272w, https://substackcdn.com/image/fetch/$s_!guD_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90f2d336-133d-414d-b45e-ef2153f143a6_720x346.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!guD_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90f2d336-133d-414d-b45e-ef2153f143a6_720x346.png" width="720" height="346" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/90f2d336-133d-414d-b45e-ef2153f143a6_720x346.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:346,&quot;width&quot;:720,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:29090,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!guD_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90f2d336-133d-414d-b45e-ef2153f143a6_720x346.png 424w, https://substackcdn.com/image/fetch/$s_!guD_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90f2d336-133d-414d-b45e-ef2153f143a6_720x346.png 848w, https://substackcdn.com/image/fetch/$s_!guD_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90f2d336-133d-414d-b45e-ef2153f143a6_720x346.png 1272w, https://substackcdn.com/image/fetch/$s_!guD_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90f2d336-133d-414d-b45e-ef2153f143a6_720x346.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></figure></div></li></ul><div><hr></div><h3>The Design of the Tax System</h3><p></p><ul><li><p><strong>Growing government revenue over time</strong>: In <strong>1902</strong>, the government collected about <strong>7% of total income</strong> through taxes. Today, that number has grown to almost <strong>30%</strong>. </p></li><li><p><strong>US Government Revenue as Percent of GDP Over Time:</strong> </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WoQ5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68a12d4-0d43-4241-8ab1-4104d7f3c9cc_1098x492.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WoQ5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68a12d4-0d43-4241-8ab1-4104d7f3c9cc_1098x492.png 424w, https://substackcdn.com/image/fetch/$s_!WoQ5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68a12d4-0d43-4241-8ab1-4104d7f3c9cc_1098x492.png 848w, https://substackcdn.com/image/fetch/$s_!WoQ5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68a12d4-0d43-4241-8ab1-4104d7f3c9cc_1098x492.png 1272w, https://substackcdn.com/image/fetch/$s_!WoQ5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68a12d4-0d43-4241-8ab1-4104d7f3c9cc_1098x492.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WoQ5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68a12d4-0d43-4241-8ab1-4104d7f3c9cc_1098x492.png" width="1098" height="492" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a68a12d4-0d43-4241-8ab1-4104d7f3c9cc_1098x492.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:492,&quot;width&quot;:1098,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:47359,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WoQ5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68a12d4-0d43-4241-8ab1-4104d7f3c9cc_1098x492.png 424w, https://substackcdn.com/image/fetch/$s_!WoQ5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68a12d4-0d43-4241-8ab1-4104d7f3c9cc_1098x492.png 848w, https://substackcdn.com/image/fetch/$s_!WoQ5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68a12d4-0d43-4241-8ab1-4104d7f3c9cc_1098x492.png 1272w, https://substackcdn.com/image/fetch/$s_!WoQ5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68a12d4-0d43-4241-8ab1-4104d7f3c9cc_1098x492.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></figure></div><p></p></li><li><p>This means that as the economy grows, so does the government's revenue from taxes. However, compared to many other advanced countries, like those in <strong>Europe</strong>, the U.S. still has a relatively <strong>low tax burden</strong>. European nations often collect more in taxes to fund <strong>more generous social programs</strong>, such as higher income support for the poor or unemployed. As an example, in countries like <strong>Germany</strong>, taxes are much higher than in the U.S., but they provide benefits like free university education and more extensive unemployment support.</p></li><li><p><strong>Types of taxes</strong>: The <strong>U.S. government</strong> collects revenue using different types of taxes:</p><ul><li><p>For the <strong>federal government</strong>, the most important taxes are <strong>personal income taxes</strong> (what you pay on your earnings) and <strong>payroll taxes</strong> (which fund things like Social Security and Medicare).</p></li><li><p>For <strong>state and local governments</strong>, the main sources of revenue are <strong>sales taxes</strong> (on goods you buy) and <strong>property taxes</strong> (on real estate, like homes or land).</p></li></ul></li><li><p><strong>Tax efficiency</strong>: The <strong>efficiency</strong> of a tax system refers to how much it costs taxpayers. There are two big costs beyond just handing money over to the government:</p><ul><li><p><strong>Deadweight loss</strong>: This happens when taxes change people&#8217;s behavior and affect how resources are used. For instance, if taxes make it less profitable to work, people might work less, which could hurt the economy overall.</p></li><li><p><strong>Administrative burden</strong>: This is the time and effort people spend <strong>filing taxes</strong> or hiring accountants to help them, which is an additional cost beyond the taxes themselves.</p></li></ul></li><li><p><strong>Tax equity</strong>: The <strong>equity</strong> of a tax system is about whether the tax burden is shared <strong>fairly</strong>. There are two main ideas about fairness:</p><ul><li><p><strong>Benefits principle</strong>: People should pay taxes in proportion to the benefits they receive from the government. For example, if you use public roads often, you should pay more in taxes that fund road maintenance.</p></li><li><p><strong>Ability-to-pay principle</strong>: People should pay taxes based on their ability to handle the financial burden. So, wealthier individuals, who can afford it, should pay more in taxes.</p></li></ul></li><li><p><strong>Efficiency vs. equity</strong>: When making changes to tax laws, policymakers often face a <strong>trade-off</strong> between making taxes <strong>efficient</strong> (minimizing deadweight loss and administrative burden) and making them <strong>fair</strong> (ensuring the tax burden is distributed equitably). Much of the debate around tax policy comes from how people weigh these two goals differently.</p><ul><li><p><strong>Example</strong>: Some people argue for cutting taxes to promote economic growth (focusing on efficiency), while others argue for higher taxes on the rich to reduce inequality (focusing on equity). Balancing these goals is a major challenge for governments.</p></li></ul></li></ul><div><hr></div><p>This ends the first part of this series. In the next part, the focus will be on firms and competitive markets. The whole point of this series is to cover the key principles that modern economists use to make decisions in a manner that anyone can understand. If you liked this write-up, please like and subscribe. </p><p>Also, I extend a huge thank you to to the paid subscribers of this Substack! This is an ad-free publication and your help means the world to me. By subscribing, you receive early access to my content, as well as priority when it comes to any future topics which you want me to cover. Thank you for reading and have a great one!</p><h3>References</h3><p>Almost all of the content (including some of the images) within this series was taken from a fantastic textbook called  <a href="https://www.amazon.com/Principles-Economics-N-Gregory-Mankiw/dp/1305585127">Principles of Economics</a> by <a href="https://scholar.harvard.edu/mankiw/home">Gregory Mankiw</a>.</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Photon-Lines Substack is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[An Intuitive Guide to Interface Design]]></title><description><![CDATA[A guide to creating web-sites and interfaces people will love using.]]></description><link>https://photonlines.substack.com/p/an-intuitive-guide-to-interface-design</link><guid isPermaLink="false">https://photonlines.substack.com/p/an-intuitive-guide-to-interface-design</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Sat, 06 Sep 2025 15:24:53 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!apjN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb7b0f76-3709-4974-8d2a-374f74d74902_1032x675.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I see loads of bad interfaces out there &#8211; and with the current AI wave making developer jobs even easier &#8211; what amazes me is that<strong> nothing is getting better.</strong> This is why I&#8217;m writing this guide &#8211; it&#8217;s a collection of design and usability principles that I&#8217;ve collected over the 20+ years of my software development journey. Hopefully you find them useful.</p><h3>Simplicity</h3><p>This is achieved when everyone can understand the design, regardless of experience or literacy. Some of the keys that aid simplicity are provided below:</p><ul><li><p>Remove unnecessary complexity.</p></li><li><p>Focus on the 20%: the 80-20 rule states that 80% of the effects generated by any large system are caused by 20 percent of the variables in that system. To implement great software, focus on making the key 20% of the features 1) easy to discover and 2) easy to use. Also &#8211; avoid including non-critical functions in the software.</p></li><li><p>Use progressive disclosure to present only relevant information and controls to the user.</p></li><li><p>Provide clear prompting and feedback for actions.</p></li><li><p>Keep textual information (wording) simple.</p></li><li><p>Flexibility-usability trade-off: flexibility allows you to do more things at the expense of complexity. Favor simplicity here: make designs easy to use and focus on the key feature set, but also do not over simplify. Hiding functionality to create the illusion of simplicity is a bad approach, so a fine-balance must be struck. In the below example, the middle remote-control is what we want.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!apjN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb7b0f76-3709-4974-8d2a-374f74d74902_1032x675.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!apjN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb7b0f76-3709-4974-8d2a-374f74d74902_1032x675.png 424w, https://substackcdn.com/image/fetch/$s_!apjN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb7b0f76-3709-4974-8d2a-374f74d74902_1032x675.png 848w, https://substackcdn.com/image/fetch/$s_!apjN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb7b0f76-3709-4974-8d2a-374f74d74902_1032x675.png 1272w, https://substackcdn.com/image/fetch/$s_!apjN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb7b0f76-3709-4974-8d2a-374f74d74902_1032x675.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!apjN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb7b0f76-3709-4974-8d2a-374f74d74902_1032x675.png" width="511" height="334.2296511627907" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/db7b0f76-3709-4974-8d2a-374f74d74902_1032x675.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:675,&quot;width&quot;:1032,&quot;resizeWidth&quot;:511,&quot;bytes&quot;:218002,&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://photonlines.substack.com/i/172401822?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb7b0f76-3709-4974-8d2a-374f74d74902_1032x675.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_!apjN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb7b0f76-3709-4974-8d2a-374f74d74902_1032x675.png 424w, https://substackcdn.com/image/fetch/$s_!apjN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb7b0f76-3709-4974-8d2a-374f74d74902_1032x675.png 848w, https://substackcdn.com/image/fetch/$s_!apjN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb7b0f76-3709-4974-8d2a-374f74d74902_1032x675.png 1272w, https://substackcdn.com/image/fetch/$s_!apjN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb7b0f76-3709-4974-8d2a-374f74d74902_1032x675.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></figure></div><p></p></li><li><p>Another great example of simplicity perfected is Google (especially in its early days):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!DZDi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc393ddc9-efde-412d-9241-933592a3c109_932x657.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!DZDi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc393ddc9-efde-412d-9241-933592a3c109_932x657.png 424w, https://substackcdn.com/image/fetch/$s_!DZDi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc393ddc9-efde-412d-9241-933592a3c109_932x657.png 848w, https://substackcdn.com/image/fetch/$s_!DZDi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc393ddc9-efde-412d-9241-933592a3c109_932x657.png 1272w, https://substackcdn.com/image/fetch/$s_!DZDi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc393ddc9-efde-412d-9241-933592a3c109_932x657.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!DZDi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc393ddc9-efde-412d-9241-933592a3c109_932x657.png" width="550" height="387.7145922746781" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c393ddc9-efde-412d-9241-933592a3c109_932x657.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:657,&quot;width&quot;:932,&quot;resizeWidth&quot;:550,&quot;bytes&quot;:137750,&quot;alt&quot;:&quot;&quot;,&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://photonlines.substack.com/i/172401822?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc393ddc9-efde-412d-9241-933592a3c109_932x657.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_!DZDi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc393ddc9-efde-412d-9241-933592a3c109_932x657.png 424w, https://substackcdn.com/image/fetch/$s_!DZDi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc393ddc9-efde-412d-9241-933592a3c109_932x657.png 848w, https://substackcdn.com/image/fetch/$s_!DZDi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc393ddc9-efde-412d-9241-933592a3c109_932x657.png 1272w, https://substackcdn.com/image/fetch/$s_!DZDi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc393ddc9-efde-412d-9241-933592a3c109_932x657.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></figure></div></li></ul><p></p><h3>Don&#8217;t Make Me Think</h3><ul><li><p>The number one usability principles for any website or interface: <strong>do not make me think!!</strong></p></li><li><p>As a software designer (or developer), your job is to get rid of any questions marks your software produces.</p></li><li><p>Things that make us think:</p><ul><li><p>Obscure names: make sure that the names of your links are clear.</p></li><li><p>Links and buttons that are not obviously click-able.</p></li><li><p>Searches: make it easy for users to search for what they are looking for.</p></li><li><p>Where am I: should be present on top of the page (via tags and titles).</p></li></ul></li><li><p>Make it easy for users to get back to what they were doing: i.e. if a user starts going through a wizard or provides inputs to forms, they should be able to log off and log back on to continue what they were doing. All data or stored information about the user should be stored safely (i.e. encrypted at REST). Avoid having users re-enter data: there is no greater source of frustration.</p></li></ul><h3>Visibility</h3><ul><li><p>If the user cannot see it, it does not exist.</p></li><li><p>Make the tasks the users want to perform easy to discover and present on the interface.</p></li><li><p>Advanced and less-used controls and features should easily be easy to discover (through progressive disclosure or sub-menus) but should not be displayed if they are not used often by your user base.</p></li><li><p>Include a search bar near the top of the page (it allows most users to find what they are looking for quickly).</p></li><li><p>Place controls which anticipate user needs prominently and consistently on the display.</p></li></ul><h3>Perceptibility</h3><p>Perceptibility refers to whether <strong>everyone </strong>(i.e. regular users, seniors, people with disabilities) can perceive your design. Basic guidelines to making your design perceptible are provided below:</p><ul><li><p>Make sure there is good contrast between text and background for readability.</p></li><li><p>Pick clean, legible fonts.</p></li><li><p>Present information using <strong>redundant coding methods </strong>(i.e. textual, iconic, and tactile). Most modern designs fail here since they&#8217;ll opt to include the key textual information and opt with presenting an icon instead &#8211; <strong>do not do this. </strong>A great design will opt to use both. This will aid different users in finding the features that your solution is attempting to provide.</p></li><li><p>Avoid visual noise: keep the user options simple and avoid providing too many options.</p></li><li><p>If you are using images or icons, make sure that they are not just familiar to you: make sure that they match your user mental model as well and focus on making the elements you select shared and clear among the target user base.</p></li><li><p>Follow real-world conventions: when a designs controls match real-world conventions and corresponding to desired outcomes, the design is easier to learn and remember. As an example, an article Title will always be positioned on top of the page while the comments will usually be available on the bottom &#8211; use conventions and position your controls and info according to established standards.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!VXPY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b46d22d-7901-461d-9752-0906aa70bf42_822x391.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VXPY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b46d22d-7901-461d-9752-0906aa70bf42_822x391.png 424w, https://substackcdn.com/image/fetch/$s_!VXPY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b46d22d-7901-461d-9752-0906aa70bf42_822x391.png 848w, https://substackcdn.com/image/fetch/$s_!VXPY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b46d22d-7901-461d-9752-0906aa70bf42_822x391.png 1272w, https://substackcdn.com/image/fetch/$s_!VXPY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b46d22d-7901-461d-9752-0906aa70bf42_822x391.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!VXPY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b46d22d-7901-461d-9752-0906aa70bf42_822x391.png" width="482" height="229.27250608272507" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8b46d22d-7901-461d-9752-0906aa70bf42_822x391.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:391,&quot;width&quot;:822,&quot;resizeWidth&quot;:482,&quot;bytes&quot;:44892,&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://photonlines.substack.com/i/172401822?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b46d22d-7901-461d-9752-0906aa70bf42_822x391.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_!VXPY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b46d22d-7901-461d-9752-0906aa70bf42_822x391.png 424w, https://substackcdn.com/image/fetch/$s_!VXPY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b46d22d-7901-461d-9752-0906aa70bf42_822x391.png 848w, https://substackcdn.com/image/fetch/$s_!VXPY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b46d22d-7901-461d-9752-0906aa70bf42_822x391.png 1272w, https://substackcdn.com/image/fetch/$s_!VXPY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b46d22d-7901-461d-9752-0906aa70bf42_822x391.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p></li></ul><h3>Point of Entry (Home Page Design)</h3><p>A home page needs to answer 4 basic questions:</p><ul><li><p>What is this?</p></li><li><p>What can I do here?</p></li><li><p>What do they have here?</p></li><li><p>Why should I be here, and not somewhere else?</p></li></ul><p>A user should be able to answer these questions at a glance, correctly and unambiguously, with very little effort.</p><p><strong>How to get the message across</strong>: There are 2 important places on the page where we expect to find explicit statements of what the site is about:</p><ul><li><p>The tagline. Right next to the site ID.</p></li><li><p>The Welcome blurb. The Welcome blurb is a terse description of the site, displayed in a prominent block on the home page that's visible without scrolling.</p></li></ul><p><strong>Nothing beats a great tagline</strong>. A tagline is a small phrase that summarizes what the site is and what makes it great. It appears right below, above, or next to the site ID.</p><ul><li><p>Good taglines are clear and informative (avoid vagueness and ambiguity).</p></li><li><p>Good tag lines are just long enough. 6 to 8 words seem good enough to convey a thought.</p></li><li><p>Good taglines convey differentiation and a clear benefit.</p></li><li><p>Good taglines are personable, lively, and sometimes clever.</p></li></ul><p>When a user enters a new site, they should be able to say with confidence:</p><ul><li><p>Here's where I start if I want to search (i.e. include a search bar).</p></li><li><p>Here's where I start if I want to browse (i.e. include a menu that allows the user to view the key pages and content provided within the website).</p></li><li><p>Here's where I start if I want to sample their best stuff.</p></li></ul><h3>Language</h3><ul><li><p>The design should speak the users language.</p></li><li><p>Use words, phrases, and concepts familiar to the user, rather than jargon.</p></li><li><p>Omit needless words and punctuation. Most of the words on a web-page are just taking up unnecessary space. Nobody is going to read them. Get rid of half the words. And then get rid of the other half. Be careful not to sacrifice clarity though.</p></li><li><p>Eliminate all happy talk, which is that part of the site that tells the user how great it is. Let the functionality speak for itself.</p></li><li><p>Generally, use an active voice rather than passive &#8211; (i.e. prefer the subject performs the action rather than the subject receives the action). Examples:</p><ul><li><p>Good (active): The researcher analyzed the data.</p></li><li><p>Bad (passive): The data was analyzed by the researcher.</p></li></ul></li><li><p>Express complex material in the simplest way possible.</p></li><li><p>The other source of needless words is instructions. Nobody is going to read them, at least not until their first attempts at muddling through have failed. Make everything self-explanatory, so the users won't need instructions.</p></li></ul><h3>Text</h3><ul><li><p>Text should have high contrast (prefer black text with a white background).</p></li><li><p>Favor readability over prettiness (use large, simple, and aliased fonts).</p></li><li><p>Favor particularly large characters for the actual data you intend to display, as opposed to labels and instructions. For example, the label, &#8220;Last Name,&#8221; can afford to be somewhat small. The actual last name entered/displayed, however, must be clearly readable. This becomes even more important for numbers.</p></li><li><p>Menu and button labels should have the key word(s) first, forming unique labels.</p></li><li><p>There&#8217;s often an inverse relationship between the &#8220;prettiness&#8221; of a font and its readability. Specifically, anti-aliasing softens the edges of a font, giving it a much smoother appearance on the digital page. The problem is that the human vision system responds to sharp edges, so, in smaller font sizes, an anti-aliased font, while often appearing more attractive, can be quite difficult to comprehend.</p></li><li><p><strong>Use Framing Wisely</strong>: your wording will influence the way a user behaves and what options they choose &#8211; so frame your wording wisely. Use positive frames (i.e. present information in a positive manner) if you want to nudge the user into taking action. Use negative frames when you want to promote the opposite.</p></li><li><p><strong>Use Priming Wisely: </strong>every word you use on the page has influence and automatically primes your users&#8217; memory &#8211; so choose your words wisely. As an example, in a study &#8211; 2 groups of students were primed with 2 different sets of words: one was primed with politeness and the other group was primed with rudeness. At the end of the test, the group primed with polite words had a much lower probability of interrupting the study administrator (17%) than the group who was primed with rudeness (63%).</p></li></ul><h3>Visual Hierarchy</h3><p>The appearance of the things of the page, all of the visual cues, must clearly and accurately portray the relationships between the things on the page.</p><ul><li><p>Align elements on a grid to keep everything organized.</p></li><li><p>Break pages up into clearly defined areas.</p></li><li><p>Page names: every page needs a name. The name should be prominent and present on top of each page.</p></li><li><p>Group related items together and separate unrelated ones with spacing.</p></li><li><p>If something is more important, make it larger. Use large objects for important functions and small objects for functions you would prefer users not to perform.</p></li><li><p>Primary buttons or headlines might be larger and brighter than secondary text.</p></li><li><p>Things should be &#8220;nested&#8221; visually to show what's part of what.</p></li><li><p>By guiding users with clear headings, highlighted buttons, and logical grouping, the interface becomes much easier to scan and navigate.</p></li></ul><h3>Navigation</h3><ul><li><p>Include persistent navigation present on top of the page with local navigation (present vertically and on the left) of the page. <a href="https://photonlines.github.io/Research-Lab-Website/publications.html">Here is an example</a> which shows this &#8211; the website allows users to navigate through main web-site content (top-level menu) as well as the general page content which is easily viable 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_!SJCX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fb82b41-94dc-4d8a-b167-e1c00fcf252c_1052x937.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SJCX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fb82b41-94dc-4d8a-b167-e1c00fcf252c_1052x937.png 424w, https://substackcdn.com/image/fetch/$s_!SJCX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fb82b41-94dc-4d8a-b167-e1c00fcf252c_1052x937.png 848w, https://substackcdn.com/image/fetch/$s_!SJCX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fb82b41-94dc-4d8a-b167-e1c00fcf252c_1052x937.png 1272w, https://substackcdn.com/image/fetch/$s_!SJCX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fb82b41-94dc-4d8a-b167-e1c00fcf252c_1052x937.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SJCX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fb82b41-94dc-4d8a-b167-e1c00fcf252c_1052x937.png" width="1052" height="937" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0fb82b41-94dc-4d8a-b167-e1c00fcf252c_1052x937.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:937,&quot;width&quot;:1052,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:244660,&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://photonlines.substack.com/i/172401822?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fb82b41-94dc-4d8a-b167-e1c00fcf252c_1052x937.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_!SJCX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fb82b41-94dc-4d8a-b167-e1c00fcf252c_1052x937.png 424w, https://substackcdn.com/image/fetch/$s_!SJCX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fb82b41-94dc-4d8a-b167-e1c00fcf252c_1052x937.png 848w, https://substackcdn.com/image/fetch/$s_!SJCX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fb82b41-94dc-4d8a-b167-e1c00fcf252c_1052x937.png 1272w, https://substackcdn.com/image/fetch/$s_!SJCX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0fb82b41-94dc-4d8a-b167-e1c00fcf252c_1052x937.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></figure></div><p></p></li></ul><h3>Consistency</h3><ul><li><p>Systems are more usable and learnable when similar parts are expressed in similar ways. Stick to a unified color palette, font family, and icon set. Repeating the same colors and typography across your interface builds familiarity and trust.</p></li><li><p>If existing software systems exist with a similar set of features you are looking to implement (and that other users love using) &#8211; come up with a design that mimics the functionality rather than suffering from the not invented here syndrome.</p></li><li><p>Consistency enables people to efficiently transfer knowledge to new contexts, learn new things quickly, and focus attention to the task they are looking to accomplish.</p></li><li><p>Keep the style and appearance of your application (i.e. logos, icons, wording, menus) consistent across screens.</p></li></ul><h3>Maximize User Efficiency</h3><ul><li><p>People cost a lot more money than machines. Do not keep users waiting.</p></li><li><p>Make it easy for them to do what they want to do rather than asking them to adopt to enforced standards &amp; formats.</p></li><li><p>As a single example, forcing customers to enter telephone numbers without normal spacing or punctuation saves a single line of code and a handful of machine cycles. It also results in a lot of incorrectly captured phone numbers. (That&#8217;s exactly why phone numbers are broken up into smaller pieces.)</p></li><li><p>When possible, format data correctly using automatic methodologies. When not possible, force the users to enter the data in the correct format (think of how much time users waste in finding phone numbers stored in different formats across your system. Do not sacrifice the future for today).</p></li></ul><h3>Minimize Cognitive Load</h3><p>Cognitive load is the amount of mental activity (perception, memory, and problem solving) required to accomplish a goal. As an example, early computer systems required users to remember large sets of commands which they needed to type in specific ways to execute their tasks. The advent of graphical user interfaces that allowed them to browse rather than remember information increased computer adoption by a large factor.</p><ul><li><p>Eliminate unnecessary information from displays.</p></li><li><p>Chunk information to be remembered.</p></li><li><p>Provide memory aids to assist with remembering tasks.</p></li><li><p>Reduce the amount of steps needed in order to accomplish a task or completely look to automate any complex or memory intensive tasks all together.</p></li></ul><p>Overall, always look to help the user by making their job easier and simplifying the tasks they have to perform. One great example of this is the use of UPC code and bar-codes in the modern world.</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vZJG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90e5d9b4-422a-4a82-8520-057ae333be96_962x385.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vZJG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90e5d9b4-422a-4a82-8520-057ae333be96_962x385.png 424w, https://substackcdn.com/image/fetch/$s_!vZJG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90e5d9b4-422a-4a82-8520-057ae333be96_962x385.png 848w, https://substackcdn.com/image/fetch/$s_!vZJG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90e5d9b4-422a-4a82-8520-057ae333be96_962x385.png 1272w, https://substackcdn.com/image/fetch/$s_!vZJG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90e5d9b4-422a-4a82-8520-057ae333be96_962x385.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vZJG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90e5d9b4-422a-4a82-8520-057ae333be96_962x385.png" width="573" height="229.3191268191268" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/90e5d9b4-422a-4a82-8520-057ae333be96_962x385.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:385,&quot;width&quot;:962,&quot;resizeWidth&quot;:573,&quot;bytes&quot;:102994,&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://photonlines.substack.com/i/172401822?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90e5d9b4-422a-4a82-8520-057ae333be96_962x385.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_!vZJG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90e5d9b4-422a-4a82-8520-057ae333be96_962x385.png 424w, https://substackcdn.com/image/fetch/$s_!vZJG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90e5d9b4-422a-4a82-8520-057ae333be96_962x385.png 848w, https://substackcdn.com/image/fetch/$s_!vZJG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90e5d9b4-422a-4a82-8520-057ae333be96_962x385.png 1272w, https://substackcdn.com/image/fetch/$s_!vZJG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90e5d9b4-422a-4a82-8520-057ae333be96_962x385.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p><h3>Anticipation (and Recognition Rather than Recall)</h3><p>Bring to the user all the information and tools needed to perform each step of the process:</p><ul><li><p>Your interface needs to anticipate the user needs and wants. Do not expect users to leave the current screen to search for the necessary information: all the information he or she needs should be in place and should be visible.</p></li><li><p>Understand the task domain and the user domain so that you can understand the information that is needed in order to create the solution.</p></li><li><p>Make the tool or information present on the screen where users can easily find it.</p></li><li><p>Do not ask users to remember information from one part of the interface to another. Information that is needed should be easily retrievable within the interface.</p></li><li><p>Provide easy to use auto-completion text boxes and select boxes that limit the burden on users. Avoid having users manually entering information when you can provide assistance to them through easy to use controls.</p></li></ul><h3>Maximize Signal-to-Noise</h3><p>Simplify the presentation and remove and unnecessary elements to maximize the signal-to-noise ratio. The below shows some examples of data presented where removing information from the image results in a better visual presentation (image on the right):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!v68M!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe97918d-d1f1-4fe0-ab2d-5939e71b4b9a_1098x452.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!v68M!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe97918d-d1f1-4fe0-ab2d-5939e71b4b9a_1098x452.png 424w, https://substackcdn.com/image/fetch/$s_!v68M!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe97918d-d1f1-4fe0-ab2d-5939e71b4b9a_1098x452.png 848w, https://substackcdn.com/image/fetch/$s_!v68M!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe97918d-d1f1-4fe0-ab2d-5939e71b4b9a_1098x452.png 1272w, https://substackcdn.com/image/fetch/$s_!v68M!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe97918d-d1f1-4fe0-ab2d-5939e71b4b9a_1098x452.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!v68M!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe97918d-d1f1-4fe0-ab2d-5939e71b4b9a_1098x452.png" width="1098" height="452" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/be97918d-d1f1-4fe0-ab2d-5939e71b4b9a_1098x452.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:452,&quot;width&quot;:1098,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:148085,&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://photonlines.substack.com/i/172401822?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe97918d-d1f1-4fe0-ab2d-5939e71b4b9a_1098x452.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_!v68M!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe97918d-d1f1-4fe0-ab2d-5939e71b4b9a_1098x452.png 424w, https://substackcdn.com/image/fetch/$s_!v68M!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe97918d-d1f1-4fe0-ab2d-5939e71b4b9a_1098x452.png 848w, https://substackcdn.com/image/fetch/$s_!v68M!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe97918d-d1f1-4fe0-ab2d-5939e71b4b9a_1098x452.png 1272w, https://substackcdn.com/image/fetch/$s_!v68M!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe97918d-d1f1-4fe0-ab2d-5939e71b4b9a_1098x452.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></figure></div><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7t5h!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67cd4537-01a9-48e6-ab60-11d08c942451_888x356.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7t5h!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67cd4537-01a9-48e6-ab60-11d08c942451_888x356.png 424w, https://substackcdn.com/image/fetch/$s_!7t5h!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67cd4537-01a9-48e6-ab60-11d08c942451_888x356.png 848w, https://substackcdn.com/image/fetch/$s_!7t5h!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67cd4537-01a9-48e6-ab60-11d08c942451_888x356.png 1272w, https://substackcdn.com/image/fetch/$s_!7t5h!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67cd4537-01a9-48e6-ab60-11d08c942451_888x356.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7t5h!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67cd4537-01a9-48e6-ab60-11d08c942451_888x356.png" width="888" height="356" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/67cd4537-01a9-48e6-ab60-11d08c942451_888x356.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:356,&quot;width&quot;:888,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:73129,&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://photonlines.substack.com/i/172401822?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67cd4537-01a9-48e6-ab60-11d08c942451_888x356.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_!7t5h!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67cd4537-01a9-48e6-ab60-11d08c942451_888x356.png 424w, https://substackcdn.com/image/fetch/$s_!7t5h!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67cd4537-01a9-48e6-ab60-11d08c942451_888x356.png 848w, https://substackcdn.com/image/fetch/$s_!7t5h!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67cd4537-01a9-48e6-ab60-11d08c942451_888x356.png 1272w, https://substackcdn.com/image/fetch/$s_!7t5h!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67cd4537-01a9-48e6-ab60-11d08c942451_888x356.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></figure></div><h3>Create Aesthetic Interfaces</h3><p>Aesthetic designs are perceived as easier to use than less aesthetic designs so:</p><ul><li><p>Aesthetic designs look easier to use and have a higher probability of being used, whether or not they actually are easier to use &#8211; so make your interfaces look beautiful.</p></li><li><p>Embrace whitespace (maximize simplicity). Less is more. Remove any non-essential elements and give important items room to breathe. Proper whitespace greatly improves clarity.</p></li><li><p>Embrace minimalism: A clean, minimalist layout (think Google&#8217;s homepage or Apple&#8217;s style) will feel fast and intuitive to users.</p></li><li><p>Polished look: consistent colors, crisp icons, balanced spacing &#8211; makes the product feel more engaging and trustworthy.</p></li><li><p>Create a clear visual hierarchy: Lead the user&#8217;s eye by making key elements stand out with size, contrast, or color.</p></li><li><p>Proper line spacing and margins in your text also add to a polished, easy-on-the-eyes design.</p></li><li><p>Use colors conservatively. Limit the palette to what the eye can process at once glance (about 5 colors depending on the complexity of the design).</p></li><li><p>Achieve aesthetic color combinations by using adjacent colors on the color wheel.</p></li><li><p>Use warmer colors for foreground elements and cooler colors for background elements.</p></li><li><p>Prefer Most Advanced Yet Acceptable: aesthetic appeal is a balancing act between 2 variables: familiarity and uniqueness. You need to balance those 2 in order to find commercial success. According to research, the MAYA principle states that the best design is something that is recognizable as familiar while also being novel and unique is the best formula for success (i.e. software adoption). Make the design easy to use and recognize while adding some novelty in order to make it stand out from the competition.</p></li></ul><h3>Contours</h3><ul><li><p>Prefer rounded contours or corners in your interfaces. In experiments where subjects were presented with otherwise similar angled vs contoured objects, subjects strongly preferred more rounded, contoured objects.</p></li><li><p>Use angular and pointy features to attract attention and provoke thought: in other words, any alerts or confirmations or system notifications which alerts users to urgent issues or which may require more deep thinking should have sharp angles. Studies show that fear-processing centers and associative memory segments of the brain are activated more using sharp edges than rounded corners. The degree of the angularity is correlated with the strength of amygdala (fear processing activation) so sharper edges evoke more attention.</p></li></ul><p>To sum it up: use rounded corners for most interfaces (that provide a regular flow and do not need special attention) &#8211; reserve sharp edges for things that do need attention (like warnings or critical alerts).</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BjQR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff73e7815-9a96-49d7-9552-0247dc4eef3a_807x131.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BjQR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff73e7815-9a96-49d7-9552-0247dc4eef3a_807x131.png 424w, https://substackcdn.com/image/fetch/$s_!BjQR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff73e7815-9a96-49d7-9552-0247dc4eef3a_807x131.png 848w, https://substackcdn.com/image/fetch/$s_!BjQR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff73e7815-9a96-49d7-9552-0247dc4eef3a_807x131.png 1272w, https://substackcdn.com/image/fetch/$s_!BjQR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff73e7815-9a96-49d7-9552-0247dc4eef3a_807x131.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BjQR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff73e7815-9a96-49d7-9552-0247dc4eef3a_807x131.png" width="508" height="82.4634448574969" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f73e7815-9a96-49d7-9552-0247dc4eef3a_807x131.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:131,&quot;width&quot;:807,&quot;resizeWidth&quot;:508,&quot;bytes&quot;:11979,&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://photonlines.substack.com/i/172401822?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff73e7815-9a96-49d7-9552-0247dc4eef3a_807x131.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_!BjQR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff73e7815-9a96-49d7-9552-0247dc4eef3a_807x131.png 424w, https://substackcdn.com/image/fetch/$s_!BjQR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff73e7815-9a96-49d7-9552-0247dc4eef3a_807x131.png 848w, https://substackcdn.com/image/fetch/$s_!BjQR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff73e7815-9a96-49d7-9552-0247dc4eef3a_807x131.png 1272w, https://substackcdn.com/image/fetch/$s_!BjQR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff73e7815-9a96-49d7-9552-0247dc4eef3a_807x131.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p><h3>Control</h3><ul><li><p>Visibility of system status: the page should always keep users informed about what is going on, through appropriate feedback and in a reasonable amount of time. The user needs to be in control. Predictable interactions create trust in the product and brand.</p></li><li><p>Present feedback to the user as quickly as possible (ideally immediately).</p></li><li><p>Build trust through open and continuous communication.</p></li><li><p>There are two target users for every piece of software: beginning users (which the design should be focused on accommodating) and advanced users (which the design should also make room for).</p></li><li><p>Avoid adding too many advanced features for users who want to have shortcuts: focus in on being accommodating to these users without cluttering the interface and provide key-board shortcuts for them to execute actions more quickly.</p></li></ul><h3>Input Validation</h3><p><strong>Validate all user inputs </strong>(i.e. garbage in &#8211; garbage out dictates that we want to avoid garbage data within our systems).</p><ul><li><p>Make it hard for users to enter bad or invalid data (i.e. do data validation for all inputs).</p></li><li><p>Use constraints to help users input valid data.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zta_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af37b71-d6e0-47b2-8920-da059c581396_346x357.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zta_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af37b71-d6e0-47b2-8920-da059c581396_346x357.png 424w, https://substackcdn.com/image/fetch/$s_!zta_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af37b71-d6e0-47b2-8920-da059c581396_346x357.png 848w, https://substackcdn.com/image/fetch/$s_!zta_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af37b71-d6e0-47b2-8920-da059c581396_346x357.png 1272w, https://substackcdn.com/image/fetch/$s_!zta_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af37b71-d6e0-47b2-8920-da059c581396_346x357.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zta_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af37b71-d6e0-47b2-8920-da059c581396_346x357.png" width="346" height="357" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7af37b71-d6e0-47b2-8920-da059c581396_346x357.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:357,&quot;width&quot;:346,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:36142,&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://photonlines.substack.com/i/172401822?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af37b71-d6e0-47b2-8920-da059c581396_346x357.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_!zta_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af37b71-d6e0-47b2-8920-da059c581396_346x357.png 424w, https://substackcdn.com/image/fetch/$s_!zta_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af37b71-d6e0-47b2-8920-da059c581396_346x357.png 848w, https://substackcdn.com/image/fetch/$s_!zta_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af37b71-d6e0-47b2-8920-da059c581396_346x357.png 1272w, https://substackcdn.com/image/fetch/$s_!zta_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af37b71-d6e0-47b2-8920-da059c581396_346x357.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></figure></div><p></p></li><li><p>Format data according to a consistent standard prior to storing it within the data layer (i.e. keep the data consistent).</p></li><li><p>Avoid free form fields which may contain multiple data elements.</p></li><li><p>Keep the data consistent (i.e. formatted in the same way within your data layer).</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Cwv7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515d1787-4574-4cbb-a0f2-39fe7f3c41e7_992x856.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Cwv7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515d1787-4574-4cbb-a0f2-39fe7f3c41e7_992x856.png 424w, https://substackcdn.com/image/fetch/$s_!Cwv7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515d1787-4574-4cbb-a0f2-39fe7f3c41e7_992x856.png 848w, https://substackcdn.com/image/fetch/$s_!Cwv7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515d1787-4574-4cbb-a0f2-39fe7f3c41e7_992x856.png 1272w, https://substackcdn.com/image/fetch/$s_!Cwv7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515d1787-4574-4cbb-a0f2-39fe7f3c41e7_992x856.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Cwv7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515d1787-4574-4cbb-a0f2-39fe7f3c41e7_992x856.png" width="649" height="560.0241935483871" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/515d1787-4574-4cbb-a0f2-39fe7f3c41e7_992x856.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:856,&quot;width&quot;:992,&quot;resizeWidth&quot;:649,&quot;bytes&quot;:343795,&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://photonlines.substack.com/i/172401822?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515d1787-4574-4cbb-a0f2-39fe7f3c41e7_992x856.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_!Cwv7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515d1787-4574-4cbb-a0f2-39fe7f3c41e7_992x856.png 424w, https://substackcdn.com/image/fetch/$s_!Cwv7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515d1787-4574-4cbb-a0f2-39fe7f3c41e7_992x856.png 848w, https://substackcdn.com/image/fetch/$s_!Cwv7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515d1787-4574-4cbb-a0f2-39fe7f3c41e7_992x856.png 1272w, https://substackcdn.com/image/fetch/$s_!Cwv7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F515d1787-4574-4cbb-a0f2-39fe7f3c41e7_992x856.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></figure></div><p></p></li></ul><h3>Error Messages</h3><p>Error messages must be written to show:</p><ul><li><p>Explain what is wrong.</p></li><li><p>Tell the user what to do about it.</p></li></ul><p>Avoid displaying system errors or exceptions within error messages (i.e. like error 4421). Provide information which is simply worded and which displays the 2 main things we outlined above.</p><h3>Forgiveness</h3><p>Minimize the consequences and occurrences of errors by:</p><ul><li><p>Using constraints (to limit user input such that only valid data can be used).</p></li><li><p>Using confirmations and warnings to reduce the occurrences of errors.</p></li><li><p>Using confirmations only on non-reversible and serious actions (since they slow task performance) &#8211; if an action is reversible, avoid presenting confirmation dialogs or messages. Also &#8211; they should be used sparingly: people do not like continually being interrupted.</p></li><li><p>For non-critical confirmations, a select box which allows the user to turn them off should be available.</p></li><li><p>Include reversible actions and safety nets to minimize the consequence of errors (i.e. include undo and redo as a possible action).</p></li><li><p>Show a clear way to exist the current interaction by including a Cancel button.</p></li><li><p>Cancel is particularly important in Wizards. Let people leave at any time and make sure to tell them where they can finish the task later on.</p></li></ul><h3>Dialog Design</h3><ul><li><p>Nobody reads your dialog boxes. Use a verb whenever possible instead of 'Yes' or 'OK' because your buttons will make sense out of context with the explanatory text or title.</p></li><li><p><strong>Bad Example </strong>(in the example below, there is a chance the users will not read what they are confirming)<strong>:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Lvup!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb20f155a-b73c-4773-b62a-a74bd0390033_742x293.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Lvup!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb20f155a-b73c-4773-b62a-a74bd0390033_742x293.png 424w, https://substackcdn.com/image/fetch/$s_!Lvup!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb20f155a-b73c-4773-b62a-a74bd0390033_742x293.png 848w, https://substackcdn.com/image/fetch/$s_!Lvup!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb20f155a-b73c-4773-b62a-a74bd0390033_742x293.png 1272w, https://substackcdn.com/image/fetch/$s_!Lvup!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb20f155a-b73c-4773-b62a-a74bd0390033_742x293.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Lvup!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb20f155a-b73c-4773-b62a-a74bd0390033_742x293.png" width="469" height="185.19811320754718" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b20f155a-b73c-4773-b62a-a74bd0390033_742x293.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:293,&quot;width&quot;:742,&quot;resizeWidth&quot;:469,&quot;bytes&quot;:75783,&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://photonlines.substack.com/i/172401822?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb20f155a-b73c-4773-b62a-a74bd0390033_742x293.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_!Lvup!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb20f155a-b73c-4773-b62a-a74bd0390033_742x293.png 424w, https://substackcdn.com/image/fetch/$s_!Lvup!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb20f155a-b73c-4773-b62a-a74bd0390033_742x293.png 848w, https://substackcdn.com/image/fetch/$s_!Lvup!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb20f155a-b73c-4773-b62a-a74bd0390033_742x293.png 1272w, https://substackcdn.com/image/fetch/$s_!Lvup!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb20f155a-b73c-4773-b62a-a74bd0390033_742x293.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p></li><li><p><strong>Great Example </strong>(you can be sure that at least users understand that they are about to format a disk)<strong>:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4gBB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3418c42f-8698-4261-b44f-a816dc512877_783x331.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4gBB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3418c42f-8698-4261-b44f-a816dc512877_783x331.png 424w, https://substackcdn.com/image/fetch/$s_!4gBB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3418c42f-8698-4261-b44f-a816dc512877_783x331.png 848w, https://substackcdn.com/image/fetch/$s_!4gBB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3418c42f-8698-4261-b44f-a816dc512877_783x331.png 1272w, https://substackcdn.com/image/fetch/$s_!4gBB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3418c42f-8698-4261-b44f-a816dc512877_783x331.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4gBB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3418c42f-8698-4261-b44f-a816dc512877_783x331.png" width="507" height="214.3256704980843" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3418c42f-8698-4261-b44f-a816dc512877_783x331.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:331,&quot;width&quot;:783,&quot;resizeWidth&quot;:507,&quot;bytes&quot;:67867,&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://photonlines.substack.com/i/172401822?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3418c42f-8698-4261-b44f-a816dc512877_783x331.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_!4gBB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3418c42f-8698-4261-b44f-a816dc512877_783x331.png 424w, https://substackcdn.com/image/fetch/$s_!4gBB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3418c42f-8698-4261-b44f-a816dc512877_783x331.png 848w, https://substackcdn.com/image/fetch/$s_!4gBB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3418c42f-8698-4261-b44f-a816dc512877_783x331.png 1272w, https://substackcdn.com/image/fetch/$s_!4gBB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3418c42f-8698-4261-b44f-a816dc512877_783x331.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p></li><li><p>Apple's Human Interface Guidelines expand on this even further, recommending multi-word verbs instead of "OK" or "Yes" buttons, and clearly defining the suggested regions for an alert box:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NpC0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571bebb2-2142-476e-837a-4e4316bc5001_843x586.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NpC0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571bebb2-2142-476e-837a-4e4316bc5001_843x586.png 424w, https://substackcdn.com/image/fetch/$s_!NpC0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571bebb2-2142-476e-837a-4e4316bc5001_843x586.png 848w, https://substackcdn.com/image/fetch/$s_!NpC0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571bebb2-2142-476e-837a-4e4316bc5001_843x586.png 1272w, https://substackcdn.com/image/fetch/$s_!NpC0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571bebb2-2142-476e-837a-4e4316bc5001_843x586.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NpC0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571bebb2-2142-476e-837a-4e4316bc5001_843x586.png" width="578" height="401.7888493475682" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/571bebb2-2142-476e-837a-4e4316bc5001_843x586.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:586,&quot;width&quot;:843,&quot;resizeWidth&quot;:578,&quot;bytes&quot;:211539,&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://photonlines.substack.com/i/172401822?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571bebb2-2142-476e-837a-4e4316bc5001_843x586.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_!NpC0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571bebb2-2142-476e-837a-4e4316bc5001_843x586.png 424w, https://substackcdn.com/image/fetch/$s_!NpC0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571bebb2-2142-476e-837a-4e4316bc5001_843x586.png 848w, https://substackcdn.com/image/fetch/$s_!NpC0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571bebb2-2142-476e-837a-4e4316bc5001_843x586.png 1272w, https://substackcdn.com/image/fetch/$s_!NpC0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571bebb2-2142-476e-837a-4e4316bc5001_843x586.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></figure></div><p></p></li><li><p>Ensure that the default button name corresponds to the action you describe. In particular, it&#8217;s a good idea to avoid using OK for the default button. </p></li><li><p>Also note that, given a choice between 'No' and 'Cancel', 'Cancel' is almost always better for exactly the same reasons as above: the meaning of 'Cancel' is clear even if the user hasn't read the rest of the dialog box.</p></li></ul><h3>Defaults</h3><ul><li><p>Defaults within fields should be easy to remove (i.e. when a user activates a field, the current entry should be auto-selected so that pressing backspace or delete will eliminate the current entry).</p></li><li><p>Not everything should have a default: if there isn&#8217;t one winner, consider offering no default.</p></li><li><p>For defaults that do not have a clear winner and that should be set: choose the default which does the least harm and delivers the most good (i.e. enroll employees into a pension plan to promote savings, or choose to automatically opt-in people for organ donations as an example).</p></li><li><p>The default word: avoid using it. If you want the user to revert to standard settings for example, create a button which shows the text &#8216;revert to standard settings&#8217;, &#8216;use customary settings&#8217;, or &#8216;restore initial settings&#8217;. Use terminology which describes what will happen rather than generic terms.</p></li></ul><h3>Depth of Processing</h3><ul><li><p>The key determining factors of how deeply information is processed:</p><ul><li><p>Distinctiveness of the information (uniqueness of the info with respect to previous experience).</p></li><li><p>Relevance of the information (how important is the information).</p></li><li><p>Degree of elaboration (how much thought is required to interpret the information).</p></li></ul></li><li><p>Use a unique presentation and interesting activities to engage people to deeply process information and to aid in learning. The more deeply learners process information, the better they learn.</p></li><li><p>People remember pictures better than words (especially when forming memories) &#8211; so use both to aid recall.</p></li></ul><p>Present important items at the beginning or end of a list (rather than the middle) to aid recall. When a list is visual, present important items at the beginning of the list. If the list is auditory, present important items at the end.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7-L8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ec7ed-7bb9-4c32-86fc-37d11323b88f_710x722.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7-L8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ec7ed-7bb9-4c32-86fc-37d11323b88f_710x722.png 424w, https://substackcdn.com/image/fetch/$s_!7-L8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ec7ed-7bb9-4c32-86fc-37d11323b88f_710x722.png 848w, https://substackcdn.com/image/fetch/$s_!7-L8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ec7ed-7bb9-4c32-86fc-37d11323b88f_710x722.png 1272w, https://substackcdn.com/image/fetch/$s_!7-L8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ec7ed-7bb9-4c32-86fc-37d11323b88f_710x722.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7-L8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ec7ed-7bb9-4c32-86fc-37d11323b88f_710x722.png" width="463" height="470.82535211267606" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7d3ec7ed-7bb9-4c32-86fc-37d11323b88f_710x722.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:722,&quot;width&quot;:710,&quot;resizeWidth&quot;:463,&quot;bytes&quot;:57193,&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://photonlines.substack.com/i/172401822?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ec7ed-7bb9-4c32-86fc-37d11323b88f_710x722.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_!7-L8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ec7ed-7bb9-4c32-86fc-37d11323b88f_710x722.png 424w, https://substackcdn.com/image/fetch/$s_!7-L8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ec7ed-7bb9-4c32-86fc-37d11323b88f_710x722.png 848w, https://substackcdn.com/image/fetch/$s_!7-L8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ec7ed-7bb9-4c32-86fc-37d11323b88f_710x722.png 1272w, https://substackcdn.com/image/fetch/$s_!7-L8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ec7ed-7bb9-4c32-86fc-37d11323b88f_710x722.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></figure></div><h3>User Testing</h3><p>If you want a great site, you've got to test. Testing reminds you that not everybody thinks the way you do, knows what you do, and uses the web the way you do.</p><ul><li><p>Testing one user is 100% better than testing none. Even the worst test with the wrong user can show you how you can improve your site.</p></li><li><p>How many users should you test? Usually, the ideal number for each round of testing is 3-4. The first 3 users are very likely to encounter all the most significant problems.</p></li><li><p>Testing one user early in the project is better than testing 50 near the end. Don't make a big deal out of testing. Do it early and often. Users don't like changes in the system, so it's better to test them early than doing it later and having to change things.</p></li><li><p>If users find the interface confusing or slow, simplify it.</p></li><li><p>The importance of recruiting representative users is overrated.</p></li><li><p>Testing is an iterative process. Testing isn't something you do once. You make something, test it, fix it, and test it again. It's also important that once you fix these problems, you do more rounds of testing, where the users will encounter other problems with your site. It's better to focus on the biggest problems, fix them, and then do further testing.</p></li></ul><h3>Key Questions When Starting a Design</h3><p>If you are designing a new concept or interface, or just getting started on a design project, some great questions to ask <strong>prior </strong>to doing any design work are shown below:</p><ul><li><p>What are your goals and objectives?</p></li><li><p>What are your top priorities?</p></li><li><p>How do you know if you are successful? </p></li><li><p>Do you measure success and if so &#8211; how do you define it?</p></li><li><p>Who do you consider to be your primary customer? </p></li><li><p>What are their priorities and goals?</p></li><li><p>Why do they use your products? </p></li><li><p>What prevents them from using your products, if anything?</p></li><li><p>What questions do you have about your users which you do not have answers to?</p></li><li><p>Who are your competitors, and how well are you doing compared to them?</p></li><li><p>What do you do well?</p></li><li><p>What could be improved?</p></li><li><p>What differentiates you and your company and your product in the market?</p></li></ul><p>The key point here is to try to find the root-cause of the problem that they are trying to solve, as well as to design something which differentiates them from the existing competition. The Y-Combinator Principle is that creating a product that a small group of users LOVE is much better than designing a product that meets the needs of all users but that most users like. Also, focus on creating something that a market-segment loves and something which is different from what is already available (i.e. blue ocean market).</p><p>This ends the first part of my design series. If you enjoyed this content - leave a message or subscribe. </p><h3>Credits and References</h3><p>Most of the images available within the blog post were taken from the book <a href="https://universalprinciplesofdesign.com/">Universal Principles of Design</a> referenced below. </p><ol><li><p><a href="https://universalprinciplesofdesign.com/">Universal Principles of Design, Revised and Updated: 125 Ways to Enhance Usability, Influence Perception, Increase Appeal, Make Better Design Decisions, and Teach through Design</a></p></li><li><p><a href="https://sensible.com/dont-make-me-think/">Don&#8217;t Make Me Think</a></p></li><li><p><a href="https://www.nngroup.com/articles/ten-usability-heuristics/">10 Usability Heuristics for User Interface Design</a></p></li><li><p><a href="https://asktog.com/atc/principles-of-interaction-design/">First Principles of Interaction Design (Revised &amp; Expanded)</a></p></li><li><p><a href="https://rosenfeldmedia.com/books/the-user-experience-team-of-one-second-edition/?srsltid=AfmBOoorzWD_KFlI96XR7XcpyDuePfXfSGf5IdMkN-OM_TsvXxmPBcp-">The User Experience Team of One</a></p></li><li><p><a href="https://ux.stackexchange.com/questions/9946/should-i-use-yes-no-or-ok-cancel-on-my-message-box">Should I use Yes/No or Ok/Cancel on my message box?</a></p></li></ol><p>Last but not least, many thanks to the paid subscribers of this Substack!! This is an ad-free publication and your help means the world to me. By subscribing, you receive early access to my content, as well as priority when it comes to any future topics which you want me to cover. Thank you for reading and have a great one!</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Photon-Lines Substack is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Photon-Lines Tech Notes - July 2025]]></title><description><![CDATA[My own favorite notes & highlights from the world of tech - July 2025 Edition]]></description><link>https://photonlines.substack.com/p/photon-lines-tech-notes-july-2025</link><guid isPermaLink="false">https://photonlines.substack.com/p/photon-lines-tech-notes-july-2025</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Thu, 31 Jul 2025 16:02:46 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!J4Y4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03669ecf-7063-4101-b6da-bc5d59a3898e_988x422.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I told myself that I&#8217;d make an attempt to post explanations for interesting things on a monthly basis &#8211; but let&#8217;s face it, accomplishing that given my current work-load is going to be difficult, so in instances where I can&#8217;t meet this deadline, I&#8217;m simply going to post my own notes on interesting topics that I&#8217;ve read on Hacker news and other various tech outlets. </p><p>Noting this, here are some of my favorite articles from Hacker news which I&#8217;ve made notes on over the last month.</p><div><hr></div><h3><strong>Reflections on OpenAI</strong></h3><p><strong>Kevin French-Owen </strong>(a former OpenAI employee) makes some notes on what his experience was while working for OpenAI which can be <a href="https://calv.info/openai-reflections">found here</a>, and some special items of note which every company can learn from are provided below:</p><ul><li><p>The company has grown rapidly from 2024 (from 1,000 to 3,000 employees).</p></li><li><p>Organization started off more like <strong>Los Alamos</strong> (many different projects and directions along with researchers <strong>probing the cutting edge of science</strong>) and one group happened to have accidental spawned the most viral consumer app in history (ChatGPT).</p></li><li><p>Everything there runs on Slack (there is no email) so the <strong>communication is very open </strong>within the org.</p></li><li><p>There is no road-map and everything is <strong>bottom-up </strong>rather than top-down: good ideas come out of anywhere.</p></li><li><p>Rather than having a master plan, <strong>progress is iterative and uncovered as new research is done</strong>.</p></li><li><p>Very meritocratic culture (best ideas tend to win) and a <strong>strong bias for action </strong>(you <strong>don&#8217;t need to ask for permission</strong> &#8211; you just get things done).</p></li><li><p>Strong bias to just &#8216;work on your own thing&#8217; and see if it pans out and each researcher is treated as a &#8216;mini-executive&#8217; (i.e. they decide what they work on).</p></li><li><p>The company <strong>changes direction quickly</strong> and this is valued a lot.</p></li><li><p>They value doing the right thing rather than trying to stay &#8216;on course&#8217; and use new information to steer the project in the right direction &#8211; if new information shows that the strategy or plan needs to change, then it&#8217;s changed.</p></li><li><p>They pay attention what is happening at other companies who are also attempting to tackle AGI (like Google, Meta, Anthropic) and they are pretty sure the other companies are also paying attention to them.</p></li><li><p>They have extraordinarily high GPU costs and everything else pales in comparison (not a really huge surprise).</p></li><li><p>They are <strong>incredibly ambitious</strong> in what they want to accomplish. You&#8217;d think that coming up with ChatGPT would deter them a bit, but they have plans to dominate / succeed in other areas as well.</p></li><li><p><strong>Teams are extremely fluid. </strong>If something needs to get done, team member from other teams can easily be on-boarded and brought into the new team (as an example, 2 members of the ChatGPT team joined the Codex team when they needed to hit a launch date).</p></li><li><p><strong>Leadership is quite visibly and heavily involved</strong> (i.e. every exec was dialed in and communicating with the rest of the team on Slack).</p></li><li><p>The team uses a giant monorepo to host the code, and most of the code is written in Python. Everything is run on Azure.</p></li><li><p>They have a lot of members which they brought over from Meta / Instagram and their early infra also resembles Meta.</p></li><li><p>&#8216;Most ideas start out as small-scale experiments. If the results look promising, they then get incorporated into a bigger run.&#8217;</p></li><li><p>Author notes and writes about sleepless nights where he had to work frantically prior to codex launch to make the project happen and on schedule (i.e. <strong>they move fast and work hard to make things happen</strong>).</p></li></ul><p>The original article goes into much more detail than I did above, but I figured that I&#8217;d share some of the key highlights that I made note of. Overall, OpenAI is more like a very driven and very ambitious research lab running decentralized teams that are given freedom to take rapid action and work on interesting and ambitious projects. They also prefer to take actions and ship things quickly, and they made some really smart decisions on the infrastructure side as well which I think greatly helped them out. </p><div><hr></div><h3><strong>How does diffusion / CLIP (AI driven image / video generation) work?</strong></h3><p><a href="https://www.youtube.com/@3blue1brown">3Blue1Brown </a>(my favorite math Youtuber) and <a href="https://www.youtube.com/@WelchLabsVideo">Welch Labs</a> collaborated together to produce a masterpiece which describes the gist of how diffusion and video generation models (like CLIP) work and you can find their excellent <a href="https://www.youtube.com/watch?v=iv-5mZ_9CPY">explanation here</a>.</p><p>For anyone who wants a very high-level summary, it&#8217;s provided below:</p><ul><li><p>In February 2021, a team at OpenAI released a new model architecture called clip. It trained on a data-set of 400 million image + caption pairs scraped directly from the internet.</p></li><li><p>Clip is composed of 2 models &#8211; one that processes text and the other that processes images. The output of each of these 2 models is a vector of length 512.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!J4Y4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03669ecf-7063-4101-b6da-bc5d59a3898e_988x422.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!J4Y4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03669ecf-7063-4101-b6da-bc5d59a3898e_988x422.png 424w, https://substackcdn.com/image/fetch/$s_!J4Y4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03669ecf-7063-4101-b6da-bc5d59a3898e_988x422.png 848w, https://substackcdn.com/image/fetch/$s_!J4Y4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03669ecf-7063-4101-b6da-bc5d59a3898e_988x422.png 1272w, https://substackcdn.com/image/fetch/$s_!J4Y4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03669ecf-7063-4101-b6da-bc5d59a3898e_988x422.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!J4Y4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03669ecf-7063-4101-b6da-bc5d59a3898e_988x422.png" width="988" height="422" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/03669ecf-7063-4101-b6da-bc5d59a3898e_988x422.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:422,&quot;width&quot;:988,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:718900,&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://photonlines.substack.com/i/169410814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03669ecf-7063-4101-b6da-bc5d59a3898e_988x422.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_!J4Y4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03669ecf-7063-4101-b6da-bc5d59a3898e_988x422.png 424w, https://substackcdn.com/image/fetch/$s_!J4Y4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03669ecf-7063-4101-b6da-bc5d59a3898e_988x422.png 848w, https://substackcdn.com/image/fetch/$s_!J4Y4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03669ecf-7063-4101-b6da-bc5d59a3898e_988x422.png 1272w, https://substackcdn.com/image/fetch/$s_!J4Y4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03669ecf-7063-4101-b6da-bc5d59a3898e_988x422.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></figure></div><p></p></li><li><p>In essence, the encoded text and image are supposed to be &#8216;similar.&#8217; That way, the images could be associated with the textual encoding / representation.</p></li><li><p>To ensure that the 512 dimensional vectors are similar, OpenAI used a clever approach: it used a cosine similarity metric (i.e. it took the cosine of each text / image vector and attempted to maximize it).</p></li><li><p>To get an intuition of how cosine similarity works, you can use the image 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_!SZB7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69d15862-7ea6-4bec-8f7c-eb56a09ca7e0_823x608.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SZB7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69d15862-7ea6-4bec-8f7c-eb56a09ca7e0_823x608.png 424w, https://substackcdn.com/image/fetch/$s_!SZB7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69d15862-7ea6-4bec-8f7c-eb56a09ca7e0_823x608.png 848w, https://substackcdn.com/image/fetch/$s_!SZB7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69d15862-7ea6-4bec-8f7c-eb56a09ca7e0_823x608.png 1272w, https://substackcdn.com/image/fetch/$s_!SZB7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69d15862-7ea6-4bec-8f7c-eb56a09ca7e0_823x608.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SZB7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69d15862-7ea6-4bec-8f7c-eb56a09ca7e0_823x608.png" width="492" height="363.47023086269746" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/69d15862-7ea6-4bec-8f7c-eb56a09ca7e0_823x608.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:608,&quot;width&quot;:823,&quot;resizeWidth&quot;:492,&quot;bytes&quot;:152979,&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://photonlines.substack.com/i/169410814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69d15862-7ea6-4bec-8f7c-eb56a09ca7e0_823x608.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_!SZB7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69d15862-7ea6-4bec-8f7c-eb56a09ca7e0_823x608.png 424w, https://substackcdn.com/image/fetch/$s_!SZB7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69d15862-7ea6-4bec-8f7c-eb56a09ca7e0_823x608.png 848w, https://substackcdn.com/image/fetch/$s_!SZB7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69d15862-7ea6-4bec-8f7c-eb56a09ca7e0_823x608.png 1272w, https://substackcdn.com/image/fetch/$s_!SZB7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69d15862-7ea6-4bec-8f7c-eb56a09ca7e0_823x608.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></figure></div><p></p><p>You should be able to notice that in the above vector space, the image for cat points in the same direction of the textual representation: and thus the cosine between their vectors is 1 and thus maximizing the cosine similarity between each image and text was done while the opposite was true for <strong>non-matching and contrasting </strong>image / text pairs: in those instances, the model tried to minimize the cosine similarity (thus attempting to represent dissimilar data as being &#8216;distant&#8217; from the original vectors in that space).</p></li><li><p>In the below image, you can see 3 image / text pairs and the <strong>diagonals</strong> within the matrix which contain the matching image and text info align (i.e. have a high cosine similarity) while the non-diagonal entries (non-matching image &amp; text) have a more distant similarity score:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_qGS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b5837b7-17cd-41c0-9c4b-f0d2ac926b78_997x676.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_qGS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b5837b7-17cd-41c0-9c4b-f0d2ac926b78_997x676.png 424w, https://substackcdn.com/image/fetch/$s_!_qGS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b5837b7-17cd-41c0-9c4b-f0d2ac926b78_997x676.png 848w, https://substackcdn.com/image/fetch/$s_!_qGS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b5837b7-17cd-41c0-9c4b-f0d2ac926b78_997x676.png 1272w, https://substackcdn.com/image/fetch/$s_!_qGS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b5837b7-17cd-41c0-9c4b-f0d2ac926b78_997x676.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_qGS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b5837b7-17cd-41c0-9c4b-f0d2ac926b78_997x676.png" width="997" height="676" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0b5837b7-17cd-41c0-9c4b-f0d2ac926b78_997x676.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:676,&quot;width&quot;:997,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:594297,&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://photonlines.substack.com/i/169410814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b5837b7-17cd-41c0-9c4b-f0d2ac926b78_997x676.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_!_qGS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b5837b7-17cd-41c0-9c4b-f0d2ac926b78_997x676.png 424w, https://substackcdn.com/image/fetch/$s_!_qGS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b5837b7-17cd-41c0-9c4b-f0d2ac926b78_997x676.png 848w, https://substackcdn.com/image/fetch/$s_!_qGS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b5837b7-17cd-41c0-9c4b-f0d2ac926b78_997x676.png 1272w, https://substackcdn.com/image/fetch/$s_!_qGS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b5837b7-17cd-41c0-9c4b-f0d2ac926b78_997x676.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></figure></div><p></p></li><li><p>The learned geometry of this shared vector space has some <strong>really interesting properties. </strong>Let&#8217;s say that someone takes one image of themselves not wearing a hat, and then right after putting a hat on, takes another image of them wearing a hat &#8211; and pass both of these into our image model. In the result set, we get 2 separate 512 dimensional vectors in our embedding space. Now...if you take the vector of that someone wearing a hat and subtract it from the image of them not wearing a hat, we get a new vector in that embedding space.</p><p>Now &#8211; you think to yourself &#8211; what text might this vector correspond to? <strong>Yes &#8211; the vector we get from performing the above operation is the encoding of a &#8216;hat&#8217; (with the 2<sup>nd</sup> most similar word being &#8216;cap&#8217;)!!!</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!S9JZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42afa7ad-d76b-4aa5-a421-c04abde4c509_917x441.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!S9JZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42afa7ad-d76b-4aa5-a421-c04abde4c509_917x441.png 424w, https://substackcdn.com/image/fetch/$s_!S9JZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42afa7ad-d76b-4aa5-a421-c04abde4c509_917x441.png 848w, https://substackcdn.com/image/fetch/$s_!S9JZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42afa7ad-d76b-4aa5-a421-c04abde4c509_917x441.png 1272w, https://substackcdn.com/image/fetch/$s_!S9JZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42afa7ad-d76b-4aa5-a421-c04abde4c509_917x441.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!S9JZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42afa7ad-d76b-4aa5-a421-c04abde4c509_917x441.png" width="917" height="441" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/42afa7ad-d76b-4aa5-a421-c04abde4c509_917x441.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:441,&quot;width&quot;:917,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:120094,&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://photonlines.substack.com/i/169410814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42afa7ad-d76b-4aa5-a421-c04abde4c509_917x441.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_!S9JZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42afa7ad-d76b-4aa5-a421-c04abde4c509_917x441.png 424w, https://substackcdn.com/image/fetch/$s_!S9JZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42afa7ad-d76b-4aa5-a421-c04abde4c509_917x441.png 848w, https://substackcdn.com/image/fetch/$s_!S9JZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42afa7ad-d76b-4aa5-a421-c04abde4c509_917x441.png 1272w, https://substackcdn.com/image/fetch/$s_!S9JZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42afa7ad-d76b-4aa5-a421-c04abde4c509_917x441.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></figure></div><p></p></li><li><p>In essence, CLIP gives us an excellent way of encoding a shared representation of image and text. However, CLIP only gives us a way of embedding our original image / text data into a shared embedding space <strong>in one direction. </strong>We have no way of generating actual image / text from our resulting embedding space / vectors.</p></li><li><p>A few weeks after GPT3 came out, a team at Berkeley came out with a paper called <strong>Denoising Diffusion Probabilistic Models (known as DDPM). </strong>The core idea behind these models is pretty straight forward:</p><ul><li><p>You take a set of training images and you add noise to the images in a step-by-step manner until the image is completely destroyed:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GH-p!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c8d6c6d-576d-4597-8998-b6195ee8074f_920x192.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GH-p!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c8d6c6d-576d-4597-8998-b6195ee8074f_920x192.png 424w, https://substackcdn.com/image/fetch/$s_!GH-p!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c8d6c6d-576d-4597-8998-b6195ee8074f_920x192.png 848w, https://substackcdn.com/image/fetch/$s_!GH-p!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c8d6c6d-576d-4597-8998-b6195ee8074f_920x192.png 1272w, https://substackcdn.com/image/fetch/$s_!GH-p!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c8d6c6d-576d-4597-8998-b6195ee8074f_920x192.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GH-p!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c8d6c6d-576d-4597-8998-b6195ee8074f_920x192.png" width="920" height="192" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6c8d6c6d-576d-4597-8998-b6195ee8074f_920x192.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:192,&quot;width&quot;:920,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:318221,&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://photonlines.substack.com/i/169410814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c8d6c6d-576d-4597-8998-b6195ee8074f_920x192.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_!GH-p!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c8d6c6d-576d-4597-8998-b6195ee8074f_920x192.png 424w, https://substackcdn.com/image/fetch/$s_!GH-p!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c8d6c6d-576d-4597-8998-b6195ee8074f_920x192.png 848w, https://substackcdn.com/image/fetch/$s_!GH-p!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c8d6c6d-576d-4597-8998-b6195ee8074f_920x192.png 1272w, https://substackcdn.com/image/fetch/$s_!GH-p!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c8d6c6d-576d-4597-8998-b6195ee8074f_920x192.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p></li><li><p>From here, we create a neural network to reverse this process (and regenerate the original image) and the neural network is asked to do this <strong>in one step</strong>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Ixes!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52746fed-0bf0-4860-a320-a465e680610c_882x310.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Ixes!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52746fed-0bf0-4860-a320-a465e680610c_882x310.png 424w, https://substackcdn.com/image/fetch/$s_!Ixes!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52746fed-0bf0-4860-a320-a465e680610c_882x310.png 848w, https://substackcdn.com/image/fetch/$s_!Ixes!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52746fed-0bf0-4860-a320-a465e680610c_882x310.png 1272w, https://substackcdn.com/image/fetch/$s_!Ixes!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52746fed-0bf0-4860-a320-a465e680610c_882x310.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Ixes!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52746fed-0bf0-4860-a320-a465e680610c_882x310.png" width="882" height="310" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/52746fed-0bf0-4860-a320-a465e680610c_882x310.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:310,&quot;width&quot;:882,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:415891,&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://photonlines.substack.com/i/169410814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52746fed-0bf0-4860-a320-a465e680610c_882x310.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_!Ixes!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52746fed-0bf0-4860-a320-a465e680610c_882x310.png 424w, https://substackcdn.com/image/fetch/$s_!Ixes!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52746fed-0bf0-4860-a320-a465e680610c_882x310.png 848w, https://substackcdn.com/image/fetch/$s_!Ixes!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52746fed-0bf0-4860-a320-a465e680610c_882x310.png 1272w, https://substackcdn.com/image/fetch/$s_!Ixes!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52746fed-0bf0-4860-a320-a465e680610c_882x310.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></figure></div><p></p></li></ul></li><li><p><strong>The surprise? </strong>The neural network which is trained and which produces the output doesn&#8217;t just attempt to create the final output vector &#8211; <strong>random noise / steps are added to the final image as well (which produces much better results).</strong></p></li><li><p>You can think of the first step of adding noise to a diffusion model as being similar to Brownian motion (i.e. a random walk) across our image space. Each image point is distributed across the image randomly in a step by step manner (and in a random direction). In the below example, we show a spiral image and a sample of where 1 point may go through after taking 100 random steps:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4BEm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80af5e13-8ff7-4dfa-89e0-8c8156103418_845x591.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4BEm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80af5e13-8ff7-4dfa-89e0-8c8156103418_845x591.png 424w, https://substackcdn.com/image/fetch/$s_!4BEm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80af5e13-8ff7-4dfa-89e0-8c8156103418_845x591.png 848w, https://substackcdn.com/image/fetch/$s_!4BEm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80af5e13-8ff7-4dfa-89e0-8c8156103418_845x591.png 1272w, https://substackcdn.com/image/fetch/$s_!4BEm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80af5e13-8ff7-4dfa-89e0-8c8156103418_845x591.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4BEm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80af5e13-8ff7-4dfa-89e0-8c8156103418_845x591.png" width="619" height="432.9337278106509" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/80af5e13-8ff7-4dfa-89e0-8c8156103418_845x591.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:591,&quot;width&quot;:845,&quot;resizeWidth&quot;:619,&quot;bytes&quot;:68581,&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://photonlines.substack.com/i/169410814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80af5e13-8ff7-4dfa-89e0-8c8156103418_845x591.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_!4BEm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80af5e13-8ff7-4dfa-89e0-8c8156103418_845x591.png 424w, https://substackcdn.com/image/fetch/$s_!4BEm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80af5e13-8ff7-4dfa-89e0-8c8156103418_845x591.png 848w, https://substackcdn.com/image/fetch/$s_!4BEm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80af5e13-8ff7-4dfa-89e0-8c8156103418_845x591.png 1272w, https://substackcdn.com/image/fetch/$s_!4BEm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80af5e13-8ff7-4dfa-89e0-8c8156103418_845x591.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></figure></div><p></p></li><li><p>Our model in essence will see many random walks starting from our original image &#8211; and we&#8217;re essentially asking it to reverse the clock. How can our model learn to do this though? Our &#8216;walks&#8217; are random after all?</p></li><li><p>The essence is that our model <strong>is NOT trying to </strong>actually predict<strong> </strong>the <strong>actual diffusion paths (i.e. Brownian motions)</strong> which took place within our model (i.e. steps 100, 99, 98, .... 3, 2, 1, 0) &#8211; the model instead tries to predict the total noise added across the <strong>entire image </strong>(i.e. the neural network must predict the step from 100 -&gt; 0 in one 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_!840N!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be48c02-13e7-47b1-9eea-a43e561954b1_903x417.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!840N!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be48c02-13e7-47b1-9eea-a43e561954b1_903x417.png 424w, https://substackcdn.com/image/fetch/$s_!840N!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be48c02-13e7-47b1-9eea-a43e561954b1_903x417.png 848w, https://substackcdn.com/image/fetch/$s_!840N!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be48c02-13e7-47b1-9eea-a43e561954b1_903x417.png 1272w, https://substackcdn.com/image/fetch/$s_!840N!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be48c02-13e7-47b1-9eea-a43e561954b1_903x417.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!840N!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be48c02-13e7-47b1-9eea-a43e561954b1_903x417.png" width="634" height="292.77740863787375" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9be48c02-13e7-47b1-9eea-a43e561954b1_903x417.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:417,&quot;width&quot;:903,&quot;resizeWidth&quot;:634,&quot;bytes&quot;:100570,&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://photonlines.substack.com/i/169410814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be48c02-13e7-47b1-9eea-a43e561954b1_903x417.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_!840N!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be48c02-13e7-47b1-9eea-a43e561954b1_903x417.png 424w, https://substackcdn.com/image/fetch/$s_!840N!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be48c02-13e7-47b1-9eea-a43e561954b1_903x417.png 848w, https://substackcdn.com/image/fetch/$s_!840N!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be48c02-13e7-47b1-9eea-a43e561954b1_903x417.png 1272w, https://substackcdn.com/image/fetch/$s_!840N!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be48c02-13e7-47b1-9eea-a43e561954b1_903x417.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></figure></div><p></p></li><li><p>In essence, what this means is that for each point in our resulting space (after we&#8217;ve added our noise / diffusion), our neural network learns the vector or set of vectors pointing back to the original data distribution and this is extremely valuable information to have &#8211; we can grok the general resulting vector field produced by the neural network by looking at the image below (where the neural-network learns to reconstruct the spiral after adding random noise to each point in the spiral image).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gabH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b81c096-0183-439a-bc29-74ade9ec5d6c_827x597.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gabH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b81c096-0183-439a-bc29-74ade9ec5d6c_827x597.png 424w, https://substackcdn.com/image/fetch/$s_!gabH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b81c096-0183-439a-bc29-74ade9ec5d6c_827x597.png 848w, https://substackcdn.com/image/fetch/$s_!gabH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b81c096-0183-439a-bc29-74ade9ec5d6c_827x597.png 1272w, https://substackcdn.com/image/fetch/$s_!gabH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b81c096-0183-439a-bc29-74ade9ec5d6c_827x597.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gabH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b81c096-0183-439a-bc29-74ade9ec5d6c_827x597.png" width="571" height="412.1970979443773" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1b81c096-0183-439a-bc29-74ade9ec5d6c_827x597.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:597,&quot;width&quot;:827,&quot;resizeWidth&quot;:571,&quot;bytes&quot;:165868,&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://photonlines.substack.com/i/169410814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b81c096-0183-439a-bc29-74ade9ec5d6c_827x597.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_!gabH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b81c096-0183-439a-bc29-74ade9ec5d6c_827x597.png 424w, https://substackcdn.com/image/fetch/$s_!gabH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b81c096-0183-439a-bc29-74ade9ec5d6c_827x597.png 848w, https://substackcdn.com/image/fetch/$s_!gabH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b81c096-0183-439a-bc29-74ade9ec5d6c_827x597.png 1272w, https://substackcdn.com/image/fetch/$s_!gabH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b81c096-0183-439a-bc29-74ade9ec5d6c_827x597.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></figure></div><p></p></li><li><p>An interesting phenomenon occurs after a large number of random steps are added to the model: a &#8216;phase transition&#8217; occurs where the vector field which points back to our original image stops pointing towards <strong>the center of the original image and starts pointing to the actual / original image itself. </strong>In other words &#8211; adding noise plays a huge role in making sure that our model works.</p></li><li><p>In a similar manner, when attempting to reconstruct the original image &#8211; <strong>adding noise plays a vital role in the reverse direction as well!! </strong>Let&#8217;s go through an example:</p><ul><li><p>Let&#8217;s say that we attempt to model a spiral after 100 steps (using our diffusion model).</p></li><li><p>If we don&#8217;t add noise as we try to predict where our point will land &#8211; we end up with each resulting point taking a walk back to <strong>around the center of our original image. </strong>As a result &#8211; in the below image we show what the neural network reconstructs:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gNUZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f88de6a-f9ee-49f1-ae0f-911f82603a63_718x487.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gNUZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f88de6a-f9ee-49f1-ae0f-911f82603a63_718x487.png 424w, https://substackcdn.com/image/fetch/$s_!gNUZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f88de6a-f9ee-49f1-ae0f-911f82603a63_718x487.png 848w, https://substackcdn.com/image/fetch/$s_!gNUZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f88de6a-f9ee-49f1-ae0f-911f82603a63_718x487.png 1272w, https://substackcdn.com/image/fetch/$s_!gNUZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f88de6a-f9ee-49f1-ae0f-911f82603a63_718x487.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gNUZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f88de6a-f9ee-49f1-ae0f-911f82603a63_718x487.png" width="718" height="487" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5f88de6a-f9ee-49f1-ae0f-911f82603a63_718x487.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:487,&quot;width&quot;:718,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:44376,&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://photonlines.substack.com/i/169410814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f88de6a-f9ee-49f1-ae0f-911f82603a63_718x487.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_!gNUZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f88de6a-f9ee-49f1-ae0f-911f82603a63_718x487.png 424w, https://substackcdn.com/image/fetch/$s_!gNUZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f88de6a-f9ee-49f1-ae0f-911f82603a63_718x487.png 848w, https://substackcdn.com/image/fetch/$s_!gNUZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f88de6a-f9ee-49f1-ae0f-911f82603a63_718x487.png 1272w, https://substackcdn.com/image/fetch/$s_!gNUZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f88de6a-f9ee-49f1-ae0f-911f82603a63_718x487.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></figure></div><p></p></li><li><p>You should be able to notice that the end result doesn&#8217;t really resemble our original image but instead re-constructs a small cluster of points near the center of our image. </p></li><li><p>To enable the model to re-construct the essence of the original image &#8211; this is why <strong>random noise is added</strong> as the model attempts to walk each of the resulting Brownian points back: the randomness ensures that each point is walked back to a more broad representation located within our phase space.</p></li><li><p>In the example below, one sample point is shown and the walk back is given random directions / transitions which results in the point being located away from our center points within our original image:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!cRFU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6f50937-8182-4275-8bfb-00ab576b7c31_853x622.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cRFU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6f50937-8182-4275-8bfb-00ab576b7c31_853x622.png 424w, https://substackcdn.com/image/fetch/$s_!cRFU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6f50937-8182-4275-8bfb-00ab576b7c31_853x622.png 848w, https://substackcdn.com/image/fetch/$s_!cRFU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6f50937-8182-4275-8bfb-00ab576b7c31_853x622.png 1272w, https://substackcdn.com/image/fetch/$s_!cRFU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6f50937-8182-4275-8bfb-00ab576b7c31_853x622.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cRFU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6f50937-8182-4275-8bfb-00ab576b7c31_853x622.png" width="613" height="446.99413833528723" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f6f50937-8182-4275-8bfb-00ab576b7c31_853x622.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:622,&quot;width&quot;:853,&quot;resizeWidth&quot;:613,&quot;bytes&quot;:151170,&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://photonlines.substack.com/i/169410814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6f50937-8182-4275-8bfb-00ab576b7c31_853x622.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_!cRFU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6f50937-8182-4275-8bfb-00ab576b7c31_853x622.png 424w, https://substackcdn.com/image/fetch/$s_!cRFU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6f50937-8182-4275-8bfb-00ab576b7c31_853x622.png 848w, https://substackcdn.com/image/fetch/$s_!cRFU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6f50937-8182-4275-8bfb-00ab576b7c31_853x622.png 1272w, https://substackcdn.com/image/fetch/$s_!cRFU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6f50937-8182-4275-8bfb-00ab576b7c31_853x622.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></figure></div><p></p></li><li><p>Adding this noise is vitally important: once again, it ensures that the model walks back each point and distributes it along our spiral (instead of focusing each one within the center of the image (or towards the &#8216;mean&#8217; of our image)). Although the result may look chaotic, the final mapping shows a much more representative &#8216;image&#8217; of our original sample:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!m7T4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff09276b9-b62e-4f7c-afab-bd220dafb8ac_752x688.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!m7T4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff09276b9-b62e-4f7c-afab-bd220dafb8ac_752x688.png 424w, https://substackcdn.com/image/fetch/$s_!m7T4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff09276b9-b62e-4f7c-afab-bd220dafb8ac_752x688.png 848w, https://substackcdn.com/image/fetch/$s_!m7T4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff09276b9-b62e-4f7c-afab-bd220dafb8ac_752x688.png 1272w, https://substackcdn.com/image/fetch/$s_!m7T4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff09276b9-b62e-4f7c-afab-bd220dafb8ac_752x688.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!m7T4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff09276b9-b62e-4f7c-afab-bd220dafb8ac_752x688.png" width="523" height="478.48936170212767" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f09276b9-b62e-4f7c-afab-bd220dafb8ac_752x688.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:688,&quot;width&quot;:752,&quot;resizeWidth&quot;:523,&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_!m7T4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff09276b9-b62e-4f7c-afab-bd220dafb8ac_752x688.png 424w, https://substackcdn.com/image/fetch/$s_!m7T4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff09276b9-b62e-4f7c-afab-bd220dafb8ac_752x688.png 848w, https://substackcdn.com/image/fetch/$s_!m7T4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff09276b9-b62e-4f7c-afab-bd220dafb8ac_752x688.png 1272w, https://substackcdn.com/image/fetch/$s_!m7T4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff09276b9-b62e-4f7c-afab-bd220dafb8ac_752x688.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></figure></div><p></p></li></ul></li><li><p>Although the above procedure produced fantastic results &#8211; the amount of compute needed to generate the models was large and a Google team found a way to simplify the above process (without the need to add random noise).</p></li><li><p>To simplify the model, the team turned the original model (modelled by something called a stochastic differential equation which models noise / randomness) into an ordinary differential equation which was equivalent. ODEs ordinary differential equations are much simpler to solve. The change in model allowed their team to lower the amount of compute needed to train the model thus lowering the amount of steps the model needed to take to generate each original image.</p></li><li><p>In 2022 &#8211; another breakthrough at OpenAI occurred. Using textual data &#8211; it was able to produce models which generated outstanding images (which represented the embedded textual information):</p><ul><li><p>The model first encoded the textual information into a text encoder which transformed the info into a high-dimensional embedding vector.</p></li><li><p>A diffusion model took that embedding vector and was used to generate an image (or a video) of what the prompt / text describes.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ALUq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F746f62da-5b9e-4bf9-b309-1ad1737ddf04_827x418.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ALUq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F746f62da-5b9e-4bf9-b309-1ad1737ddf04_827x418.png 424w, https://substackcdn.com/image/fetch/$s_!ALUq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F746f62da-5b9e-4bf9-b309-1ad1737ddf04_827x418.png 848w, https://substackcdn.com/image/fetch/$s_!ALUq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F746f62da-5b9e-4bf9-b309-1ad1737ddf04_827x418.png 1272w, https://substackcdn.com/image/fetch/$s_!ALUq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F746f62da-5b9e-4bf9-b309-1ad1737ddf04_827x418.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ALUq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F746f62da-5b9e-4bf9-b309-1ad1737ddf04_827x418.png" width="827" height="418" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/746f62da-5b9e-4bf9-b309-1ad1737ddf04_827x418.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:418,&quot;width&quot;:827,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:585641,&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://photonlines.substack.com/i/169410814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F746f62da-5b9e-4bf9-b309-1ad1737ddf04_827x418.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_!ALUq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F746f62da-5b9e-4bf9-b309-1ad1737ddf04_827x418.png 424w, https://substackcdn.com/image/fetch/$s_!ALUq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F746f62da-5b9e-4bf9-b309-1ad1737ddf04_827x418.png 848w, https://substackcdn.com/image/fetch/$s_!ALUq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F746f62da-5b9e-4bf9-b309-1ad1737ddf04_827x418.png 1272w, https://substackcdn.com/image/fetch/$s_!ALUq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F746f62da-5b9e-4bf9-b309-1ad1737ddf04_827x418.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></figure></div><p></p></li></ul></li><li><p>The resulting model is known today as DOLL-E 2 &#8211; but there&#8217;s one more step they took in order to make the idea work so the process isn&#8217;t quite as simple as what we outlined above. In order to generate the image / video, the model they produced uses something called classifier free guidance.</p></li></ul><p>We won&#8217;t go into the full details here, but you should watch the entire video if you want a more in-depth overview as the video in general is outstanding and does a much better job in explaining the nuances of how these models work.</p><p>Overall, outstanding video once again by Grand Sanderson (3Blue1Brown) and Welch Labs &#8211; full credit goes to them for all of the content above (as well as the images).</p><div><hr></div><h3><strong>Hidden Controls: Lamenting Against Today&#8217;s Bad UI Usability</strong></h3><p>The world today is <strong>full of bad software</strong>. I&#8217;m not going to go into the details on the exact reason why I hate modern interfaces, but the below article identifies one of the key reasons I hate most of them: the <strong>HIDDEN CONTROLS</strong>!!</p><p><a href="https://interactions.acm.org/archive/view/july-august-2025/stop-hiding-my-controls-hidden-interface-controls-are-affecting-usability?utm_source=hackernewsletter&amp;utm_medium=email&amp;utm_term=design">Stop Hiding My Controls: Hidden Interface Controls Are Affecting Usability</a></p><p>Making controls visible was something that was highly touted by Douglas Engelbart (an early pioneer and legend within the world of UI design). Human memory is fallible so making things recognizable rather than asking your users to recall information should be part of every great UI design; or at least that&#8217;s the gist that needs to be taught and re-taught to modern designers and developers.</p><p>In the modern era, computing tasks require a significant amount of knowledge that&#8217;s not simply recalled. This is the reason why most users don&#8217;t love command lines: you need to use memory (i..e. recall) more than recognition, and it&#8217;s one of the reasons why many people prefer the modern desktop experience. Rather than typing things into a terminal, you don&#8217;t need to think as hard when using a desktop UI: it makes finding information a breeze by easing the memory burden on you (i.e. by using folders and other metaphors to aid your recall). In the early days, UI specialists knew this and recognized that providing aids to people&#8217;s recall / memories helped non-specialist users use it more easily (and thus made computing accessible to almost everyone).</p><p>Let&#8217;s fast forward 40 years. Using a phone flash-light isn&#8217;t very intuitive. You have to swipe-down (since this action isn&#8217;t broadly visible to most users &#8211; nor is its location really intuitive) &#8212; discovering this feature is a royal pain in the a**. Another example is Apple Maps in CarPlay requires you to tap on a button located on the bottom left of the screen (which brings up a search option) and this 1) isn&#8217;t very usable nor 2) intuitive at all.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nM81!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4cbfcd1-bc53-4ba1-bc63-990885025acb_670x740.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nM81!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4cbfcd1-bc53-4ba1-bc63-990885025acb_670x740.png 424w, https://substackcdn.com/image/fetch/$s_!nM81!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4cbfcd1-bc53-4ba1-bc63-990885025acb_670x740.png 848w, https://substackcdn.com/image/fetch/$s_!nM81!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4cbfcd1-bc53-4ba1-bc63-990885025acb_670x740.png 1272w, https://substackcdn.com/image/fetch/$s_!nM81!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4cbfcd1-bc53-4ba1-bc63-990885025acb_670x740.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nM81!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4cbfcd1-bc53-4ba1-bc63-990885025acb_670x740.png" width="514" height="567.7014925373135" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c4cbfcd1-bc53-4ba1-bc63-990885025acb_670x740.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:740,&quot;width&quot;:670,&quot;resizeWidth&quot;:514,&quot;bytes&quot;:845546,&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://photonlines.substack.com/i/169410814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4cbfcd1-bc53-4ba1-bc63-990885025acb_670x740.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_!nM81!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4cbfcd1-bc53-4ba1-bc63-990885025acb_670x740.png 424w, https://substackcdn.com/image/fetch/$s_!nM81!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4cbfcd1-bc53-4ba1-bc63-990885025acb_670x740.png 848w, https://substackcdn.com/image/fetch/$s_!nM81!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4cbfcd1-bc53-4ba1-bc63-990885025acb_670x740.png 1272w, https://substackcdn.com/image/fetch/$s_!nM81!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4cbfcd1-bc53-4ba1-bc63-990885025acb_670x740.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></figure></div><p></p><p>This lack of usability is present everywhere today and most software systems are getting worse.</p><p>A major source of hidden controls being everywhere is the number of features that are being shipped with modern software: the need for more functionality within modern systems seems to require us to free up screen space to accommodate all of the visible controls, but designers shouldn&#8217;t use this as an excuse: you can still create great software that keeps the key functionality visible and the myriad of options more easy to discover.</p><p>As an example, the General Motors&#8217; engineers designed an excellent map interface that balances complexity with visibility and it fixes most of the problems that are present within Apple maps interface:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OtZe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaa23a8-1026-49fa-8d2f-12e5930f4ef0_860x505.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OtZe!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaa23a8-1026-49fa-8d2f-12e5930f4ef0_860x505.png 424w, https://substackcdn.com/image/fetch/$s_!OtZe!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaa23a8-1026-49fa-8d2f-12e5930f4ef0_860x505.png 848w, https://substackcdn.com/image/fetch/$s_!OtZe!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaa23a8-1026-49fa-8d2f-12e5930f4ef0_860x505.png 1272w, https://substackcdn.com/image/fetch/$s_!OtZe!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaa23a8-1026-49fa-8d2f-12e5930f4ef0_860x505.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OtZe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaa23a8-1026-49fa-8d2f-12e5930f4ef0_860x505.png" width="538" height="315.9186046511628" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/feaa23a8-1026-49fa-8d2f-12e5930f4ef0_860x505.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:505,&quot;width&quot;:860,&quot;resizeWidth&quot;:538,&quot;bytes&quot;:560504,&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://photonlines.substack.com/i/169410814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaa23a8-1026-49fa-8d2f-12e5930f4ef0_860x505.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_!OtZe!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaa23a8-1026-49fa-8d2f-12e5930f4ef0_860x505.png 424w, https://substackcdn.com/image/fetch/$s_!OtZe!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaa23a8-1026-49fa-8d2f-12e5930f4ef0_860x505.png 848w, https://substackcdn.com/image/fetch/$s_!OtZe!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaa23a8-1026-49fa-8d2f-12e5930f4ef0_860x505.png 1272w, https://substackcdn.com/image/fetch/$s_!OtZe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaa23a8-1026-49fa-8d2f-12e5930f4ef0_860x505.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></figure></div><p></p><p>Most great software (and mission critical systems) don&#8217;t have hidden controls!! They rely on controls that are</p><ol><li><p>Visible</p></li><li><p>Persistent</p></li><li><p>Show the system state</p></li></ol><p>The key actions and functionality within any great software should abide by the 3 properties outlined above! Modern designers need to reevaluate their use of hidden controls and prioritize making modern software more usable.</p><div><hr></div><h3><strong>Why Facts Don&#8217;t Change Minds</strong></h3><p>This is just a fantastic article which goes through a fascinating model which can be used to model beliefs:</p><p><a href="https://vasily.cc/blog/facts-dont-change-minds/">https://vasily.cc/blog/facts-dont-change-minds/</a></p><p>The gist of the article is that we can visualize a belief system as a graph i.e. a &#8220;network of concepts, values, and connections&#8221; and thus, whenever you challenge something &#8211; you&#8217;re not just challenging that single &#8216;point&#8217; within the network &#8211; you&#8217;re also challenging the rest of the nodes and edges which effect the entire graph.</p><p>Challenging one point is more like challenging the foundation of a building or cathedral in other words rather than just one brick or stub which supports the building. Of course &#8211; most human beings don&#8217;t challenge the models which we believe in. Instead &#8211; we look for evidence to reinforce them and we actively ignore or dismiss the information which goes against our beliefs. This is why challenging people&#8217;s beliefs is so hard. When belief systems are challenged, the real contest isn&#8217;t just about exchanging arguments&#8212;it&#8217;s about trying to reshape the other person&#8217;s underlying foundation and structures; it&#8217;s about changing the active landscape within their mental world.</p><p>The Author uses a graph to illustrate the model of &#8216;growth-first capitalism&#8217; which is provided 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_!9MEo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F564c0545-104b-46bc-add9-f00daa45a3c0_427x877.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9MEo!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F564c0545-104b-46bc-add9-f00daa45a3c0_427x877.png 424w, https://substackcdn.com/image/fetch/$s_!9MEo!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F564c0545-104b-46bc-add9-f00daa45a3c0_427x877.png 848w, https://substackcdn.com/image/fetch/$s_!9MEo!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F564c0545-104b-46bc-add9-f00daa45a3c0_427x877.png 1272w, https://substackcdn.com/image/fetch/$s_!9MEo!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F564c0545-104b-46bc-add9-f00daa45a3c0_427x877.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9MEo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F564c0545-104b-46bc-add9-f00daa45a3c0_427x877.png" width="341" height="700.367681498829" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/564c0545-104b-46bc-add9-f00daa45a3c0_427x877.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:877,&quot;width&quot;:427,&quot;resizeWidth&quot;:341,&quot;bytes&quot;:54124,&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://photonlines.substack.com/i/169410814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F564c0545-104b-46bc-add9-f00daa45a3c0_427x877.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_!9MEo!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F564c0545-104b-46bc-add9-f00daa45a3c0_427x877.png 424w, https://substackcdn.com/image/fetch/$s_!9MEo!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F564c0545-104b-46bc-add9-f00daa45a3c0_427x877.png 848w, https://substackcdn.com/image/fetch/$s_!9MEo!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F564c0545-104b-46bc-add9-f00daa45a3c0_427x877.png 1272w, https://substackcdn.com/image/fetch/$s_!9MEo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F564c0545-104b-46bc-add9-f00daa45a3c0_427x877.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></figure></div><p></p><p>In the growth-first capitalism model, we assume that all of the connections are strong and that profits lead to more shareholder returns, which furthermore drives more investment in innovation &#8211; but this re-investment in innovation and growth isn&#8217;t necessarily true. In a lot of cases, the maximization of shareholder returns may not necessarily lead to more purchasing power for the company. The company shareholders may instead choose to instead keep the profits for themselves and to attempt to &#8216;milk&#8217; them for their own personal gain as much as possible (thus breaking the self-reinforcing graph we originally outlined):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!AUNC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8125d28-688c-40a4-bb09-033bfc7d539d_548x746.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!AUNC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8125d28-688c-40a4-bb09-033bfc7d539d_548x746.png 424w, https://substackcdn.com/image/fetch/$s_!AUNC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8125d28-688c-40a4-bb09-033bfc7d539d_548x746.png 848w, https://substackcdn.com/image/fetch/$s_!AUNC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8125d28-688c-40a4-bb09-033bfc7d539d_548x746.png 1272w, https://substackcdn.com/image/fetch/$s_!AUNC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8125d28-688c-40a4-bb09-033bfc7d539d_548x746.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!AUNC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8125d28-688c-40a4-bb09-033bfc7d539d_548x746.png" width="420" height="571.7518248175182" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e8125d28-688c-40a4-bb09-033bfc7d539d_548x746.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:746,&quot;width&quot;:548,&quot;resizeWidth&quot;:420,&quot;bytes&quot;:52308,&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://photonlines.substack.com/i/169410814?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8125d28-688c-40a4-bb09-033bfc7d539d_548x746.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_!AUNC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8125d28-688c-40a4-bb09-033bfc7d539d_548x746.png 424w, https://substackcdn.com/image/fetch/$s_!AUNC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8125d28-688c-40a4-bb09-033bfc7d539d_548x746.png 848w, https://substackcdn.com/image/fetch/$s_!AUNC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8125d28-688c-40a4-bb09-033bfc7d539d_548x746.png 1272w, https://substackcdn.com/image/fetch/$s_!AUNC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8125d28-688c-40a4-bb09-033bfc7d539d_548x746.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></figure></div><blockquote><p>&#8220;<em>Attacking the connections between ideas can force a belief system to reroute its logic, making it less direct, more convoluted, and sometimes less persuasive&#8212;even if the system doesn&#8217;t collapse outright.&#8221;</em></p></blockquote><p>The above example shows how attacking one node can completely change the model and perception of a system: invalidating one of the key assumptions can make us question whether maximizing shareholder value and going all in on &#8216;growth first capitalism&#8217; is the best thing to do given the fact that it tends to distribute wealth to a select few rather than re-investing it to benefit the many.</p><blockquote><p>&#8220;<em>So when you encounter someone whose worldview seems impenetrable, remember: you&#8217;re not just arguing with a person, you&#8217;re engaging with a living, self-stabilizing information pattern&#8212;one that is enacted and protected by the very architecture of human cognition.&#8221;</em></p></blockquote><p>The whole article and write-up is just fantastic and I highly recommend you give it a read.</p><div><hr></div><h3><strong>The Rise and Downfall of Yahoo</strong></h3><p>This <a href="https://dfarq.homeip.net/what-went-wrong-for-yahoo/">excellent article</a> does a great job of over-viewing what went wrong (and what also went right) within the rise and downfall of Yahoo:</p><ul><li><p>Started off as a website called &#8220;Jerry&#8217;s Guide to the World Wide Web&#8221; by 2 Stanford students in 1994.</p></li><li><p>Initially, it was more of a directory or portal rather than a search engine: it had categories with linked sub-categories which users could click on to find relevant web-sites.</p></li><li><p>To become a &#8216;portal&#8217; to the internet, they recognized that they needed not just to link to content &#8211; they also needed to produce it as well. To do this, they acquired other companies and started producing their own stuff. In 1996, they turned their first profit.</p></li><li><p>Between September 1997 and July 2015, Yahoo made 114 acquisitions.</p></li><li><p>Some of its acquisitions were disastrous (i.e. acquired Broadcast.com and Geocities.com for 10 billion) while some turned out to be fantastic (i.e. acquired 40% of Chinese e-commerce site Alibaba in 2005 for $1 billion which turned into a 36 billion dollar profit).</p></li><li><p>Still &#8211; their biggest blunder might have been not making 2 major acquisitions which could have radically changed the trajectory of the company:</p><ul><li><p>Yahoo had multiple opportunities to buy Google and failed to do so. In 1998, Yahoo actually turned down the opportunity to acquire Google for $1 million (currently Google has over 1 trillion in market capitalization).</p></li><li><p>Also whiffed at the opportunity to acquire Facebook in 2006 for 1.1 billion dollars (Facebook today is also a company with over 1 trillion in market cap).</p></li></ul></li><li><p>In the end, Yahoo ended up being sold to Verizon in 2016 for about 5 billion dollars (which didn&#8217;t end up working out so well for Verizon).</p></li></ul><div><hr></div><h3><strong>Layoffs at Microsoft</strong></h3><p>Microsoft announced <a href="https://www.bloomberg.com/news/articles/2025-07-02/microsoft-to-cut-9-000-workers-in-second-wave-of-major-layoffs">cuts to 9,000 workers</a> in second wave of major layoffs last month &#8211; all while watching their stock / market cap almost double in valuation just over the last 3 months. Their profit margins are also huge. Meanwhile, they&#8217;re spending a lot in bringing in <a href="https://www.myvisajobs.com/employer/microsoft/">cheaper labor from over-seas</a>. Layoffs in the good old days used to be a measure of last resort: you did it when you had to and when your company was very much unprofitable. To lay people off while you are making billions in profit is shameful. It&#8217;s an inexcusable thing to do &#8211; especially when you&#8217;re invested in a technology (an LLM called ChatGPT) that will one day replace a lot of jobs.</p><p>I remember when working for a tech-leader used to mean something. So much for that notion.</p><p>Noting that, I hope you enjoyed this monthly update.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Photon-Lines Substack is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[An Intuitive Guide to Black Holes]]></title><description><![CDATA[An intuitive and visual-focused guide to what black-holes are (primarily lead by a simple thought-experiment).]]></description><link>https://photonlines.substack.com/p/an-intuitive-guide-to-black-holes</link><guid isPermaLink="false">https://photonlines.substack.com/p/an-intuitive-guide-to-black-holes</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Sun, 06 Jul 2025 15:02:51 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!_rvW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55119078-11a5-49ea-8aca-71aa3a711bef_1494x1401.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Introduction</h2><p>Black holes are a hugely interesting topic &#8211; but many of the explanations of what they actually are are mired in complexity, and I&#8217;m not a big fan of complexity and so I decided to do a more in-depth exploration of what they actually are and what they represent. This write-up will outline exactly what black holes are (as well as what their equations mean) in a more intuitive and visual manner. Saddle up &#8211; here we go.</p><h3><strong>What in the world is a black hole?</strong></h3><p>A black hole, in simple terms, is a region in space where the escape velocity (the speed needed to break free from its gravitational pull) exceeds the speed of light.</p><p>Imagine you're throwing a ball upward. If you throw it too softly, it falls back down.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_rvW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55119078-11a5-49ea-8aca-71aa3a711bef_1494x1401.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_rvW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55119078-11a5-49ea-8aca-71aa3a711bef_1494x1401.png 424w, https://substackcdn.com/image/fetch/$s_!_rvW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55119078-11a5-49ea-8aca-71aa3a711bef_1494x1401.png 848w, https://substackcdn.com/image/fetch/$s_!_rvW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55119078-11a5-49ea-8aca-71aa3a711bef_1494x1401.png 1272w, https://substackcdn.com/image/fetch/$s_!_rvW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55119078-11a5-49ea-8aca-71aa3a711bef_1494x1401.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_rvW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55119078-11a5-49ea-8aca-71aa3a711bef_1494x1401.png" width="461" height="432.1875" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/55119078-11a5-49ea-8aca-71aa3a711bef_1494x1401.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1365,&quot;width&quot;:1456,&quot;resizeWidth&quot;:461,&quot;bytes&quot;:2379722,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55119078-11a5-49ea-8aca-71aa3a711bef_1494x1401.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_!_rvW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55119078-11a5-49ea-8aca-71aa3a711bef_1494x1401.png 424w, https://substackcdn.com/image/fetch/$s_!_rvW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55119078-11a5-49ea-8aca-71aa3a711bef_1494x1401.png 848w, https://substackcdn.com/image/fetch/$s_!_rvW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55119078-11a5-49ea-8aca-71aa3a711bef_1494x1401.png 1272w, https://substackcdn.com/image/fetch/$s_!_rvW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55119078-11a5-49ea-8aca-71aa3a711bef_1494x1401.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></figure></div><p>Throw it harder, and it goes higher &#8212; but still comes back.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jeDS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd47bf4f0-58b6-42cb-ac45-4485a8704609_1517x1445.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jeDS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd47bf4f0-58b6-42cb-ac45-4485a8704609_1517x1445.png 424w, https://substackcdn.com/image/fetch/$s_!jeDS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd47bf4f0-58b6-42cb-ac45-4485a8704609_1517x1445.png 848w, https://substackcdn.com/image/fetch/$s_!jeDS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd47bf4f0-58b6-42cb-ac45-4485a8704609_1517x1445.png 1272w, https://substackcdn.com/image/fetch/$s_!jeDS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd47bf4f0-58b6-42cb-ac45-4485a8704609_1517x1445.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jeDS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd47bf4f0-58b6-42cb-ac45-4485a8704609_1517x1445.png" width="481" height="458.20535714285717" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d47bf4f0-58b6-42cb-ac45-4485a8704609_1517x1445.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1387,&quot;width&quot;:1456,&quot;resizeWidth&quot;:481,&quot;bytes&quot;:2382927,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd47bf4f0-58b6-42cb-ac45-4485a8704609_1517x1445.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_!jeDS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd47bf4f0-58b6-42cb-ac45-4485a8704609_1517x1445.png 424w, https://substackcdn.com/image/fetch/$s_!jeDS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd47bf4f0-58b6-42cb-ac45-4485a8704609_1517x1445.png 848w, https://substackcdn.com/image/fetch/$s_!jeDS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd47bf4f0-58b6-42cb-ac45-4485a8704609_1517x1445.png 1272w, https://substackcdn.com/image/fetch/$s_!jeDS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd47bf4f0-58b6-42cb-ac45-4485a8704609_1517x1445.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></figure></div><p>There's a specific speed that you&#8217;d need to throw it so it never comes back, and that&#8217;s called the escape velocity.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dil4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22da5283-3961-4111-aeee-01b3a07ec472_2364x1535.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dil4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22da5283-3961-4111-aeee-01b3a07ec472_2364x1535.png 424w, https://substackcdn.com/image/fetch/$s_!dil4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22da5283-3961-4111-aeee-01b3a07ec472_2364x1535.png 848w, https://substackcdn.com/image/fetch/$s_!dil4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22da5283-3961-4111-aeee-01b3a07ec472_2364x1535.png 1272w, https://substackcdn.com/image/fetch/$s_!dil4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22da5283-3961-4111-aeee-01b3a07ec472_2364x1535.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dil4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22da5283-3961-4111-aeee-01b3a07ec472_2364x1535.png" width="1456" height="945" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/22da5283-3961-4111-aeee-01b3a07ec472_2364x1535.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:945,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2495522,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22da5283-3961-4111-aeee-01b3a07ec472_2364x1535.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_!dil4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22da5283-3961-4111-aeee-01b3a07ec472_2364x1535.png 424w, https://substackcdn.com/image/fetch/$s_!dil4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22da5283-3961-4111-aeee-01b3a07ec472_2364x1535.png 848w, https://substackcdn.com/image/fetch/$s_!dil4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22da5283-3961-4111-aeee-01b3a07ec472_2364x1535.png 1272w, https://substackcdn.com/image/fetch/$s_!dil4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22da5283-3961-4111-aeee-01b3a07ec472_2364x1535.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></figure></div><h3><strong>What exactly is earth&#8217;s escape velocity?</strong></h3><p>Let&#8217;s derive it. We need to use a few formulas to do this, and they&#8217;re provided below.</p><h4><strong>Gravitational Force Equation</strong></h4><p>The <strong>gravitational force</strong> F between two masses is:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hT2I!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e90f4e7-7552-4cb3-8a90-d55d59e03bef_2200x1411.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hT2I!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e90f4e7-7552-4cb3-8a90-d55d59e03bef_2200x1411.png 424w, https://substackcdn.com/image/fetch/$s_!hT2I!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e90f4e7-7552-4cb3-8a90-d55d59e03bef_2200x1411.png 848w, https://substackcdn.com/image/fetch/$s_!hT2I!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e90f4e7-7552-4cb3-8a90-d55d59e03bef_2200x1411.png 1272w, https://substackcdn.com/image/fetch/$s_!hT2I!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e90f4e7-7552-4cb3-8a90-d55d59e03bef_2200x1411.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hT2I!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e90f4e7-7552-4cb3-8a90-d55d59e03bef_2200x1411.png" width="1456" height="934" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7e90f4e7-7552-4cb3-8a90-d55d59e03bef_2200x1411.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:934,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:142975,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e90f4e7-7552-4cb3-8a90-d55d59e03bef_2200x1411.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_!hT2I!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e90f4e7-7552-4cb3-8a90-d55d59e03bef_2200x1411.png 424w, https://substackcdn.com/image/fetch/$s_!hT2I!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e90f4e7-7552-4cb3-8a90-d55d59e03bef_2200x1411.png 848w, https://substackcdn.com/image/fetch/$s_!hT2I!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e90f4e7-7552-4cb3-8a90-d55d59e03bef_2200x1411.png 1272w, https://substackcdn.com/image/fetch/$s_!hT2I!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e90f4e7-7552-4cb3-8a90-d55d59e03bef_2200x1411.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></figure></div><p>In simple terms, the above equation tells us that the gravitational (attractive) force between the 2 masses is directly proportional to their masses (the higher their masses, the stronger the force) and inversely proportional to their distance squared (the further away they are, the weaker the force).</p><p>The above equation also abides by the <strong>inverse square law. </strong>The inverse square law not only applies to the force of gravity, but many different phenomena, including the electric field, light, sound or electromagnetic or nuclear radiation, which also obey this law. The law can easily be pictured through geometric intuition by visualizing an expanding sphere, with the force being distributed throughout the surface area of the sphere. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sbhM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c591217-9d03-4b56-b072-cfa919841092_420x280.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sbhM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c591217-9d03-4b56-b072-cfa919841092_420x280.png 424w, https://substackcdn.com/image/fetch/$s_!sbhM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c591217-9d03-4b56-b072-cfa919841092_420x280.png 848w, https://substackcdn.com/image/fetch/$s_!sbhM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c591217-9d03-4b56-b072-cfa919841092_420x280.png 1272w, https://substackcdn.com/image/fetch/$s_!sbhM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c591217-9d03-4b56-b072-cfa919841092_420x280.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sbhM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c591217-9d03-4b56-b072-cfa919841092_420x280.png" width="420" height="280" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2c591217-9d03-4b56-b072-cfa919841092_420x280.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:280,&quot;width&quot;:420,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:35052,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c591217-9d03-4b56-b072-cfa919841092_420x280.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_!sbhM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c591217-9d03-4b56-b072-cfa919841092_420x280.png 424w, https://substackcdn.com/image/fetch/$s_!sbhM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c591217-9d03-4b56-b072-cfa919841092_420x280.png 848w, https://substackcdn.com/image/fetch/$s_!sbhM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c591217-9d03-4b56-b072-cfa919841092_420x280.png 1272w, https://substackcdn.com/image/fetch/$s_!sbhM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c591217-9d03-4b56-b072-cfa919841092_420x280.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></figure></div><p>In other words, the force spreads out in an ever expanding spherical shell as the sphere itself moves radially and the surface area expands by r<sup>2 </sup>and so the field gets weaker as we expand outward.</p><h4><strong>Gravitational Potential Energy</strong></h4><p>This is the energy stored between Earth&#8217;s gravitational field and our ball. It can be represented by the equation 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_!_VDo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5d60702-6356-48e2-9cf5-047a7e054e1a_2311x1315.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_VDo!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5d60702-6356-48e2-9cf5-047a7e054e1a_2311x1315.png 424w, https://substackcdn.com/image/fetch/$s_!_VDo!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5d60702-6356-48e2-9cf5-047a7e054e1a_2311x1315.png 848w, https://substackcdn.com/image/fetch/$s_!_VDo!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5d60702-6356-48e2-9cf5-047a7e054e1a_2311x1315.png 1272w, https://substackcdn.com/image/fetch/$s_!_VDo!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5d60702-6356-48e2-9cf5-047a7e054e1a_2311x1315.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_VDo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5d60702-6356-48e2-9cf5-047a7e054e1a_2311x1315.png" width="1456" height="828" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f5d60702-6356-48e2-9cf5-047a7e054e1a_2311x1315.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:828,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:94226,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5d60702-6356-48e2-9cf5-047a7e054e1a_2311x1315.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_!_VDo!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5d60702-6356-48e2-9cf5-047a7e054e1a_2311x1315.png 424w, https://substackcdn.com/image/fetch/$s_!_VDo!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5d60702-6356-48e2-9cf5-047a7e054e1a_2311x1315.png 848w, https://substackcdn.com/image/fetch/$s_!_VDo!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5d60702-6356-48e2-9cf5-047a7e054e1a_2311x1315.png 1272w, https://substackcdn.com/image/fetch/$s_!_VDo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5d60702-6356-48e2-9cf5-047a7e054e1a_2311x1315.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></figure></div><p>The negative sign shows that the ball is bound to the Earth and that gravity works to pull the objects closer. To escape, you&#8217;d need to add energy to free it. As you can probably observe, it&#8217;s extremely similar to our original gravitational force equation, and it simply outlines that the larger the distance between our 2 masses (r) &#8211; the less work we need to do in order to move our ball away from the gravitational pull that it receives from Earth. To use a more intuitive analogy, you can think of gravitational energy as &#8220;debt.&#8221; You owe the earth for being close to it and the further away you go, the smaller the debt becomes (less negative) until it finally disappears at infinity (where U would equal 0).</p><p>The negative sign means gravity traps the ball. To escape, you must repay this energy debt by giving the ball enough kinetic energy (KE) to balance the gravitational potential (U). Unlike the gravitational force (F &#8733; 1 / r<sup>2</sup>), the potential energy (F &#8733; 1 / r) weakens more slowly with distance. This is why escaping gravity requires a &#8220;lump sum&#8221; of energy upfront. In other words, to escape, you must balance this debt with kinetic energy, and that&#8217;s essentially what our escape velocity represents.</p><h3><strong>What is Energy? (The Universe&#8217;s Currency)</strong></h3><p>Energy is the "currency" of the universe &#8212; it&#8217;s what you "spend" to make anything happen. Think of it like money:</p><ul><li><p>Do you need to move something? You spend energy (muscle power) in order to move it.</p></li><li><p>Do you need to keep a light bulb on? You need to spend energy (electricity &#8211; flowing electron energy) in order to keep the light on.</p></li><li><p>Do you need to launch a rocket? You need fuel in order to put it in motion.</p></li></ul><p>Energy isn&#8217;t really anything physical &#8211; it measures your <strong>capability of doing something</strong>, and it comes in two primary forms: potential and kinetic energies.</p><h4><strong>Potential Energy: Stored "Savings"</strong></h4><p>You can think of the potential energy as the &#8220;stored&#8221; energy of our system. It represents something that&#8217;s waiting to be used and depends on the object&#8217;s position or state in whatever state-space it currently occupies. As an example, assuming that you put your baseball on a book-shelf &#8211; we can say that the object contains &#8216;potential&#8217; energy by occupying a position on this shelf: if it falls, it can displace or move another object (i.e. do work) through the action of falling from this shelf &#8211; and the higher our shelf is, the more gravitational potential energy our ball has. In other words, you can think of potential energy as money in a bank account: you might not be able to directly see it, but it&#8217;s there and it&#8217;s ready to be spent.</p><h4><strong>Kinetic Energy: Energy in Motion</strong></h4><p>Kinetic energy is the energy of movement. It depends on an object&#8217;s current speed and mass. If you throw a baseball, it&#8217;s movement represents kinetic energy. The heavier the ball is or the faster you throw it &#8211; the more kinetic energy it has. You can imagine kinetic energy as being the cash you have in your wallet: it represents energy currently being used / put to work.</p><h4><strong>Total Energy</strong></h4><p>Now, energy is constantly being swapped between the 2 key forms we outlined above, and it cannot be created nor destroyed. In other words: we need to balance our account. To put this more formally, we say that <strong>total energy is always conserved.</strong> To escape Earth in other words, a rocket (or ball) must convert its kinetic energy into &#8216;climbing&#8217; out of Earth&#8217;s gravitational &#8216;well&#8217; (potential) energy to balance the books. To escape Earth&#8217;s gravity, an object needs enough kinetic energy (cash in hand) to pay off its gravitational potential energy (debt - i.e. money owed to Earth). Let&#8217;s balance the cosmic "checkbook" step by step.</p><h3><strong>The Energy Budget</strong></h3><p>As we should already know, at launch, our baseball has two types of energy:</p><ul><li><p>Kinetic Energy (KE) (i.e. the energy from its current motion):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YXcQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8eb3ad78-d856-4764-afca-11459c3ca10c_2242x744.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YXcQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8eb3ad78-d856-4764-afca-11459c3ca10c_2242x744.png 424w, https://substackcdn.com/image/fetch/$s_!YXcQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8eb3ad78-d856-4764-afca-11459c3ca10c_2242x744.png 848w, https://substackcdn.com/image/fetch/$s_!YXcQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8eb3ad78-d856-4764-afca-11459c3ca10c_2242x744.png 1272w, https://substackcdn.com/image/fetch/$s_!YXcQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8eb3ad78-d856-4764-afca-11459c3ca10c_2242x744.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YXcQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8eb3ad78-d856-4764-afca-11459c3ca10c_2242x744.png" width="1456" height="483" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8eb3ad78-d856-4764-afca-11459c3ca10c_2242x744.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:483,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:67706,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8eb3ad78-d856-4764-afca-11459c3ca10c_2242x744.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_!YXcQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8eb3ad78-d856-4764-afca-11459c3ca10c_2242x744.png 424w, https://substackcdn.com/image/fetch/$s_!YXcQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8eb3ad78-d856-4764-afca-11459c3ca10c_2242x744.png 848w, https://substackcdn.com/image/fetch/$s_!YXcQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8eb3ad78-d856-4764-afca-11459c3ca10c_2242x744.png 1272w, https://substackcdn.com/image/fetch/$s_!YXcQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8eb3ad78-d856-4764-afca-11459c3ca10c_2242x744.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></figure></div><p></p></li><li><p>Gravitational Potential Energy (PE) (i.e. the &#8216;stored&#8217; energy from being near the Earth):</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7-rK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6443d36c-8100-4054-b78f-d1310ed7d903_2389x1357.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7-rK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6443d36c-8100-4054-b78f-d1310ed7d903_2389x1357.png 424w, https://substackcdn.com/image/fetch/$s_!7-rK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6443d36c-8100-4054-b78f-d1310ed7d903_2389x1357.png 848w, https://substackcdn.com/image/fetch/$s_!7-rK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6443d36c-8100-4054-b78f-d1310ed7d903_2389x1357.png 1272w, https://substackcdn.com/image/fetch/$s_!7-rK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6443d36c-8100-4054-b78f-d1310ed7d903_2389x1357.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7-rK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6443d36c-8100-4054-b78f-d1310ed7d903_2389x1357.png" width="1456" height="827" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6443d36c-8100-4054-b78f-d1310ed7d903_2389x1357.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:827,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:98639,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6443d36c-8100-4054-b78f-d1310ed7d903_2389x1357.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_!7-rK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6443d36c-8100-4054-b78f-d1310ed7d903_2389x1357.png 424w, https://substackcdn.com/image/fetch/$s_!7-rK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6443d36c-8100-4054-b78f-d1310ed7d903_2389x1357.png 848w, https://substackcdn.com/image/fetch/$s_!7-rK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6443d36c-8100-4054-b78f-d1310ed7d903_2389x1357.png 1272w, https://substackcdn.com/image/fetch/$s_!7-rK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6443d36c-8100-4054-b78f-d1310ed7d903_2389x1357.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></figure></div><p>Although we may have used the analogy of potential energy as being the &#8220;stored energy&#8221; in our system (thus being similar to money in a bank account) &#8211; in the above equation, we have a negative sign which we can now associate as being equal to owing your bank money (i.e. as being analogous to the debt you owe) and thus, positive energy terms equate to &#8216;stored&#8217; money while negative terms equate to &#8216;owed&#8217; money and we thus use the more appropriate <strong>debt</strong> term to represent this situation.</p><p>The total energy is equal to the kinetic energy plus the potential energy:</p><h3><strong>Total Energy = KE + PE</strong></h3><p>To escape Earth forever, the object must eliminate the potential energy within our books (i.e. no cash, no debt). So:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GfZU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46e55cbd-e08a-4564-8f09-70afe4d8c71d_1058x184.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GfZU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46e55cbd-e08a-4564-8f09-70afe4d8c71d_1058x184.png 424w, https://substackcdn.com/image/fetch/$s_!GfZU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46e55cbd-e08a-4564-8f09-70afe4d8c71d_1058x184.png 848w, https://substackcdn.com/image/fetch/$s_!GfZU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46e55cbd-e08a-4564-8f09-70afe4d8c71d_1058x184.png 1272w, https://substackcdn.com/image/fetch/$s_!GfZU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46e55cbd-e08a-4564-8f09-70afe4d8c71d_1058x184.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GfZU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46e55cbd-e08a-4564-8f09-70afe4d8c71d_1058x184.png" width="625" height="108.69565217391305" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/46e55cbd-e08a-4564-8f09-70afe4d8c71d_1058x184.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:184,&quot;width&quot;:1058,&quot;resizeWidth&quot;:625,&quot;bytes&quot;:10025,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46e55cbd-e08a-4564-8f09-70afe4d8c71d_1058x184.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_!GfZU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46e55cbd-e08a-4564-8f09-70afe4d8c71d_1058x184.png 424w, https://substackcdn.com/image/fetch/$s_!GfZU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46e55cbd-e08a-4564-8f09-70afe4d8c71d_1058x184.png 848w, https://substackcdn.com/image/fetch/$s_!GfZU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46e55cbd-e08a-4564-8f09-70afe4d8c71d_1058x184.png 1272w, https://substackcdn.com/image/fetch/$s_!GfZU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46e55cbd-e08a-4564-8f09-70afe4d8c71d_1058x184.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>In order to find the escape velocity in other words, we need to solve for v. To do this, we first move the potential energy term to the other side:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Puhg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F111c0f40-acfb-4aa1-b34d-8ec5309dc0f4_540x233.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Puhg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F111c0f40-acfb-4aa1-b34d-8ec5309dc0f4_540x233.png 424w, https://substackcdn.com/image/fetch/$s_!Puhg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F111c0f40-acfb-4aa1-b34d-8ec5309dc0f4_540x233.png 848w, https://substackcdn.com/image/fetch/$s_!Puhg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F111c0f40-acfb-4aa1-b34d-8ec5309dc0f4_540x233.png 1272w, https://substackcdn.com/image/fetch/$s_!Puhg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F111c0f40-acfb-4aa1-b34d-8ec5309dc0f4_540x233.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Puhg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F111c0f40-acfb-4aa1-b34d-8ec5309dc0f4_540x233.png" width="284" height="122.54074074074074" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/111c0f40-acfb-4aa1-b34d-8ec5309dc0f4_540x233.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:233,&quot;width&quot;:540,&quot;resizeWidth&quot;:284,&quot;bytes&quot;:13602,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F111c0f40-acfb-4aa1-b34d-8ec5309dc0f4_540x233.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_!Puhg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F111c0f40-acfb-4aa1-b34d-8ec5309dc0f4_540x233.png 424w, https://substackcdn.com/image/fetch/$s_!Puhg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F111c0f40-acfb-4aa1-b34d-8ec5309dc0f4_540x233.png 848w, https://substackcdn.com/image/fetch/$s_!Puhg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F111c0f40-acfb-4aa1-b34d-8ec5309dc0f4_540x233.png 1272w, https://substackcdn.com/image/fetch/$s_!Puhg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F111c0f40-acfb-4aa1-b34d-8ec5309dc0f4_540x233.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Then, we cancel out the mass term from both sides:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bi1B!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1ba79c1-d3fa-4369-901e-0960ee7370ba_408x226.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bi1B!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1ba79c1-d3fa-4369-901e-0960ee7370ba_408x226.png 424w, https://substackcdn.com/image/fetch/$s_!bi1B!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1ba79c1-d3fa-4369-901e-0960ee7370ba_408x226.png 848w, https://substackcdn.com/image/fetch/$s_!bi1B!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1ba79c1-d3fa-4369-901e-0960ee7370ba_408x226.png 1272w, https://substackcdn.com/image/fetch/$s_!bi1B!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1ba79c1-d3fa-4369-901e-0960ee7370ba_408x226.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bi1B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1ba79c1-d3fa-4369-901e-0960ee7370ba_408x226.png" width="222" height="122.97058823529412" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a1ba79c1-d3fa-4369-901e-0960ee7370ba_408x226.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:226,&quot;width&quot;:408,&quot;resizeWidth&quot;:222,&quot;bytes&quot;:10155,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1ba79c1-d3fa-4369-901e-0960ee7370ba_408x226.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_!bi1B!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1ba79c1-d3fa-4369-901e-0960ee7370ba_408x226.png 424w, https://substackcdn.com/image/fetch/$s_!bi1B!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1ba79c1-d3fa-4369-901e-0960ee7370ba_408x226.png 848w, https://substackcdn.com/image/fetch/$s_!bi1B!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1ba79c1-d3fa-4369-901e-0960ee7370ba_408x226.png 1272w, https://substackcdn.com/image/fetch/$s_!bi1B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1ba79c1-d3fa-4369-901e-0960ee7370ba_408x226.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>To make the equation cleaner, we simply multiply both sides by 2:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_Y8R!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cd921a5-3b24-418d-826e-eabd00e77ba5_402x222.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_Y8R!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cd921a5-3b24-418d-826e-eabd00e77ba5_402x222.png 424w, https://substackcdn.com/image/fetch/$s_!_Y8R!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cd921a5-3b24-418d-826e-eabd00e77ba5_402x222.png 848w, https://substackcdn.com/image/fetch/$s_!_Y8R!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cd921a5-3b24-418d-826e-eabd00e77ba5_402x222.png 1272w, https://substackcdn.com/image/fetch/$s_!_Y8R!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cd921a5-3b24-418d-826e-eabd00e77ba5_402x222.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_Y8R!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cd921a5-3b24-418d-826e-eabd00e77ba5_402x222.png" width="224" height="123.70149253731343" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5cd921a5-3b24-418d-826e-eabd00e77ba5_402x222.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:222,&quot;width&quot;:402,&quot;resizeWidth&quot;:224,&quot;bytes&quot;:9722,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cd921a5-3b24-418d-826e-eabd00e77ba5_402x222.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_!_Y8R!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cd921a5-3b24-418d-826e-eabd00e77ba5_402x222.png 424w, https://substackcdn.com/image/fetch/$s_!_Y8R!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cd921a5-3b24-418d-826e-eabd00e77ba5_402x222.png 848w, https://substackcdn.com/image/fetch/$s_!_Y8R!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cd921a5-3b24-418d-826e-eabd00e77ba5_402x222.png 1272w, https://substackcdn.com/image/fetch/$s_!_Y8R!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cd921a5-3b24-418d-826e-eabd00e77ba5_402x222.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Finally, we simply take the square root to obtain our formula for v (the escape velocity that we need in order to &#8216;balance or books&#8217;):</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Oqk9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe917787f-59e8-4fa0-925d-637db53c3efd_456x261.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Oqk9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe917787f-59e8-4fa0-925d-637db53c3efd_456x261.png 424w, https://substackcdn.com/image/fetch/$s_!Oqk9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe917787f-59e8-4fa0-925d-637db53c3efd_456x261.png 848w, https://substackcdn.com/image/fetch/$s_!Oqk9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe917787f-59e8-4fa0-925d-637db53c3efd_456x261.png 1272w, https://substackcdn.com/image/fetch/$s_!Oqk9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe917787f-59e8-4fa0-925d-637db53c3efd_456x261.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Oqk9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe917787f-59e8-4fa0-925d-637db53c3efd_456x261.png" width="272" height="155.68421052631578" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e917787f-59e8-4fa0-925d-637db53c3efd_456x261.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:261,&quot;width&quot;:456,&quot;resizeWidth&quot;:272,&quot;bytes&quot;:11395,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe917787f-59e8-4fa0-925d-637db53c3efd_456x261.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_!Oqk9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe917787f-59e8-4fa0-925d-637db53c3efd_456x261.png 424w, https://substackcdn.com/image/fetch/$s_!Oqk9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe917787f-59e8-4fa0-925d-637db53c3efd_456x261.png 848w, https://substackcdn.com/image/fetch/$s_!Oqk9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe917787f-59e8-4fa0-925d-637db53c3efd_456x261.png 1272w, https://substackcdn.com/image/fetch/$s_!Oqk9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe917787f-59e8-4fa0-925d-637db53c3efd_456x261.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h4>Let&#8217;s explain the above formula in a much more intuitive manner. </h4><p>In order to escape&#8217;s Earth&#8217;s gravitational field, the distance between our ball and the Earth center of mass must be infinity:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!UfjL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11a4adce-17db-4b9b-8baa-2d3837646241_2898x1138.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UfjL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11a4adce-17db-4b9b-8baa-2d3837646241_2898x1138.png 424w, https://substackcdn.com/image/fetch/$s_!UfjL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11a4adce-17db-4b9b-8baa-2d3837646241_2898x1138.png 848w, https://substackcdn.com/image/fetch/$s_!UfjL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11a4adce-17db-4b9b-8baa-2d3837646241_2898x1138.png 1272w, https://substackcdn.com/image/fetch/$s_!UfjL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11a4adce-17db-4b9b-8baa-2d3837646241_2898x1138.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!UfjL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11a4adce-17db-4b9b-8baa-2d3837646241_2898x1138.png" width="1456" height="572" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/11a4adce-17db-4b9b-8baa-2d3837646241_2898x1138.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:572,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:638051,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11a4adce-17db-4b9b-8baa-2d3837646241_2898x1138.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_!UfjL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11a4adce-17db-4b9b-8baa-2d3837646241_2898x1138.png 424w, https://substackcdn.com/image/fetch/$s_!UfjL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11a4adce-17db-4b9b-8baa-2d3837646241_2898x1138.png 848w, https://substackcdn.com/image/fetch/$s_!UfjL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11a4adce-17db-4b9b-8baa-2d3837646241_2898x1138.png 1272w, https://substackcdn.com/image/fetch/$s_!UfjL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11a4adce-17db-4b9b-8baa-2d3837646241_2898x1138.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></figure></div><p>In order to make the potential (U) equal to zero, r must be equal to infinity. Of course it will never reach infinity (because this is impossible) but conceptually if it were to stop before it gets to infinity, then there will be some potential energy because the potential energy never really goes away. But, hypothetically, when our distance is equal to infinity, the ball will eventually stop moving (so our kinetic energy at this point will be 0 (i.e. we will have 0 cash in our wallet)). When this happens, our potential energy will also be 0 as well (since we will no longer be effected by Earth&#8217;s gravitational energy) and so both of our energy terms would be 0 (0 debt and 0 cash). But energy can&#8217;t really be created nor destroyed. Essentially, this means that our total energy (kinetic + potential) must be equal to 0 <strong>all along this particular trajectory</strong>. </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lu18!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8a69f25-9519-4a7b-a5d7-3dada577c102_1212x161.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lu18!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8a69f25-9519-4a7b-a5d7-3dada577c102_1212x161.png 424w, https://substackcdn.com/image/fetch/$s_!lu18!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8a69f25-9519-4a7b-a5d7-3dada577c102_1212x161.png 848w, https://substackcdn.com/image/fetch/$s_!lu18!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8a69f25-9519-4a7b-a5d7-3dada577c102_1212x161.png 1272w, https://substackcdn.com/image/fetch/$s_!lu18!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8a69f25-9519-4a7b-a5d7-3dada577c102_1212x161.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lu18!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8a69f25-9519-4a7b-a5d7-3dada577c102_1212x161.png" width="519" height="68.9430693069307" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c8a69f25-9519-4a7b-a5d7-3dada577c102_1212x161.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:161,&quot;width&quot;:1212,&quot;resizeWidth&quot;:519,&quot;bytes&quot;:20753,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8a69f25-9519-4a7b-a5d7-3dada577c102_1212x161.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_!lu18!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8a69f25-9519-4a7b-a5d7-3dada577c102_1212x161.png 424w, https://substackcdn.com/image/fetch/$s_!lu18!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8a69f25-9519-4a7b-a5d7-3dada577c102_1212x161.png 848w, https://substackcdn.com/image/fetch/$s_!lu18!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8a69f25-9519-4a7b-a5d7-3dada577c102_1212x161.png 1272w, https://substackcdn.com/image/fetch/$s_!lu18!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8a69f25-9519-4a7b-a5d7-3dada577c102_1212x161.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>When you&#8217;re standing on the Earth&#8217;s surface, you&#8217;re deep in this "gravity well" so you have a big &#8216;debt&#8217; (your potential energy is a large negative number) which you owe to Earth. If you want to leave Earth forever, you need enough cash (kinetic energy) to completely <strong>pay off</strong> that gravitational debt &#8212; and to totally escape it, your distance from Earth must be equal to infinity wherein both our potential and kinetic energy terms would be equal to 0. Since this is the case, what we&#8217;re doing with our equation above is simply &#8216;balancing&#8217; our books and calculating how much kinetic energy (&#8216;cash&#8217;) we would need in order to &#8216;pay off&#8217; or balance the potential energy &#8216;debt&#8217; such that the total within our system equals 0. To do this, we combine the equations (using the 2 terms we provided above), set them to equal 0 (KE + PE = 0) to ensure that our &#8216;books balance&#8217; and we solve for v to obtain our escape velocity.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!R_FD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae2dfedc-0182-4857-8ab0-1a8982841b0f_501x561.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!R_FD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae2dfedc-0182-4857-8ab0-1a8982841b0f_501x561.png 424w, https://substackcdn.com/image/fetch/$s_!R_FD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae2dfedc-0182-4857-8ab0-1a8982841b0f_501x561.png 848w, https://substackcdn.com/image/fetch/$s_!R_FD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae2dfedc-0182-4857-8ab0-1a8982841b0f_501x561.png 1272w, https://substackcdn.com/image/fetch/$s_!R_FD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae2dfedc-0182-4857-8ab0-1a8982841b0f_501x561.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!R_FD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae2dfedc-0182-4857-8ab0-1a8982841b0f_501x561.png" width="321" height="359.4431137724551" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ae2dfedc-0182-4857-8ab0-1a8982841b0f_501x561.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:561,&quot;width&quot;:501,&quot;resizeWidth&quot;:321,&quot;bytes&quot;:35112,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae2dfedc-0182-4857-8ab0-1a8982841b0f_501x561.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_!R_FD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae2dfedc-0182-4857-8ab0-1a8982841b0f_501x561.png 424w, https://substackcdn.com/image/fetch/$s_!R_FD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae2dfedc-0182-4857-8ab0-1a8982841b0f_501x561.png 848w, https://substackcdn.com/image/fetch/$s_!R_FD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae2dfedc-0182-4857-8ab0-1a8982841b0f_501x561.png 1272w, https://substackcdn.com/image/fetch/$s_!R_FD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae2dfedc-0182-4857-8ab0-1a8982841b0f_501x561.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></figure></div><h4>Deriving Earth&#8217;s Escape Velocity</h4><p>Noting this, let&#8217;s continue on and plug in the right numbers to finally derive our finalized escape velocity. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5R76!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde693395-4e2f-4483-8085-69ac2a157730_2172x1355.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5R76!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde693395-4e2f-4483-8085-69ac2a157730_2172x1355.png 424w, https://substackcdn.com/image/fetch/$s_!5R76!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde693395-4e2f-4483-8085-69ac2a157730_2172x1355.png 848w, https://substackcdn.com/image/fetch/$s_!5R76!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde693395-4e2f-4483-8085-69ac2a157730_2172x1355.png 1272w, https://substackcdn.com/image/fetch/$s_!5R76!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde693395-4e2f-4483-8085-69ac2a157730_2172x1355.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5R76!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde693395-4e2f-4483-8085-69ac2a157730_2172x1355.png" width="1456" height="908" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/de693395-4e2f-4483-8085-69ac2a157730_2172x1355.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:908,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:81634,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde693395-4e2f-4483-8085-69ac2a157730_2172x1355.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_!5R76!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde693395-4e2f-4483-8085-69ac2a157730_2172x1355.png 424w, https://substackcdn.com/image/fetch/$s_!5R76!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde693395-4e2f-4483-8085-69ac2a157730_2172x1355.png 848w, https://substackcdn.com/image/fetch/$s_!5R76!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde693395-4e2f-4483-8085-69ac2a157730_2172x1355.png 1272w, https://substackcdn.com/image/fetch/$s_!5R76!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde693395-4e2f-4483-8085-69ac2a157730_2172x1355.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></figure></div><p>Plugging in the appropriate values we obtain:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7Ldq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2b85918-6e8e-46d6-a47c-d9b7f8028e19_1809x769.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7Ldq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2b85918-6e8e-46d6-a47c-d9b7f8028e19_1809x769.png 424w, https://substackcdn.com/image/fetch/$s_!7Ldq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2b85918-6e8e-46d6-a47c-d9b7f8028e19_1809x769.png 848w, https://substackcdn.com/image/fetch/$s_!7Ldq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2b85918-6e8e-46d6-a47c-d9b7f8028e19_1809x769.png 1272w, https://substackcdn.com/image/fetch/$s_!7Ldq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2b85918-6e8e-46d6-a47c-d9b7f8028e19_1809x769.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7Ldq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2b85918-6e8e-46d6-a47c-d9b7f8028e19_1809x769.png" width="693" height="294.6201923076923" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e2b85918-6e8e-46d6-a47c-d9b7f8028e19_1809x769.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:619,&quot;width&quot;:1456,&quot;resizeWidth&quot;:693,&quot;bytes&quot;:129932,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2b85918-6e8e-46d6-a47c-d9b7f8028e19_1809x769.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_!7Ldq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2b85918-6e8e-46d6-a47c-d9b7f8028e19_1809x769.png 424w, https://substackcdn.com/image/fetch/$s_!7Ldq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2b85918-6e8e-46d6-a47c-d9b7f8028e19_1809x769.png 848w, https://substackcdn.com/image/fetch/$s_!7Ldq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2b85918-6e8e-46d6-a47c-d9b7f8028e19_1809x769.png 1272w, https://substackcdn.com/image/fetch/$s_!7Ldq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2b85918-6e8e-46d6-a47c-d9b7f8028e19_1809x769.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></figure></div><p>And so &#8211; Earth&#8217;s escape velocity is exactly 11,186 meters per second, and this equates to 11 kilometers per second (km/s). What we're saying here is that the escape velocity from the earth is 11 kilometers per second (which is approximately equal to 7 miles per second) and this is approximately equal to 25,000 miles per hour. That's quite a lot of up-front energy we have to put up in order to get our baseball out of Earth&#8217;s gravitational field!</p><p>This might seem like a lot, but it&#8217;s nothing compared to a black hole!!! You'll should be able to notice that 7 miles a second is a <strong>long way short of the speed of light</strong> which is 3 times 10 to the 8 meters a second.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wViU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12725a1-3803-4b38-9ed6-3f5c3f48f056_545x261.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wViU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12725a1-3803-4b38-9ed6-3f5c3f48f056_545x261.png 424w, https://substackcdn.com/image/fetch/$s_!wViU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12725a1-3803-4b38-9ed6-3f5c3f48f056_545x261.png 848w, https://substackcdn.com/image/fetch/$s_!wViU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12725a1-3803-4b38-9ed6-3f5c3f48f056_545x261.png 1272w, https://substackcdn.com/image/fetch/$s_!wViU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12725a1-3803-4b38-9ed6-3f5c3f48f056_545x261.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wViU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12725a1-3803-4b38-9ed6-3f5c3f48f056_545x261.png" width="435" height="208.32110091743118" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e12725a1-3803-4b38-9ed6-3f5c3f48f056_545x261.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:261,&quot;width&quot;:545,&quot;resizeWidth&quot;:435,&quot;bytes&quot;:19781,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12725a1-3803-4b38-9ed6-3f5c3f48f056_545x261.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_!wViU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12725a1-3803-4b38-9ed6-3f5c3f48f056_545x261.png 424w, https://substackcdn.com/image/fetch/$s_!wViU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12725a1-3803-4b38-9ed6-3f5c3f48f056_545x261.png 848w, https://substackcdn.com/image/fetch/$s_!wViU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12725a1-3803-4b38-9ed6-3f5c3f48f056_545x261.png 1272w, https://substackcdn.com/image/fetch/$s_!wViU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12725a1-3803-4b38-9ed6-3f5c3f48f056_545x261.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Let&#8217;s remind ourselves of what a black hole once again represents:</p><blockquote><p>&#8220;<em>A black hole, in simple terms, is <strong>a region in space where the escape velocity exceeds the speed of light.</strong>&#8221;</em></p></blockquote><p>So, we should be able to easily see that the earth is nowhere near to a black hole &#8211; a black hole needs an escape velocity of greater than the speed of light and earth&#8217;s escape velocity (of 11,000 meters per second) is nowhere near this!!</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3yZY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a4157da-fda8-47fe-a673-60714578ded9_853x394.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3yZY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a4157da-fda8-47fe-a673-60714578ded9_853x394.png 424w, https://substackcdn.com/image/fetch/$s_!3yZY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a4157da-fda8-47fe-a673-60714578ded9_853x394.png 848w, https://substackcdn.com/image/fetch/$s_!3yZY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a4157da-fda8-47fe-a673-60714578ded9_853x394.png 1272w, https://substackcdn.com/image/fetch/$s_!3yZY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a4157da-fda8-47fe-a673-60714578ded9_853x394.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3yZY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a4157da-fda8-47fe-a673-60714578ded9_853x394.png" width="517" height="238.80187573270808" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2a4157da-fda8-47fe-a673-60714578ded9_853x394.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:394,&quot;width&quot;:853,&quot;resizeWidth&quot;:517,&quot;bytes&quot;:45277,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a4157da-fda8-47fe-a673-60714578ded9_853x394.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_!3yZY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a4157da-fda8-47fe-a673-60714578ded9_853x394.png 424w, https://substackcdn.com/image/fetch/$s_!3yZY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a4157da-fda8-47fe-a673-60714578ded9_853x394.png 848w, https://substackcdn.com/image/fetch/$s_!3yZY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a4157da-fda8-47fe-a673-60714578ded9_853x394.png 1272w, https://substackcdn.com/image/fetch/$s_!3yZY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a4157da-fda8-47fe-a673-60714578ded9_853x394.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>So let's just remind ourselves of what the original formula is for calculating the escape velocity:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!E-ve!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5223f7a5-6250-4600-aba5-085e479b437d_439x420.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!E-ve!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5223f7a5-6250-4600-aba5-085e479b437d_439x420.png 424w, https://substackcdn.com/image/fetch/$s_!E-ve!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5223f7a5-6250-4600-aba5-085e479b437d_439x420.png 848w, https://substackcdn.com/image/fetch/$s_!E-ve!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5223f7a5-6250-4600-aba5-085e479b437d_439x420.png 1272w, https://substackcdn.com/image/fetch/$s_!E-ve!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5223f7a5-6250-4600-aba5-085e479b437d_439x420.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!E-ve!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5223f7a5-6250-4600-aba5-085e479b437d_439x420.png" width="371" height="354.94305239179954" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5223f7a5-6250-4600-aba5-085e479b437d_439x420.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:420,&quot;width&quot;:439,&quot;resizeWidth&quot;:371,&quot;bytes&quot;:28816,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5223f7a5-6250-4600-aba5-085e479b437d_439x420.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_!E-ve!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5223f7a5-6250-4600-aba5-085e479b437d_439x420.png 424w, https://substackcdn.com/image/fetch/$s_!E-ve!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5223f7a5-6250-4600-aba5-085e479b437d_439x420.png 848w, https://substackcdn.com/image/fetch/$s_!E-ve!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5223f7a5-6250-4600-aba5-085e479b437d_439x420.png 1272w, https://substackcdn.com/image/fetch/$s_!E-ve!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5223f7a5-6250-4600-aba5-085e479b437d_439x420.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></figure></div><p>You'll notice that v squared will get greater as r gets smaller. So &#8211; let&#8217;s do a little thought experiment. Let&#8217;s say that you take the earth and squash it (retaining all it&#8217;s current mass) so that it covers a much smaller area:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mdtj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F106b9bce-55c5-47e0-976d-4a3db6604153_1021x670.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mdtj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F106b9bce-55c5-47e0-976d-4a3db6604153_1021x670.png 424w, https://substackcdn.com/image/fetch/$s_!mdtj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F106b9bce-55c5-47e0-976d-4a3db6604153_1021x670.png 848w, https://substackcdn.com/image/fetch/$s_!mdtj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F106b9bce-55c5-47e0-976d-4a3db6604153_1021x670.png 1272w, https://substackcdn.com/image/fetch/$s_!mdtj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F106b9bce-55c5-47e0-976d-4a3db6604153_1021x670.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mdtj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F106b9bce-55c5-47e0-976d-4a3db6604153_1021x670.png" width="1021" height="670" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/106b9bce-55c5-47e0-976d-4a3db6604153_1021x670.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:670,&quot;width&quot;:1021,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:543795,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F106b9bce-55c5-47e0-976d-4a3db6604153_1021x670.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_!mdtj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F106b9bce-55c5-47e0-976d-4a3db6604153_1021x670.png 424w, https://substackcdn.com/image/fetch/$s_!mdtj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F106b9bce-55c5-47e0-976d-4a3db6604153_1021x670.png 848w, https://substackcdn.com/image/fetch/$s_!mdtj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F106b9bce-55c5-47e0-976d-4a3db6604153_1021x670.png 1272w, https://substackcdn.com/image/fetch/$s_!mdtj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F106b9bce-55c5-47e0-976d-4a3db6604153_1021x670.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></figure></div><h4>How much would we need to shrink it in order to make the v (the escape velocity) equal to the speed of light??</h4><p>Well, we need to use mathematics to do this, and it&#8217;s actually quite simple. First, we take our original formula:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ykeR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd446cdc9-3314-49a8-8a61-6f7c3055a135_550x278.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ykeR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd446cdc9-3314-49a8-8a61-6f7c3055a135_550x278.png 424w, https://substackcdn.com/image/fetch/$s_!ykeR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd446cdc9-3314-49a8-8a61-6f7c3055a135_550x278.png 848w, https://substackcdn.com/image/fetch/$s_!ykeR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd446cdc9-3314-49a8-8a61-6f7c3055a135_550x278.png 1272w, https://substackcdn.com/image/fetch/$s_!ykeR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd446cdc9-3314-49a8-8a61-6f7c3055a135_550x278.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ykeR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd446cdc9-3314-49a8-8a61-6f7c3055a135_550x278.png" width="268" height="135.4618181818182" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d446cdc9-3314-49a8-8a61-6f7c3055a135_550x278.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:278,&quot;width&quot;:550,&quot;resizeWidth&quot;:268,&quot;bytes&quot;:14905,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd446cdc9-3314-49a8-8a61-6f7c3055a135_550x278.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_!ykeR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd446cdc9-3314-49a8-8a61-6f7c3055a135_550x278.png 424w, https://substackcdn.com/image/fetch/$s_!ykeR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd446cdc9-3314-49a8-8a61-6f7c3055a135_550x278.png 848w, https://substackcdn.com/image/fetch/$s_!ykeR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd446cdc9-3314-49a8-8a61-6f7c3055a135_550x278.png 1272w, https://substackcdn.com/image/fetch/$s_!ykeR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd446cdc9-3314-49a8-8a61-6f7c3055a135_550x278.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We want to know when the escape velocity v = c (the speed of light) and so we set v equal to c:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!cNMz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f42241-dc95-41f2-b4e6-b1d9f5d2f257_548x301.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cNMz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f42241-dc95-41f2-b4e6-b1d9f5d2f257_548x301.png 424w, https://substackcdn.com/image/fetch/$s_!cNMz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f42241-dc95-41f2-b4e6-b1d9f5d2f257_548x301.png 848w, https://substackcdn.com/image/fetch/$s_!cNMz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f42241-dc95-41f2-b4e6-b1d9f5d2f257_548x301.png 1272w, https://substackcdn.com/image/fetch/$s_!cNMz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f42241-dc95-41f2-b4e6-b1d9f5d2f257_548x301.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cNMz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f42241-dc95-41f2-b4e6-b1d9f5d2f257_548x301.png" width="260" height="142.8102189781022" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/50f42241-dc95-41f2-b4e6-b1d9f5d2f257_548x301.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:301,&quot;width&quot;:548,&quot;resizeWidth&quot;:260,&quot;bytes&quot;:14717,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f42241-dc95-41f2-b4e6-b1d9f5d2f257_548x301.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_!cNMz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f42241-dc95-41f2-b4e6-b1d9f5d2f257_548x301.png 424w, https://substackcdn.com/image/fetch/$s_!cNMz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f42241-dc95-41f2-b4e6-b1d9f5d2f257_548x301.png 848w, https://substackcdn.com/image/fetch/$s_!cNMz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f42241-dc95-41f2-b4e6-b1d9f5d2f257_548x301.png 1272w, https://substackcdn.com/image/fetch/$s_!cNMz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f42241-dc95-41f2-b4e6-b1d9f5d2f257_548x301.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Now, to simplify things even further (so we can get the formula for r), we square both sides:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!78R3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F786b6fe6-5f13-410d-bfe5-87a9c24c29cc_531x300.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!78R3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F786b6fe6-5f13-410d-bfe5-87a9c24c29cc_531x300.png 424w, https://substackcdn.com/image/fetch/$s_!78R3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F786b6fe6-5f13-410d-bfe5-87a9c24c29cc_531x300.png 848w, https://substackcdn.com/image/fetch/$s_!78R3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F786b6fe6-5f13-410d-bfe5-87a9c24c29cc_531x300.png 1272w, https://substackcdn.com/image/fetch/$s_!78R3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F786b6fe6-5f13-410d-bfe5-87a9c24c29cc_531x300.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!78R3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F786b6fe6-5f13-410d-bfe5-87a9c24c29cc_531x300.png" width="281" height="158.75706214689265" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/786b6fe6-5f13-410d-bfe5-87a9c24c29cc_531x300.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:300,&quot;width&quot;:531,&quot;resizeWidth&quot;:281,&quot;bytes&quot;:12984,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F786b6fe6-5f13-410d-bfe5-87a9c24c29cc_531x300.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_!78R3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F786b6fe6-5f13-410d-bfe5-87a9c24c29cc_531x300.png 424w, https://substackcdn.com/image/fetch/$s_!78R3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F786b6fe6-5f13-410d-bfe5-87a9c24c29cc_531x300.png 848w, https://substackcdn.com/image/fetch/$s_!78R3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F786b6fe6-5f13-410d-bfe5-87a9c24c29cc_531x300.png 1272w, https://substackcdn.com/image/fetch/$s_!78R3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F786b6fe6-5f13-410d-bfe5-87a9c24c29cc_531x300.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We re-arrange the above to solve for r and we get:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!DObl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F423b7910-c55b-4ac3-8c2b-becacae32e6a_484x269.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!DObl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F423b7910-c55b-4ac3-8c2b-becacae32e6a_484x269.png 424w, https://substackcdn.com/image/fetch/$s_!DObl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F423b7910-c55b-4ac3-8c2b-becacae32e6a_484x269.png 848w, https://substackcdn.com/image/fetch/$s_!DObl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F423b7910-c55b-4ac3-8c2b-becacae32e6a_484x269.png 1272w, https://substackcdn.com/image/fetch/$s_!DObl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F423b7910-c55b-4ac3-8c2b-becacae32e6a_484x269.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!DObl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F423b7910-c55b-4ac3-8c2b-becacae32e6a_484x269.png" width="274" height="152.28512396694214" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/423b7910-c55b-4ac3-8c2b-becacae32e6a_484x269.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:269,&quot;width&quot;:484,&quot;resizeWidth&quot;:274,&quot;bytes&quot;:12612,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F423b7910-c55b-4ac3-8c2b-becacae32e6a_484x269.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_!DObl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F423b7910-c55b-4ac3-8c2b-becacae32e6a_484x269.png 424w, https://substackcdn.com/image/fetch/$s_!DObl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F423b7910-c55b-4ac3-8c2b-becacae32e6a_484x269.png 848w, https://substackcdn.com/image/fetch/$s_!DObl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F423b7910-c55b-4ac3-8c2b-becacae32e6a_484x269.png 1272w, https://substackcdn.com/image/fetch/$s_!DObl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F423b7910-c55b-4ac3-8c2b-becacae32e6a_484x269.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h4>This is known as the <strong>Schwarzschild radius!!</strong></h4><p>This is the radius at which an object becomes a black hole. Let&#8217;s not stop here though &#8211; let&#8217;s plug in the appropriate values to find our radius and so now we have:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tkoY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6c0d63-6a5d-4cfe-8189-bdeaef65b964_1447x523.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tkoY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6c0d63-6a5d-4cfe-8189-bdeaef65b964_1447x523.png 424w, https://substackcdn.com/image/fetch/$s_!tkoY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6c0d63-6a5d-4cfe-8189-bdeaef65b964_1447x523.png 848w, https://substackcdn.com/image/fetch/$s_!tkoY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6c0d63-6a5d-4cfe-8189-bdeaef65b964_1447x523.png 1272w, https://substackcdn.com/image/fetch/$s_!tkoY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6c0d63-6a5d-4cfe-8189-bdeaef65b964_1447x523.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tkoY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6c0d63-6a5d-4cfe-8189-bdeaef65b964_1447x523.png" width="446" height="161.20110573600553" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/aa6c0d63-6a5d-4cfe-8189-bdeaef65b964_1447x523.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:523,&quot;width&quot;:1447,&quot;resizeWidth&quot;:446,&quot;bytes&quot;:69496,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6c0d63-6a5d-4cfe-8189-bdeaef65b964_1447x523.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_!tkoY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6c0d63-6a5d-4cfe-8189-bdeaef65b964_1447x523.png 424w, https://substackcdn.com/image/fetch/$s_!tkoY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6c0d63-6a5d-4cfe-8189-bdeaef65b964_1447x523.png 848w, https://substackcdn.com/image/fetch/$s_!tkoY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6c0d63-6a5d-4cfe-8189-bdeaef65b964_1447x523.png 1272w, https://substackcdn.com/image/fetch/$s_!tkoY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa6c0d63-6a5d-4cfe-8189-bdeaef65b964_1447x523.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Plugging the values in we get:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rgkj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc44b8ad-8b33-4be9-b3e8-2132091ca4f3_1407x299.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rgkj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc44b8ad-8b33-4be9-b3e8-2132091ca4f3_1407x299.png 424w, https://substackcdn.com/image/fetch/$s_!rgkj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc44b8ad-8b33-4be9-b3e8-2132091ca4f3_1407x299.png 848w, https://substackcdn.com/image/fetch/$s_!rgkj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc44b8ad-8b33-4be9-b3e8-2132091ca4f3_1407x299.png 1272w, https://substackcdn.com/image/fetch/$s_!rgkj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc44b8ad-8b33-4be9-b3e8-2132091ca4f3_1407x299.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rgkj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc44b8ad-8b33-4be9-b3e8-2132091ca4f3_1407x299.png" width="453" height="96.26652452025586" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bc44b8ad-8b33-4be9-b3e8-2132091ca4f3_1407x299.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:299,&quot;width&quot;:1407,&quot;resizeWidth&quot;:453,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!rgkj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc44b8ad-8b33-4be9-b3e8-2132091ca4f3_1407x299.png 424w, https://substackcdn.com/image/fetch/$s_!rgkj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc44b8ad-8b33-4be9-b3e8-2132091ca4f3_1407x299.png 848w, https://substackcdn.com/image/fetch/$s_!rgkj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc44b8ad-8b33-4be9-b3e8-2132091ca4f3_1407x299.png 1272w, https://substackcdn.com/image/fetch/$s_!rgkj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc44b8ad-8b33-4be9-b3e8-2132091ca4f3_1407x299.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>After simplifying we finally get:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iDid!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82ad54ef-cc93-4d91-b7e2-935962f43d03_1967x347.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iDid!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82ad54ef-cc93-4d91-b7e2-935962f43d03_1967x347.png 424w, https://substackcdn.com/image/fetch/$s_!iDid!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82ad54ef-cc93-4d91-b7e2-935962f43d03_1967x347.png 848w, https://substackcdn.com/image/fetch/$s_!iDid!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82ad54ef-cc93-4d91-b7e2-935962f43d03_1967x347.png 1272w, https://substackcdn.com/image/fetch/$s_!iDid!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82ad54ef-cc93-4d91-b7e2-935962f43d03_1967x347.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iDid!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82ad54ef-cc93-4d91-b7e2-935962f43d03_1967x347.png" width="657" height="115.96771978021978" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/82ad54ef-cc93-4d91-b7e2-935962f43d03_1967x347.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:257,&quot;width&quot;:1456,&quot;resizeWidth&quot;:657,&quot;bytes&quot;:44118,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82ad54ef-cc93-4d91-b7e2-935962f43d03_1967x347.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_!iDid!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82ad54ef-cc93-4d91-b7e2-935962f43d03_1967x347.png 424w, https://substackcdn.com/image/fetch/$s_!iDid!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82ad54ef-cc93-4d91-b7e2-935962f43d03_1967x347.png 848w, https://substackcdn.com/image/fetch/$s_!iDid!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82ad54ef-cc93-4d91-b7e2-935962f43d03_1967x347.png 1272w, https://substackcdn.com/image/fetch/$s_!iDid!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82ad54ef-cc93-4d91-b7e2-935962f43d03_1967x347.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h4>So -- if you compress the Earth into a sphere that has a radius of about 8.5 millimeters (a diameter of about 1.7 centimeters) it would become a black hole!!</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NJzP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa62fc424-4c41-47cb-bb5c-81786a18626a_1085x659.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NJzP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa62fc424-4c41-47cb-bb5c-81786a18626a_1085x659.png 424w, https://substackcdn.com/image/fetch/$s_!NJzP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa62fc424-4c41-47cb-bb5c-81786a18626a_1085x659.png 848w, https://substackcdn.com/image/fetch/$s_!NJzP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa62fc424-4c41-47cb-bb5c-81786a18626a_1085x659.png 1272w, https://substackcdn.com/image/fetch/$s_!NJzP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa62fc424-4c41-47cb-bb5c-81786a18626a_1085x659.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NJzP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa62fc424-4c41-47cb-bb5c-81786a18626a_1085x659.png" width="1085" height="659" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a62fc424-4c41-47cb-bb5c-81786a18626a_1085x659.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:659,&quot;width&quot;:1085,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:565539,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa62fc424-4c41-47cb-bb5c-81786a18626a_1085x659.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_!NJzP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa62fc424-4c41-47cb-bb5c-81786a18626a_1085x659.png 424w, https://substackcdn.com/image/fetch/$s_!NJzP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa62fc424-4c41-47cb-bb5c-81786a18626a_1085x659.png 848w, https://substackcdn.com/image/fetch/$s_!NJzP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa62fc424-4c41-47cb-bb5c-81786a18626a_1085x659.png 1272w, https://substackcdn.com/image/fetch/$s_!NJzP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa62fc424-4c41-47cb-bb5c-81786a18626a_1085x659.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></figure></div><p>In other words, if we could shrink all of Earth&#8217;s mass (about 6 times 10<sup>24</sup> kilograms) into a sphere the size of a marble (~1.7 cms), the escape velocity would exceed the speed of light and at that point, and Earth would become a black hole from which not even light could escape!!</p><p>You may not be able to comprehend the gravitational force which Earth would have should someone, somehow, find a way to do this, so let&#8217;s do another thought experiment. Let&#8217;s inflate Earth once again to its regular size and see what impact placing a 1 kg weight on it has.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!i9nw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F927808e5-3fd4-49ee-a6e5-5cd3cb210098_1247x862.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!i9nw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F927808e5-3fd4-49ee-a6e5-5cd3cb210098_1247x862.png 424w, https://substackcdn.com/image/fetch/$s_!i9nw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F927808e5-3fd4-49ee-a6e5-5cd3cb210098_1247x862.png 848w, https://substackcdn.com/image/fetch/$s_!i9nw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F927808e5-3fd4-49ee-a6e5-5cd3cb210098_1247x862.png 1272w, https://substackcdn.com/image/fetch/$s_!i9nw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F927808e5-3fd4-49ee-a6e5-5cd3cb210098_1247x862.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!i9nw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F927808e5-3fd4-49ee-a6e5-5cd3cb210098_1247x862.png" width="1247" height="862" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/927808e5-3fd4-49ee-a6e5-5cd3cb210098_1247x862.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:862,&quot;width&quot;:1247,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:761958,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F927808e5-3fd4-49ee-a6e5-5cd3cb210098_1247x862.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_!i9nw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F927808e5-3fd4-49ee-a6e5-5cd3cb210098_1247x862.png 424w, https://substackcdn.com/image/fetch/$s_!i9nw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F927808e5-3fd4-49ee-a6e5-5cd3cb210098_1247x862.png 848w, https://substackcdn.com/image/fetch/$s_!i9nw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F927808e5-3fd4-49ee-a6e5-5cd3cb210098_1247x862.png 1272w, https://substackcdn.com/image/fetch/$s_!i9nw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F927808e5-3fd4-49ee-a6e5-5cd3cb210098_1247x862.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></figure></div><p>To do this, we&#8217;ll once again need our gravitational force formula and we&#8217;ll need to plug in the appropriate constants / inputs to obtain:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!akOP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b9db89b-27a5-4fe5-9db9-4916fc85b268_248x111.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!akOP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b9db89b-27a5-4fe5-9db9-4916fc85b268_248x111.png 424w, https://substackcdn.com/image/fetch/$s_!akOP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b9db89b-27a5-4fe5-9db9-4916fc85b268_248x111.png 848w, https://substackcdn.com/image/fetch/$s_!akOP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b9db89b-27a5-4fe5-9db9-4916fc85b268_248x111.png 1272w, https://substackcdn.com/image/fetch/$s_!akOP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b9db89b-27a5-4fe5-9db9-4916fc85b268_248x111.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!akOP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b9db89b-27a5-4fe5-9db9-4916fc85b268_248x111.png" width="248" height="111" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7b9db89b-27a5-4fe5-9db9-4916fc85b268_248x111.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:111,&quot;width&quot;:248,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:6526,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b9db89b-27a5-4fe5-9db9-4916fc85b268_248x111.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_!akOP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b9db89b-27a5-4fe5-9db9-4916fc85b268_248x111.png 424w, https://substackcdn.com/image/fetch/$s_!akOP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b9db89b-27a5-4fe5-9db9-4916fc85b268_248x111.png 848w, https://substackcdn.com/image/fetch/$s_!akOP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b9db89b-27a5-4fe5-9db9-4916fc85b268_248x111.png 1272w, https://substackcdn.com/image/fetch/$s_!akOP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7b9db89b-27a5-4fe5-9db9-4916fc85b268_248x111.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Y--e!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2034b4-10b0-46f3-8840-28852bac1e64_785x256.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Y--e!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2034b4-10b0-46f3-8840-28852bac1e64_785x256.png 424w, https://substackcdn.com/image/fetch/$s_!Y--e!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2034b4-10b0-46f3-8840-28852bac1e64_785x256.png 848w, https://substackcdn.com/image/fetch/$s_!Y--e!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2034b4-10b0-46f3-8840-28852bac1e64_785x256.png 1272w, https://substackcdn.com/image/fetch/$s_!Y--e!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2034b4-10b0-46f3-8840-28852bac1e64_785x256.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Y--e!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2034b4-10b0-46f3-8840-28852bac1e64_785x256.png" width="613" height="199.90828025477708" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/da2034b4-10b0-46f3-8840-28852bac1e64_785x256.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:256,&quot;width&quot;:785,&quot;resizeWidth&quot;:613,&quot;bytes&quot;:64779,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2034b4-10b0-46f3-8840-28852bac1e64_785x256.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_!Y--e!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2034b4-10b0-46f3-8840-28852bac1e64_785x256.png 424w, https://substackcdn.com/image/fetch/$s_!Y--e!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2034b4-10b0-46f3-8840-28852bac1e64_785x256.png 848w, https://substackcdn.com/image/fetch/$s_!Y--e!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2034b4-10b0-46f3-8840-28852bac1e64_785x256.png 1272w, https://substackcdn.com/image/fetch/$s_!Y--e!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda2034b4-10b0-46f3-8840-28852bac1e64_785x256.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>So we plug in the appropriate values to get:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YnsO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9043e2f8-e933-4450-b612-8942b404842f_1167x337.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YnsO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9043e2f8-e933-4450-b612-8942b404842f_1167x337.png 424w, https://substackcdn.com/image/fetch/$s_!YnsO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9043e2f8-e933-4450-b612-8942b404842f_1167x337.png 848w, https://substackcdn.com/image/fetch/$s_!YnsO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9043e2f8-e933-4450-b612-8942b404842f_1167x337.png 1272w, https://substackcdn.com/image/fetch/$s_!YnsO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9043e2f8-e933-4450-b612-8942b404842f_1167x337.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YnsO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9043e2f8-e933-4450-b612-8942b404842f_1167x337.png" width="416" height="120.13024850042845" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9043e2f8-e933-4450-b612-8942b404842f_1167x337.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:337,&quot;width&quot;:1167,&quot;resizeWidth&quot;:416,&quot;bytes&quot;:36733,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9043e2f8-e933-4450-b612-8942b404842f_1167x337.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_!YnsO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9043e2f8-e933-4450-b612-8942b404842f_1167x337.png 424w, https://substackcdn.com/image/fetch/$s_!YnsO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9043e2f8-e933-4450-b612-8942b404842f_1167x337.png 848w, https://substackcdn.com/image/fetch/$s_!YnsO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9043e2f8-e933-4450-b612-8942b404842f_1167x337.png 1272w, https://substackcdn.com/image/fetch/$s_!YnsO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9043e2f8-e933-4450-b612-8942b404842f_1167x337.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We simplify even further to obtain:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pbLZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F657f577b-194a-41b4-8946-68a58a59bc80_2023x278.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pbLZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F657f577b-194a-41b4-8946-68a58a59bc80_2023x278.png 424w, https://substackcdn.com/image/fetch/$s_!pbLZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F657f577b-194a-41b4-8946-68a58a59bc80_2023x278.png 848w, https://substackcdn.com/image/fetch/$s_!pbLZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F657f577b-194a-41b4-8946-68a58a59bc80_2023x278.png 1272w, https://substackcdn.com/image/fetch/$s_!pbLZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F657f577b-194a-41b4-8946-68a58a59bc80_2023x278.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pbLZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F657f577b-194a-41b4-8946-68a58a59bc80_2023x278.png" width="1456" height="200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/657f577b-194a-41b4-8946-68a58a59bc80_2023x278.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:40869,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F657f577b-194a-41b4-8946-68a58a59bc80_2023x278.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_!pbLZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F657f577b-194a-41b4-8946-68a58a59bc80_2023x278.png 424w, https://substackcdn.com/image/fetch/$s_!pbLZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F657f577b-194a-41b4-8946-68a58a59bc80_2023x278.png 848w, https://substackcdn.com/image/fetch/$s_!pbLZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F657f577b-194a-41b4-8946-68a58a59bc80_2023x278.png 1272w, https://substackcdn.com/image/fetch/$s_!pbLZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F657f577b-194a-41b4-8946-68a58a59bc80_2023x278.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We obtain 9.8 Newtons which we&#8217;ll round up to 10 to simplify things:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hkQ2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc33f860-80c6-4e3b-9ac2-c417945bf7ea_657x195.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hkQ2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc33f860-80c6-4e3b-9ac2-c417945bf7ea_657x195.png 424w, https://substackcdn.com/image/fetch/$s_!hkQ2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc33f860-80c6-4e3b-9ac2-c417945bf7ea_657x195.png 848w, https://substackcdn.com/image/fetch/$s_!hkQ2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc33f860-80c6-4e3b-9ac2-c417945bf7ea_657x195.png 1272w, https://substackcdn.com/image/fetch/$s_!hkQ2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc33f860-80c6-4e3b-9ac2-c417945bf7ea_657x195.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hkQ2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc33f860-80c6-4e3b-9ac2-c417945bf7ea_657x195.png" width="301" height="89.337899543379" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bc33f860-80c6-4e3b-9ac2-c417945bf7ea_657x195.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:195,&quot;width&quot;:657,&quot;resizeWidth&quot;:301,&quot;bytes&quot;:12815,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc33f860-80c6-4e3b-9ac2-c417945bf7ea_657x195.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_!hkQ2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc33f860-80c6-4e3b-9ac2-c417945bf7ea_657x195.png 424w, https://substackcdn.com/image/fetch/$s_!hkQ2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc33f860-80c6-4e3b-9ac2-c417945bf7ea_657x195.png 848w, https://substackcdn.com/image/fetch/$s_!hkQ2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc33f860-80c6-4e3b-9ac2-c417945bf7ea_657x195.png 1272w, https://substackcdn.com/image/fetch/$s_!hkQ2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbc33f860-80c6-4e3b-9ac2-c417945bf7ea_657x195.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>To be more precise, a 1 kg mass at Earth&#8217;s surface feels a gravitational force of about 10 Newtons (N). This may seem like a rather silly question, but now we ask: <strong>why doesn&#8217;t our 1 kg weight fall through our floor?</strong></p><p>We know that gravity is &#8220;pulling down&#8221; on the 1 kg weight with about a 10 Newton force. If gravity were the only force acting on our weight, it would indeed accelerate downward!! In reality, the earth&#8217;s surface needs to &#8220;push back&#8221; upward with an equal and opposite force of about 10 Newtons in order to keep our weight in its stable position &#8211; but where does this force come from?</p><p>Well, we should all know by now that the floor in your house (or living area) is made out of concrete / wood, and these materials are made of atoms and molecules bound together. Those atoms form a rigid lattice held by electromagnetic (chemical) bonds. The best visual for this is to imagine these atoms and molecules being bound by springs that hold them together (and in equilibrium):</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7NQw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c5a487f-4e6c-40d7-bda2-fcfc701e7b4a_605x466.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7NQw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c5a487f-4e6c-40d7-bda2-fcfc701e7b4a_605x466.png 424w, https://substackcdn.com/image/fetch/$s_!7NQw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c5a487f-4e6c-40d7-bda2-fcfc701e7b4a_605x466.png 848w, https://substackcdn.com/image/fetch/$s_!7NQw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c5a487f-4e6c-40d7-bda2-fcfc701e7b4a_605x466.png 1272w, https://substackcdn.com/image/fetch/$s_!7NQw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c5a487f-4e6c-40d7-bda2-fcfc701e7b4a_605x466.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7NQw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c5a487f-4e6c-40d7-bda2-fcfc701e7b4a_605x466.png" width="437" height="336.59834710743803" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2c5a487f-4e6c-40d7-bda2-fcfc701e7b4a_605x466.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:466,&quot;width&quot;:605,&quot;resizeWidth&quot;:437,&quot;bytes&quot;:74983,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c5a487f-4e6c-40d7-bda2-fcfc701e7b4a_605x466.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_!7NQw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c5a487f-4e6c-40d7-bda2-fcfc701e7b4a_605x466.png 424w, https://substackcdn.com/image/fetch/$s_!7NQw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c5a487f-4e6c-40d7-bda2-fcfc701e7b4a_605x466.png 848w, https://substackcdn.com/image/fetch/$s_!7NQw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c5a487f-4e6c-40d7-bda2-fcfc701e7b4a_605x466.png 1272w, https://substackcdn.com/image/fetch/$s_!7NQw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c5a487f-4e6c-40d7-bda2-fcfc701e7b4a_605x466.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></figure></div><p></p><p>Now, you can imagine these springs as representations of the bonds which hold you floor (or any solid) together &#8211; and this is really why a solid is...well solid &#8211; there are &#8216;spring like&#8217; bonds between these atoms which hold it together.</p><p>Now &#8211; you can imagine our 1 kg weight sitting on the floor: the weight&#8217;s force downward isn&#8217;t carried by one tiny point; it&#8217;s spread across the floor it is sitting on. Because the load is shared, no single spot gets overloaded and the floor doesn&#8217;t collapse.</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gqvP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff938728f-4133-47a6-9480-6de606308614_615x411.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gqvP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff938728f-4133-47a6-9480-6de606308614_615x411.png 424w, https://substackcdn.com/image/fetch/$s_!gqvP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff938728f-4133-47a6-9480-6de606308614_615x411.png 848w, https://substackcdn.com/image/fetch/$s_!gqvP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff938728f-4133-47a6-9480-6de606308614_615x411.png 1272w, https://substackcdn.com/image/fetch/$s_!gqvP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff938728f-4133-47a6-9480-6de606308614_615x411.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gqvP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff938728f-4133-47a6-9480-6de606308614_615x411.png" width="505" height="337.4878048780488" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f938728f-4133-47a6-9480-6de606308614_615x411.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:411,&quot;width&quot;:615,&quot;resizeWidth&quot;:505,&quot;bytes&quot;:83586,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff938728f-4133-47a6-9480-6de606308614_615x411.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_!gqvP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff938728f-4133-47a6-9480-6de606308614_615x411.png 424w, https://substackcdn.com/image/fetch/$s_!gqvP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff938728f-4133-47a6-9480-6de606308614_615x411.png 848w, https://substackcdn.com/image/fetch/$s_!gqvP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff938728f-4133-47a6-9480-6de606308614_615x411.png 1272w, https://substackcdn.com/image/fetch/$s_!gqvP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff938728f-4133-47a6-9480-6de606308614_615x411.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></figure></div><p>In the same way, when you press on a solid material, that force is passed along through its network of atomic or molecular bonds &#8211; each bond takes just a tiny piece of the total load, so the material as a whole holds up rather than breaking.</p><p>You can think of it as being a trampoline woven by trillions of microscopic strings (atomic bonds). When you place a load (like a 10 Newton force) on these springs, it spreads out among them and each spring barely stretches. This means that those forces are stronger than the 10 Newton force (applied by gravity) to the 1 kilogram weight and so the 1 kilogram weight doesn't fall through the floorboards due to the molecular structure of the floorboards withstanding it.</p><h4><strong>But&#8230;what if gravity turned into a cosmic wrecking ball?</strong></h4><p>Now, let&#8217;s go back to squishing earth down to the size of an ordinary marble.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!L3hW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7b89de8-76c4-42cb-8661-5e373f7315f1_1109x735.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!L3hW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7b89de8-76c4-42cb-8661-5e373f7315f1_1109x735.png 424w, https://substackcdn.com/image/fetch/$s_!L3hW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7b89de8-76c4-42cb-8661-5e373f7315f1_1109x735.png 848w, https://substackcdn.com/image/fetch/$s_!L3hW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7b89de8-76c4-42cb-8661-5e373f7315f1_1109x735.png 1272w, https://substackcdn.com/image/fetch/$s_!L3hW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7b89de8-76c4-42cb-8661-5e373f7315f1_1109x735.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!L3hW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7b89de8-76c4-42cb-8661-5e373f7315f1_1109x735.png" width="1109" height="735" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f7b89de8-76c4-42cb-8661-5e373f7315f1_1109x735.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:735,&quot;width&quot;:1109,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:568455,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7b89de8-76c4-42cb-8661-5e373f7315f1_1109x735.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_!L3hW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7b89de8-76c4-42cb-8661-5e373f7315f1_1109x735.png 424w, https://substackcdn.com/image/fetch/$s_!L3hW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7b89de8-76c4-42cb-8661-5e373f7315f1_1109x735.png 848w, https://substackcdn.com/image/fetch/$s_!L3hW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7b89de8-76c4-42cb-8661-5e373f7315f1_1109x735.png 1272w, https://substackcdn.com/image/fetch/$s_!L3hW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7b89de8-76c4-42cb-8661-5e373f7315f1_1109x735.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></figure></div><p>The question which I want to ask: <strong>what is the force acting on that 1 kilogram weight resting on its surface?</strong></p><p>In this instance, we once again go back to our original formula and plug in the appropriate values:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!O3Sl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb850dd-b93a-498d-99bf-9fd3f3cafb4e_493x278.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!O3Sl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb850dd-b93a-498d-99bf-9fd3f3cafb4e_493x278.png 424w, https://substackcdn.com/image/fetch/$s_!O3Sl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb850dd-b93a-498d-99bf-9fd3f3cafb4e_493x278.png 848w, https://substackcdn.com/image/fetch/$s_!O3Sl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb850dd-b93a-498d-99bf-9fd3f3cafb4e_493x278.png 1272w, https://substackcdn.com/image/fetch/$s_!O3Sl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb850dd-b93a-498d-99bf-9fd3f3cafb4e_493x278.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!O3Sl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb850dd-b93a-498d-99bf-9fd3f3cafb4e_493x278.png" width="219" height="123.49290060851926" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dfb850dd-b93a-498d-99bf-9fd3f3cafb4e_493x278.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:278,&quot;width&quot;:493,&quot;resizeWidth&quot;:219,&quot;bytes&quot;:12028,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb850dd-b93a-498d-99bf-9fd3f3cafb4e_493x278.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_!O3Sl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb850dd-b93a-498d-99bf-9fd3f3cafb4e_493x278.png 424w, https://substackcdn.com/image/fetch/$s_!O3Sl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb850dd-b93a-498d-99bf-9fd3f3cafb4e_493x278.png 848w, https://substackcdn.com/image/fetch/$s_!O3Sl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb850dd-b93a-498d-99bf-9fd3f3cafb4e_493x278.png 1272w, https://substackcdn.com/image/fetch/$s_!O3Sl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb850dd-b93a-498d-99bf-9fd3f3cafb4e_493x278.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ui6o!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb02563d-0df0-4425-9eb6-9e931f966655_1575x598.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ui6o!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb02563d-0df0-4425-9eb6-9e931f966655_1575x598.png 424w, https://substackcdn.com/image/fetch/$s_!ui6o!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb02563d-0df0-4425-9eb6-9e931f966655_1575x598.png 848w, https://substackcdn.com/image/fetch/$s_!ui6o!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb02563d-0df0-4425-9eb6-9e931f966655_1575x598.png 1272w, https://substackcdn.com/image/fetch/$s_!ui6o!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb02563d-0df0-4425-9eb6-9e931f966655_1575x598.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ui6o!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb02563d-0df0-4425-9eb6-9e931f966655_1575x598.png" width="522" height="198.2596153846154" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/db02563d-0df0-4425-9eb6-9e931f966655_1575x598.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:553,&quot;width&quot;:1456,&quot;resizeWidth&quot;:522,&quot;bytes&quot;:85900,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb02563d-0df0-4425-9eb6-9e931f966655_1575x598.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_!ui6o!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb02563d-0df0-4425-9eb6-9e931f966655_1575x598.png 424w, https://substackcdn.com/image/fetch/$s_!ui6o!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb02563d-0df0-4425-9eb6-9e931f966655_1575x598.png 848w, https://substackcdn.com/image/fetch/$s_!ui6o!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb02563d-0df0-4425-9eb6-9e931f966655_1575x598.png 1272w, https://substackcdn.com/image/fetch/$s_!ui6o!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb02563d-0df0-4425-9eb6-9e931f966655_1575x598.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Plugging in our values we get:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!T7Ip!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96fd3da2-92e9-417b-aeef-0a24bdca1838_1146x334.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!T7Ip!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96fd3da2-92e9-417b-aeef-0a24bdca1838_1146x334.png 424w, https://substackcdn.com/image/fetch/$s_!T7Ip!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96fd3da2-92e9-417b-aeef-0a24bdca1838_1146x334.png 848w, https://substackcdn.com/image/fetch/$s_!T7Ip!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96fd3da2-92e9-417b-aeef-0a24bdca1838_1146x334.png 1272w, https://substackcdn.com/image/fetch/$s_!T7Ip!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96fd3da2-92e9-417b-aeef-0a24bdca1838_1146x334.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!T7Ip!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96fd3da2-92e9-417b-aeef-0a24bdca1838_1146x334.png" width="389" height="113.37347294938918" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/96fd3da2-92e9-417b-aeef-0a24bdca1838_1146x334.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:334,&quot;width&quot;:1146,&quot;resizeWidth&quot;:389,&quot;bytes&quot;:34580,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96fd3da2-92e9-417b-aeef-0a24bdca1838_1146x334.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_!T7Ip!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96fd3da2-92e9-417b-aeef-0a24bdca1838_1146x334.png 424w, https://substackcdn.com/image/fetch/$s_!T7Ip!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96fd3da2-92e9-417b-aeef-0a24bdca1838_1146x334.png 848w, https://substackcdn.com/image/fetch/$s_!T7Ip!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96fd3da2-92e9-417b-aeef-0a24bdca1838_1146x334.png 1272w, https://substackcdn.com/image/fetch/$s_!T7Ip!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96fd3da2-92e9-417b-aeef-0a24bdca1838_1146x334.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>And finally, the final force in Newton&#8217;s is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XT3I!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19906318-3edc-4b53-a421-46065568b03d_2163x279.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XT3I!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19906318-3edc-4b53-a421-46065568b03d_2163x279.png 424w, https://substackcdn.com/image/fetch/$s_!XT3I!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19906318-3edc-4b53-a421-46065568b03d_2163x279.png 848w, https://substackcdn.com/image/fetch/$s_!XT3I!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19906318-3edc-4b53-a421-46065568b03d_2163x279.png 1272w, https://substackcdn.com/image/fetch/$s_!XT3I!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19906318-3edc-4b53-a421-46065568b03d_2163x279.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XT3I!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19906318-3edc-4b53-a421-46065568b03d_2163x279.png" width="1456" height="188" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/19906318-3edc-4b53-a421-46065568b03d_2163x279.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:188,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:47678,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19906318-3edc-4b53-a421-46065568b03d_2163x279.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_!XT3I!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19906318-3edc-4b53-a421-46065568b03d_2163x279.png 424w, https://substackcdn.com/image/fetch/$s_!XT3I!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19906318-3edc-4b53-a421-46065568b03d_2163x279.png 848w, https://substackcdn.com/image/fetch/$s_!XT3I!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19906318-3edc-4b53-a421-46065568b03d_2163x279.png 1272w, https://substackcdn.com/image/fetch/$s_!XT3I!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19906318-3edc-4b53-a421-46065568b03d_2163x279.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>The answer:</strong> the force on our 1 kilogram weight is now an astounding 10<sup>19</sup> Newtons. Suddenly, gravity isn&#8217;t a gentle tug&#8212;<strong>it&#8217;s a crushing avalanche</strong>.</p><p>In long form, this equates to:</p><h4>10,000,000,000,000,000,000 Newtons</h4><p>No known force (atomic or molecular) can resist this type of force!! Picture those trusty atomic springs again: on normal Earth, they share the load and they are thus able to over-come the gravitational potential energy from almost every object placed on them. Now &#8211; on marble-sized Earth, gravity&#8217;s force is a billion (1,000,000,000) times a billion times heavier: it&#8217;s like stacking every mountain on Earth onto a single spring. <strong>No atomic bond can withstand this!! </strong>The springs are &#8216;vaporized&#8217; thus making gravity the winner!</p><p>In other words, the gravitational pull from Earth&#8217;s &#8216;surface&#8217; drags everything inward. If you could squash the earth down to the size of a marble &#8211; the gravitational force would be so huge that nothing could stop it (due to Earth&#8217;s atomic bonds not being strong enough to hold it together) and it would thus carry on contracting under its own gravitational force and shrink until it essentially became a <strong>dimensionless point</strong>!!</p><p>This point is what we call a <strong>singularity. </strong>The point of no-return around the black hole from which nothing can escape is called the <strong>event horizon.</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SySE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe552465-d758-4cf6-858c-624537b9438b_701x542.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SySE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe552465-d758-4cf6-858c-624537b9438b_701x542.png 424w, https://substackcdn.com/image/fetch/$s_!SySE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe552465-d758-4cf6-858c-624537b9438b_701x542.png 848w, https://substackcdn.com/image/fetch/$s_!SySE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe552465-d758-4cf6-858c-624537b9438b_701x542.png 1272w, https://substackcdn.com/image/fetch/$s_!SySE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe552465-d758-4cf6-858c-624537b9438b_701x542.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SySE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe552465-d758-4cf6-858c-624537b9438b_701x542.png" width="587" height="453.85734664764624" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fe552465-d758-4cf6-858c-624537b9438b_701x542.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:542,&quot;width&quot;:701,&quot;resizeWidth&quot;:587,&quot;bytes&quot;:63306,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe552465-d758-4cf6-858c-624537b9438b_701x542.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_!SySE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe552465-d758-4cf6-858c-624537b9438b_701x542.png 424w, https://substackcdn.com/image/fetch/$s_!SySE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe552465-d758-4cf6-858c-624537b9438b_701x542.png 848w, https://substackcdn.com/image/fetch/$s_!SySE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe552465-d758-4cf6-858c-624537b9438b_701x542.png 1272w, https://substackcdn.com/image/fetch/$s_!SySE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe552465-d758-4cf6-858c-624537b9438b_701x542.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></figure></div><p><strong>At that stage, all of Earth&#8217;s mass resides in a point with zero volume. </strong>If it had any width (or volume), the tremendous gravitational energy would just pull it in. </p><p>There is a radius around that singularity of 8 millimeters which says that anything inside that radius has an escape velocity of greater than the speed of light. The boundary is what we call the event horizon because gravity inside remains unstoppable and all matter inevitably falls into the singularity.</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!I2ko!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741d2608-1434-4bd1-95d1-c4344687908a_442x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!I2ko!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741d2608-1434-4bd1-95d1-c4344687908a_442x500.png 424w, https://substackcdn.com/image/fetch/$s_!I2ko!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741d2608-1434-4bd1-95d1-c4344687908a_442x500.png 848w, https://substackcdn.com/image/fetch/$s_!I2ko!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741d2608-1434-4bd1-95d1-c4344687908a_442x500.png 1272w, https://substackcdn.com/image/fetch/$s_!I2ko!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741d2608-1434-4bd1-95d1-c4344687908a_442x500.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!I2ko!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741d2608-1434-4bd1-95d1-c4344687908a_442x500.png" width="398" height="450.2262443438914" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/741d2608-1434-4bd1-95d1-c4344687908a_442x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:442,&quot;resizeWidth&quot;:398,&quot;bytes&quot;:60502,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741d2608-1434-4bd1-95d1-c4344687908a_442x500.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_!I2ko!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741d2608-1434-4bd1-95d1-c4344687908a_442x500.png 424w, https://substackcdn.com/image/fetch/$s_!I2ko!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741d2608-1434-4bd1-95d1-c4344687908a_442x500.png 848w, https://substackcdn.com/image/fetch/$s_!I2ko!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741d2608-1434-4bd1-95d1-c4344687908a_442x500.png 1272w, https://substackcdn.com/image/fetch/$s_!I2ko!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F741d2608-1434-4bd1-95d1-c4344687908a_442x500.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></figure></div><p></p><h4>This is in essence of what a black hole represents: <strong>a celestial object so dense that no nearby matter or radiation can escape its gravitational field</strong>.</h4><p>Often, this is described as the boundary within which the black hole's escape velocity is greater than the speed of light. However, a more detailed description is that within this horizon, all light-like paths (paths that light could take) and hence all paths in the forward light cones of particles within the horizon are warped so as to fall farther into the hole. Once a particle is inside the horizon, moving into the hole is inevitable.</p><h3><strong>How to Create a Black Hole</strong></h3><p>Now, you have to ask yourself: this is all great and it sounds interesting, but how in the world can a black-hole be created? Squashing the earth to the size of a marble doesn&#8217;t seem like a very feasible plan, after all &#8211; so how does the universe do it?</p><p>In nature, black holes aren&#8217;t made by squeezing planets&#8212;they&#8217;re born from the corpses of massive stars. And when I say massive, I mean stars at least 20 times heavier than our Sun. What keeps a star from collapsing in the first place is a process called <strong>nuclear fusion</strong>. </p><p>For most of its life, a massive star is caught in a tug&#8209;of&#8209;war between two forces. Gravity constantly tries to pull all its mass inward, while the heat and light generated by nuclear fusion push outward. You can think of fusion as the star&#8217;s &#8220;engine,&#8221; taking hydrogen nuclei and slamming them together into helium, releasing energy in the process.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vQKb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470acb68-4153-4117-9dfa-118b81440a1d_792x629.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vQKb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470acb68-4153-4117-9dfa-118b81440a1d_792x629.png 424w, https://substackcdn.com/image/fetch/$s_!vQKb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470acb68-4153-4117-9dfa-118b81440a1d_792x629.png 848w, https://substackcdn.com/image/fetch/$s_!vQKb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470acb68-4153-4117-9dfa-118b81440a1d_792x629.png 1272w, https://substackcdn.com/image/fetch/$s_!vQKb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470acb68-4153-4117-9dfa-118b81440a1d_792x629.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vQKb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470acb68-4153-4117-9dfa-118b81440a1d_792x629.png" width="514" height="408.2146464646465" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/470acb68-4153-4117-9dfa-118b81440a1d_792x629.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:629,&quot;width&quot;:792,&quot;resizeWidth&quot;:514,&quot;bytes&quot;:54053,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470acb68-4153-4117-9dfa-118b81440a1d_792x629.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_!vQKb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470acb68-4153-4117-9dfa-118b81440a1d_792x629.png 424w, https://substackcdn.com/image/fetch/$s_!vQKb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470acb68-4153-4117-9dfa-118b81440a1d_792x629.png 848w, https://substackcdn.com/image/fetch/$s_!vQKb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470acb68-4153-4117-9dfa-118b81440a1d_792x629.png 1272w, https://substackcdn.com/image/fetch/$s_!vQKb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F470acb68-4153-4117-9dfa-118b81440a1d_792x629.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">Original image source: <a href="https://commons.wikimedia.org/wiki/File:FusionintheSun.svg">https://commons.wikimedia.org/wiki/File:FusionintheSun.svg</a> </figcaption></figure></div><p>Whenever two lighter nuclei fuse into one heavier nucleus, the process sheds a bit of mass as energy (E = mc&#178;). That energy emerges as heat and light, creating an outward pressure that exactly counters gravity&#8212;so long as there&#8217;s hydrogen fuel in the core, the star stays intact and continues shining.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iMPS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b1031ab-a64e-4da2-8f26-141ef6b327c6_965x504.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iMPS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b1031ab-a64e-4da2-8f26-141ef6b327c6_965x504.png 424w, https://substackcdn.com/image/fetch/$s_!iMPS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b1031ab-a64e-4da2-8f26-141ef6b327c6_965x504.png 848w, https://substackcdn.com/image/fetch/$s_!iMPS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b1031ab-a64e-4da2-8f26-141ef6b327c6_965x504.png 1272w, https://substackcdn.com/image/fetch/$s_!iMPS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b1031ab-a64e-4da2-8f26-141ef6b327c6_965x504.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iMPS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b1031ab-a64e-4da2-8f26-141ef6b327c6_965x504.png" width="965" height="504" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0b1031ab-a64e-4da2-8f26-141ef6b327c6_965x504.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:504,&quot;width&quot;:965,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:69771,&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://photonlines.substack.com/i/167457426?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b1031ab-a64e-4da2-8f26-141ef6b327c6_965x504.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_!iMPS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b1031ab-a64e-4da2-8f26-141ef6b327c6_965x504.png 424w, https://substackcdn.com/image/fetch/$s_!iMPS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b1031ab-a64e-4da2-8f26-141ef6b327c6_965x504.png 848w, https://substackcdn.com/image/fetch/$s_!iMPS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b1031ab-a64e-4da2-8f26-141ef6b327c6_965x504.png 1272w, https://substackcdn.com/image/fetch/$s_!iMPS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b1031ab-a64e-4da2-8f26-141ef6b327c6_965x504.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></figure></div><p>After millions of years, the hydrogen in the core starts to run out. The core contracts under gravity, heats up, and begins fusing helium into carbon, oxygen, and so on&#8212;building successively heavier elements all the way up to iron. Every new fusion stage lasts a shorter time than the last, but fusion of iron is special: it consumes energy instead of releasing it. Once a critical mass of iron builds up, there&#8217;s no more outward pressure from fusion. In an instant, gravity gains the upper hand.</p><p>Now, remember those atomic "springs" that held up our 1 kg weight? Here, they don&#8217;t just fail&#8212;they&#8217;re annihilated. Gravity ramps up to unimaginable forces (around 10<sup>30</sup> Newtons per square meter) and the imploding core reaches densities so extreme that protons and electrons merge into neutrons. If the remaining core mass is around 1.4&#8211;3&#8239;solar masses, neutron degeneracy pressure stops the collapse, leaving behind a neutron star. But if the dead star&#8217;s core is more massive&#8212;say, five or ten times our Sun&#8217;s mass&#8212;the neutron star gambit fails. Even neutron degeneracy pressure (the quantum mechanical force that keeps neutrons from being squeezed into the same space) can&#8217;t halt the collapse. In a dramatic final act, nothing remains to hold the core up, and it shrinks below its own Schwarzschild radius (the point of no return) becoming a black hole. The star&#8217;s outer layers rebound off the collapsing core and explode outward in a brilliant supernova, briefly outshining an entire galaxy, while the core vanishes into a singularity.</p><p>In other words, creating a black hole is less like squeezing the Earth into a marble and more like building up a massive star, letting it burn brightly for millions of years, then watching as it exhausts its nuclear fuel and succumbs to gravity&#8217;s ruthless pull. From the fiery forge of fusion to the final, crushing collapse, black holes are born in one of nature&#8217;s most spectacular fireworks shows&#8212;and therein lies gravity&#8217;s ultimate triumph.</p><h2>Final Note</h2><p>A big thank you to all my supporters and to my paid subscribers &#8211; this is an ad free publication and I appreciate the support!!</p><h3>Credits / References</h3><p>Stock photos:</p><ul><li><p>Earth image: <a href="https://pixabay.com/illustrations/earth-world-planet-globe-1303628/">https://pixabay.com/illustrations/earth-world-planet-globe-1303628/</a></p></li><li><p>1 kg weight image: <a href="https://openclipart.org/detail/190320/1kg-weight">https://openclipart.org/detail/190320/1kg-weight</a></p></li><li><p>Event horizon (Wikipedia entry): <a href="https://en.wikipedia.org/wiki/Event_horizon">https://en.wikipedia.org/wiki/Event_horizon</a></p></li><li><p>Fusion image source: <a href="https://commons.wikimedia.org/wiki/File:FusionintheSun.svg">https://commons.wikimedia.org/wiki/File:FusionintheSun.svg</a></p></li></ul><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Photon-Lines Substack is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[A Walk Through Combinatorics]]></title><description><![CDATA[An intuitive and visual focused walk-through and overview of combinatorics.]]></description><link>https://photonlines.substack.com/p/a-walk-through-combinatorics-part</link><guid isPermaLink="false">https://photonlines.substack.com/p/a-walk-through-combinatorics-part</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Fri, 25 Apr 2025 13:51:37 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!ZZje!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1417fc7-ded2-4285-809b-dc0413776b5a_512x412.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I recently got a chance to dive into the field of Combinatorics and decided to provide some of my own notes for anyone who&#8217;s interested in the topic and wants a high-level overview of this field. Many of the notes here are inspired by the book <a href="https://archive.org/details/a-walk-through-combinatorics">A Walk Through Combinatorics</a> and a lot of the credit goes to <a href="https://en.wikipedia.org/wiki/Mikl%C3%B3s_B%C3%B3na">Mikl&#243;s B&#243;na</a>. Noting this - let&#8217;s dive in!!</p><h3>Introduction</h3><p>Combinatorics is the branch of mathematics that studies how objects can be arranged, combined, or selected according to specific rules with a focus on <strong>patterns</strong> and <strong>relationships</strong>. By focusing on these relationships, we can gain a deeper understanding of how to model and count the objects in question. This intuition helps us solve many complex real-world problems including how to secure digital communications, understand genetic sequences, and efficiently plan trips. It&#8217;s influence extends to areas like artificial intelligence, cryptography, and game theory, making it indispensable for both theoretical research and real-world problem-solving.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Photon-Lines Substack is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div><hr></div><h3><strong>The Pigeon Hole Principle</strong></h3><p>The Pigeonhole Principle is a simple yet powerful concept in combinatorics. It states that if you have more "pigeons" than "pigeonholes" and you want to put each pigeon into a pigeonhole, at least one pigeonhole must contain more than one pigeon.</p><p>In mathematical terms: If n items are put into m containers and n&gt;m, then at least one container must hold more than one item.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://builtin.com/data-science/pigeonhole-principle" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZZje!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1417fc7-ded2-4285-809b-dc0413776b5a_512x412.png 424w, https://substackcdn.com/image/fetch/$s_!ZZje!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1417fc7-ded2-4285-809b-dc0413776b5a_512x412.png 848w, https://substackcdn.com/image/fetch/$s_!ZZje!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1417fc7-ded2-4285-809b-dc0413776b5a_512x412.png 1272w, https://substackcdn.com/image/fetch/$s_!ZZje!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1417fc7-ded2-4285-809b-dc0413776b5a_512x412.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZZje!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1417fc7-ded2-4285-809b-dc0413776b5a_512x412.png" width="438" height="352.453125" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b1417fc7-ded2-4285-809b-dc0413776b5a_512x412.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:412,&quot;width&quot;:512,&quot;resizeWidth&quot;:438,&quot;bytes&quot;:57921,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://builtin.com/data-science/pigeonhole-principle&quot;,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&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_!ZZje!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1417fc7-ded2-4285-809b-dc0413776b5a_512x412.png 424w, https://substackcdn.com/image/fetch/$s_!ZZje!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1417fc7-ded2-4285-809b-dc0413776b5a_512x412.png 848w, https://substackcdn.com/image/fetch/$s_!ZZje!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1417fc7-ded2-4285-809b-dc0413776b5a_512x412.png 1272w, https://substackcdn.com/image/fetch/$s_!ZZje!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1417fc7-ded2-4285-809b-dc0413776b5a_512x412.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></figure></div><h4>Simple Example</h4><p>Suppose you have a group of 13 people. Show that at least two of them were born in the same month.</p><p><strong>Solution:</strong></p><ol><li><p><strong>Identify the pigeons and pigeonholes:</strong> Here, the "pigeons" are the 13 people, and the "pigeonholes" are the 12 months of the year.</p></li><li><p><strong>Apply the Pigeonhole Principle:</strong> Since there are more people (13) than months (12), by the Pigeonhole Principle, at least one month must have at least two people born in it. Thus, at least two people in this group were born in the same month.</p></li></ol><div><hr></div><h3><strong>Mathematical Induction (i.e. One Step at a Time)</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!aRm4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4af7fa28-f1a1-4adf-9100-dec81bb29999_1355x1408.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!aRm4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4af7fa28-f1a1-4adf-9100-dec81bb29999_1355x1408.png 424w, https://substackcdn.com/image/fetch/$s_!aRm4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4af7fa28-f1a1-4adf-9100-dec81bb29999_1355x1408.png 848w, https://substackcdn.com/image/fetch/$s_!aRm4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4af7fa28-f1a1-4adf-9100-dec81bb29999_1355x1408.png 1272w, https://substackcdn.com/image/fetch/$s_!aRm4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4af7fa28-f1a1-4adf-9100-dec81bb29999_1355x1408.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!aRm4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4af7fa28-f1a1-4adf-9100-dec81bb29999_1355x1408.png" width="419" height="435.3889298892989" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4af7fa28-f1a1-4adf-9100-dec81bb29999_1355x1408.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1408,&quot;width&quot;:1355,&quot;resizeWidth&quot;:419,&quot;bytes&quot;:730563,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!aRm4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4af7fa28-f1a1-4adf-9100-dec81bb29999_1355x1408.png 424w, https://substackcdn.com/image/fetch/$s_!aRm4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4af7fa28-f1a1-4adf-9100-dec81bb29999_1355x1408.png 848w, https://substackcdn.com/image/fetch/$s_!aRm4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4af7fa28-f1a1-4adf-9100-dec81bb29999_1355x1408.png 1272w, https://substackcdn.com/image/fetch/$s_!aRm4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4af7fa28-f1a1-4adf-9100-dec81bb29999_1355x1408.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></figure></div><p></p><div><hr></div><h4><strong>Weak Induction</strong></h4><p>Weak induction, often simply called mathematical induction, is a proof technique used to show that a statement is true for all natural numbers. It works by proving two main steps:</p><ol><li><p><strong>Base Case:</strong> Prove that the statement is true for the first natural number (usually n=0 or n=1).</p></li><li><p><strong>Inductive Step:</strong> Assume that the statement is true for some arbitrary natural number k (this assumption is called the inductive hypothesis). Then, use this assumption to prove that the statement is true for k+1.</p></li></ol><h4><strong>Simple Example</strong></h4><p>Let's use weak induction to prove a simpler statement:</p><h3><strong>The sum of the first n odd numbers is n<sup>2</sup></strong></h3><p></p><h4><strong>Proof:</strong></h4><ol><li><p>First, we start off with our <strong>base case</strong> (n = 1):</p><p>The first odd number is 1. Since:</p><h4>1 = 1<sup>2</sup></h4><p>The base case holds.</p></li><li><p>Next, we go on to our <strong>inductive step. </strong>Assume that the statement is true for some arbitrary natural number k. That is, we can assume:</p><h4> 1 + 3 + 5 + &#8230; + (2k &#8722; 1) = k<sup>2</sup></h4><p>We need to prove that the statement is true for k+1. That is, we need to show:</p><h4> 1 + 3 + 5 + &#8230; + (2k &#8722; 1) + (2k + 1) = (k + 1)<sup>2</sup></h4><p></p><p>Using our original inductive hypothesis:</p><h4> 1 + 3 + 5 + &#8230; + (2k &#8722; 1) = k<sup>2</sup></h4><p>And subbing this into our new formula:</p><h4> 1 + 3 + 5 + &#8230; + (2k &#8722; 1) + (2k + 1) = (k + 1)<sup>2</sup></h4><h4> 1 + 3 + 5 + &#8230; + (2k &#8722; 1) = k<sup>2</sup></h4><p>We get:</p><h4> k<sup>2</sup> + (2k + 1) = (k + 1)<sup>2</sup></h4><p>And since we know that:</p><h4> (k + 1)<sup>2</sup> = k<sup>2</sup> + 2k + 1</h4><p>We know that our above statement holds and that:</p><h4> k<sup>2</sup> + (2k + 1) = (k + 1)<sup>2</sup></h4><h4> = k<sup>2</sup> + 2k + 1</h4><p>Since the statement holds for k+1, by the principle of mathematical induction, the sum of the first n odd numbers is n<sup>2</sup> for all natural numbers n.</p></li></ol><div><hr></div><h4>Strong Induction</h4><p>Strong induction, also known as complete induction, is similar to weak induction but with a slight difference in the inductive step. For weak induction, to prove that P(k+1) is true, you only assume that the previous step P(k) is true. For strong induction, you assume that <strong>all </strong>of the previous steps ( P(0), P(1), P(2), &#8230; , P(k) ) are true and use this to prove P(k + 1). In other words, weak induction is when you only use the immediately previous step. Strong induction is when you <strong>can use any previous step</strong>.</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="http://mathfoundations.lti.cs.cmu.edu/class2/induction.html" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bSJa!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d6e376c-c223-4705-924c-0ed2aae59b4d_553x283.png 424w, https://substackcdn.com/image/fetch/$s_!bSJa!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d6e376c-c223-4705-924c-0ed2aae59b4d_553x283.png 848w, https://substackcdn.com/image/fetch/$s_!bSJa!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d6e376c-c223-4705-924c-0ed2aae59b4d_553x283.png 1272w, https://substackcdn.com/image/fetch/$s_!bSJa!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d6e376c-c223-4705-924c-0ed2aae59b4d_553x283.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bSJa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d6e376c-c223-4705-924c-0ed2aae59b4d_553x283.png" width="463" height="236.94213381555153" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1d6e376c-c223-4705-924c-0ed2aae59b4d_553x283.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:283,&quot;width&quot;:553,&quot;resizeWidth&quot;:463,&quot;bytes&quot;:30427,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;http://mathfoundations.lti.cs.cmu.edu/class2/induction.html&quot;,&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_!bSJa!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d6e376c-c223-4705-924c-0ed2aae59b4d_553x283.png 424w, https://substackcdn.com/image/fetch/$s_!bSJa!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d6e376c-c223-4705-924c-0ed2aae59b4d_553x283.png 848w, https://substackcdn.com/image/fetch/$s_!bSJa!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d6e376c-c223-4705-924c-0ed2aae59b4d_553x283.png 1272w, https://substackcdn.com/image/fetch/$s_!bSJa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d6e376c-c223-4705-924c-0ed2aae59b4d_553x283.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h4>Simple Example</h4><p>Let's use strong induction to prove a simpler statement:</p><h4><strong>Every natural number n &#8805; 2 can be written as a product of one or more prime numbers.</strong></h4><p></p><h4><strong>Proof:</strong></h4><ol><li><p>First, we start off with our <strong>base case</strong> (n = 2):</p><p>2 is a prime number, so it can be written as itself, which is a product of one prime number, thus the base case holds.</p><p>Next, we go on to our <strong>inductive step.</strong></p></li><li><p>Assume that for all natural numbers m such that 2 &#8804; m &#8804; k, m can be written as a product of prime numbers. Now we need to prove that the statement is true for k+1:</p><ol><li><p>If k + 1 is a prime number:</p><ol><li><p>Then k + 1 itself is a product of one prime number (itself).</p></li></ol></li><li><p>If k+1 is not a prime number:</p><ol><li><p>Then k+1 can be written as a product of two natural numbers, say a and b, where 2 &#8804; a &#8804; k and 2 &#8804; b &#8804; k.</p></li><li><p>By the inductive hypothesis, both a and b can be written as products of prime numbers because they are both less than or equal to k.</p></li><li><p>Therefore, since k + 1 is a product of a and b:</p><h4> k + 1 = a * b</h4><p>We know that it can be written as a product of prime numbers which make up a and b:</p><h4>k + 1 = (primes which produce a) * (primes which produce b)</h4></li></ol><p>Since the statement holds for the base case and the inductive step has been proven, by the principle of strong induction, every natural number n &#8805; 2 can be written as a product of one or more prime numbers.</p></li></ol></li></ol><div><hr></div><h3><strong>Elementary Counting Problems</strong></h3><div><hr></div><h4><strong>Permutations</strong></h4><p>In simple terms, a permutation is a way of arranging items. The number of permutations of n distinct items is given by n! (n factorial), which is the product of all positive integers up to n. For 3 items, there are</p><h4>3! = 3 &#215; 2 &#215; 1 = 6 permutations</h4><p>Let&#8217;s consider a simple set of 3 items composed of A, B and C. If we want to list all the possible permutations (arrangements) of these three items, they would be:</p><ol><li><p>ABC</p></li><li><p>ACB</p></li><li><p>BAC</p></li><li><p>BCA</p></li><li><p>CAB</p></li><li><p>CBA</p></li></ol><h4><strong>Can you see why n different arrangements of n distinct items is n! (n factorial)?</strong></h4><p>We can get a good intuition for this by imagining that n people arrive at a doctor&#8217;s office at the same time. The doctor needs to treat them one by one, so they need to decide the order in which they&#8217;ll be served. Assuming there are n patients, there are n different choices which we can make on who to serve first. Knowing this then &#8211; how many choices do we have for which person goes second?</p><p>Well, we can observe that we already made a choice of who goes first, and we thus now have n &#8211; 1 patients to choose from for our 2<sup>nd</sup> choice. Once we make this choice, we have 1 less patient to once again choose from (thus obtaining n &#8211; 2) for our 3<sup>rd</sup> patient. Therefore, the number of orders in which the patients can be chosen in is:</p><h4>n &#215; (n - 1) &#215; (n &#8211; 2) &#215; ... &#215; 2 &#215;<strong> </strong>1</h4><h4>= n! (n factorial)</h4><div><hr></div><h4><strong>Stirling&#8217;s Formula: </strong></h4><p>Stirling's formula is an approximation used to estimate the factorial of a large number n:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HDzl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad9ffb0-5ad4-4317-8744-efddee8189f3_213x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HDzl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad9ffb0-5ad4-4317-8744-efddee8189f3_213x81.png 424w, https://substackcdn.com/image/fetch/$s_!HDzl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad9ffb0-5ad4-4317-8744-efddee8189f3_213x81.png 848w, https://substackcdn.com/image/fetch/$s_!HDzl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad9ffb0-5ad4-4317-8744-efddee8189f3_213x81.png 1272w, https://substackcdn.com/image/fetch/$s_!HDzl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad9ffb0-5ad4-4317-8744-efddee8189f3_213x81.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HDzl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad9ffb0-5ad4-4317-8744-efddee8189f3_213x81.png" width="213" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6ad9ffb0-5ad4-4317-8744-efddee8189f3_213x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:213,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:5303,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HDzl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad9ffb0-5ad4-4317-8744-efddee8189f3_213x81.png 424w, https://substackcdn.com/image/fetch/$s_!HDzl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad9ffb0-5ad4-4317-8744-efddee8189f3_213x81.png 848w, https://substackcdn.com/image/fetch/$s_!HDzl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad9ffb0-5ad4-4317-8744-efddee8189f3_213x81.png 1272w, https://substackcdn.com/image/fetch/$s_!HDzl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad9ffb0-5ad4-4317-8744-efddee8189f3_213x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Stirling's formula becomes more accurate as n increases, making it a powerful tool for estimating factorials in mathematical analysis and in algorithms that deal with large numbers.</p><div><hr></div><h4><strong>Permutations with Multisets</strong></h4><p>In our first example, we had a number of items (patients) and we assumed that no items could be repeated &#8211; but let&#8217;s now assume that we can have repetitions:</p><p><strong>Example:</strong> Find the number of ways to arrange the letters in the word "AAB".</p><p><strong>Solution</strong>: there are 3 distinct permutations of these letters provided below:</p><ol><li><p>AAB</p></li><li><p>ABA</p></li><li><p>BAA</p></li></ol><p>Notice that in this example, if all items were distinct, our formula would be 3! which equates to 6, but this time we only have 3. Why is this?</p><p>Well, and in multiset problems &#8211; we need to account for the fact that when items are repeated &#8211; some arrangements are identical because swapping identical elements results in an identical arrangement. If we were to look at our above example, we know that swapping two A&#8217;s in the AAB or ABA and BAA combinations doesn&#8217;t change the arrangement, so to adjust for the over-counting, we need to divide by the number of ways we can arrange the identical items within our set.</p><p>Thus, if you have n items in total, with n1 items of one type, n2 items of another type, and so on, the number of permutations is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zTX8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685ba98a-3416-4dec-a583-d3ae89f71a40_217x96.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zTX8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685ba98a-3416-4dec-a583-d3ae89f71a40_217x96.png 424w, https://substackcdn.com/image/fetch/$s_!zTX8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685ba98a-3416-4dec-a583-d3ae89f71a40_217x96.png 848w, https://substackcdn.com/image/fetch/$s_!zTX8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685ba98a-3416-4dec-a583-d3ae89f71a40_217x96.png 1272w, https://substackcdn.com/image/fetch/$s_!zTX8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685ba98a-3416-4dec-a583-d3ae89f71a40_217x96.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zTX8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685ba98a-3416-4dec-a583-d3ae89f71a40_217x96.png" width="217" height="96" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/685ba98a-3416-4dec-a583-d3ae89f71a40_217x96.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:96,&quot;width&quot;:217,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2780,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!zTX8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685ba98a-3416-4dec-a583-d3ae89f71a40_217x96.png 424w, https://substackcdn.com/image/fetch/$s_!zTX8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685ba98a-3416-4dec-a583-d3ae89f71a40_217x96.png 848w, https://substackcdn.com/image/fetch/$s_!zTX8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685ba98a-3416-4dec-a583-d3ae89f71a40_217x96.png 1272w, https://substackcdn.com/image/fetch/$s_!zTX8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685ba98a-3416-4dec-a583-d3ae89f71a40_217x96.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>In the above formula, the numerator (n!) simply represents the total number of permutations were unique, and the denominator is our &#8216;adjustment factor&#8217; created by the fact that we have identical elements where<strong> n1!&#8901;n2!&#8943;nk! a</strong>djusts for the fact that n1 items are identical, n2 items are identical, and so on, thereby correcting for over-counting.</p><p>In our earlier example (involving the unique permutations of &#8216;AAB&#8217;), we would obtain:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4Ttl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c96ddba-dece-44f5-b85d-0af12a695631_100x94.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4Ttl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c96ddba-dece-44f5-b85d-0af12a695631_100x94.png 424w, https://substackcdn.com/image/fetch/$s_!4Ttl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c96ddba-dece-44f5-b85d-0af12a695631_100x94.png 848w, https://substackcdn.com/image/fetch/$s_!4Ttl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c96ddba-dece-44f5-b85d-0af12a695631_100x94.png 1272w, https://substackcdn.com/image/fetch/$s_!4Ttl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c96ddba-dece-44f5-b85d-0af12a695631_100x94.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4Ttl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c96ddba-dece-44f5-b85d-0af12a695631_100x94.png" width="100" height="94" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7c96ddba-dece-44f5-b85d-0af12a695631_100x94.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:94,&quot;width&quot;:100,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2077,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4Ttl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c96ddba-dece-44f5-b85d-0af12a695631_100x94.png 424w, https://substackcdn.com/image/fetch/$s_!4Ttl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c96ddba-dece-44f5-b85d-0af12a695631_100x94.png 848w, https://substackcdn.com/image/fetch/$s_!4Ttl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c96ddba-dece-44f5-b85d-0af12a695631_100x94.png 1272w, https://substackcdn.com/image/fetch/$s_!4Ttl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c96ddba-dece-44f5-b85d-0af12a695631_100x94.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The above results in:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Or8j!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed36220-2d8a-4656-bf8a-ab7b0a8ca089_145x126.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Or8j!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed36220-2d8a-4656-bf8a-ab7b0a8ca089_145x126.png 424w, https://substackcdn.com/image/fetch/$s_!Or8j!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed36220-2d8a-4656-bf8a-ab7b0a8ca089_145x126.png 848w, https://substackcdn.com/image/fetch/$s_!Or8j!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed36220-2d8a-4656-bf8a-ab7b0a8ca089_145x126.png 1272w, https://substackcdn.com/image/fetch/$s_!Or8j!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed36220-2d8a-4656-bf8a-ab7b0a8ca089_145x126.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Or8j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed36220-2d8a-4656-bf8a-ab7b0a8ca089_145x126.png" width="145" height="126" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4ed36220-2d8a-4656-bf8a-ab7b0a8ca089_145x126.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:126,&quot;width&quot;:145,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2150,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Or8j!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed36220-2d8a-4656-bf8a-ab7b0a8ca089_145x126.png 424w, https://substackcdn.com/image/fetch/$s_!Or8j!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed36220-2d8a-4656-bf8a-ab7b0a8ca089_145x126.png 848w, https://substackcdn.com/image/fetch/$s_!Or8j!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed36220-2d8a-4656-bf8a-ab7b0a8ca089_145x126.png 1272w, https://substackcdn.com/image/fetch/$s_!Or8j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ed36220-2d8a-4656-bf8a-ab7b0a8ca089_145x126.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h4><strong>Another multiset example: </strong></h4><p>A box contains 3 red balls, 2 blue balls, and 1 green ball. How many distinct ways can you arrange these 6 balls in a row?</p><p><strong>Solution:</strong></p><ul><li><p>First, we count the total number of elements we have:</p><ul><li><p>Total balls = 3 red + 2 blue + 1 green = 6</p></li></ul></li><li><p>Next, we identify the repetitions:</p><ul><li><p>Number of red balls (n1) = 3</p></li><li><p>Number of blue balls (n2) = 2</p></li><li><p>Number of green balls (n3) = 1</p></li></ul></li></ul><p>Apply the multiset permutation formula:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Pr-C!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6b6a004-8c33-4816-8200-3255256c351d_162x95.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Pr-C!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6b6a004-8c33-4816-8200-3255256c351d_162x95.png 424w, https://substackcdn.com/image/fetch/$s_!Pr-C!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6b6a004-8c33-4816-8200-3255256c351d_162x95.png 848w, https://substackcdn.com/image/fetch/$s_!Pr-C!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6b6a004-8c33-4816-8200-3255256c351d_162x95.png 1272w, https://substackcdn.com/image/fetch/$s_!Pr-C!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6b6a004-8c33-4816-8200-3255256c351d_162x95.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Pr-C!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6b6a004-8c33-4816-8200-3255256c351d_162x95.png" width="162" height="95" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b6b6a004-8c33-4816-8200-3255256c351d_162x95.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:95,&quot;width&quot;:162,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2616,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Pr-C!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6b6a004-8c33-4816-8200-3255256c351d_162x95.png 424w, https://substackcdn.com/image/fetch/$s_!Pr-C!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6b6a004-8c33-4816-8200-3255256c351d_162x95.png 848w, https://substackcdn.com/image/fetch/$s_!Pr-C!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6b6a004-8c33-4816-8200-3255256c351d_162x95.png 1272w, https://substackcdn.com/image/fetch/$s_!Pr-C!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6b6a004-8c33-4816-8200-3255256c351d_162x95.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!t3zA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23c9277f-7bab-4a06-8ad9-a1946881ab32_291x121.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!t3zA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23c9277f-7bab-4a06-8ad9-a1946881ab32_291x121.png 424w, https://substackcdn.com/image/fetch/$s_!t3zA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23c9277f-7bab-4a06-8ad9-a1946881ab32_291x121.png 848w, https://substackcdn.com/image/fetch/$s_!t3zA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23c9277f-7bab-4a06-8ad9-a1946881ab32_291x121.png 1272w, https://substackcdn.com/image/fetch/$s_!t3zA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23c9277f-7bab-4a06-8ad9-a1946881ab32_291x121.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!t3zA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23c9277f-7bab-4a06-8ad9-a1946881ab32_291x121.png" width="291" height="121" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/23c9277f-7bab-4a06-8ad9-a1946881ab32_291x121.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:121,&quot;width&quot;:291,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:5004,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!t3zA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23c9277f-7bab-4a06-8ad9-a1946881ab32_291x121.png 424w, https://substackcdn.com/image/fetch/$s_!t3zA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23c9277f-7bab-4a06-8ad9-a1946881ab32_291x121.png 848w, https://substackcdn.com/image/fetch/$s_!t3zA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23c9277f-7bab-4a06-8ad9-a1946881ab32_291x121.png 1272w, https://substackcdn.com/image/fetch/$s_!t3zA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23c9277f-7bab-4a06-8ad9-a1946881ab32_291x121.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We thus know that there are 60 distinct ways of arranging 3 red balls, 2 blue balls, and 1 green ball in a row.</p><div><hr></div><h4><strong>Strings Over a Finite Alphabet</strong></h4><p>Next, we&#8217;ll examine problems where we aren&#8217;t merely arranging a given number of objects with specified usage limits. Instead, we&#8217;ll be creating strings or words using symbols from a finite set, called a finite alphabet. While we won&#8217;t need to specify how many times each symbol should appear, we might impose a restriction that each symbol can only appear once.</p><p><strong>Example: </strong>Suppose you have an alphabet with 3 symbols: {A,B,C}. How many different 3-digit strings can you create using these symbols?</p><p><strong>Solution</strong>: This time, we don&#8217;t have any limitations of which symbol we can pick in each position, so we can use each one of the 3 letters in our alphabet to get:</p><ol><li><p>AAA</p></li><li><p>AAB</p></li><li><p>AAC</p></li><li><p>ABA</p></li><li><p>ABB</p></li><li><p>ABC</p></li><li><p>ACA</p></li><li><p>ACB</p></li><li><p>ACC</p><p>&#8230;</p></li></ol><p>In the above examples, we enumerated over all of the possible combinations starting with the letter A &#8211; but we can keep going and substitute B and C as well. Enumerating over all arrangements thus nets us 3 * 9 = 27 different 3-letter strings.</p><p>We should be able to see the formula just by using our intuition:</p><p>Total number of possible combinations = (3 choices from A, B or C) &#215; (3 choices from A, B or C) &#215; (3 choices from A, B or C) = 3 &#215; 3 &#215; 3 = 27.</p><p>Our final solution is thus 3<sup>3</sup> = 27</p><h4><strong>Formula: </strong>The formula n<sup>k</sup> calculates the number of possible k-digit strings when using an n-element alphabet.</h4><div><hr></div><p>If you have n different symbols and want to create k-digit strings without repeating any symbols, the number of possible strings is given by the formula:</p><h4>n &#215; (n - 1) &#215; (n &#8211; 2) &#215; ... &#215; (n &#8211; k + 1)</h4><p>which can also be equivalently written down as:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zJjq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe566b847-7d43-4b46-8f41-8be8c36a0f61_134x108.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zJjq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe566b847-7d43-4b46-8f41-8be8c36a0f61_134x108.png 424w, https://substackcdn.com/image/fetch/$s_!zJjq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe566b847-7d43-4b46-8f41-8be8c36a0f61_134x108.png 848w, https://substackcdn.com/image/fetch/$s_!zJjq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe566b847-7d43-4b46-8f41-8be8c36a0f61_134x108.png 1272w, https://substackcdn.com/image/fetch/$s_!zJjq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe566b847-7d43-4b46-8f41-8be8c36a0f61_134x108.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zJjq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe566b847-7d43-4b46-8f41-8be8c36a0f61_134x108.png" width="124" height="99.94029850746269" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e566b847-7d43-4b46-8f41-8be8c36a0f61_134x108.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:108,&quot;width&quot;:134,&quot;resizeWidth&quot;:124,&quot;bytes&quot;:3491,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!zJjq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe566b847-7d43-4b46-8f41-8be8c36a0f61_134x108.png 424w, https://substackcdn.com/image/fetch/$s_!zJjq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe566b847-7d43-4b46-8f41-8be8c36a0f61_134x108.png 848w, https://substackcdn.com/image/fetch/$s_!zJjq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe566b847-7d43-4b46-8f41-8be8c36a0f61_134x108.png 1272w, https://substackcdn.com/image/fetch/$s_!zJjq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe566b847-7d43-4b46-8f41-8be8c36a0f61_134x108.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h4><strong>Example</strong>:</h4><p>If you have 5 symbols (A, B, C, D, E) and want to create 3-digit strings:</p><ul><li><p><strong>Choose and arrange 3 out of 5 symbols</strong>:</p><p>5 &#215; 4 &#215; 3 = 60</p></li><li><p><strong>This is equivalent to using the formula</strong>:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!utn7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F607605dc-f7e6-40c4-a4b7-d3fed0047b8e_585x92.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!utn7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F607605dc-f7e6-40c4-a4b7-d3fed0047b8e_585x92.png 424w, https://substackcdn.com/image/fetch/$s_!utn7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F607605dc-f7e6-40c4-a4b7-d3fed0047b8e_585x92.png 848w, https://substackcdn.com/image/fetch/$s_!utn7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F607605dc-f7e6-40c4-a4b7-d3fed0047b8e_585x92.png 1272w, https://substackcdn.com/image/fetch/$s_!utn7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F607605dc-f7e6-40c4-a4b7-d3fed0047b8e_585x92.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!utn7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F607605dc-f7e6-40c4-a4b7-d3fed0047b8e_585x92.png" width="489" height="76.9025641025641" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/607605dc-f7e6-40c4-a4b7-d3fed0047b8e_585x92.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:92,&quot;width&quot;:585,&quot;resizeWidth&quot;:489,&quot;bytes&quot;:10044,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!utn7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F607605dc-f7e6-40c4-a4b7-d3fed0047b8e_585x92.png 424w, https://substackcdn.com/image/fetch/$s_!utn7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F607605dc-f7e6-40c4-a4b7-d3fed0047b8e_585x92.png 848w, https://substackcdn.com/image/fetch/$s_!utn7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F607605dc-f7e6-40c4-a4b7-d3fed0047b8e_585x92.png 1272w, https://substackcdn.com/image/fetch/$s_!utn7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F607605dc-f7e6-40c4-a4b7-d3fed0047b8e_585x92.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p></li></ul><p>In both cases, you get 60 possible 3-digit strings without repeating any symbols.</p><div><hr></div><h4><strong>Bijections:</strong></h4><p>Imagine a large parking lot with many cars and many parking spaces. We don&#8217;t know the exact number of cars, but we know there are exactly 500 parking spaces. We suspect there are also 500 cars, but we&#8217;re not certain. How can we quickly test this idea? We can ask each car to park in a space. If every car finds a space and every space is filled, then we know there are exactly 500 cars. However, if some cars can&#8217;t find a space, it means there are more than 500 cars. Conversely, if some spaces remain empty, then there are fewer than 500 cars.</p><p>This technique of matching two sets element-wise and then conclude (in case of success) that the sets are equinumerous is very often used in combinatorial enumeration. Let us put it in a more formal context.</p><p>Let X and Y be two finite sets, and let f : X &#8594; Y be a function so that</p><ol><li><p>If f(a) = f(b), then a = b, and</p></li><li><p>For all y &#8712; Y there is an x &#8712; X so that f(x) = y,</p></li></ol><p>Then we say that <strong>f is a bijection</strong> from X onto Y. Equivalently, f is a bijection if for all y &#8712; Y , there exists a unique x &#8712; X so that f(x) = y.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LK_X!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd99afc1c-9c1f-4b4a-92b8-b3b2286b1232_390x489.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LK_X!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd99afc1c-9c1f-4b4a-92b8-b3b2286b1232_390x489.png 424w, https://substackcdn.com/image/fetch/$s_!LK_X!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd99afc1c-9c1f-4b4a-92b8-b3b2286b1232_390x489.png 848w, https://substackcdn.com/image/fetch/$s_!LK_X!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd99afc1c-9c1f-4b4a-92b8-b3b2286b1232_390x489.png 1272w, https://substackcdn.com/image/fetch/$s_!LK_X!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd99afc1c-9c1f-4b4a-92b8-b3b2286b1232_390x489.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LK_X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd99afc1c-9c1f-4b4a-92b8-b3b2286b1232_390x489.png" width="304" height="381.16923076923075" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d99afc1c-9c1f-4b4a-92b8-b3b2286b1232_390x489.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:489,&quot;width&quot;:390,&quot;resizeWidth&quot;:304,&quot;bytes&quot;:25805,&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://photonlines.substack.com/i/148107255?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd99afc1c-9c1f-4b4a-92b8-b3b2286b1232_390x489.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_!LK_X!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd99afc1c-9c1f-4b4a-92b8-b3b2286b1232_390x489.png 424w, https://substackcdn.com/image/fetch/$s_!LK_X!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd99afc1c-9c1f-4b4a-92b8-b3b2286b1232_390x489.png 848w, https://substackcdn.com/image/fetch/$s_!LK_X!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd99afc1c-9c1f-4b4a-92b8-b3b2286b1232_390x489.png 1272w, https://substackcdn.com/image/fetch/$s_!LK_X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd99afc1c-9c1f-4b4a-92b8-b3b2286b1232_390x489.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></figure></div><p>In other words, a bijection matches the elements of X with the elements of Y , so that each element will have exactly one match.</p><p>The functions that have only one of the two defining properties of bijections also have their own names:</p><h4><strong>Injection: </strong></h4><p>If f satisfies criterion (1) (i.e. f(a) = f(b), then a = b) then we say that f is <strong>one-to-one</strong> or <strong>injective</strong>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zNt_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F847db480-de71-4cba-ac20-677ce31d22ef_1270x1040.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zNt_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F847db480-de71-4cba-ac20-677ce31d22ef_1270x1040.png 424w, https://substackcdn.com/image/fetch/$s_!zNt_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F847db480-de71-4cba-ac20-677ce31d22ef_1270x1040.png 848w, https://substackcdn.com/image/fetch/$s_!zNt_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F847db480-de71-4cba-ac20-677ce31d22ef_1270x1040.png 1272w, https://substackcdn.com/image/fetch/$s_!zNt_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F847db480-de71-4cba-ac20-677ce31d22ef_1270x1040.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zNt_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F847db480-de71-4cba-ac20-677ce31d22ef_1270x1040.png" width="455" height="372.59842519685037" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/847db480-de71-4cba-ac20-677ce31d22ef_1270x1040.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1040,&quot;width&quot;:1270,&quot;resizeWidth&quot;:455,&quot;bytes&quot;:284693,&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://photonlines.substack.com/i/148107255?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F847db480-de71-4cba-ac20-677ce31d22ef_1270x1040.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_!zNt_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F847db480-de71-4cba-ac20-677ce31d22ef_1270x1040.png 424w, https://substackcdn.com/image/fetch/$s_!zNt_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F847db480-de71-4cba-ac20-677ce31d22ef_1270x1040.png 848w, https://substackcdn.com/image/fetch/$s_!zNt_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F847db480-de71-4cba-ac20-677ce31d22ef_1270x1040.png 1272w, https://substackcdn.com/image/fetch/$s_!zNt_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F847db480-de71-4cba-ac20-677ce31d22ef_1270x1040.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">Image Source: https://www.cuemath.com/algebra/injective-function/ </figcaption></figure></div><p>In the above image, we can observe that every element of set A is mapped to a unique element in set B. Further, if any element is set B is an image of more than one element of set A, then it is not a one-to-one or injective function.</p><h4><strong>Surjection: </strong></h4><p>If f satisfies criterion (2) (i.e. for all y &#8712; Y there is an x &#8712; X so that f(x) = y), then we say f is <strong>onto</strong> or <strong>surjective. </strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!k9rH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa90e7455-c69d-46ea-927a-3183371f7335_1329x1019.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!k9rH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa90e7455-c69d-46ea-927a-3183371f7335_1329x1019.png 424w, https://substackcdn.com/image/fetch/$s_!k9rH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa90e7455-c69d-46ea-927a-3183371f7335_1329x1019.png 848w, https://substackcdn.com/image/fetch/$s_!k9rH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa90e7455-c69d-46ea-927a-3183371f7335_1329x1019.png 1272w, https://substackcdn.com/image/fetch/$s_!k9rH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa90e7455-c69d-46ea-927a-3183371f7335_1329x1019.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!k9rH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa90e7455-c69d-46ea-927a-3183371f7335_1329x1019.png" width="484" height="371.1030850263356" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a90e7455-c69d-46ea-927a-3183371f7335_1329x1019.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1019,&quot;width&quot;:1329,&quot;resizeWidth&quot;:484,&quot;bytes&quot;:313286,&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://photonlines.substack.com/i/148107255?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa90e7455-c69d-46ea-927a-3183371f7335_1329x1019.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_!k9rH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa90e7455-c69d-46ea-927a-3183371f7335_1329x1019.png 424w, https://substackcdn.com/image/fetch/$s_!k9rH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa90e7455-c69d-46ea-927a-3183371f7335_1329x1019.png 848w, https://substackcdn.com/image/fetch/$s_!k9rH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa90e7455-c69d-46ea-927a-3183371f7335_1329x1019.png 1272w, https://substackcdn.com/image/fetch/$s_!k9rH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa90e7455-c69d-46ea-927a-3183371f7335_1329x1019.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">Image Source: https://www.cuemath.com/algebra/surjective-function/ </figcaption></figure></div><p>In other words, in a surjective function, every element of set B has been mapped from one or more than one element of set A. Also, the functions which are not surjective functions have elements in set B that have not been mapped from any element of set A.</p><p>Finally, two sets have the <strong>same size if and only if there is a b&#307;ection between them</strong>. Knowing this, we can use bijection to solve many combinatorial problems by converting one problem into another. Let&#8217;s show an example which illustrates this concept.</p><h4><strong>Simple Example:</strong> </h4><p>How many ways are there to distribute 4 identical candies to 3 children?</p><p><strong>Solution: </strong>To solve this problem, we'll use a bijection to relate it to a problem involving "stars and bars," a common combinatorial technique. Let&#8217;s first restate the problem in terms of stars and bars:</p><p>Think of the 4 candies as stars (&#8727;) and the separations between different children as bars (&#8739;). For example, distributing candies so that the first child gets 1 candy, the second child gets 2 candies, and the third child gets 1 candy can be represented as:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Zv59!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F051a3fe4-5d12-4cd8-ba80-ebe880b871a6_328x110.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Zv59!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F051a3fe4-5d12-4cd8-ba80-ebe880b871a6_328x110.png 424w, https://substackcdn.com/image/fetch/$s_!Zv59!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F051a3fe4-5d12-4cd8-ba80-ebe880b871a6_328x110.png 848w, https://substackcdn.com/image/fetch/$s_!Zv59!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F051a3fe4-5d12-4cd8-ba80-ebe880b871a6_328x110.png 1272w, https://substackcdn.com/image/fetch/$s_!Zv59!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F051a3fe4-5d12-4cd8-ba80-ebe880b871a6_328x110.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Zv59!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F051a3fe4-5d12-4cd8-ba80-ebe880b871a6_328x110.png" width="126" height="42.25609756097561" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/051a3fe4-5d12-4cd8-ba80-ebe880b871a6_328x110.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:110,&quot;width&quot;:328,&quot;resizeWidth&quot;:126,&quot;bytes&quot;:2851,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Zv59!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F051a3fe4-5d12-4cd8-ba80-ebe880b871a6_328x110.png 424w, https://substackcdn.com/image/fetch/$s_!Zv59!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F051a3fe4-5d12-4cd8-ba80-ebe880b871a6_328x110.png 848w, https://substackcdn.com/image/fetch/$s_!Zv59!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F051a3fe4-5d12-4cd8-ba80-ebe880b871a6_328x110.png 1272w, https://substackcdn.com/image/fetch/$s_!Zv59!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F051a3fe4-5d12-4cd8-ba80-ebe880b871a6_328x110.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Some other examples are provided below:</p><p>1 candy for first child, 1 candy for second child, 2 candies for third child:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7M9Z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5807bb9c-532f-47fb-be95-c3c2d429da76_358x141.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7M9Z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5807bb9c-532f-47fb-be95-c3c2d429da76_358x141.png 424w, https://substackcdn.com/image/fetch/$s_!7M9Z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5807bb9c-532f-47fb-be95-c3c2d429da76_358x141.png 848w, https://substackcdn.com/image/fetch/$s_!7M9Z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5807bb9c-532f-47fb-be95-c3c2d429da76_358x141.png 1272w, https://substackcdn.com/image/fetch/$s_!7M9Z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5807bb9c-532f-47fb-be95-c3c2d429da76_358x141.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7M9Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5807bb9c-532f-47fb-be95-c3c2d429da76_358x141.png" width="136" height="53.564245810055866" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5807bb9c-532f-47fb-be95-c3c2d429da76_358x141.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:141,&quot;width&quot;:358,&quot;resizeWidth&quot;:136,&quot;bytes&quot;:3131,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!7M9Z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5807bb9c-532f-47fb-be95-c3c2d429da76_358x141.png 424w, https://substackcdn.com/image/fetch/$s_!7M9Z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5807bb9c-532f-47fb-be95-c3c2d429da76_358x141.png 848w, https://substackcdn.com/image/fetch/$s_!7M9Z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5807bb9c-532f-47fb-be95-c3c2d429da76_358x141.png 1272w, https://substackcdn.com/image/fetch/$s_!7M9Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5807bb9c-532f-47fb-be95-c3c2d429da76_358x141.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>1 candy for first child, 3 candies for second child, 0 candies for third child:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!n9vn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b6dbab8-01bc-4f86-b49d-f10bb245051b_323x116.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!n9vn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b6dbab8-01bc-4f86-b49d-f10bb245051b_323x116.png 424w, https://substackcdn.com/image/fetch/$s_!n9vn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b6dbab8-01bc-4f86-b49d-f10bb245051b_323x116.png 848w, https://substackcdn.com/image/fetch/$s_!n9vn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b6dbab8-01bc-4f86-b49d-f10bb245051b_323x116.png 1272w, https://substackcdn.com/image/fetch/$s_!n9vn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b6dbab8-01bc-4f86-b49d-f10bb245051b_323x116.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!n9vn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b6dbab8-01bc-4f86-b49d-f10bb245051b_323x116.png" width="125" height="44.89164086687307" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2b6dbab8-01bc-4f86-b49d-f10bb245051b_323x116.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:116,&quot;width&quot;:323,&quot;resizeWidth&quot;:125,&quot;bytes&quot;:2851,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!n9vn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b6dbab8-01bc-4f86-b49d-f10bb245051b_323x116.png 424w, https://substackcdn.com/image/fetch/$s_!n9vn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b6dbab8-01bc-4f86-b49d-f10bb245051b_323x116.png 848w, https://substackcdn.com/image/fetch/$s_!n9vn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b6dbab8-01bc-4f86-b49d-f10bb245051b_323x116.png 1272w, https://substackcdn.com/image/fetch/$s_!n9vn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b6dbab8-01bc-4f86-b49d-f10bb245051b_323x116.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>0 candies for first child, 4 candies for second child, 0 candies for third child:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hj7E!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d79661f-d4d9-403d-8fe1-c257b5eb5f9d_330x115.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hj7E!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d79661f-d4d9-403d-8fe1-c257b5eb5f9d_330x115.png 424w, https://substackcdn.com/image/fetch/$s_!hj7E!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d79661f-d4d9-403d-8fe1-c257b5eb5f9d_330x115.png 848w, https://substackcdn.com/image/fetch/$s_!hj7E!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d79661f-d4d9-403d-8fe1-c257b5eb5f9d_330x115.png 1272w, https://substackcdn.com/image/fetch/$s_!hj7E!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d79661f-d4d9-403d-8fe1-c257b5eb5f9d_330x115.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hj7E!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d79661f-d4d9-403d-8fe1-c257b5eb5f9d_330x115.png" width="130" height="45.303030303030305" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5d79661f-d4d9-403d-8fe1-c257b5eb5f9d_330x115.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:115,&quot;width&quot;:330,&quot;resizeWidth&quot;:130,&quot;bytes&quot;:2576,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hj7E!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d79661f-d4d9-403d-8fe1-c257b5eb5f9d_330x115.png 424w, https://substackcdn.com/image/fetch/$s_!hj7E!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d79661f-d4d9-403d-8fe1-c257b5eb5f9d_330x115.png 848w, https://substackcdn.com/image/fetch/$s_!hj7E!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d79661f-d4d9-403d-8fe1-c257b5eb5f9d_330x115.png 1272w, https://substackcdn.com/image/fetch/$s_!hj7E!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d79661f-d4d9-403d-8fe1-c257b5eb5f9d_330x115.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Seeing the bijection</strong>: we should be able to easily see that the problem of distributing 4 candies to 3 children is equivalent to finding the number of ways of arranging 4 stars and 2 bars in a sequence by looking at our examples, and we can thus proceed.</p><p>To solve the problem, we can treat it as a permutation problem involving multisets. We have count the ways of arranging 4 stars and 2 bars to get:</p><ul><li><p>The total number of symbols (stars + bars) is 4 + 2 = 6, thus 6 is our numerator.</p></li></ul><p>Since we have 4 identical stars and 2 bars, these are the values we have in the denominator to produce:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iGsi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc57764c-f261-421d-9813-b1a072ff2689_268x103.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iGsi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc57764c-f261-421d-9813-b1a072ff2689_268x103.png 424w, https://substackcdn.com/image/fetch/$s_!iGsi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc57764c-f261-421d-9813-b1a072ff2689_268x103.png 848w, https://substackcdn.com/image/fetch/$s_!iGsi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc57764c-f261-421d-9813-b1a072ff2689_268x103.png 1272w, https://substackcdn.com/image/fetch/$s_!iGsi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc57764c-f261-421d-9813-b1a072ff2689_268x103.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iGsi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc57764c-f261-421d-9813-b1a072ff2689_268x103.png" width="268" height="103" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fc57764c-f261-421d-9813-b1a072ff2689_268x103.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:103,&quot;width&quot;:268,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:4862,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!iGsi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc57764c-f261-421d-9813-b1a072ff2689_268x103.png 424w, https://substackcdn.com/image/fetch/$s_!iGsi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc57764c-f261-421d-9813-b1a072ff2689_268x103.png 848w, https://substackcdn.com/image/fetch/$s_!iGsi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc57764c-f261-421d-9813-b1a072ff2689_268x103.png 1272w, https://substackcdn.com/image/fetch/$s_!iGsi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc57764c-f261-421d-9813-b1a072ff2689_268x103.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Using bijection, we transformed the problem of distributing candies into the problem of arranging stars and bars and so, we now know that there are 15 ways of distributing 4 identical candies to 3 children.</p><div><hr></div><h4><strong>Choice Problems</strong></h4><p>In a local raffle, six numbers are chosen at random from a set of 50 numbers. To win the grand prize, you need to guess all six numbers correctly. How many different combinations are there to guarantee a win?</p><p>This type of problem is known as a "choice problem" in combinatorics. In these problems, we select certain subsets from a given set, often requiring the subsets to have a specific size. Unlike previous examples where the order mattered, here the order of the elements in the subset does not matter; for example, {5, 7, 9, 14} and {7, 5, 9, 14} are considered the same subset of the set of 50 numbers.</p><p>The number of ways to choose a subset of k elements from a set of n elements is crucial in combinatorics, so it has its own symbol and name which we denote as &#8220;<strong>n choose k</strong>&#8221; and which we represent below:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iG7L!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc66a2679-2a76-42d6-8c9f-663f4975c2d4_298x119.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iG7L!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc66a2679-2a76-42d6-8c9f-663f4975c2d4_298x119.png 424w, https://substackcdn.com/image/fetch/$s_!iG7L!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc66a2679-2a76-42d6-8c9f-663f4975c2d4_298x119.png 848w, https://substackcdn.com/image/fetch/$s_!iG7L!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc66a2679-2a76-42d6-8c9f-663f4975c2d4_298x119.png 1272w, https://substackcdn.com/image/fetch/$s_!iG7L!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc66a2679-2a76-42d6-8c9f-663f4975c2d4_298x119.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iG7L!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc66a2679-2a76-42d6-8c9f-663f4975c2d4_298x119.png" width="264" height="105.42281879194631" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c66a2679-2a76-42d6-8c9f-663f4975c2d4_298x119.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:119,&quot;width&quot;:298,&quot;resizeWidth&quot;:264,&quot;bytes&quot;:8739,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!iG7L!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc66a2679-2a76-42d6-8c9f-663f4975c2d4_298x119.png 424w, https://substackcdn.com/image/fetch/$s_!iG7L!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc66a2679-2a76-42d6-8c9f-663f4975c2d4_298x119.png 848w, https://substackcdn.com/image/fetch/$s_!iG7L!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc66a2679-2a76-42d6-8c9f-663f4975c2d4_298x119.png 1272w, https://substackcdn.com/image/fetch/$s_!iG7L!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc66a2679-2a76-42d6-8c9f-663f4975c2d4_298x119.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>If you want to find out how many ways you can choose 6 numbers out of 50 distinct ones, we simple plug this into our formula to get:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xnAP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d2e7a91-549f-4964-a7a9-f2c5ff94227c_649x168.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xnAP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d2e7a91-549f-4964-a7a9-f2c5ff94227c_649x168.png 424w, https://substackcdn.com/image/fetch/$s_!xnAP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d2e7a91-549f-4964-a7a9-f2c5ff94227c_649x168.png 848w, https://substackcdn.com/image/fetch/$s_!xnAP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d2e7a91-549f-4964-a7a9-f2c5ff94227c_649x168.png 1272w, https://substackcdn.com/image/fetch/$s_!xnAP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d2e7a91-549f-4964-a7a9-f2c5ff94227c_649x168.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xnAP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d2e7a91-549f-4964-a7a9-f2c5ff94227c_649x168.png" width="417" height="107.94453004622495" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9d2e7a91-549f-4964-a7a9-f2c5ff94227c_649x168.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:168,&quot;width&quot;:649,&quot;resizeWidth&quot;:417,&quot;bytes&quot;:16773,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!xnAP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d2e7a91-549f-4964-a7a9-f2c5ff94227c_649x168.png 424w, https://substackcdn.com/image/fetch/$s_!xnAP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d2e7a91-549f-4964-a7a9-f2c5ff94227c_649x168.png 848w, https://substackcdn.com/image/fetch/$s_!xnAP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d2e7a91-549f-4964-a7a9-f2c5ff94227c_649x168.png 1272w, https://substackcdn.com/image/fetch/$s_!xnAP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d2e7a91-549f-4964-a7a9-f2c5ff94227c_649x168.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!84VX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd99dd5c-0fb7-4812-b89d-0a6ed1564414_320x99.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!84VX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd99dd5c-0fb7-4812-b89d-0a6ed1564414_320x99.png 424w, https://substackcdn.com/image/fetch/$s_!84VX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd99dd5c-0fb7-4812-b89d-0a6ed1564414_320x99.png 848w, https://substackcdn.com/image/fetch/$s_!84VX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd99dd5c-0fb7-4812-b89d-0a6ed1564414_320x99.png 1272w, https://substackcdn.com/image/fetch/$s_!84VX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd99dd5c-0fb7-4812-b89d-0a6ed1564414_320x99.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!84VX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd99dd5c-0fb7-4812-b89d-0a6ed1564414_320x99.png" width="206" height="63.73125" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dd99dd5c-0fb7-4812-b89d-0a6ed1564414_320x99.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:99,&quot;width&quot;:320,&quot;resizeWidth&quot;:206,&quot;bytes&quot;:5839,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!84VX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd99dd5c-0fb7-4812-b89d-0a6ed1564414_320x99.png 424w, https://substackcdn.com/image/fetch/$s_!84VX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd99dd5c-0fb7-4812-b89d-0a6ed1564414_320x99.png 848w, https://substackcdn.com/image/fetch/$s_!84VX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd99dd5c-0fb7-4812-b89d-0a6ed1564414_320x99.png 1272w, https://substackcdn.com/image/fetch/$s_!84VX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd99dd5c-0fb7-4812-b89d-0a6ed1564414_320x99.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h4><strong>Another Example: </strong></h4><p>A committee of 5 people is to be formed from a group of 10 candidates. How many different ways can the committee be formed?</p><p><strong>Solution:</strong></p><p>To solve this problem, we need to find the number of ways to choose 5 people out of 10.</p><ul><li><p>Identify n and k:</p><ul><li><p>n is the total number of candidates, which is 10.</p></li><li><p>k is the number of people to be chosen, which is 5.</p></li></ul></li><li><p>Apply the Binomial Coefficient Formula:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OsMs!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4bd640-a9f0-4fe6-8a07-4fa9626d9d31_397x114.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OsMs!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4bd640-a9f0-4fe6-8a07-4fa9626d9d31_397x114.png 424w, https://substackcdn.com/image/fetch/$s_!OsMs!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4bd640-a9f0-4fe6-8a07-4fa9626d9d31_397x114.png 848w, https://substackcdn.com/image/fetch/$s_!OsMs!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4bd640-a9f0-4fe6-8a07-4fa9626d9d31_397x114.png 1272w, https://substackcdn.com/image/fetch/$s_!OsMs!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4bd640-a9f0-4fe6-8a07-4fa9626d9d31_397x114.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OsMs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4bd640-a9f0-4fe6-8a07-4fa9626d9d31_397x114.png" width="397" height="114" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ca4bd640-a9f0-4fe6-8a07-4fa9626d9d31_397x114.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:114,&quot;width&quot;:397,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:6399,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OsMs!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4bd640-a9f0-4fe6-8a07-4fa9626d9d31_397x114.png 424w, https://substackcdn.com/image/fetch/$s_!OsMs!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4bd640-a9f0-4fe6-8a07-4fa9626d9d31_397x114.png 848w, https://substackcdn.com/image/fetch/$s_!OsMs!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4bd640-a9f0-4fe6-8a07-4fa9626d9d31_397x114.png 1272w, https://substackcdn.com/image/fetch/$s_!OsMs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca4bd640-a9f0-4fe6-8a07-4fa9626d9d31_397x114.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div></li></ul><p>The above gives us 252, so there are 252 different ways to form a committee of 5 people from a group of 10 candidates.</p><div><hr></div><h4>Enumeration / Counting Summary</h4><p>The following table summarizes the enumeration theorems we went over in this section:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vHmS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ad70ba9-a2d2-48ba-826c-914105dd85cc_1499x1372.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vHmS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ad70ba9-a2d2-48ba-826c-914105dd85cc_1499x1372.png 424w, https://substackcdn.com/image/fetch/$s_!vHmS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ad70ba9-a2d2-48ba-826c-914105dd85cc_1499x1372.png 848w, https://substackcdn.com/image/fetch/$s_!vHmS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ad70ba9-a2d2-48ba-826c-914105dd85cc_1499x1372.png 1272w, https://substackcdn.com/image/fetch/$s_!vHmS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ad70ba9-a2d2-48ba-826c-914105dd85cc_1499x1372.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vHmS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ad70ba9-a2d2-48ba-826c-914105dd85cc_1499x1372.png" width="727" height="665.584478021978" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4ad70ba9-a2d2-48ba-826c-914105dd85cc_1499x1372.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1333,&quot;width&quot;:1456,&quot;resizeWidth&quot;:727,&quot;bytes&quot;:158399,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!vHmS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ad70ba9-a2d2-48ba-826c-914105dd85cc_1499x1372.png 424w, https://substackcdn.com/image/fetch/$s_!vHmS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ad70ba9-a2d2-48ba-826c-914105dd85cc_1499x1372.png 848w, https://substackcdn.com/image/fetch/$s_!vHmS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ad70ba9-a2d2-48ba-826c-914105dd85cc_1499x1372.png 1272w, https://substackcdn.com/image/fetch/$s_!vHmS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ad70ba9-a2d2-48ba-826c-914105dd85cc_1499x1372.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></figure></div><div><hr></div><h3><strong>The Binomial theorem and Related Identities</strong></h3><div><hr></div><h4><strong>The Binomial Theorem</strong></h4><p>The binomial theorem states that:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!EuR5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb10c207-62d8-499a-93f8-34514bbdd50f_887x244.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!EuR5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb10c207-62d8-499a-93f8-34514bbdd50f_887x244.png 424w, https://substackcdn.com/image/fetch/$s_!EuR5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb10c207-62d8-499a-93f8-34514bbdd50f_887x244.png 848w, https://substackcdn.com/image/fetch/$s_!EuR5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb10c207-62d8-499a-93f8-34514bbdd50f_887x244.png 1272w, https://substackcdn.com/image/fetch/$s_!EuR5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb10c207-62d8-499a-93f8-34514bbdd50f_887x244.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!EuR5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb10c207-62d8-499a-93f8-34514bbdd50f_887x244.png" width="337" height="92.70349492671927" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bb10c207-62d8-499a-93f8-34514bbdd50f_887x244.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:244,&quot;width&quot;:887,&quot;resizeWidth&quot;:337,&quot;bytes&quot;:26757,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!EuR5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb10c207-62d8-499a-93f8-34514bbdd50f_887x244.png 424w, https://substackcdn.com/image/fetch/$s_!EuR5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb10c207-62d8-499a-93f8-34514bbdd50f_887x244.png 848w, https://substackcdn.com/image/fetch/$s_!EuR5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb10c207-62d8-499a-93f8-34514bbdd50f_887x244.png 1272w, https://substackcdn.com/image/fetch/$s_!EuR5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb10c207-62d8-499a-93f8-34514bbdd50f_887x244.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The theorem tells us how to expand (multiply out) a binomial that is raised to a power n. Let's look at a concrete example to make this clearer.</p><h4><strong>Example:</strong></h4><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!85fw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bd27ecf-d2b6-4b57-9e34-b693dfdb256b_560x143.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!85fw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bd27ecf-d2b6-4b57-9e34-b693dfdb256b_560x143.png 424w, https://substackcdn.com/image/fetch/$s_!85fw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bd27ecf-d2b6-4b57-9e34-b693dfdb256b_560x143.png 848w, https://substackcdn.com/image/fetch/$s_!85fw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bd27ecf-d2b6-4b57-9e34-b693dfdb256b_560x143.png 1272w, https://substackcdn.com/image/fetch/$s_!85fw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bd27ecf-d2b6-4b57-9e34-b693dfdb256b_560x143.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!85fw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bd27ecf-d2b6-4b57-9e34-b693dfdb256b_560x143.png" width="178" height="45.45357142857143" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6bd27ecf-d2b6-4b57-9e34-b693dfdb256b_560x143.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:143,&quot;width&quot;:560,&quot;resizeWidth&quot;:178,&quot;bytes&quot;:10559,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!85fw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bd27ecf-d2b6-4b57-9e34-b693dfdb256b_560x143.png 424w, https://substackcdn.com/image/fetch/$s_!85fw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bd27ecf-d2b6-4b57-9e34-b693dfdb256b_560x143.png 848w, https://substackcdn.com/image/fetch/$s_!85fw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bd27ecf-d2b6-4b57-9e34-b693dfdb256b_560x143.png 1272w, https://substackcdn.com/image/fetch/$s_!85fw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bd27ecf-d2b6-4b57-9e34-b693dfdb256b_560x143.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We can write out this expansion using our binomial theorem / formula:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4_PA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d50d16d-cd3f-4824-90f7-9467092a74e3_905x320.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4_PA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d50d16d-cd3f-4824-90f7-9467092a74e3_905x320.png 424w, https://substackcdn.com/image/fetch/$s_!4_PA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d50d16d-cd3f-4824-90f7-9467092a74e3_905x320.png 848w, https://substackcdn.com/image/fetch/$s_!4_PA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d50d16d-cd3f-4824-90f7-9467092a74e3_905x320.png 1272w, https://substackcdn.com/image/fetch/$s_!4_PA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d50d16d-cd3f-4824-90f7-9467092a74e3_905x320.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4_PA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d50d16d-cd3f-4824-90f7-9467092a74e3_905x320.png" width="369" height="130.47513812154696" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8d50d16d-cd3f-4824-90f7-9467092a74e3_905x320.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:320,&quot;width&quot;:905,&quot;resizeWidth&quot;:369,&quot;bytes&quot;:29102,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4_PA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d50d16d-cd3f-4824-90f7-9467092a74e3_905x320.png 424w, https://substackcdn.com/image/fetch/$s_!4_PA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d50d16d-cd3f-4824-90f7-9467092a74e3_905x320.png 848w, https://substackcdn.com/image/fetch/$s_!4_PA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d50d16d-cd3f-4824-90f7-9467092a74e3_905x320.png 1272w, https://substackcdn.com/image/fetch/$s_!4_PA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d50d16d-cd3f-4824-90f7-9467092a74e3_905x320.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Let&#8217;s calculate each term using the formula above:</p><ul><li><p>When k = 0:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Qmm5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd1581f9-708a-4d1c-82ac-c09ea51d0813_913x243.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Qmm5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd1581f9-708a-4d1c-82ac-c09ea51d0813_913x243.png 424w, https://substackcdn.com/image/fetch/$s_!Qmm5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd1581f9-708a-4d1c-82ac-c09ea51d0813_913x243.png 848w, https://substackcdn.com/image/fetch/$s_!Qmm5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd1581f9-708a-4d1c-82ac-c09ea51d0813_913x243.png 1272w, https://substackcdn.com/image/fetch/$s_!Qmm5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd1581f9-708a-4d1c-82ac-c09ea51d0813_913x243.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Qmm5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd1581f9-708a-4d1c-82ac-c09ea51d0813_913x243.png" width="356" height="94.7513691128149" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fd1581f9-708a-4d1c-82ac-c09ea51d0813_913x243.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:243,&quot;width&quot;:913,&quot;resizeWidth&quot;:356,&quot;bytes&quot;:19802,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Qmm5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd1581f9-708a-4d1c-82ac-c09ea51d0813_913x243.png 424w, https://substackcdn.com/image/fetch/$s_!Qmm5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd1581f9-708a-4d1c-82ac-c09ea51d0813_913x243.png 848w, https://substackcdn.com/image/fetch/$s_!Qmm5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd1581f9-708a-4d1c-82ac-c09ea51d0813_913x243.png 1272w, https://substackcdn.com/image/fetch/$s_!Qmm5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd1581f9-708a-4d1c-82ac-c09ea51d0813_913x243.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div></li><li><p>When k = 1:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bCps!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91087bb2-3f5b-448a-be93-39bd453c17bf_992x242.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bCps!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91087bb2-3f5b-448a-be93-39bd453c17bf_992x242.png 424w, https://substackcdn.com/image/fetch/$s_!bCps!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91087bb2-3f5b-448a-be93-39bd453c17bf_992x242.png 848w, https://substackcdn.com/image/fetch/$s_!bCps!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91087bb2-3f5b-448a-be93-39bd453c17bf_992x242.png 1272w, https://substackcdn.com/image/fetch/$s_!bCps!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91087bb2-3f5b-448a-be93-39bd453c17bf_992x242.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bCps!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91087bb2-3f5b-448a-be93-39bd453c17bf_992x242.png" width="350" height="85.38306451612904" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/91087bb2-3f5b-448a-be93-39bd453c17bf_992x242.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:242,&quot;width&quot;:992,&quot;resizeWidth&quot;:350,&quot;bytes&quot;:24655,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!bCps!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91087bb2-3f5b-448a-be93-39bd453c17bf_992x242.png 424w, https://substackcdn.com/image/fetch/$s_!bCps!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91087bb2-3f5b-448a-be93-39bd453c17bf_992x242.png 848w, https://substackcdn.com/image/fetch/$s_!bCps!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91087bb2-3f5b-448a-be93-39bd453c17bf_992x242.png 1272w, https://substackcdn.com/image/fetch/$s_!bCps!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91087bb2-3f5b-448a-be93-39bd453c17bf_992x242.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div></li><li><p>When k = 2:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mqjx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F504eba15-4987-409c-bf7f-4ea49b7fb8d4_1012x256.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mqjx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F504eba15-4987-409c-bf7f-4ea49b7fb8d4_1012x256.png 424w, https://substackcdn.com/image/fetch/$s_!mqjx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F504eba15-4987-409c-bf7f-4ea49b7fb8d4_1012x256.png 848w, https://substackcdn.com/image/fetch/$s_!mqjx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F504eba15-4987-409c-bf7f-4ea49b7fb8d4_1012x256.png 1272w, https://substackcdn.com/image/fetch/$s_!mqjx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F504eba15-4987-409c-bf7f-4ea49b7fb8d4_1012x256.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mqjx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F504eba15-4987-409c-bf7f-4ea49b7fb8d4_1012x256.png" width="356" height="90.05533596837945" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/504eba15-4987-409c-bf7f-4ea49b7fb8d4_1012x256.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:256,&quot;width&quot;:1012,&quot;resizeWidth&quot;:356,&quot;bytes&quot;:25822,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mqjx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F504eba15-4987-409c-bf7f-4ea49b7fb8d4_1012x256.png 424w, https://substackcdn.com/image/fetch/$s_!mqjx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F504eba15-4987-409c-bf7f-4ea49b7fb8d4_1012x256.png 848w, https://substackcdn.com/image/fetch/$s_!mqjx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F504eba15-4987-409c-bf7f-4ea49b7fb8d4_1012x256.png 1272w, https://substackcdn.com/image/fetch/$s_!mqjx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F504eba15-4987-409c-bf7f-4ea49b7fb8d4_1012x256.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div></li><li><p>When k = 3:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RfG2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0e24faa-a73c-4984-9529-01728daa74a9_927x227.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RfG2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0e24faa-a73c-4984-9529-01728daa74a9_927x227.png 424w, https://substackcdn.com/image/fetch/$s_!RfG2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0e24faa-a73c-4984-9529-01728daa74a9_927x227.png 848w, https://substackcdn.com/image/fetch/$s_!RfG2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0e24faa-a73c-4984-9529-01728daa74a9_927x227.png 1272w, https://substackcdn.com/image/fetch/$s_!RfG2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0e24faa-a73c-4984-9529-01728daa74a9_927x227.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RfG2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0e24faa-a73c-4984-9529-01728daa74a9_927x227.png" width="354" height="86.68608414239482" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d0e24faa-a73c-4984-9529-01728daa74a9_927x227.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:227,&quot;width&quot;:927,&quot;resizeWidth&quot;:354,&quot;bytes&quot;:20090,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!RfG2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0e24faa-a73c-4984-9529-01728daa74a9_927x227.png 424w, https://substackcdn.com/image/fetch/$s_!RfG2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0e24faa-a73c-4984-9529-01728daa74a9_927x227.png 848w, https://substackcdn.com/image/fetch/$s_!RfG2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0e24faa-a73c-4984-9529-01728daa74a9_927x227.png 1272w, https://substackcdn.com/image/fetch/$s_!RfG2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd0e24faa-a73c-4984-9529-01728daa74a9_927x227.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p></li></ul><p>When we combine all of our terms we finally get:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3kTN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69463941-c5df-457c-8b2a-3cfcda4501f9_1103x190.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3kTN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69463941-c5df-457c-8b2a-3cfcda4501f9_1103x190.png 424w, https://substackcdn.com/image/fetch/$s_!3kTN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69463941-c5df-457c-8b2a-3cfcda4501f9_1103x190.png 848w, https://substackcdn.com/image/fetch/$s_!3kTN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69463941-c5df-457c-8b2a-3cfcda4501f9_1103x190.png 1272w, https://substackcdn.com/image/fetch/$s_!3kTN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69463941-c5df-457c-8b2a-3cfcda4501f9_1103x190.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3kTN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69463941-c5df-457c-8b2a-3cfcda4501f9_1103x190.png" width="476" height="81.99456029011786" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/69463941-c5df-457c-8b2a-3cfcda4501f9_1103x190.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:190,&quot;width&quot;:1103,&quot;resizeWidth&quot;:476,&quot;bytes&quot;:19721,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3kTN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69463941-c5df-457c-8b2a-3cfcda4501f9_1103x190.png 424w, https://substackcdn.com/image/fetch/$s_!3kTN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69463941-c5df-457c-8b2a-3cfcda4501f9_1103x190.png 848w, https://substackcdn.com/image/fetch/$s_!3kTN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69463941-c5df-457c-8b2a-3cfcda4501f9_1103x190.png 1272w, https://substackcdn.com/image/fetch/$s_!3kTN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69463941-c5df-457c-8b2a-3cfcda4501f9_1103x190.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We should be able to see that the binomial theorem provides a way to expand expressions of the form (a+b)<sup>n</sup> into a sum of terms involving powers of a and b. The coefficients of these terms are given by the binomial coefficients, which can be calculated using factorials. This theorem is widely used in algebra and combinatorics.</p><div><hr></div><h4><strong>Pascal&#8217;s Triangle</strong></h4><p>Pascal's triangle is a triangular array of numbers. Each number is the sum of the two numbers directly above it in the previous row. The first few rows of Pascal's triangle look like this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!k-57!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F489afb7e-74f0-4bf4-a1ba-d47952030887_611x478.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!k-57!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F489afb7e-74f0-4bf4-a1ba-d47952030887_611x478.png 424w, https://substackcdn.com/image/fetch/$s_!k-57!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F489afb7e-74f0-4bf4-a1ba-d47952030887_611x478.png 848w, https://substackcdn.com/image/fetch/$s_!k-57!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F489afb7e-74f0-4bf4-a1ba-d47952030887_611x478.png 1272w, https://substackcdn.com/image/fetch/$s_!k-57!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F489afb7e-74f0-4bf4-a1ba-d47952030887_611x478.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!k-57!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F489afb7e-74f0-4bf4-a1ba-d47952030887_611x478.png" width="471" height="368.4746317512275" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/489afb7e-74f0-4bf4-a1ba-d47952030887_611x478.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:478,&quot;width&quot;:611,&quot;resizeWidth&quot;:471,&quot;bytes&quot;:9383,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!k-57!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F489afb7e-74f0-4bf4-a1ba-d47952030887_611x478.png 424w, https://substackcdn.com/image/fetch/$s_!k-57!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F489afb7e-74f0-4bf4-a1ba-d47952030887_611x478.png 848w, https://substackcdn.com/image/fetch/$s_!k-57!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F489afb7e-74f0-4bf4-a1ba-d47952030887_611x478.png 1272w, https://substackcdn.com/image/fetch/$s_!k-57!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F489afb7e-74f0-4bf4-a1ba-d47952030887_611x478.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></figure></div><p></p><p>Another fantastic illustration:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JRzO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e2f41bf-1baa-4766-a71a-5fcf00116293_1166x961.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JRzO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e2f41bf-1baa-4766-a71a-5fcf00116293_1166x961.png 424w, https://substackcdn.com/image/fetch/$s_!JRzO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e2f41bf-1baa-4766-a71a-5fcf00116293_1166x961.png 848w, https://substackcdn.com/image/fetch/$s_!JRzO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e2f41bf-1baa-4766-a71a-5fcf00116293_1166x961.png 1272w, https://substackcdn.com/image/fetch/$s_!JRzO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e2f41bf-1baa-4766-a71a-5fcf00116293_1166x961.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JRzO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e2f41bf-1baa-4766-a71a-5fcf00116293_1166x961.png" width="337" height="277.7504288164665" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e2f41bf-1baa-4766-a71a-5fcf00116293_1166x961.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:961,&quot;width&quot;:1166,&quot;resizeWidth&quot;:337,&quot;bytes&quot;:174636,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!JRzO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e2f41bf-1baa-4766-a71a-5fcf00116293_1166x961.png 424w, https://substackcdn.com/image/fetch/$s_!JRzO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e2f41bf-1baa-4766-a71a-5fcf00116293_1166x961.png 848w, https://substackcdn.com/image/fetch/$s_!JRzO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e2f41bf-1baa-4766-a71a-5fcf00116293_1166x961.png 1272w, https://substackcdn.com/image/fetch/$s_!JRzO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e2f41bf-1baa-4766-a71a-5fcf00116293_1166x961.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></figure></div><p>The numbers in Pascal's triangle are the binomial coefficients n choose k. Each row n of Pascal's triangle corresponds to the coefficients of the expanded form of (a + b)<sup>n</sup>.</p><p>As an example, the 4th row of Pascal's triangle is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5waj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3be3f0-65fb-4d29-b1c2-ba45386010ae_574x110.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5waj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3be3f0-65fb-4d29-b1c2-ba45386010ae_574x110.png 424w, https://substackcdn.com/image/fetch/$s_!5waj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3be3f0-65fb-4d29-b1c2-ba45386010ae_574x110.png 848w, https://substackcdn.com/image/fetch/$s_!5waj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3be3f0-65fb-4d29-b1c2-ba45386010ae_574x110.png 1272w, https://substackcdn.com/image/fetch/$s_!5waj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3be3f0-65fb-4d29-b1c2-ba45386010ae_574x110.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5waj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3be3f0-65fb-4d29-b1c2-ba45386010ae_574x110.png" width="252" height="48.292682926829265" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fa3be3f0-65fb-4d29-b1c2-ba45386010ae_574x110.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:110,&quot;width&quot;:574,&quot;resizeWidth&quot;:252,&quot;bytes&quot;:4121,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5waj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3be3f0-65fb-4d29-b1c2-ba45386010ae_574x110.png 424w, https://substackcdn.com/image/fetch/$s_!5waj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3be3f0-65fb-4d29-b1c2-ba45386010ae_574x110.png 848w, https://substackcdn.com/image/fetch/$s_!5waj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3be3f0-65fb-4d29-b1c2-ba45386010ae_574x110.png 1272w, https://substackcdn.com/image/fetch/$s_!5waj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3be3f0-65fb-4d29-b1c2-ba45386010ae_574x110.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The binomial theorem states:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_oja!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1da853cc-5edf-4e27-bc72-b452a6894a6c_899x269.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_oja!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1da853cc-5edf-4e27-bc72-b452a6894a6c_899x269.png 424w, https://substackcdn.com/image/fetch/$s_!_oja!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1da853cc-5edf-4e27-bc72-b452a6894a6c_899x269.png 848w, https://substackcdn.com/image/fetch/$s_!_oja!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1da853cc-5edf-4e27-bc72-b452a6894a6c_899x269.png 1272w, https://substackcdn.com/image/fetch/$s_!_oja!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1da853cc-5edf-4e27-bc72-b452a6894a6c_899x269.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_oja!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1da853cc-5edf-4e27-bc72-b452a6894a6c_899x269.png" width="389" height="116.39710789766407" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1da853cc-5edf-4e27-bc72-b452a6894a6c_899x269.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:269,&quot;width&quot;:899,&quot;resizeWidth&quot;:389,&quot;bytes&quot;:26142,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_oja!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1da853cc-5edf-4e27-bc72-b452a6894a6c_899x269.png 424w, https://substackcdn.com/image/fetch/$s_!_oja!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1da853cc-5edf-4e27-bc72-b452a6894a6c_899x269.png 848w, https://substackcdn.com/image/fetch/$s_!_oja!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1da853cc-5edf-4e27-bc72-b452a6894a6c_899x269.png 1272w, https://substackcdn.com/image/fetch/$s_!_oja!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1da853cc-5edf-4e27-bc72-b452a6894a6c_899x269.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>And when we expand it out 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_!NSU1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2227632-09bb-4c5a-a466-653f711d988b_321x723.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NSU1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2227632-09bb-4c5a-a466-653f711d988b_321x723.png 424w, https://substackcdn.com/image/fetch/$s_!NSU1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2227632-09bb-4c5a-a466-653f711d988b_321x723.png 848w, https://substackcdn.com/image/fetch/$s_!NSU1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2227632-09bb-4c5a-a466-653f711d988b_321x723.png 1272w, https://substackcdn.com/image/fetch/$s_!NSU1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2227632-09bb-4c5a-a466-653f711d988b_321x723.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NSU1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2227632-09bb-4c5a-a466-653f711d988b_321x723.png" width="163" height="367.13084112149534" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b2227632-09bb-4c5a-a466-653f711d988b_321x723.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:723,&quot;width&quot;:321,&quot;resizeWidth&quot;:163,&quot;bytes&quot;:26842,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!NSU1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2227632-09bb-4c5a-a466-653f711d988b_321x723.png 424w, https://substackcdn.com/image/fetch/$s_!NSU1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2227632-09bb-4c5a-a466-653f711d988b_321x723.png 848w, https://substackcdn.com/image/fetch/$s_!NSU1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2227632-09bb-4c5a-a466-653f711d988b_321x723.png 1272w, https://substackcdn.com/image/fetch/$s_!NSU1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2227632-09bb-4c5a-a466-653f711d988b_321x723.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></figure></div><p>And this relates directly to the row in our triangle:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!V2ED!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52d803e-58c8-4d84-bab2-8b8941e1c4f0_1552x381.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!V2ED!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52d803e-58c8-4d84-bab2-8b8941e1c4f0_1552x381.png 424w, https://substackcdn.com/image/fetch/$s_!V2ED!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52d803e-58c8-4d84-bab2-8b8941e1c4f0_1552x381.png 848w, https://substackcdn.com/image/fetch/$s_!V2ED!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52d803e-58c8-4d84-bab2-8b8941e1c4f0_1552x381.png 1272w, https://substackcdn.com/image/fetch/$s_!V2ED!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52d803e-58c8-4d84-bab2-8b8941e1c4f0_1552x381.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!V2ED!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52d803e-58c8-4d84-bab2-8b8941e1c4f0_1552x381.png" width="601" height="147.36057692307693" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d52d803e-58c8-4d84-bab2-8b8941e1c4f0_1552x381.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:357,&quot;width&quot;:1456,&quot;resizeWidth&quot;:601,&quot;bytes&quot;:58737,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!V2ED!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52d803e-58c8-4d84-bab2-8b8941e1c4f0_1552x381.png 424w, https://substackcdn.com/image/fetch/$s_!V2ED!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52d803e-58c8-4d84-bab2-8b8941e1c4f0_1552x381.png 848w, https://substackcdn.com/image/fetch/$s_!V2ED!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52d803e-58c8-4d84-bab2-8b8941e1c4f0_1552x381.png 1272w, https://substackcdn.com/image/fetch/$s_!V2ED!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd52d803e-58c8-4d84-bab2-8b8941e1c4f0_1552x381.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div><hr></div><h4><strong>The Binomial Theorem (General Version)</strong></h4><p>Let me be any real number. Then:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!UHws!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96601a2f-d16f-47a8-ada1-3a4fc2ffcd71_901x297.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UHws!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96601a2f-d16f-47a8-ada1-3a4fc2ffcd71_901x297.png 424w, https://substackcdn.com/image/fetch/$s_!UHws!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96601a2f-d16f-47a8-ada1-3a4fc2ffcd71_901x297.png 848w, https://substackcdn.com/image/fetch/$s_!UHws!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96601a2f-d16f-47a8-ada1-3a4fc2ffcd71_901x297.png 1272w, https://substackcdn.com/image/fetch/$s_!UHws!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96601a2f-d16f-47a8-ada1-3a4fc2ffcd71_901x297.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!UHws!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96601a2f-d16f-47a8-ada1-3a4fc2ffcd71_901x297.png" width="349" height="115.04217536071032" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/96601a2f-d16f-47a8-ada1-3a4fc2ffcd71_901x297.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:297,&quot;width&quot;:901,&quot;resizeWidth&quot;:349,&quot;bytes&quot;:26991,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!UHws!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96601a2f-d16f-47a8-ada1-3a4fc2ffcd71_901x297.png 424w, https://substackcdn.com/image/fetch/$s_!UHws!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96601a2f-d16f-47a8-ada1-3a4fc2ffcd71_901x297.png 848w, https://substackcdn.com/image/fetch/$s_!UHws!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96601a2f-d16f-47a8-ada1-3a4fc2ffcd71_901x297.png 1272w, https://substackcdn.com/image/fetch/$s_!UHws!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96601a2f-d16f-47a8-ada1-3a4fc2ffcd71_901x297.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>where the sum is taken over all non-negative integers n.</p><div><hr></div><h3><strong>Divide and Conquer. Partitions.</strong></h3><p>In our previous coverage, we mainly focused on lists of objects, distinct or not, with repetitions allowed or not, and with the order of the elements on the list being relevant or not. Here, we will go one step further by discussing distribution problems.</p><div><hr></div><h4><strong>Compositions</strong></h4><p>Suppose we have fifteen identical candies and we want to give them to three children: Emma, Jack, and Lily. Since the candies are identical, what matters is how many candies each child gets. To find out the number of ways we can distribute these candies, we need to know how many ways we can write 15 as a sum of three non-negative integers. The order in which the integers are written matters because it represents different distributions. For example, 3 + 7 + 5 is different from 7 + 3 + 5 because in the first case, Emma gets three candies, while in the second case, Emma gets seven.</p><h4><strong>Definition:</strong></h4><p>A sequence (a1, a2, &#8230; , ak) of integers where each ai &#8805; 0 and a1 + a2 + &#8943; + ak = n is called a <strong>weak composition</strong> of n. If, in addition, each ai is positive for all i, then the sequence (a1, a2, &#8230; , ak) is called a <strong>composition</strong> of n.</p><p><strong>Example:</strong></p><p>If we have 15 candies and want to distribute them among Emma, Jack, and Lily, one possible weak composition of 15 could be:</p><ul><li><p>Emma gets 2 candies,</p></li><li><p>Jack gets 4 candies,</p></li><li><p>Lily gets 9 candies.</p></li></ul><p>This can be written as the sequence (2, 4, 9).</p><p>If the sequence were (4, 9, 2), it would mean Emma gets 4 candies, Jack gets 9 candies, and Lily gets 2 candies.</p><p>These different sequences represent different ways of distributing the candies, even though the sum is still 15.</p><h4><strong>Formula for Computing Weak Compositions</strong></h4><p>The number of weak compositions of a positive integer n into k parts is given by the binomial coefficient:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_h_6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feede242c-5610-43a8-9c74-667101c3986f_452x246.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_h_6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feede242c-5610-43a8-9c74-667101c3986f_452x246.png 424w, https://substackcdn.com/image/fetch/$s_!_h_6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feede242c-5610-43a8-9c74-667101c3986f_452x246.png 848w, https://substackcdn.com/image/fetch/$s_!_h_6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feede242c-5610-43a8-9c74-667101c3986f_452x246.png 1272w, https://substackcdn.com/image/fetch/$s_!_h_6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feede242c-5610-43a8-9c74-667101c3986f_452x246.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_h_6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feede242c-5610-43a8-9c74-667101c3986f_452x246.png" width="196" height="106.67256637168141" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eede242c-5610-43a8-9c74-667101c3986f_452x246.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:246,&quot;width&quot;:452,&quot;resizeWidth&quot;:196,&quot;bytes&quot;:12050,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_h_6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feede242c-5610-43a8-9c74-667101c3986f_452x246.png 424w, https://substackcdn.com/image/fetch/$s_!_h_6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feede242c-5610-43a8-9c74-667101c3986f_452x246.png 848w, https://substackcdn.com/image/fetch/$s_!_h_6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feede242c-5610-43a8-9c74-667101c3986f_452x246.png 1272w, https://substackcdn.com/image/fetch/$s_!_h_6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feede242c-5610-43a8-9c74-667101c3986f_452x246.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h4><strong>Example:</strong></h4><p>Let's solve the example of distributing 15 candies to three children (Emma, Jack, and Lily) using this formula.</p><p><strong>Identify n and k:</strong></p><ul><li><p>n = 15 (the total number of candies)</p></li><li><p>k = 3 (the number of children)</p></li></ul><p><strong>Apply the Formula:</strong></p><p>The number of weak compositions is given by:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!eaip!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe308644-fa96-4d86-8fce-c9fadc3eb42b_1279x252.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!eaip!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe308644-fa96-4d86-8fce-c9fadc3eb42b_1279x252.png 424w, https://substackcdn.com/image/fetch/$s_!eaip!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe308644-fa96-4d86-8fce-c9fadc3eb42b_1279x252.png 848w, https://substackcdn.com/image/fetch/$s_!eaip!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe308644-fa96-4d86-8fce-c9fadc3eb42b_1279x252.png 1272w, https://substackcdn.com/image/fetch/$s_!eaip!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe308644-fa96-4d86-8fce-c9fadc3eb42b_1279x252.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!eaip!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe308644-fa96-4d86-8fce-c9fadc3eb42b_1279x252.png" width="524" height="103.24315871774824" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fe308644-fa96-4d86-8fce-c9fadc3eb42b_1279x252.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:252,&quot;width&quot;:1279,&quot;resizeWidth&quot;:524,&quot;bytes&quot;:30353,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!eaip!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe308644-fa96-4d86-8fce-c9fadc3eb42b_1279x252.png 424w, https://substackcdn.com/image/fetch/$s_!eaip!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe308644-fa96-4d86-8fce-c9fadc3eb42b_1279x252.png 848w, https://substackcdn.com/image/fetch/$s_!eaip!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe308644-fa96-4d86-8fce-c9fadc3eb42b_1279x252.png 1272w, https://substackcdn.com/image/fetch/$s_!eaip!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe308644-fa96-4d86-8fce-c9fadc3eb42b_1279x252.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Calculating the binomial coefficient 17 choose 2 gives us 136 and so there are 136 different ways to distribute 15 candies among 3 children.</p><div><hr></div><h4><strong>For all positive integers n and k, the number of compositions of n into k parts is</strong>:</h4><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ExKe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7425dd98-600d-497b-babd-e05a31250417_357x241.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ExKe!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7425dd98-600d-497b-babd-e05a31250417_357x241.png 424w, https://substackcdn.com/image/fetch/$s_!ExKe!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7425dd98-600d-497b-babd-e05a31250417_357x241.png 848w, https://substackcdn.com/image/fetch/$s_!ExKe!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7425dd98-600d-497b-babd-e05a31250417_357x241.png 1272w, https://substackcdn.com/image/fetch/$s_!ExKe!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7425dd98-600d-497b-babd-e05a31250417_357x241.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ExKe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7425dd98-600d-497b-babd-e05a31250417_357x241.png" width="167" height="112.73669467787114" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7425dd98-600d-497b-babd-e05a31250417_357x241.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:241,&quot;width&quot;:357,&quot;resizeWidth&quot;:167,&quot;bytes&quot;:10101,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ExKe!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7425dd98-600d-497b-babd-e05a31250417_357x241.png 424w, https://substackcdn.com/image/fetch/$s_!ExKe!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7425dd98-600d-497b-babd-e05a31250417_357x241.png 848w, https://substackcdn.com/image/fetch/$s_!ExKe!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7425dd98-600d-497b-babd-e05a31250417_357x241.png 1272w, https://substackcdn.com/image/fetch/$s_!ExKe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7425dd98-600d-497b-babd-e05a31250417_357x241.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Example: </strong>Let's solve an example using this formula. Suppose we want to find the number of compositions of the number 8 into 3 parts.</p><p>Let&#8217;s first use our formula and plugin the correct components to find the correct solution:</p><p><strong>Identify n and k:</strong></p><ul><li><p>n = 8 (the total number to be split)</p></li><li><p>k = 3 (the number of parts)</p></li></ul><p><strong>Apply the formula:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Oear!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F690a61c6-d0cb-4325-8987-b90776e58d4e_937x243.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Oear!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F690a61c6-d0cb-4325-8987-b90776e58d4e_937x243.png 424w, https://substackcdn.com/image/fetch/$s_!Oear!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F690a61c6-d0cb-4325-8987-b90776e58d4e_937x243.png 848w, https://substackcdn.com/image/fetch/$s_!Oear!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F690a61c6-d0cb-4325-8987-b90776e58d4e_937x243.png 1272w, https://substackcdn.com/image/fetch/$s_!Oear!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F690a61c6-d0cb-4325-8987-b90776e58d4e_937x243.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Oear!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F690a61c6-d0cb-4325-8987-b90776e58d4e_937x243.png" width="407" height="105.55069370330843" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/690a61c6-d0cb-4325-8987-b90776e58d4e_937x243.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:243,&quot;width&quot;:937,&quot;resizeWidth&quot;:407,&quot;bytes&quot;:21245,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Oear!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F690a61c6-d0cb-4325-8987-b90776e58d4e_937x243.png 424w, https://substackcdn.com/image/fetch/$s_!Oear!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F690a61c6-d0cb-4325-8987-b90776e58d4e_937x243.png 848w, https://substackcdn.com/image/fetch/$s_!Oear!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F690a61c6-d0cb-4325-8987-b90776e58d4e_937x243.png 1272w, https://substackcdn.com/image/fetch/$s_!Oear!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F690a61c6-d0cb-4325-8987-b90776e58d4e_937x243.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The above gives us an answer of 21, so there are 21 different compositions of 8 into 3 parts.</p><p><strong>Explanation: </strong>A composition of n into k parts means breaking down n into k positive integers where the order of the integers matters. For example, the compositions of 8 into 3 parts could include sequences like (1, 2, 5) and (2, 1, 5), which are considered different because the order is different.</p><p>We can visualize this problem as a bijection into placing 2 dividers into 7 possible slots, so we need to choose 2 dividers out of our 7 available ones. As an example, the number 8 can be represented as:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!X3Az!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f1fdc8-aba5-4aba-b91c-80c039710e46_604x120.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!X3Az!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f1fdc8-aba5-4aba-b91c-80c039710e46_604x120.png 424w, https://substackcdn.com/image/fetch/$s_!X3Az!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f1fdc8-aba5-4aba-b91c-80c039710e46_604x120.png 848w, https://substackcdn.com/image/fetch/$s_!X3Az!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f1fdc8-aba5-4aba-b91c-80c039710e46_604x120.png 1272w, https://substackcdn.com/image/fetch/$s_!X3Az!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f1fdc8-aba5-4aba-b91c-80c039710e46_604x120.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!X3Az!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f1fdc8-aba5-4aba-b91c-80c039710e46_604x120.png" width="244" height="48.47682119205298" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/50f1fdc8-aba5-4aba-b91c-80c039710e46_604x120.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:120,&quot;width&quot;:604,&quot;resizeWidth&quot;:244,&quot;bytes&quot;:3685,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!X3Az!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f1fdc8-aba5-4aba-b91c-80c039710e46_604x120.png 424w, https://substackcdn.com/image/fetch/$s_!X3Az!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f1fdc8-aba5-4aba-b91c-80c039710e46_604x120.png 848w, https://substackcdn.com/image/fetch/$s_!X3Az!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f1fdc8-aba5-4aba-b91c-80c039710e46_604x120.png 1272w, https://substackcdn.com/image/fetch/$s_!X3Az!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f1fdc8-aba5-4aba-b91c-80c039710e46_604x120.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>And you should be able to visualize the possible slots we have to select from through the visual presented below:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Pux8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3338ae8-7289-47ee-8c7a-cb8590c8b1fd_871x135.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Pux8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3338ae8-7289-47ee-8c7a-cb8590c8b1fd_871x135.png 424w, https://substackcdn.com/image/fetch/$s_!Pux8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3338ae8-7289-47ee-8c7a-cb8590c8b1fd_871x135.png 848w, https://substackcdn.com/image/fetch/$s_!Pux8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3338ae8-7289-47ee-8c7a-cb8590c8b1fd_871x135.png 1272w, https://substackcdn.com/image/fetch/$s_!Pux8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3338ae8-7289-47ee-8c7a-cb8590c8b1fd_871x135.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Pux8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3338ae8-7289-47ee-8c7a-cb8590c8b1fd_871x135.png" width="349" height="54.09299655568312" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f3338ae8-7289-47ee-8c7a-cb8590c8b1fd_871x135.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:135,&quot;width&quot;:871,&quot;resizeWidth&quot;:349,&quot;bytes&quot;:5207,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Pux8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3338ae8-7289-47ee-8c7a-cb8590c8b1fd_871x135.png 424w, https://substackcdn.com/image/fetch/$s_!Pux8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3338ae8-7289-47ee-8c7a-cb8590c8b1fd_871x135.png 848w, https://substackcdn.com/image/fetch/$s_!Pux8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3338ae8-7289-47ee-8c7a-cb8590c8b1fd_871x135.png 1272w, https://substackcdn.com/image/fetch/$s_!Pux8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3338ae8-7289-47ee-8c7a-cb8590c8b1fd_871x135.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>To divide these 8 items into 3 parts, we must choose 2 of the available slots which we presented above. As an example, the partition (2, 4, 2) can be represented as:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hb5B!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e70f6c-ae7b-4b54-8817-90965c91fa78_658x115.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hb5B!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e70f6c-ae7b-4b54-8817-90965c91fa78_658x115.png 424w, https://substackcdn.com/image/fetch/$s_!hb5B!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e70f6c-ae7b-4b54-8817-90965c91fa78_658x115.png 848w, https://substackcdn.com/image/fetch/$s_!hb5B!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e70f6c-ae7b-4b54-8817-90965c91fa78_658x115.png 1272w, https://substackcdn.com/image/fetch/$s_!hb5B!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e70f6c-ae7b-4b54-8817-90965c91fa78_658x115.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hb5B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e70f6c-ae7b-4b54-8817-90965c91fa78_658x115.png" width="264" height="46.13981762917933" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/89e70f6c-ae7b-4b54-8817-90965c91fa78_658x115.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:115,&quot;width&quot;:658,&quot;resizeWidth&quot;:264,&quot;bytes&quot;:4463,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hb5B!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e70f6c-ae7b-4b54-8817-90965c91fa78_658x115.png 424w, https://substackcdn.com/image/fetch/$s_!hb5B!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e70f6c-ae7b-4b54-8817-90965c91fa78_658x115.png 848w, https://substackcdn.com/image/fetch/$s_!hb5B!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e70f6c-ae7b-4b54-8817-90965c91fa78_658x115.png 1272w, https://substackcdn.com/image/fetch/$s_!hb5B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89e70f6c-ae7b-4b54-8817-90965c91fa78_658x115.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>As another example, the partition (2, 1, 5) could be represented as:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mNQy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdf2fb22-ea8c-45bf-9434-0cd90a99bce4_704x146.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mNQy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdf2fb22-ea8c-45bf-9434-0cd90a99bce4_704x146.png 424w, https://substackcdn.com/image/fetch/$s_!mNQy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdf2fb22-ea8c-45bf-9434-0cd90a99bce4_704x146.png 848w, https://substackcdn.com/image/fetch/$s_!mNQy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdf2fb22-ea8c-45bf-9434-0cd90a99bce4_704x146.png 1272w, https://substackcdn.com/image/fetch/$s_!mNQy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdf2fb22-ea8c-45bf-9434-0cd90a99bce4_704x146.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mNQy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdf2fb22-ea8c-45bf-9434-0cd90a99bce4_704x146.png" width="288" height="59.72727272727273" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fdf2fb22-ea8c-45bf-9434-0cd90a99bce4_704x146.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:146,&quot;width&quot;:704,&quot;resizeWidth&quot;:288,&quot;bytes&quot;:4856,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mNQy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdf2fb22-ea8c-45bf-9434-0cd90a99bce4_704x146.png 424w, https://substackcdn.com/image/fetch/$s_!mNQy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdf2fb22-ea8c-45bf-9434-0cd90a99bce4_704x146.png 848w, https://substackcdn.com/image/fetch/$s_!mNQy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdf2fb22-ea8c-45bf-9434-0cd90a99bce4_704x146.png 1272w, https://substackcdn.com/image/fetch/$s_!mNQy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdf2fb22-ea8c-45bf-9434-0cd90a99bce4_704x146.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Since we need to select (choose) 2 slots out of 7 possible ones, we should be able to see the intuition behind our formula!!</p><div><hr></div><h4><strong>For all positive integers n, the number of all compositions of n is:</strong></h4><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!U2I9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e52f1e6-98ed-4f15-a110-2e804a85527e_227x181.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!U2I9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e52f1e6-98ed-4f15-a110-2e804a85527e_227x181.png 424w, https://substackcdn.com/image/fetch/$s_!U2I9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e52f1e6-98ed-4f15-a110-2e804a85527e_227x181.png 848w, https://substackcdn.com/image/fetch/$s_!U2I9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e52f1e6-98ed-4f15-a110-2e804a85527e_227x181.png 1272w, https://substackcdn.com/image/fetch/$s_!U2I9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e52f1e6-98ed-4f15-a110-2e804a85527e_227x181.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!U2I9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e52f1e6-98ed-4f15-a110-2e804a85527e_227x181.png" width="105" height="83.72246696035242" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9e52f1e6-98ed-4f15-a110-2e804a85527e_227x181.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:181,&quot;width&quot;:227,&quot;resizeWidth&quot;:105,&quot;bytes&quot;:3182,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!U2I9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e52f1e6-98ed-4f15-a110-2e804a85527e_227x181.png 424w, https://substackcdn.com/image/fetch/$s_!U2I9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e52f1e6-98ed-4f15-a110-2e804a85527e_227x181.png 848w, https://substackcdn.com/image/fetch/$s_!U2I9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e52f1e6-98ed-4f15-a110-2e804a85527e_227x181.png 1272w, https://substackcdn.com/image/fetch/$s_!U2I9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e52f1e6-98ed-4f15-a110-2e804a85527e_227x181.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Example and Explanation:</strong></p><p>A composition of n is a way of writing n as a sum of positive integers where the order matters. For example, for n=4, the compositions include sequences like 1+1+1+1, 2+2, 1+3, and so on. When we compose n, we are effectively placing n&#8722;1 potential "dividers" between the numbers 1 through n&#8722;1 to create different parts.</p><p>As n example, to compose 4 into parts, we can visualize our possible dividers through the diagrams presented below:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qfQb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d3f70d7-536d-4de5-a8fa-696d14438536_1097x178.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qfQb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d3f70d7-536d-4de5-a8fa-696d14438536_1097x178.png 424w, https://substackcdn.com/image/fetch/$s_!qfQb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d3f70d7-536d-4de5-a8fa-696d14438536_1097x178.png 848w, https://substackcdn.com/image/fetch/$s_!qfQb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d3f70d7-536d-4de5-a8fa-696d14438536_1097x178.png 1272w, https://substackcdn.com/image/fetch/$s_!qfQb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d3f70d7-536d-4de5-a8fa-696d14438536_1097x178.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qfQb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d3f70d7-536d-4de5-a8fa-696d14438536_1097x178.png" width="383" height="62.14585232452142" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1d3f70d7-536d-4de5-a8fa-696d14438536_1097x178.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:178,&quot;width&quot;:1097,&quot;resizeWidth&quot;:383,&quot;bytes&quot;:13327,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qfQb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d3f70d7-536d-4de5-a8fa-696d14438536_1097x178.png 424w, https://substackcdn.com/image/fetch/$s_!qfQb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d3f70d7-536d-4de5-a8fa-696d14438536_1097x178.png 848w, https://substackcdn.com/image/fetch/$s_!qfQb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d3f70d7-536d-4de5-a8fa-696d14438536_1097x178.png 1272w, https://substackcdn.com/image/fetch/$s_!qfQb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d3f70d7-536d-4de5-a8fa-696d14438536_1097x178.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4zak!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b8f17a4-97c3-4d7f-83ba-31a51e7901fe_1001x134.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4zak!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b8f17a4-97c3-4d7f-83ba-31a51e7901fe_1001x134.png 424w, https://substackcdn.com/image/fetch/$s_!4zak!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b8f17a4-97c3-4d7f-83ba-31a51e7901fe_1001x134.png 848w, https://substackcdn.com/image/fetch/$s_!4zak!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b8f17a4-97c3-4d7f-83ba-31a51e7901fe_1001x134.png 1272w, https://substackcdn.com/image/fetch/$s_!4zak!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b8f17a4-97c3-4d7f-83ba-31a51e7901fe_1001x134.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4zak!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b8f17a4-97c3-4d7f-83ba-31a51e7901fe_1001x134.png" width="353" height="47.25474525474525" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6b8f17a4-97c3-4d7f-83ba-31a51e7901fe_1001x134.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:134,&quot;width&quot;:1001,&quot;resizeWidth&quot;:353,&quot;bytes&quot;:12502,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4zak!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b8f17a4-97c3-4d7f-83ba-31a51e7901fe_1001x134.png 424w, https://substackcdn.com/image/fetch/$s_!4zak!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b8f17a4-97c3-4d7f-83ba-31a51e7901fe_1001x134.png 848w, https://substackcdn.com/image/fetch/$s_!4zak!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b8f17a4-97c3-4d7f-83ba-31a51e7901fe_1001x134.png 1272w, https://substackcdn.com/image/fetch/$s_!4zak!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b8f17a4-97c3-4d7f-83ba-31a51e7901fe_1001x134.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Ri1i!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6a27500-8906-463c-92f5-8eaf57bd238f_1043x139.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Ri1i!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6a27500-8906-463c-92f5-8eaf57bd238f_1043x139.png 424w, https://substackcdn.com/image/fetch/$s_!Ri1i!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6a27500-8906-463c-92f5-8eaf57bd238f_1043x139.png 848w, https://substackcdn.com/image/fetch/$s_!Ri1i!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6a27500-8906-463c-92f5-8eaf57bd238f_1043x139.png 1272w, https://substackcdn.com/image/fetch/$s_!Ri1i!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6a27500-8906-463c-92f5-8eaf57bd238f_1043x139.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Ri1i!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6a27500-8906-463c-92f5-8eaf57bd238f_1043x139.png" width="367" height="48.90987535953979" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a6a27500-8906-463c-92f5-8eaf57bd238f_1043x139.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:139,&quot;width&quot;:1043,&quot;resizeWidth&quot;:367,&quot;bytes&quot;:13348,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Ri1i!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6a27500-8906-463c-92f5-8eaf57bd238f_1043x139.png 424w, https://substackcdn.com/image/fetch/$s_!Ri1i!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6a27500-8906-463c-92f5-8eaf57bd238f_1043x139.png 848w, https://substackcdn.com/image/fetch/$s_!Ri1i!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6a27500-8906-463c-92f5-8eaf57bd238f_1043x139.png 1272w, https://substackcdn.com/image/fetch/$s_!Ri1i!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6a27500-8906-463c-92f5-8eaf57bd238f_1043x139.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dIFt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99601896-e945-44a6-bcc3-cf0b5151f010_1013x139.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dIFt!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99601896-e945-44a6-bcc3-cf0b5151f010_1013x139.png 424w, https://substackcdn.com/image/fetch/$s_!dIFt!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99601896-e945-44a6-bcc3-cf0b5151f010_1013x139.png 848w, https://substackcdn.com/image/fetch/$s_!dIFt!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99601896-e945-44a6-bcc3-cf0b5151f010_1013x139.png 1272w, https://substackcdn.com/image/fetch/$s_!dIFt!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99601896-e945-44a6-bcc3-cf0b5151f010_1013x139.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dIFt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99601896-e945-44a6-bcc3-cf0b5151f010_1013x139.png" width="357" height="48.98617966436328" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/99601896-e945-44a6-bcc3-cf0b5151f010_1013x139.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:139,&quot;width&quot;:1013,&quot;resizeWidth&quot;:357,&quot;bytes&quot;:12822,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!dIFt!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99601896-e945-44a6-bcc3-cf0b5151f010_1013x139.png 424w, https://substackcdn.com/image/fetch/$s_!dIFt!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99601896-e945-44a6-bcc3-cf0b5151f010_1013x139.png 848w, https://substackcdn.com/image/fetch/$s_!dIFt!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99601896-e945-44a6-bcc3-cf0b5151f010_1013x139.png 1272w, https://substackcdn.com/image/fetch/$s_!dIFt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99601896-e945-44a6-bcc3-cf0b5151f010_1013x139.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dhEY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9b4d01-7686-4758-abdd-a1860594cc6e_964x132.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dhEY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9b4d01-7686-4758-abdd-a1860594cc6e_964x132.png 424w, https://substackcdn.com/image/fetch/$s_!dhEY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9b4d01-7686-4758-abdd-a1860594cc6e_964x132.png 848w, https://substackcdn.com/image/fetch/$s_!dhEY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9b4d01-7686-4758-abdd-a1860594cc6e_964x132.png 1272w, https://substackcdn.com/image/fetch/$s_!dhEY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9b4d01-7686-4758-abdd-a1860594cc6e_964x132.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dhEY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9b4d01-7686-4758-abdd-a1860594cc6e_964x132.png" width="361" height="49.43153526970954" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4d9b4d01-7686-4758-abdd-a1860594cc6e_964x132.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:132,&quot;width&quot;:964,&quot;resizeWidth&quot;:361,&quot;bytes&quot;:12164,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!dhEY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9b4d01-7686-4758-abdd-a1860594cc6e_964x132.png 424w, https://substackcdn.com/image/fetch/$s_!dhEY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9b4d01-7686-4758-abdd-a1860594cc6e_964x132.png 848w, https://substackcdn.com/image/fetch/$s_!dhEY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9b4d01-7686-4758-abdd-a1860594cc6e_964x132.png 1272w, https://substackcdn.com/image/fetch/$s_!dhEY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d9b4d01-7686-4758-abdd-a1860594cc6e_964x132.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!I5q-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa22702a3-a95c-4346-a4d1-15b83e5d8964_956x133.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!I5q-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa22702a3-a95c-4346-a4d1-15b83e5d8964_956x133.png 424w, https://substackcdn.com/image/fetch/$s_!I5q-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa22702a3-a95c-4346-a4d1-15b83e5d8964_956x133.png 848w, https://substackcdn.com/image/fetch/$s_!I5q-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa22702a3-a95c-4346-a4d1-15b83e5d8964_956x133.png 1272w, https://substackcdn.com/image/fetch/$s_!I5q-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa22702a3-a95c-4346-a4d1-15b83e5d8964_956x133.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!I5q-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa22702a3-a95c-4346-a4d1-15b83e5d8964_956x133.png" width="361" height="50.22280334728033" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a22702a3-a95c-4346-a4d1-15b83e5d8964_956x133.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:133,&quot;width&quot;:956,&quot;resizeWidth&quot;:361,&quot;bytes&quot;:12031,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!I5q-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa22702a3-a95c-4346-a4d1-15b83e5d8964_956x133.png 424w, https://substackcdn.com/image/fetch/$s_!I5q-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa22702a3-a95c-4346-a4d1-15b83e5d8964_956x133.png 848w, https://substackcdn.com/image/fetch/$s_!I5q-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa22702a3-a95c-4346-a4d1-15b83e5d8964_956x133.png 1272w, https://substackcdn.com/image/fetch/$s_!I5q-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa22702a3-a95c-4346-a4d1-15b83e5d8964_956x133.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Qt-S!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F667d5aab-9f3f-4837-b4a9-0bb3df4675bd_979x138.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Qt-S!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F667d5aab-9f3f-4837-b4a9-0bb3df4675bd_979x138.png 424w, https://substackcdn.com/image/fetch/$s_!Qt-S!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F667d5aab-9f3f-4837-b4a9-0bb3df4675bd_979x138.png 848w, https://substackcdn.com/image/fetch/$s_!Qt-S!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F667d5aab-9f3f-4837-b4a9-0bb3df4675bd_979x138.png 1272w, https://substackcdn.com/image/fetch/$s_!Qt-S!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F667d5aab-9f3f-4837-b4a9-0bb3df4675bd_979x138.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Qt-S!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F667d5aab-9f3f-4837-b4a9-0bb3df4675bd_979x138.png" width="365" height="51.45045965270685" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/667d5aab-9f3f-4837-b4a9-0bb3df4675bd_979x138.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:138,&quot;width&quot;:979,&quot;resizeWidth&quot;:365,&quot;bytes&quot;:12125,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Qt-S!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F667d5aab-9f3f-4837-b4a9-0bb3df4675bd_979x138.png 424w, https://substackcdn.com/image/fetch/$s_!Qt-S!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F667d5aab-9f3f-4837-b4a9-0bb3df4675bd_979x138.png 848w, https://substackcdn.com/image/fetch/$s_!Qt-S!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F667d5aab-9f3f-4837-b4a9-0bb3df4675bd_979x138.png 1272w, https://substackcdn.com/image/fetch/$s_!Qt-S!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F667d5aab-9f3f-4837-b4a9-0bb3df4675bd_979x138.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fCcl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0230143c-6d13-4f13-a3a5-fa95a01a8df0_895x138.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fCcl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0230143c-6d13-4f13-a3a5-fa95a01a8df0_895x138.png 424w, https://substackcdn.com/image/fetch/$s_!fCcl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0230143c-6d13-4f13-a3a5-fa95a01a8df0_895x138.png 848w, https://substackcdn.com/image/fetch/$s_!fCcl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0230143c-6d13-4f13-a3a5-fa95a01a8df0_895x138.png 1272w, https://substackcdn.com/image/fetch/$s_!fCcl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0230143c-6d13-4f13-a3a5-fa95a01a8df0_895x138.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fCcl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0230143c-6d13-4f13-a3a5-fa95a01a8df0_895x138.png" width="329" height="50.72849162011173" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0230143c-6d13-4f13-a3a5-fa95a01a8df0_895x138.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:138,&quot;width&quot;:895,&quot;resizeWidth&quot;:329,&quot;bytes&quot;:10705,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fCcl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0230143c-6d13-4f13-a3a5-fa95a01a8df0_895x138.png 424w, https://substackcdn.com/image/fetch/$s_!fCcl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0230143c-6d13-4f13-a3a5-fa95a01a8df0_895x138.png 848w, https://substackcdn.com/image/fetch/$s_!fCcl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0230143c-6d13-4f13-a3a5-fa95a01a8df0_895x138.png 1272w, https://substackcdn.com/image/fetch/$s_!fCcl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0230143c-6d13-4f13-a3a5-fa95a01a8df0_895x138.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>For each position between the numbers, we have two choices: place a divider or not to place a divider. Since we have n&#8722;1 positions where we can either place or not place a divider, each position represents a binary choice. The total number of ways to make these choices is 2<sup>n&#8722;1 </sup>because there are n&#8722;1 positions and each position has 2 options. In the above example, we have 3 slots to choose from so our answer is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!176W!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e6d54d9-07c3-49f8-a50a-f8c2ab9c63c5_525x142.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!176W!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e6d54d9-07c3-49f8-a50a-f8c2ab9c63c5_525x142.png 424w, https://substackcdn.com/image/fetch/$s_!176W!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e6d54d9-07c3-49f8-a50a-f8c2ab9c63c5_525x142.png 848w, https://substackcdn.com/image/fetch/$s_!176W!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e6d54d9-07c3-49f8-a50a-f8c2ab9c63c5_525x142.png 1272w, https://substackcdn.com/image/fetch/$s_!176W!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e6d54d9-07c3-49f8-a50a-f8c2ab9c63c5_525x142.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!176W!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e6d54d9-07c3-49f8-a50a-f8c2ab9c63c5_525x142.png" width="209" height="56.52952380952381" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7e6d54d9-07c3-49f8-a50a-f8c2ab9c63c5_525x142.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:142,&quot;width&quot;:525,&quot;resizeWidth&quot;:209,&quot;bytes&quot;:6084,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!176W!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e6d54d9-07c3-49f8-a50a-f8c2ab9c63c5_525x142.png 424w, https://substackcdn.com/image/fetch/$s_!176W!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e6d54d9-07c3-49f8-a50a-f8c2ab9c63c5_525x142.png 848w, https://substackcdn.com/image/fetch/$s_!176W!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e6d54d9-07c3-49f8-a50a-f8c2ab9c63c5_525x142.png 1272w, https://substackcdn.com/image/fetch/$s_!176W!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e6d54d9-07c3-49f8-a50a-f8c2ab9c63c5_525x142.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div><hr></div><h4><strong>Set Partitions</strong></h4><p>Let&#8217;s take the example of assigning balls to boxes. Partitions refer to instances where we assume that the balls are different, but the boxes are not.</p><p>A partition of the set [n] means dividing the set into non-empty groups so that each element is in exactly one group. The number of ways to partition [n] into k non-empty groups is represented by S(n, k). These numbers are called the <strong>Stirling numbers</strong> of the second kind.</p><p><strong>Simplification:</strong></p><p>A <strong>partition</strong> means dividing a set into groups where each group has at least one element and no element is left out. As an example, for set [3] = {1, 2, 3}, one partition into 2 groups could be {{1, 2}, {3}}.</p><p>We use [n] to denote the set of the first n positive integers. As an example [2] = {1, 2}.</p><p>When we use S(n, k) notation, we mean Stirling numbers of the second kind and it denotes the number of ways to partition the set [n] (first positive n integers) into k non-empty groups.</p><p>As an example, S(3, 2) is the number of ways to partition {1, 2, 3} into 2 groups. There are 3 such partitions and they are:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!E8rt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08d6ecab-0471-4018-bdab-74c4b632d76c_463x434.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!E8rt!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08d6ecab-0471-4018-bdab-74c4b632d76c_463x434.png 424w, https://substackcdn.com/image/fetch/$s_!E8rt!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08d6ecab-0471-4018-bdab-74c4b632d76c_463x434.png 848w, https://substackcdn.com/image/fetch/$s_!E8rt!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08d6ecab-0471-4018-bdab-74c4b632d76c_463x434.png 1272w, https://substackcdn.com/image/fetch/$s_!E8rt!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08d6ecab-0471-4018-bdab-74c4b632d76c_463x434.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!E8rt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08d6ecab-0471-4018-bdab-74c4b632d76c_463x434.png" width="179" height="167.78833693304534" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/08d6ecab-0471-4018-bdab-74c4b632d76c_463x434.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:434,&quot;width&quot;:463,&quot;resizeWidth&quot;:179,&quot;bytes&quot;:22497,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!E8rt!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08d6ecab-0471-4018-bdab-74c4b632d76c_463x434.png 424w, https://substackcdn.com/image/fetch/$s_!E8rt!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08d6ecab-0471-4018-bdab-74c4b632d76c_463x434.png 848w, https://substackcdn.com/image/fetch/$s_!E8rt!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08d6ecab-0471-4018-bdab-74c4b632d76c_463x434.png 1272w, https://substackcdn.com/image/fetch/$s_!E8rt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08d6ecab-0471-4018-bdab-74c4b632d76c_463x434.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div><hr></div><p>If we have to put <strong>n different</strong> balls into <strong>k</strong> <strong>different</strong> boxes then the number of ways to do this is <strong>k! &#183; S(n, k)</strong>. Indeed, first we can partition [n] into <strong>k non-distinguishable blocks</strong> in <strong>S(n, k)</strong> ways, then we can label the <strong>k blocks with labels 1, 2,...,k in k!</strong> different ways.</p><div><hr></div><p>The number of all set partitions of [n] into nonempty parts is denoted by B(n), and is called the nth <strong>Bell number</strong>. We also set B(0) = 1.</p><h4><strong>Example: </strong></h4><p>B(3) is the number of ways to partition {1,2,3}. There are 5 such partitions:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fThH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7265ef9b-c009-4e9f-a052-e8eef50ffae0_560x686.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fThH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7265ef9b-c009-4e9f-a052-e8eef50ffae0_560x686.png 424w, https://substackcdn.com/image/fetch/$s_!fThH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7265ef9b-c009-4e9f-a052-e8eef50ffae0_560x686.png 848w, https://substackcdn.com/image/fetch/$s_!fThH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7265ef9b-c009-4e9f-a052-e8eef50ffae0_560x686.png 1272w, https://substackcdn.com/image/fetch/$s_!fThH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7265ef9b-c009-4e9f-a052-e8eef50ffae0_560x686.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fThH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7265ef9b-c009-4e9f-a052-e8eef50ffae0_560x686.png" width="226" height="276.85" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7265ef9b-c009-4e9f-a052-e8eef50ffae0_560x686.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:686,&quot;width&quot;:560,&quot;resizeWidth&quot;:226,&quot;bytes&quot;:39375,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fThH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7265ef9b-c009-4e9f-a052-e8eef50ffae0_560x686.png 424w, https://substackcdn.com/image/fetch/$s_!fThH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7265ef9b-c009-4e9f-a052-e8eef50ffae0_560x686.png 848w, https://substackcdn.com/image/fetch/$s_!fThH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7265ef9b-c009-4e9f-a052-e8eef50ffae0_560x686.png 1272w, https://substackcdn.com/image/fetch/$s_!fThH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7265ef9b-c009-4e9f-a052-e8eef50ffae0_560x686.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></figure></div><p>There are 5 partitions, so B(3) = 5.</p><div><hr></div><h4><strong>Integer Partitions</strong></h4><p>Now, let's assume that both the balls and the boxes are identical. This means the only thing that matters is the number of balls in each box. We want to find out how many ways we can write the number n as a sum of positive integers, where the order doesn't matter. For example, 4 = 3 + 1 is considered the same as 4 = 1 + 3.</p><p>More formally, let a1 + a2 + &#8230; + ak be the integers which equal to n. The sequence (a1, a2,...,ak) is called a <strong>partition</strong> of the integer n. The number of all partitions of n is denoted by <strong>p(n)</strong>. The number of partitions of n into exactly k parts is denoted by <strong>p<sub>k</sub>(n)</strong>.</p><p>We note that the word &#8220;partition&#8221; is used in a new meaning here.</p><h4><strong>Example:</strong></h4><p>The positive integer 5 has 7 partitions. Indeed, they are:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!oqFH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44f727de-f6d2-46a3-b1be-d61ec421615f_652x1001.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!oqFH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44f727de-f6d2-46a3-b1be-d61ec421615f_652x1001.png 424w, https://substackcdn.com/image/fetch/$s_!oqFH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44f727de-f6d2-46a3-b1be-d61ec421615f_652x1001.png 848w, https://substackcdn.com/image/fetch/$s_!oqFH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44f727de-f6d2-46a3-b1be-d61ec421615f_652x1001.png 1272w, https://substackcdn.com/image/fetch/$s_!oqFH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44f727de-f6d2-46a3-b1be-d61ec421615f_652x1001.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!oqFH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44f727de-f6d2-46a3-b1be-d61ec421615f_652x1001.png" width="250" height="383.819018404908" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/44f727de-f6d2-46a3-b1be-d61ec421615f_652x1001.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1001,&quot;width&quot;:652,&quot;resizeWidth&quot;:250,&quot;bytes&quot;:38305,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!oqFH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44f727de-f6d2-46a3-b1be-d61ec421615f_652x1001.png 424w, https://substackcdn.com/image/fetch/$s_!oqFH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44f727de-f6d2-46a3-b1be-d61ec421615f_652x1001.png 848w, https://substackcdn.com/image/fetch/$s_!oqFH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44f727de-f6d2-46a3-b1be-d61ec421615f_652x1001.png 1272w, https://substackcdn.com/image/fetch/$s_!oqFH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44f727de-f6d2-46a3-b1be-d61ec421615f_652x1001.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></figure></div><p>Therefore, p(5) = 7.</p><p>The problem of finding an exact formula for p(n) is even harder than that of finding an exact formula for S(n, k) (for which there is no formula). The approximate size of the number p(n) is provided by the following asymptotic formula:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!L89H!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4340733e-f986-4cf4-a325-3137b1741944_993x297.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!L89H!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4340733e-f986-4cf4-a325-3137b1741944_993x297.png 424w, https://substackcdn.com/image/fetch/$s_!L89H!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4340733e-f986-4cf4-a325-3137b1741944_993x297.png 848w, https://substackcdn.com/image/fetch/$s_!L89H!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4340733e-f986-4cf4-a325-3137b1741944_993x297.png 1272w, https://substackcdn.com/image/fetch/$s_!L89H!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4340733e-f986-4cf4-a325-3137b1741944_993x297.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!L89H!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4340733e-f986-4cf4-a325-3137b1741944_993x297.png" width="389" height="116.34743202416918" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4340733e-f986-4cf4-a325-3137b1741944_993x297.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:297,&quot;width&quot;:993,&quot;resizeWidth&quot;:389,&quot;bytes&quot;:34194,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!L89H!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4340733e-f986-4cf4-a325-3137b1741944_993x297.png 424w, https://substackcdn.com/image/fetch/$s_!L89H!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4340733e-f986-4cf4-a325-3137b1741944_993x297.png 848w, https://substackcdn.com/image/fetch/$s_!L89H!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4340733e-f986-4cf4-a325-3137b1741944_993x297.png 1272w, https://substackcdn.com/image/fetch/$s_!L89H!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4340733e-f986-4cf4-a325-3137b1741944_993x297.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div><hr></div><h4>Section Summary</h4><p>A table summarizing our results is provided 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_!73Cp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff65a663d-383b-41e7-8f2d-bd2931b07e2f_1609x1574.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!73Cp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff65a663d-383b-41e7-8f2d-bd2931b07e2f_1609x1574.png 424w, https://substackcdn.com/image/fetch/$s_!73Cp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff65a663d-383b-41e7-8f2d-bd2931b07e2f_1609x1574.png 848w, https://substackcdn.com/image/fetch/$s_!73Cp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff65a663d-383b-41e7-8f2d-bd2931b07e2f_1609x1574.png 1272w, https://substackcdn.com/image/fetch/$s_!73Cp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff65a663d-383b-41e7-8f2d-bd2931b07e2f_1609x1574.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!73Cp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff65a663d-383b-41e7-8f2d-bd2931b07e2f_1609x1574.png" width="1456" height="1424" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f65a663d-383b-41e7-8f2d-bd2931b07e2f_1609x1574.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1424,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:264278,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!73Cp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff65a663d-383b-41e7-8f2d-bd2931b07e2f_1609x1574.png 424w, https://substackcdn.com/image/fetch/$s_!73Cp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff65a663d-383b-41e7-8f2d-bd2931b07e2f_1609x1574.png 848w, https://substackcdn.com/image/fetch/$s_!73Cp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff65a663d-383b-41e7-8f2d-bd2931b07e2f_1609x1574.png 1272w, https://substackcdn.com/image/fetch/$s_!73Cp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff65a663d-383b-41e7-8f2d-bd2931b07e2f_1609x1574.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></figure></div><div><hr></div><h3><strong>Cycles in Permutations</strong></h3><p>Permutations can be viewed not only as linear orders of different objects, most often elements of [n], but also as functions from [n] to [n].</p><h4><strong>Example: </strong></h4><p>The permutation 312 can be viewed as the (bijective) function f: [3] &#8594; [3] defined by f(1) = 3, f(2) = 1, and f(3) = 2.</p><p>The advantage of this approach is that now one can define the product of two permutations on [n] by simply taking their composition as a composition of functions.</p><h4><strong>Another Example: </strong></h4><p>Let f = 312 and let g = 213. Then:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rYv_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f01fc4f-349e-4361-b205-c1e87b463778_1004x427.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rYv_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f01fc4f-349e-4361-b205-c1e87b463778_1004x427.png 424w, https://substackcdn.com/image/fetch/$s_!rYv_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f01fc4f-349e-4361-b205-c1e87b463778_1004x427.png 848w, https://substackcdn.com/image/fetch/$s_!rYv_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f01fc4f-349e-4361-b205-c1e87b463778_1004x427.png 1272w, https://substackcdn.com/image/fetch/$s_!rYv_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f01fc4f-349e-4361-b205-c1e87b463778_1004x427.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rYv_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f01fc4f-349e-4361-b205-c1e87b463778_1004x427.png" width="359" height="152.68227091633466" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0f01fc4f-349e-4361-b205-c1e87b463778_1004x427.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:427,&quot;width&quot;:1004,&quot;resizeWidth&quot;:359,&quot;bytes&quot;:47770,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!rYv_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f01fc4f-349e-4361-b205-c1e87b463778_1004x427.png 424w, https://substackcdn.com/image/fetch/$s_!rYv_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f01fc4f-349e-4361-b205-c1e87b463778_1004x427.png 848w, https://substackcdn.com/image/fetch/$s_!rYv_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f01fc4f-349e-4361-b205-c1e87b463778_1004x427.png 1272w, https://substackcdn.com/image/fetch/$s_!rYv_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f01fc4f-349e-4361-b205-c1e87b463778_1004x427.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Therefore, fg = 321.</p><p>As these two examples show, <strong>multiplication of permutations is not a commutative operation</strong>, that is, it is not true in general that fg = gf.</p><h4><strong>Cycles in Permutations</strong></h4><p>Consider the permutation 321564. We can think of this permutation as a function g from the set [6] to itself. Let's examine g more closely: First, g(2) = 2. This means 2 stays in its place and is called a <strong>fixed point</strong>.</p><ul><li><p>Second, g(1) = 3 and g(3) = 1. This means applying g twice returns 1 and 3 to their original positions. So, 1 and 3 swap places and form a <strong>2-cycle</strong>.</p></li><li><p>Similarly, g(4) = 5, g(5) = 6, and g(6) = 4. Applying g twice gives g<sup>2</sup>(4) = 6, g<sup>2</sup>(5) = 4, and g<sup>2</sup>(6)=5. Applying g three times returns 4, 5, and 6 to their original positions. So, 4, 5, and 6 rotate among themselves and form a <strong>3-cycle</strong>.</p></li></ul><p>All permutations can be decomposed into the disjoint unions of their cycles.</p><h4><strong>Example:</strong></h4><p>While the cycle decomposition of a permutation f is unique, the same cycle decomposition can be written in many different ways. The convention is to write entries that belong to the same cycle in parentheses. The order of the entries in the parentheses is such that j immediately follows i if f(i) = j. Furthermore, f(b) = a, where b is the last entry and a is the first entry in the parentheses. However, these principles do not preclude multiple notations for the same permutation. For instance, (241)(35) and (53)(412) denote the same permutation. In that permutation, f(2) = 4, f(4) = 1, f(1) = 2, f(3) = 5, and f(5) = 3.</p><p>We would like to avoid the danger of confusion caused by the phenomenon we have just described. Therefore, we will write our permutations in canonical cycle form. That is, each cycle will be written with its largest element first, and the cycles will be written in increasing order of their first elements. Thus the permutation f of our previous example has canonical cycle form (412)(53).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zE3Z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42ca2baf-f65e-41d3-aec6-9c9cff045f04_2393x1307.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zE3Z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42ca2baf-f65e-41d3-aec6-9c9cff045f04_2393x1307.png 424w, https://substackcdn.com/image/fetch/$s_!zE3Z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42ca2baf-f65e-41d3-aec6-9c9cff045f04_2393x1307.png 848w, https://substackcdn.com/image/fetch/$s_!zE3Z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42ca2baf-f65e-41d3-aec6-9c9cff045f04_2393x1307.png 1272w, https://substackcdn.com/image/fetch/$s_!zE3Z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42ca2baf-f65e-41d3-aec6-9c9cff045f04_2393x1307.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zE3Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42ca2baf-f65e-41d3-aec6-9c9cff045f04_2393x1307.png" width="1456" height="795" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/42ca2baf-f65e-41d3-aec6-9c9cff045f04_2393x1307.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:795,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:131792,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!zE3Z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42ca2baf-f65e-41d3-aec6-9c9cff045f04_2393x1307.png 424w, https://substackcdn.com/image/fetch/$s_!zE3Z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42ca2baf-f65e-41d3-aec6-9c9cff045f04_2393x1307.png 848w, https://substackcdn.com/image/fetch/$s_!zE3Z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42ca2baf-f65e-41d3-aec6-9c9cff045f04_2393x1307.png 1272w, https://substackcdn.com/image/fetch/$s_!zE3Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42ca2baf-f65e-41d3-aec6-9c9cff045f04_2393x1307.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></figure></div><div><hr></div><h3><strong>You Shall Not Over-count. The Sieve.</strong></h3><h4><strong>Enumerating the Elements of Intersecting Sets</strong></h4><p>There are 20 students in a high school who play the piano, and there are 15 students who play the guitar. Five students play both instruments. How many students play at least one of the two instruments?</p><h4><strong>Solution:</strong></h4><p>To find the number of students who play at least one of the two instruments, we use the principle of inclusion-exclusion:</p><h4>Total = Piano + Guitar &#8722; Both (since we don&#8217;t want to double count)</h4><h4>= 20 + 15 &#8211; 5</h4><h4>= 30</h4><p>So, <strong>30 students</strong> play at least one of the two instruments.</p><h4><strong>Principle of Inclusion-Exclusion</strong>:</h4><p>When counting the total number of students who play at least one instrument, we add the number of piano players and guitar players. Since the students who play both instruments are counted twice (once in the piano group and once in the guitar group), we subtract the number of students who play both to avoid double-counting.</p><h4><strong>Another Example:</strong></h4><p>In a high school, 25 students play the piano, 20 students play the guitar, and 15 students play the violin. Eight students play both the piano and the guitar, five students play both the piano and the violin, and six students play both the guitar and the violin. Two students play all three instruments. How many students play at least one of the three instruments?</p><h4><strong>Solution:</strong></h4><p>To find the number of students who play at least one of the three instruments, we use the principle of inclusion-exclusion for three sets:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Lji6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa12c947c-3e24-41bc-b941-f1b62e3a8c11_1932x436.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Lji6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa12c947c-3e24-41bc-b941-f1b62e3a8c11_1932x436.png 424w, https://substackcdn.com/image/fetch/$s_!Lji6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa12c947c-3e24-41bc-b941-f1b62e3a8c11_1932x436.png 848w, https://substackcdn.com/image/fetch/$s_!Lji6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa12c947c-3e24-41bc-b941-f1b62e3a8c11_1932x436.png 1272w, https://substackcdn.com/image/fetch/$s_!Lji6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa12c947c-3e24-41bc-b941-f1b62e3a8c11_1932x436.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Lji6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa12c947c-3e24-41bc-b941-f1b62e3a8c11_1932x436.png" width="659" height="148.90865384615384" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a12c947c-3e24-41bc-b941-f1b62e3a8c11_1932x436.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:329,&quot;width&quot;:1456,&quot;resizeWidth&quot;:659,&quot;bytes&quot;:62107,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Lji6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa12c947c-3e24-41bc-b941-f1b62e3a8c11_1932x436.png 424w, https://substackcdn.com/image/fetch/$s_!Lji6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa12c947c-3e24-41bc-b941-f1b62e3a8c11_1932x436.png 848w, https://substackcdn.com/image/fetch/$s_!Lji6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa12c947c-3e24-41bc-b941-f1b62e3a8c11_1932x436.png 1272w, https://substackcdn.com/image/fetch/$s_!Lji6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa12c947c-3e24-41bc-b941-f1b62e3a8c11_1932x436.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h4><strong>Calculation</strong>:</h4><p>Total = 25 + 20 + 15 &#8211; 8 &#8211; 5 &#8211; 6 + 2</p><p>Total = 43</p><p>So, <strong>43 students</strong> play at least one of the three instruments.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GOYi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa63d0df3-650f-478c-a9c3-3c122fc5fff0_815x848.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GOYi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa63d0df3-650f-478c-a9c3-3c122fc5fff0_815x848.png 424w, https://substackcdn.com/image/fetch/$s_!GOYi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa63d0df3-650f-478c-a9c3-3c122fc5fff0_815x848.png 848w, https://substackcdn.com/image/fetch/$s_!GOYi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa63d0df3-650f-478c-a9c3-3c122fc5fff0_815x848.png 1272w, https://substackcdn.com/image/fetch/$s_!GOYi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa63d0df3-650f-478c-a9c3-3c122fc5fff0_815x848.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GOYi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa63d0df3-650f-478c-a9c3-3c122fc5fff0_815x848.png" width="475" height="494.23312883435585" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a63d0df3-650f-478c-a9c3-3c122fc5fff0_815x848.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:848,&quot;width&quot;:815,&quot;resizeWidth&quot;:475,&quot;bytes&quot;:76970,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GOYi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa63d0df3-650f-478c-a9c3-3c122fc5fff0_815x848.png 424w, https://substackcdn.com/image/fetch/$s_!GOYi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa63d0df3-650f-478c-a9c3-3c122fc5fff0_815x848.png 848w, https://substackcdn.com/image/fetch/$s_!GOYi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa63d0df3-650f-478c-a9c3-3c122fc5fff0_815x848.png 1272w, https://substackcdn.com/image/fetch/$s_!GOYi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa63d0df3-650f-478c-a9c3-3c122fc5fff0_815x848.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></figure></div><p></p><h4><strong>General Formula for the Principle of Inclusion-Exclusion:</strong></h4><p>Let A1, A2,...,An be finite sets. Then:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wX3u!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74e95189-ec1b-4005-aab2-26b9fe67386f_2406x310.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wX3u!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74e95189-ec1b-4005-aab2-26b9fe67386f_2406x310.png 424w, https://substackcdn.com/image/fetch/$s_!wX3u!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74e95189-ec1b-4005-aab2-26b9fe67386f_2406x310.png 848w, https://substackcdn.com/image/fetch/$s_!wX3u!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74e95189-ec1b-4005-aab2-26b9fe67386f_2406x310.png 1272w, https://substackcdn.com/image/fetch/$s_!wX3u!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74e95189-ec1b-4005-aab2-26b9fe67386f_2406x310.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wX3u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74e95189-ec1b-4005-aab2-26b9fe67386f_2406x310.png" width="1456" height="188" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/74e95189-ec1b-4005-aab2-26b9fe67386f_2406x310.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:188,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:46900,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wX3u!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74e95189-ec1b-4005-aab2-26b9fe67386f_2406x310.png 424w, https://substackcdn.com/image/fetch/$s_!wX3u!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74e95189-ec1b-4005-aab2-26b9fe67386f_2406x310.png 848w, https://substackcdn.com/image/fetch/$s_!wX3u!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74e95189-ec1b-4005-aab2-26b9fe67386f_2406x310.png 1272w, https://substackcdn.com/image/fetch/$s_!wX3u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74e95189-ec1b-4005-aab2-26b9fe67386f_2406x310.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h4><strong>Explanation:</strong></h4><p>The general formula for the Principle of Inclusion-Exclusion (PIE) involves adding the sizes of individual sets, subtracting the sizes of their pairwise intersections, adding the sizes of their triple intersections, and so on, alternately adding and subtracting higher-order intersections until the intersection of all sets is accounted for. This method ensures accurate counting by correcting for over-counting in a systematic way.</p><p>Let's illustrate this with an example using four sets A, B, C and D:</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-Gn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f1ca6f1-855b-42f4-92b7-7a6a8807b712_2314x717.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!z-Gn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f1ca6f1-855b-42f4-92b7-7a6a8807b712_2314x717.png 424w, https://substackcdn.com/image/fetch/$s_!z-Gn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f1ca6f1-855b-42f4-92b7-7a6a8807b712_2314x717.png 848w, https://substackcdn.com/image/fetch/$s_!z-Gn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f1ca6f1-855b-42f4-92b7-7a6a8807b712_2314x717.png 1272w, https://substackcdn.com/image/fetch/$s_!z-Gn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f1ca6f1-855b-42f4-92b7-7a6a8807b712_2314x717.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!z-Gn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f1ca6f1-855b-42f4-92b7-7a6a8807b712_2314x717.png" width="1456" height="451" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7f1ca6f1-855b-42f4-92b7-7a6a8807b712_2314x717.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:451,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:90924,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!z-Gn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f1ca6f1-855b-42f4-92b7-7a6a8807b712_2314x717.png 424w, https://substackcdn.com/image/fetch/$s_!z-Gn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f1ca6f1-855b-42f4-92b7-7a6a8807b712_2314x717.png 848w, https://substackcdn.com/image/fetch/$s_!z-Gn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f1ca6f1-855b-42f4-92b7-7a6a8807b712_2314x717.png 1272w, https://substackcdn.com/image/fetch/$s_!z-Gn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f1ca6f1-855b-42f4-92b7-7a6a8807b712_2314x717.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></figure></div><div><hr></div><p>This ends my write-up. Once again, most of these sections and content are inspired by the book <a href="https://archive.org/details/a-walk-through-combinatorics">A Walk Through Combinatorics</a> which I highly recommend - thank you for reading and if you enjoyed this content, please like and subscribe. </p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Photon-Lines Substack is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Visual-Focused Algorithms Cheat Sheet]]></title><description><![CDATA[A visual-focused review of some key practical algorithms used in the real world.]]></description><link>https://photonlines.substack.com/p/visual-focused-algorithms-cheat-sheet</link><guid isPermaLink="false">https://photonlines.substack.com/p/visual-focused-algorithms-cheat-sheet</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Wed, 19 Mar 2025 15:28:49 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!HC_3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b844c8-bb62-4774-9ce5-eba115035da4_612x815.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Here, I&#8217;ll provide a visual-focused overview of some key algorithms used in the real world. Last year, I posted a visual-focused overview of some key data structures which you can find here:  <a href="https://photonlines.substack.com/p/visual-data-structures-cheat-sheet">Visual Data Structures Cheat Sheet</a>. If you haven&#8217;t had a chance to go through it - I highly recommend taking a look. Data and data organization plays a vital role in deciding in how to tackle problems in an efficient way. Once you understand the data, you should be well on your way to deciding on how to approach and solve any problem. Noting this - let&#8217;s begin. </p><p><strong>Special Note: </strong>some of the visuals provided below are not generated by me and were taken from other sources. All of them are listed in the reference section.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Photon-Lines Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div><hr></div><h3>Sorting Algorithms</h3><div><hr></div><h4>Selection Sort</h4><p>Selection sort is a simple sorting algorithm that organizes an unsorted list by repeatedly finding the smallest (or largest) element and moving it to its correct position. Let&#8217;s assume that we have a a couple of cards that we want to sort in increasing order:</p><ol><li><p>Start with the entire stack, pick out the smallest card, and place it on the left side (the start of the sorted section).</p></li><li><p>Go through the rest of the cards, find the next smallest card, and move it next to the sorted section. Each time, the sorted section on the left grows by one card.</p></li><li><p>Keep doing this until there are no cards left in the unsorted pile. </p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HC_3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b844c8-bb62-4774-9ce5-eba115035da4_612x815.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HC_3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b844c8-bb62-4774-9ce5-eba115035da4_612x815.png 424w, https://substackcdn.com/image/fetch/$s_!HC_3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b844c8-bb62-4774-9ce5-eba115035da4_612x815.png 848w, https://substackcdn.com/image/fetch/$s_!HC_3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b844c8-bb62-4774-9ce5-eba115035da4_612x815.png 1272w, https://substackcdn.com/image/fetch/$s_!HC_3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b844c8-bb62-4774-9ce5-eba115035da4_612x815.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HC_3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b844c8-bb62-4774-9ce5-eba115035da4_612x815.png" width="440" height="585.9477124183006" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/79b844c8-bb62-4774-9ce5-eba115035da4_612x815.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:815,&quot;width&quot;:612,&quot;resizeWidth&quot;:440,&quot;bytes&quot;:292799,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!HC_3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b844c8-bb62-4774-9ce5-eba115035da4_612x815.png 424w, https://substackcdn.com/image/fetch/$s_!HC_3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b844c8-bb62-4774-9ce5-eba115035da4_612x815.png 848w, https://substackcdn.com/image/fetch/$s_!HC_3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b844c8-bb62-4774-9ce5-eba115035da4_612x815.png 1272w, https://substackcdn.com/image/fetch/$s_!HC_3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b844c8-bb62-4774-9ce5-eba115035da4_612x815.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></figure></div><p>Selection sort is straightforward but can be slow on large lists because it goes through the list repeatedly to find the next smallest item. It&#8217;s best for small or nearly sorted datasets since its time complexity is O(n<sup>2</sup>).</p><div><hr></div><h4>Insertion Sort</h4><p>In terms of sorting cards: </p><ol><li><p>You start with the 2nd element in the array or list (we consider the 1st element already &#8216;sorted&#8217;).</p></li><li><p>Compare it with the elements before it and insert it into the correct position among the already sorted (prior) elements.</p></li><li><p>Repeat the process until the entire array is sorted. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MjIp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F711232af-c1d9-4d6e-b99d-c9356a94b152_932x784.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MjIp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F711232af-c1d9-4d6e-b99d-c9356a94b152_932x784.png 424w, https://substackcdn.com/image/fetch/$s_!MjIp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F711232af-c1d9-4d6e-b99d-c9356a94b152_932x784.png 848w, https://substackcdn.com/image/fetch/$s_!MjIp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F711232af-c1d9-4d6e-b99d-c9356a94b152_932x784.png 1272w, https://substackcdn.com/image/fetch/$s_!MjIp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F711232af-c1d9-4d6e-b99d-c9356a94b152_932x784.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MjIp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F711232af-c1d9-4d6e-b99d-c9356a94b152_932x784.png" width="932" height="784" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/711232af-c1d9-4d6e-b99d-c9356a94b152_932x784.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:784,&quot;width&quot;:932,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:217623,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MjIp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F711232af-c1d9-4d6e-b99d-c9356a94b152_932x784.png 424w, https://substackcdn.com/image/fetch/$s_!MjIp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F711232af-c1d9-4d6e-b99d-c9356a94b152_932x784.png 848w, https://substackcdn.com/image/fetch/$s_!MjIp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F711232af-c1d9-4d6e-b99d-c9356a94b152_932x784.png 1272w, https://substackcdn.com/image/fetch/$s_!MjIp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F711232af-c1d9-4d6e-b99d-c9356a94b152_932x784.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></figure></div></li></ol><p>It&#8217;s similar to selection sort, but instead of going through the deck each time to find the next smallest (or largest element) &#8212; you simply expand the &#8216;sorted section&#8217; located to the left by one card and move the new card to its correct position. As expected, the time complexity of this sort algorithm is O(n<sup>2</sup>).</p><div><hr></div><h4>Heap Sort</h4><p>Heap sort uses a data structure called a binary heap to organize elements. It is similar to selection sort in which we first find the maximum element and put it at the end of the data structure. Here&#8217;s a quick rundown of how it works:</p><ol><li><p>First, build a max-heap (a complete binary tree where each parent node is greater than its children). This step arranges the largest element at the root of the heap.</p></li><li><p>Swap the root (largest element) with the last element in the array. Then, reduce the size of the heap by one (ignoring the last element) and heapify the root to restore the max-heap property.</p></li><li><p>Continue swapping the root with the last unsorted element and re-heapifying until the heap size is reduced to one. At this point, the array is fully sorted in ascending order.</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zOm0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F469d0b58-2c93-4ad2-8a0b-bd51b3748902_1197x872.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zOm0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F469d0b58-2c93-4ad2-8a0b-bd51b3748902_1197x872.png 424w, https://substackcdn.com/image/fetch/$s_!zOm0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F469d0b58-2c93-4ad2-8a0b-bd51b3748902_1197x872.png 848w, https://substackcdn.com/image/fetch/$s_!zOm0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F469d0b58-2c93-4ad2-8a0b-bd51b3748902_1197x872.png 1272w, https://substackcdn.com/image/fetch/$s_!zOm0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F469d0b58-2c93-4ad2-8a0b-bd51b3748902_1197x872.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zOm0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F469d0b58-2c93-4ad2-8a0b-bd51b3748902_1197x872.png" width="1197" height="872" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/469d0b58-2c93-4ad2-8a0b-bd51b3748902_1197x872.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:872,&quot;width&quot;:1197,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:59513,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!zOm0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F469d0b58-2c93-4ad2-8a0b-bd51b3748902_1197x872.png 424w, https://substackcdn.com/image/fetch/$s_!zOm0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F469d0b58-2c93-4ad2-8a0b-bd51b3748902_1197x872.png 848w, https://substackcdn.com/image/fetch/$s_!zOm0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F469d0b58-2c93-4ad2-8a0b-bd51b3748902_1197x872.png 1272w, https://substackcdn.com/image/fetch/$s_!zOm0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F469d0b58-2c93-4ad2-8a0b-bd51b3748902_1197x872.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></figure></div><p>The time complexity of heap sort is O(n*log(n)).</p><div><hr></div><h4><strong>Quick Sort</strong></h4><p>A highly efficient divide-and-conquer algorithm that is commonly used in practice due to its average-case performance of O(n*log&#8289;(n)) for which you can find a <a href="https://photonlines.substack.com/p/intuitive-and-visual-guide-to-quick">full explanation for here</a>. Essentially:</p><ol><li><p>You select an element which serves as a pivot.</p></li><li><p>Place all elements less than the pivot on the left and all elements greater than the pivot on the right. </p></li><li><p>Recursively apply the same process to the left and right sub-arrays until the entire array is sorted.</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Rg-O!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f12b133-f394-4973-9bb3-c8a4f1d34f91_786x593.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Rg-O!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f12b133-f394-4973-9bb3-c8a4f1d34f91_786x593.png 424w, https://substackcdn.com/image/fetch/$s_!Rg-O!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f12b133-f394-4973-9bb3-c8a4f1d34f91_786x593.png 848w, https://substackcdn.com/image/fetch/$s_!Rg-O!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f12b133-f394-4973-9bb3-c8a4f1d34f91_786x593.png 1272w, https://substackcdn.com/image/fetch/$s_!Rg-O!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f12b133-f394-4973-9bb3-c8a4f1d34f91_786x593.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Rg-O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f12b133-f394-4973-9bb3-c8a4f1d34f91_786x593.png" width="516" height="389.2977099236641" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3f12b133-f394-4973-9bb3-c8a4f1d34f91_786x593.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:593,&quot;width&quot;:786,&quot;resizeWidth&quot;:516,&quot;bytes&quot;:35961,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Rg-O!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f12b133-f394-4973-9bb3-c8a4f1d34f91_786x593.png 424w, https://substackcdn.com/image/fetch/$s_!Rg-O!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f12b133-f394-4973-9bb3-c8a4f1d34f91_786x593.png 848w, https://substackcdn.com/image/fetch/$s_!Rg-O!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f12b133-f394-4973-9bb3-c8a4f1d34f91_786x593.png 1272w, https://substackcdn.com/image/fetch/$s_!Rg-O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f12b133-f394-4973-9bb3-c8a4f1d34f91_786x593.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></figure></div><p>The time complexity of quicksort is O(n*log(n)).</p><div><hr></div><h4>Merge Sort</h4><p>This is very similar to quick sort but with no pivot element and is stable. A full overview of this algorithm <a href="https://photonlines.substack.com/p/intuitive-guide-to-merge-sort">can be found here</a>. To perform a merge sort </p><ol><li><p>Recursively split the array into two halves until each sub-array contains only one element.</p></li><li><p>Combine the sub arrays and sort them while merging.</p></li><li><p>Continue merging until the entire array is sorted. </p></li></ol><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RquB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff7362f5-e364-4688-a114-0afe04471761_598x828.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RquB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff7362f5-e364-4688-a114-0afe04471761_598x828.png 424w, https://substackcdn.com/image/fetch/$s_!RquB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff7362f5-e364-4688-a114-0afe04471761_598x828.png 848w, https://substackcdn.com/image/fetch/$s_!RquB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff7362f5-e364-4688-a114-0afe04471761_598x828.png 1272w, https://substackcdn.com/image/fetch/$s_!RquB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff7362f5-e364-4688-a114-0afe04471761_598x828.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RquB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff7362f5-e364-4688-a114-0afe04471761_598x828.png" width="512" height="708.9230769230769" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ff7362f5-e364-4688-a114-0afe04471761_598x828.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:828,&quot;width&quot;:598,&quot;resizeWidth&quot;:512,&quot;bytes&quot;:56821,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!RquB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff7362f5-e364-4688-a114-0afe04471761_598x828.png 424w, https://substackcdn.com/image/fetch/$s_!RquB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff7362f5-e364-4688-a114-0afe04471761_598x828.png 848w, https://substackcdn.com/image/fetch/$s_!RquB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff7362f5-e364-4688-a114-0afe04471761_598x828.png 1272w, https://substackcdn.com/image/fetch/$s_!RquB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff7362f5-e364-4688-a114-0afe04471761_598x828.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></figure></div><p>The time complexity of merge sort is O(n*log(n)). Use merge sort when you need a stable sorting algorithm, are working with linked lists, or sorting large datasets that might not fit entirely in memory (external sorting), while quicksort is generally preferred for most in-memory sorting scenarios due to its faster average performance and lower space complexity, especially when dealing with random data.</p><div><hr></div><h4>Tim Sort</h4><p>Tim sort is a hybrid sorting algorithm that combines merge sort and insertion sort. It&#8217;s designed to be efficient with real-world data, particularly data that's already partially sorted. Here&#8217;s a breakdown of how it works:</p><ol><li><p><strong>Divide the Array</strong>: It divides the data into small chunks called runs. Each run is sorted using insertion sort, which is fast for small, nearly-sorted segments.</p></li><li><p><strong>Merge Runs</strong>: The sorted runs are then merged together in a way similar to merge sort, forming larger and larger sorted sections until the entire array is sorted.</p></li></ol><p>Tim sort is optimized for practical use and is the default sorting algorithm in languages like Python and Java. The time complexity of as expected is O(n*log(n)). You can find an excellent overview of it here: <a href="https://www.drmaciver.com/2010/01/understanding-timsort-1adaptive-mergesort/">Understanding Timsort</a>.</p><div><hr></div><h3>Search Algorithms</h3><div><hr></div><h4>Binary Search</h4><p>A fast searching algorithm that works on sorted arrays and has a time complexity of O(log&#8289;(n)). It is widely used due to its simplicity and speed and works by continuously dividing up the search space in half. Think of it as opening a dictionary at the mid-point, determining whether the word we&#8217;re searching for is to the left (less than the middle element) or to the right (larger than the middle element) and continuously re-opening our new search (or page) space again. A full overview of this algorithm is <a href="https://photonlines.substack.com/p/a-visual-introduction-to-binary-search">available here</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_!AQ6m!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc41c328b-330c-4fc6-bc68-504042e90b7b_828x744.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!AQ6m!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc41c328b-330c-4fc6-bc68-504042e90b7b_828x744.png 424w, https://substackcdn.com/image/fetch/$s_!AQ6m!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc41c328b-330c-4fc6-bc68-504042e90b7b_828x744.png 848w, https://substackcdn.com/image/fetch/$s_!AQ6m!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc41c328b-330c-4fc6-bc68-504042e90b7b_828x744.png 1272w, https://substackcdn.com/image/fetch/$s_!AQ6m!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc41c328b-330c-4fc6-bc68-504042e90b7b_828x744.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!AQ6m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc41c328b-330c-4fc6-bc68-504042e90b7b_828x744.png" width="417" height="374.69565217391306" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c41c328b-330c-4fc6-bc68-504042e90b7b_828x744.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:744,&quot;width&quot;:828,&quot;resizeWidth&quot;:417,&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_!AQ6m!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc41c328b-330c-4fc6-bc68-504042e90b7b_828x744.png 424w, https://substackcdn.com/image/fetch/$s_!AQ6m!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc41c328b-330c-4fc6-bc68-504042e90b7b_828x744.png 848w, https://substackcdn.com/image/fetch/$s_!AQ6m!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc41c328b-330c-4fc6-bc68-504042e90b7b_828x744.png 1272w, https://substackcdn.com/image/fetch/$s_!AQ6m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc41c328b-330c-4fc6-bc68-504042e90b7b_828x744.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></figure></div><div><hr></div><h4><strong>Depth-First Search (DFS) and Breadth-First Search (BFS)</strong></h4><p>These are fundamental graph traversal algorithms used in networking, pathfinding, and artificial intelligence. <strong>Breadth First Search </strong>explores all nodes at the present "depth" level before moving on to nodes at the next depth level. <strong>Depth First Search </strong>explores as far down a branch as possible before backtracking to explore other branches.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SETS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F738116d6-bcaf-4412-b452-1a3da132e541_1073x661.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SETS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F738116d6-bcaf-4412-b452-1a3da132e541_1073x661.png 424w, https://substackcdn.com/image/fetch/$s_!SETS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F738116d6-bcaf-4412-b452-1a3da132e541_1073x661.png 848w, https://substackcdn.com/image/fetch/$s_!SETS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F738116d6-bcaf-4412-b452-1a3da132e541_1073x661.png 1272w, https://substackcdn.com/image/fetch/$s_!SETS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F738116d6-bcaf-4412-b452-1a3da132e541_1073x661.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SETS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F738116d6-bcaf-4412-b452-1a3da132e541_1073x661.png" width="1073" height="661" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/738116d6-bcaf-4412-b452-1a3da132e541_1073x661.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:661,&quot;width&quot;:1073,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:33268,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!SETS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F738116d6-bcaf-4412-b452-1a3da132e541_1073x661.png 424w, https://substackcdn.com/image/fetch/$s_!SETS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F738116d6-bcaf-4412-b452-1a3da132e541_1073x661.png 848w, https://substackcdn.com/image/fetch/$s_!SETS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F738116d6-bcaf-4412-b452-1a3da132e541_1073x661.png 1272w, https://substackcdn.com/image/fetch/$s_!SETS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F738116d6-bcaf-4412-b452-1a3da132e541_1073x661.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></figure></div><p>Use <strong>DFS</strong> for deep exploration, backtracking, and memory efficiency. Use <strong>BFS</strong> for shortest paths, level-wise traversal, and broader searches. DFS is better for constrained memory; BFS ensures the shortest path in unweighted graphs.</p><div><hr></div><h3>Graph Algorithms</h3><div><hr></div><h4><strong>Prim&#8217;s Algorithm</strong></h4><p>Prim&#8217;s algorithm finds the <strong>minimum spanning tree (MST)</strong> of a graph by starting with a random node and repeatedly adding the smallest edge that connects a node inside the tree to one outside of it. The process continues until all nodes are connected, ensuring the total edge weight is minimized. It&#8217;s used for optimizing network designs like roads or cables, minimizing the total cost.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!eQ4J!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20bacffa-0bd8-4fa4-8b9f-148311edca6a_1060x826.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!eQ4J!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20bacffa-0bd8-4fa4-8b9f-148311edca6a_1060x826.png 424w, https://substackcdn.com/image/fetch/$s_!eQ4J!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20bacffa-0bd8-4fa4-8b9f-148311edca6a_1060x826.png 848w, https://substackcdn.com/image/fetch/$s_!eQ4J!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20bacffa-0bd8-4fa4-8b9f-148311edca6a_1060x826.png 1272w, https://substackcdn.com/image/fetch/$s_!eQ4J!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20bacffa-0bd8-4fa4-8b9f-148311edca6a_1060x826.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!eQ4J!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20bacffa-0bd8-4fa4-8b9f-148311edca6a_1060x826.png" width="1060" height="826" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/20bacffa-0bd8-4fa4-8b9f-148311edca6a_1060x826.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:826,&quot;width&quot;:1060,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:67847,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!eQ4J!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20bacffa-0bd8-4fa4-8b9f-148311edca6a_1060x826.png 424w, https://substackcdn.com/image/fetch/$s_!eQ4J!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20bacffa-0bd8-4fa4-8b9f-148311edca6a_1060x826.png 848w, https://substackcdn.com/image/fetch/$s_!eQ4J!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20bacffa-0bd8-4fa4-8b9f-148311edca6a_1060x826.png 1272w, https://substackcdn.com/image/fetch/$s_!eQ4J!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20bacffa-0bd8-4fa4-8b9f-148311edca6a_1060x826.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></figure></div><p></p><div><hr></div><h4><strong>Kruskal&#8217;s algorithm</strong></h4><p>Kruskal&#8217;s algorithm also finds the minimum spanning tree (MST) of a graph, but it works differently from Prim&#8217;s algorithm. It starts by sorting all the edges by weight. Then, it adds the smallest edge to the tree, but only if it doesn&#8217;t form a cycle. This process is repeated until all nodes are connected, and the tree has the minimum total edge weight.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GKhQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aac2210-4833-45dc-be3f-5cb316e06d5b_1000x750.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GKhQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aac2210-4833-45dc-be3f-5cb316e06d5b_1000x750.png 424w, https://substackcdn.com/image/fetch/$s_!GKhQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aac2210-4833-45dc-be3f-5cb316e06d5b_1000x750.png 848w, https://substackcdn.com/image/fetch/$s_!GKhQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aac2210-4833-45dc-be3f-5cb316e06d5b_1000x750.png 1272w, https://substackcdn.com/image/fetch/$s_!GKhQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aac2210-4833-45dc-be3f-5cb316e06d5b_1000x750.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GKhQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aac2210-4833-45dc-be3f-5cb316e06d5b_1000x750.png" width="1000" height="750" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6aac2210-4833-45dc-be3f-5cb316e06d5b_1000x750.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:750,&quot;width&quot;:1000,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:70348,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GKhQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aac2210-4833-45dc-be3f-5cb316e06d5b_1000x750.png 424w, https://substackcdn.com/image/fetch/$s_!GKhQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aac2210-4833-45dc-be3f-5cb316e06d5b_1000x750.png 848w, https://substackcdn.com/image/fetch/$s_!GKhQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aac2210-4833-45dc-be3f-5cb316e06d5b_1000x750.png 1272w, https://substackcdn.com/image/fetch/$s_!GKhQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aac2210-4833-45dc-be3f-5cb316e06d5b_1000x750.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></figure></div><p></p><p>Prim's algorithm is significantly faster when you have a really dense graph with many more edges than vertices. Kruskal performs better in typical situations (sparse graphs) because it uses simpler data structures. </p><div><hr></div><h4><strong>Dijkstra&#8217;s algorithm</strong></h4><p>Used to find the shortest path between a source node and all other nodes in a weighted graph with non-negative weights. A step-by-step overview of the algorithm is provided below:</p><ol><li><p><strong>Initialize Distances</strong>: Set the starting node&#8217;s distance to <code>0</code> and all other nodes to infinity (&#8734;). Mark all nodes as unvisited.</p></li><li><p><strong>Select Node</strong>: Choose the unvisited node with the smallest distance (starting with the starting node).</p></li><li><p><strong>Update Neighbors</strong>: For each unvisited neighbor, calculate its distance through the current node. If this distance is smaller than its current distance, update it.</p></li><li><p><strong>Mark as Visited</strong>: Mark the current node as visited (the shortest path to it is now known).</p></li><li><p><strong>Repeat</strong>: Repeat steps 2-4 until all nodes are visited or you&#8217;ve reached the target.</p></li></ol><p>An example graph we&#8217;ll go through to demonstrate the algorithm is provided below:</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WJWs!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb51b8324-3e6f-4136-9d6e-5dce69dd70ee_1498x684.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WJWs!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb51b8324-3e6f-4136-9d6e-5dce69dd70ee_1498x684.png 424w, https://substackcdn.com/image/fetch/$s_!WJWs!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb51b8324-3e6f-4136-9d6e-5dce69dd70ee_1498x684.png 848w, https://substackcdn.com/image/fetch/$s_!WJWs!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb51b8324-3e6f-4136-9d6e-5dce69dd70ee_1498x684.png 1272w, https://substackcdn.com/image/fetch/$s_!WJWs!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb51b8324-3e6f-4136-9d6e-5dce69dd70ee_1498x684.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WJWs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb51b8324-3e6f-4136-9d6e-5dce69dd70ee_1498x684.png" width="489" height="223.34134615384616" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b51b8324-3e6f-4136-9d6e-5dce69dd70ee_1498x684.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:665,&quot;width&quot;:1456,&quot;resizeWidth&quot;:489,&quot;bytes&quot;:215085,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb51b8324-3e6f-4136-9d6e-5dce69dd70ee_1498x684.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_!WJWs!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb51b8324-3e6f-4136-9d6e-5dce69dd70ee_1498x684.png 424w, https://substackcdn.com/image/fetch/$s_!WJWs!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb51b8324-3e6f-4136-9d6e-5dce69dd70ee_1498x684.png 848w, https://substackcdn.com/image/fetch/$s_!WJWs!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb51b8324-3e6f-4136-9d6e-5dce69dd70ee_1498x684.png 1272w, https://substackcdn.com/image/fetch/$s_!WJWs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb51b8324-3e6f-4136-9d6e-5dce69dd70ee_1498x684.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p><p>We start off at node d (left-most node) in our graph and update our weights accordingly:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KADO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ff9d581-8666-4aec-a1b9-136ac22cb279_1953x1345.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KADO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ff9d581-8666-4aec-a1b9-136ac22cb279_1953x1345.png 424w, https://substackcdn.com/image/fetch/$s_!KADO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ff9d581-8666-4aec-a1b9-136ac22cb279_1953x1345.png 848w, https://substackcdn.com/image/fetch/$s_!KADO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ff9d581-8666-4aec-a1b9-136ac22cb279_1953x1345.png 1272w, https://substackcdn.com/image/fetch/$s_!KADO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ff9d581-8666-4aec-a1b9-136ac22cb279_1953x1345.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KADO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ff9d581-8666-4aec-a1b9-136ac22cb279_1953x1345.png" width="464" height="319.6373626373626" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5ff9d581-8666-4aec-a1b9-136ac22cb279_1953x1345.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1003,&quot;width&quot;:1456,&quot;resizeWidth&quot;:464,&quot;bytes&quot;:89672,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ff9d581-8666-4aec-a1b9-136ac22cb279_1953x1345.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_!KADO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ff9d581-8666-4aec-a1b9-136ac22cb279_1953x1345.png 424w, https://substackcdn.com/image/fetch/$s_!KADO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ff9d581-8666-4aec-a1b9-136ac22cb279_1953x1345.png 848w, https://substackcdn.com/image/fetch/$s_!KADO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ff9d581-8666-4aec-a1b9-136ac22cb279_1953x1345.png 1272w, https://substackcdn.com/image/fetch/$s_!KADO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ff9d581-8666-4aec-a1b9-136ac22cb279_1953x1345.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></figure></div><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!P02m!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1895f94a-7c34-4e7f-acc8-6a50cf86468c_2295x1129.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!P02m!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1895f94a-7c34-4e7f-acc8-6a50cf86468c_2295x1129.png 424w, https://substackcdn.com/image/fetch/$s_!P02m!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1895f94a-7c34-4e7f-acc8-6a50cf86468c_2295x1129.png 848w, https://substackcdn.com/image/fetch/$s_!P02m!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1895f94a-7c34-4e7f-acc8-6a50cf86468c_2295x1129.png 1272w, https://substackcdn.com/image/fetch/$s_!P02m!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1895f94a-7c34-4e7f-acc8-6a50cf86468c_2295x1129.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!P02m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1895f94a-7c34-4e7f-acc8-6a50cf86468c_2295x1129.png" width="653" height="321.11813186813185" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1895f94a-7c34-4e7f-acc8-6a50cf86468c_2295x1129.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:716,&quot;width&quot;:1456,&quot;resizeWidth&quot;:653,&quot;bytes&quot;:103206,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1895f94a-7c34-4e7f-acc8-6a50cf86468c_2295x1129.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_!P02m!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1895f94a-7c34-4e7f-acc8-6a50cf86468c_2295x1129.png 424w, https://substackcdn.com/image/fetch/$s_!P02m!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1895f94a-7c34-4e7f-acc8-6a50cf86468c_2295x1129.png 848w, https://substackcdn.com/image/fetch/$s_!P02m!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1895f94a-7c34-4e7f-acc8-6a50cf86468c_2295x1129.png 1272w, https://substackcdn.com/image/fetch/$s_!P02m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1895f94a-7c34-4e7f-acc8-6a50cf86468c_2295x1129.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></figure></div><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RilM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71829bf3-eb1b-4125-abea-21ee80590808_1831x1055.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RilM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71829bf3-eb1b-4125-abea-21ee80590808_1831x1055.png 424w, https://substackcdn.com/image/fetch/$s_!RilM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71829bf3-eb1b-4125-abea-21ee80590808_1831x1055.png 848w, https://substackcdn.com/image/fetch/$s_!RilM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71829bf3-eb1b-4125-abea-21ee80590808_1831x1055.png 1272w, https://substackcdn.com/image/fetch/$s_!RilM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71829bf3-eb1b-4125-abea-21ee80590808_1831x1055.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RilM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71829bf3-eb1b-4125-abea-21ee80590808_1831x1055.png" width="560" height="322.6923076923077" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/71829bf3-eb1b-4125-abea-21ee80590808_1831x1055.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:839,&quot;width&quot;:1456,&quot;resizeWidth&quot;:560,&quot;bytes&quot;:84976,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71829bf3-eb1b-4125-abea-21ee80590808_1831x1055.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_!RilM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71829bf3-eb1b-4125-abea-21ee80590808_1831x1055.png 424w, https://substackcdn.com/image/fetch/$s_!RilM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71829bf3-eb1b-4125-abea-21ee80590808_1831x1055.png 848w, https://substackcdn.com/image/fetch/$s_!RilM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71829bf3-eb1b-4125-abea-21ee80590808_1831x1055.png 1272w, https://substackcdn.com/image/fetch/$s_!RilM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71829bf3-eb1b-4125-abea-21ee80590808_1831x1055.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></figure></div><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XTxC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19f95a7-abda-4d58-ab5b-2753bb1ac1b7_2191x1100.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XTxC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19f95a7-abda-4d58-ab5b-2753bb1ac1b7_2191x1100.png 424w, https://substackcdn.com/image/fetch/$s_!XTxC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19f95a7-abda-4d58-ab5b-2753bb1ac1b7_2191x1100.png 848w, https://substackcdn.com/image/fetch/$s_!XTxC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19f95a7-abda-4d58-ab5b-2753bb1ac1b7_2191x1100.png 1272w, https://substackcdn.com/image/fetch/$s_!XTxC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19f95a7-abda-4d58-ab5b-2753bb1ac1b7_2191x1100.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XTxC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19f95a7-abda-4d58-ab5b-2753bb1ac1b7_2191x1100.png" width="618" height="310.27335164835165" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e19f95a7-abda-4d58-ab5b-2753bb1ac1b7_2191x1100.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:731,&quot;width&quot;:1456,&quot;resizeWidth&quot;:618,&quot;bytes&quot;:99681,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19f95a7-abda-4d58-ab5b-2753bb1ac1b7_2191x1100.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_!XTxC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19f95a7-abda-4d58-ab5b-2753bb1ac1b7_2191x1100.png 424w, https://substackcdn.com/image/fetch/$s_!XTxC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19f95a7-abda-4d58-ab5b-2753bb1ac1b7_2191x1100.png 848w, https://substackcdn.com/image/fetch/$s_!XTxC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19f95a7-abda-4d58-ab5b-2753bb1ac1b7_2191x1100.png 1272w, https://substackcdn.com/image/fetch/$s_!XTxC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19f95a7-abda-4d58-ab5b-2753bb1ac1b7_2191x1100.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></figure></div><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!D3-X!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbdc6c4-2b9a-4b28-af45-8dc97f817a07_1217x479.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!D3-X!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbdc6c4-2b9a-4b28-af45-8dc97f817a07_1217x479.png 424w, https://substackcdn.com/image/fetch/$s_!D3-X!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbdc6c4-2b9a-4b28-af45-8dc97f817a07_1217x479.png 848w, https://substackcdn.com/image/fetch/$s_!D3-X!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbdc6c4-2b9a-4b28-af45-8dc97f817a07_1217x479.png 1272w, https://substackcdn.com/image/fetch/$s_!D3-X!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbdc6c4-2b9a-4b28-af45-8dc97f817a07_1217x479.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!D3-X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbdc6c4-2b9a-4b28-af45-8dc97f817a07_1217x479.png" width="724" height="284.9597370583402" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7cbdc6c4-2b9a-4b28-af45-8dc97f817a07_1217x479.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:479,&quot;width&quot;:1217,&quot;resizeWidth&quot;:724,&quot;bytes&quot;:65201,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbdc6c4-2b9a-4b28-af45-8dc97f817a07_1217x479.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_!D3-X!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbdc6c4-2b9a-4b28-af45-8dc97f817a07_1217x479.png 424w, https://substackcdn.com/image/fetch/$s_!D3-X!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbdc6c4-2b9a-4b28-af45-8dc97f817a07_1217x479.png 848w, https://substackcdn.com/image/fetch/$s_!D3-X!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbdc6c4-2b9a-4b28-af45-8dc97f817a07_1217x479.png 1272w, https://substackcdn.com/image/fetch/$s_!D3-X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbdc6c4-2b9a-4b28-af45-8dc97f817a07_1217x479.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></figure></div><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!X9qZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9183361-945c-496d-b3f5-251350b6a17a_1001x369.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!X9qZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9183361-945c-496d-b3f5-251350b6a17a_1001x369.png 424w, https://substackcdn.com/image/fetch/$s_!X9qZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9183361-945c-496d-b3f5-251350b6a17a_1001x369.png 848w, https://substackcdn.com/image/fetch/$s_!X9qZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9183361-945c-496d-b3f5-251350b6a17a_1001x369.png 1272w, https://substackcdn.com/image/fetch/$s_!X9qZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9183361-945c-496d-b3f5-251350b6a17a_1001x369.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!X9qZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9183361-945c-496d-b3f5-251350b6a17a_1001x369.png" width="1001" height="369" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a9183361-945c-496d-b3f5-251350b6a17a_1001x369.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:369,&quot;width&quot;:1001,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:46397,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9183361-945c-496d-b3f5-251350b6a17a_1001x369.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_!X9qZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9183361-945c-496d-b3f5-251350b6a17a_1001x369.png 424w, https://substackcdn.com/image/fetch/$s_!X9qZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9183361-945c-496d-b3f5-251350b6a17a_1001x369.png 848w, https://substackcdn.com/image/fetch/$s_!X9qZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9183361-945c-496d-b3f5-251350b6a17a_1001x369.png 1272w, https://substackcdn.com/image/fetch/$s_!X9qZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9183361-945c-496d-b3f5-251350b6a17a_1001x369.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></figure></div><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tjwC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18a1cc78-0949-46a1-bf0d-2d7fb5e82994_1199x452.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tjwC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18a1cc78-0949-46a1-bf0d-2d7fb5e82994_1199x452.png 424w, https://substackcdn.com/image/fetch/$s_!tjwC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18a1cc78-0949-46a1-bf0d-2d7fb5e82994_1199x452.png 848w, https://substackcdn.com/image/fetch/$s_!tjwC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18a1cc78-0949-46a1-bf0d-2d7fb5e82994_1199x452.png 1272w, https://substackcdn.com/image/fetch/$s_!tjwC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18a1cc78-0949-46a1-bf0d-2d7fb5e82994_1199x452.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tjwC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18a1cc78-0949-46a1-bf0d-2d7fb5e82994_1199x452.png" width="1199" height="452" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/18a1cc78-0949-46a1-bf0d-2d7fb5e82994_1199x452.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:452,&quot;width&quot;:1199,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:60636,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18a1cc78-0949-46a1-bf0d-2d7fb5e82994_1199x452.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_!tjwC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18a1cc78-0949-46a1-bf0d-2d7fb5e82994_1199x452.png 424w, https://substackcdn.com/image/fetch/$s_!tjwC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18a1cc78-0949-46a1-bf0d-2d7fb5e82994_1199x452.png 848w, https://substackcdn.com/image/fetch/$s_!tjwC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18a1cc78-0949-46a1-bf0d-2d7fb5e82994_1199x452.png 1272w, https://substackcdn.com/image/fetch/$s_!tjwC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18a1cc78-0949-46a1-bf0d-2d7fb5e82994_1199x452.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></figure></div><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TBIc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6437b965-26be-47f7-a668-5ed224e44edf_1127x477.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TBIc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6437b965-26be-47f7-a668-5ed224e44edf_1127x477.png 424w, https://substackcdn.com/image/fetch/$s_!TBIc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6437b965-26be-47f7-a668-5ed224e44edf_1127x477.png 848w, https://substackcdn.com/image/fetch/$s_!TBIc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6437b965-26be-47f7-a668-5ed224e44edf_1127x477.png 1272w, https://substackcdn.com/image/fetch/$s_!TBIc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6437b965-26be-47f7-a668-5ed224e44edf_1127x477.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TBIc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6437b965-26be-47f7-a668-5ed224e44edf_1127x477.png" width="1127" height="477" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6437b965-26be-47f7-a668-5ed224e44edf_1127x477.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:477,&quot;width&quot;:1127,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:60622,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6437b965-26be-47f7-a668-5ed224e44edf_1127x477.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_!TBIc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6437b965-26be-47f7-a668-5ed224e44edf_1127x477.png 424w, https://substackcdn.com/image/fetch/$s_!TBIc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6437b965-26be-47f7-a668-5ed224e44edf_1127x477.png 848w, https://substackcdn.com/image/fetch/$s_!TBIc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6437b965-26be-47f7-a668-5ed224e44edf_1127x477.png 1272w, https://substackcdn.com/image/fetch/$s_!TBIc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6437b965-26be-47f7-a668-5ed224e44edf_1127x477.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></figure></div><p><em>Side Note: We skipped 2 iterations in our outline above (visitations to <strong>Nodes c and g</strong>) since no outbound edges (neighbors) are present within these nodes &#8212; but a regular iteration of Dijkstra&#8217;s algorithm would include those nodes as well.  </em></p><p>The updated weights after each iteration are provided 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_!j59B!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd14ffee2-0044-4ed3-80fb-6129d3c654b0_1431x1021.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!j59B!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd14ffee2-0044-4ed3-80fb-6129d3c654b0_1431x1021.png 424w, https://substackcdn.com/image/fetch/$s_!j59B!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd14ffee2-0044-4ed3-80fb-6129d3c654b0_1431x1021.png 848w, https://substackcdn.com/image/fetch/$s_!j59B!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd14ffee2-0044-4ed3-80fb-6129d3c654b0_1431x1021.png 1272w, https://substackcdn.com/image/fetch/$s_!j59B!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd14ffee2-0044-4ed3-80fb-6129d3c654b0_1431x1021.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!j59B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd14ffee2-0044-4ed3-80fb-6129d3c654b0_1431x1021.png" width="574" height="409.5415793151642" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d14ffee2-0044-4ed3-80fb-6129d3c654b0_1431x1021.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1021,&quot;width&quot;:1431,&quot;resizeWidth&quot;:574,&quot;bytes&quot;:100030,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd14ffee2-0044-4ed3-80fb-6129d3c654b0_1431x1021.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_!j59B!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd14ffee2-0044-4ed3-80fb-6129d3c654b0_1431x1021.png 424w, https://substackcdn.com/image/fetch/$s_!j59B!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd14ffee2-0044-4ed3-80fb-6129d3c654b0_1431x1021.png 848w, https://substackcdn.com/image/fetch/$s_!j59B!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd14ffee2-0044-4ed3-80fb-6129d3c654b0_1431x1021.png 1272w, https://substackcdn.com/image/fetch/$s_!j59B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd14ffee2-0044-4ed3-80fb-6129d3c654b0_1431x1021.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></figure></div><p>Dijkstra&#8217;s algorithm is crucial because it optimally solves shortest path problems in graphs, making it applicable to real-world scenarios where efficiency and correctness are key.</p><div><hr></div><h4><strong>Bellman-Ford algorithm</strong></h4><p>Bellman Ford algorithm helps us find the shortest path from a vertex to all other vertices of a weighted graph. It is similar to Dijkstra's algorithm but it can work with graphs in which edges can have negative weights. </p><p>It works by iterating over all edges multiple times, progressively relaxing edge weights to find the shortest path. After V&#8722;1 iterations (where V is the number of vertices), the shortest paths are determined. A final iteration checks for negative weight cycles. If any edge can still be relaxed to determine if a negative cycle exists. </p><p>A simple example of the Bellman-Ford algorithm in action:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!D6-L!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf94c530-98ff-4891-b916-dc8b6f5483e2_688x978.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!D6-L!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf94c530-98ff-4891-b916-dc8b6f5483e2_688x978.png 424w, https://substackcdn.com/image/fetch/$s_!D6-L!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf94c530-98ff-4891-b916-dc8b6f5483e2_688x978.png 848w, https://substackcdn.com/image/fetch/$s_!D6-L!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf94c530-98ff-4891-b916-dc8b6f5483e2_688x978.png 1272w, https://substackcdn.com/image/fetch/$s_!D6-L!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf94c530-98ff-4891-b916-dc8b6f5483e2_688x978.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!D6-L!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf94c530-98ff-4891-b916-dc8b6f5483e2_688x978.png" width="688" height="978" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/df94c530-98ff-4891-b916-dc8b6f5483e2_688x978.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:978,&quot;width&quot;:688,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:137566,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!D6-L!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf94c530-98ff-4891-b916-dc8b6f5483e2_688x978.png 424w, https://substackcdn.com/image/fetch/$s_!D6-L!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf94c530-98ff-4891-b916-dc8b6f5483e2_688x978.png 848w, https://substackcdn.com/image/fetch/$s_!D6-L!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf94c530-98ff-4891-b916-dc8b6f5483e2_688x978.png 1272w, https://substackcdn.com/image/fetch/$s_!D6-L!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf94c530-98ff-4891-b916-dc8b6f5483e2_688x978.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">Image and Example Taken From: https://www.scholarhat.com/tutorial/datastructures/bellman-fords-algorithm </figcaption></figure></div><p>The pseudo-code which demonstrates the difference between the Bellman-Ford and Dijkstra&#8217;s algorithm is provided 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_!JOho!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16d3ec9-97d7-400f-a69c-076a2549aaab_3008x1203.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JOho!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16d3ec9-97d7-400f-a69c-076a2549aaab_3008x1203.png 424w, https://substackcdn.com/image/fetch/$s_!JOho!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16d3ec9-97d7-400f-a69c-076a2549aaab_3008x1203.png 848w, https://substackcdn.com/image/fetch/$s_!JOho!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16d3ec9-97d7-400f-a69c-076a2549aaab_3008x1203.png 1272w, https://substackcdn.com/image/fetch/$s_!JOho!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16d3ec9-97d7-400f-a69c-076a2549aaab_3008x1203.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JOho!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16d3ec9-97d7-400f-a69c-076a2549aaab_3008x1203.png" width="1456" height="582" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a16d3ec9-97d7-400f-a69c-076a2549aaab_3008x1203.png&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;:1155334,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16d3ec9-97d7-400f-a69c-076a2549aaab_3008x1203.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_!JOho!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16d3ec9-97d7-400f-a69c-076a2549aaab_3008x1203.png 424w, https://substackcdn.com/image/fetch/$s_!JOho!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16d3ec9-97d7-400f-a69c-076a2549aaab_3008x1203.png 848w, https://substackcdn.com/image/fetch/$s_!JOho!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16d3ec9-97d7-400f-a69c-076a2549aaab_3008x1203.png 1272w, https://substackcdn.com/image/fetch/$s_!JOho!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa16d3ec9-97d7-400f-a69c-076a2549aaab_3008x1203.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></figure></div><p>As noted - the algorithms are similar to Dijkstra&#8217;s algorithm but includes an extra step to detect negative cycles. </p><div><hr></div><h4><strong>A* Search</strong></h4><p>A* (pronounced "A-star") is an pathfinding algorithm (similar to Dijkstra&#8217;s) that efficiently finds the shortest path between two points in a graph. It is an enhancement of Dijkstra&#8217;s algorithm, combining the benefits of shortest path search and heuristic-based search to speed up performance. It finds the shortest path by balancing actual cost and estimated distance to the goal. </p><p>Imagine you're walking through a city and trying to find the shortest route to a coffee shop.</p><ul><li><p>You know how far you&#8217;ve walked so far.</p></li><li><p>You look at the map and estimate how close each road gets you to the coffee shop.</p></li><li><p>Instead of randomly checking all streets, you prioritize the ones that seem best.</p></li><li><p>When you reach the coffee shop, you trace back the route you took!</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ayw_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d4547ff-5831-4288-9b50-cfdce7b1e5be_753x600.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ayw_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d4547ff-5831-4288-9b50-cfdce7b1e5be_753x600.png 424w, https://substackcdn.com/image/fetch/$s_!ayw_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d4547ff-5831-4288-9b50-cfdce7b1e5be_753x600.png 848w, https://substackcdn.com/image/fetch/$s_!ayw_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d4547ff-5831-4288-9b50-cfdce7b1e5be_753x600.png 1272w, https://substackcdn.com/image/fetch/$s_!ayw_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d4547ff-5831-4288-9b50-cfdce7b1e5be_753x600.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ayw_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d4547ff-5831-4288-9b50-cfdce7b1e5be_753x600.png" width="610" height="486.0557768924303" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5d4547ff-5831-4288-9b50-cfdce7b1e5be_753x600.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:600,&quot;width&quot;:753,&quot;resizeWidth&quot;:610,&quot;bytes&quot;:99222,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d4547ff-5831-4288-9b50-cfdce7b1e5be_753x600.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_!ayw_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d4547ff-5831-4288-9b50-cfdce7b1e5be_753x600.png 424w, https://substackcdn.com/image/fetch/$s_!ayw_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d4547ff-5831-4288-9b50-cfdce7b1e5be_753x600.png 848w, https://substackcdn.com/image/fetch/$s_!ayw_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d4547ff-5831-4288-9b50-cfdce7b1e5be_753x600.png 1272w, https://substackcdn.com/image/fetch/$s_!ayw_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d4547ff-5831-4288-9b50-cfdce7b1e5be_753x600.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></figure></div><p>A* is widely used in AI, game development, robotics, and navigation systems because it finds the shortest path faster than Dijkstra's algorithm in most practical cases. Obviously, the above outline only briefly glances over the actual algorithm and how it works. If you want a much more thorough overview of exactly how and why A* search  works &#8212; I highly highly recommend <a href="https://www.redblobgames.com/pathfinding/a-star/introduction.html">Introduction to the A* Algorithm</a> from Red Blob Games. </p><div><hr></div><h4><strong>Union-Find algorithm</strong> (also called <strong>Disjoint Set Union (DSU)</strong>)</h4><p>It is actually more of a data structure than an algorithm and helps efficiently manage and group items into sets. It&#8217;s particularly useful for finding whether two elements are in the same set and for uniting two sets. It&#8217;s commonly used in algorithms like Kruskal&#8217;s to detect cycles in a graph and efficiently manage components. </p><p>It supports two main operations:</p><ol><li><p><strong>Find</strong>: Determines which set an element belongs to by returning its "leader" or "representative." If two elements contain the same &#8220;leader&#8221; - we know they belong to the same set. </p></li><li><p><strong>Union</strong>: Merges two sets into one. This is done simply by finding the leaders (or roots) of the two sets, and then connecting one root to the other, merging them into a single set. For efficiency, you should always attach the smaller set under the larger one.</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!U2gC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7a568-d67d-4dce-9756-e615069e65d2_1061x545.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!U2gC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7a568-d67d-4dce-9756-e615069e65d2_1061x545.png 424w, https://substackcdn.com/image/fetch/$s_!U2gC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7a568-d67d-4dce-9756-e615069e65d2_1061x545.png 848w, https://substackcdn.com/image/fetch/$s_!U2gC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7a568-d67d-4dce-9756-e615069e65d2_1061x545.png 1272w, https://substackcdn.com/image/fetch/$s_!U2gC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7a568-d67d-4dce-9756-e615069e65d2_1061x545.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!U2gC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7a568-d67d-4dce-9756-e615069e65d2_1061x545.png" width="1061" height="545" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e0b7a568-d67d-4dce-9756-e615069e65d2_1061x545.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:545,&quot;width&quot;:1061,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:125461,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!U2gC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7a568-d67d-4dce-9756-e615069e65d2_1061x545.png 424w, https://substackcdn.com/image/fetch/$s_!U2gC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7a568-d67d-4dce-9756-e615069e65d2_1061x545.png 848w, https://substackcdn.com/image/fetch/$s_!U2gC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7a568-d67d-4dce-9756-e615069e65d2_1061x545.png 1272w, https://substackcdn.com/image/fetch/$s_!U2gC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7a568-d67d-4dce-9756-e615069e65d2_1061x545.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">Image Source: https://www.quora.com/What-is-an-intuitive-explanation-of-union-find </figcaption></figure></div><p>It efficiently tracks dynamic connectivity in graphs and sets, making it essential for problems like Kruskal&#8217;s MST, cycle detection, clustering, and network connectivity and is widely applied in graph algorithms.</p><div><hr></div><h4><strong>Ford-Fulkerson Algorithm</strong></h4><p>Finds the <strong>maximum flow</strong> in a flow network (i.e. where you want to send the most flow (e.g., water, data) from a source to a sink) through a network of edges with capacities. It works by:</p><ol><li><p>Starting with zero flow in all edges.</p></li><li><p>Looks for <strong>augmenting paths</strong>&#8212;paths from the source to the sink where more flow can be pushed, considering available capacity.</p></li><li><p>Adds the flow along this path and adjusts the capacities (both forward and backward).</p></li><li><p>Repeats until no more augmenting paths can be found.</p></li></ol><p>As an example - let&#8217;s use the graph below:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!kNuR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dd12718-8250-4324-874c-ce1dcd8a40df_1012x506.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!kNuR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dd12718-8250-4324-874c-ce1dcd8a40df_1012x506.png 424w, https://substackcdn.com/image/fetch/$s_!kNuR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dd12718-8250-4324-874c-ce1dcd8a40df_1012x506.png 848w, https://substackcdn.com/image/fetch/$s_!kNuR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dd12718-8250-4324-874c-ce1dcd8a40df_1012x506.png 1272w, https://substackcdn.com/image/fetch/$s_!kNuR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dd12718-8250-4324-874c-ce1dcd8a40df_1012x506.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!kNuR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dd12718-8250-4324-874c-ce1dcd8a40df_1012x506.png" width="358" height="179" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0dd12718-8250-4324-874c-ce1dcd8a40df_1012x506.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:506,&quot;width&quot;:1012,&quot;resizeWidth&quot;:358,&quot;bytes&quot;:58769,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dd12718-8250-4324-874c-ce1dcd8a40df_1012x506.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_!kNuR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dd12718-8250-4324-874c-ce1dcd8a40df_1012x506.png 424w, https://substackcdn.com/image/fetch/$s_!kNuR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dd12718-8250-4324-874c-ce1dcd8a40df_1012x506.png 848w, https://substackcdn.com/image/fetch/$s_!kNuR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dd12718-8250-4324-874c-ce1dcd8a40df_1012x506.png 1272w, https://substackcdn.com/image/fetch/$s_!kNuR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0dd12718-8250-4324-874c-ce1dcd8a40df_1012x506.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption">Image Source: <a href="https://cses.fi/book/book.pdf">Competitive Programmer&#8217;s Handbook</a></figcaption></figure></div><p>The algorithm uses a special representation of a graph where each original edge has a reverse edge in another direction. The weight of each edge indicates how much more flow we could route to it. Initially, the weight of each reverse edge is set to 0:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_pP4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6210164-281e-40b7-8af6-f576e8ad629a_1021x567.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_pP4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6210164-281e-40b7-8af6-f576e8ad629a_1021x567.png 424w, https://substackcdn.com/image/fetch/$s_!_pP4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6210164-281e-40b7-8af6-f576e8ad629a_1021x567.png 848w, https://substackcdn.com/image/fetch/$s_!_pP4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6210164-281e-40b7-8af6-f576e8ad629a_1021x567.png 1272w, https://substackcdn.com/image/fetch/$s_!_pP4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6210164-281e-40b7-8af6-f576e8ad629a_1021x567.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_pP4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6210164-281e-40b7-8af6-f576e8ad629a_1021x567.png" width="363" height="201.58765915768853" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d6210164-281e-40b7-8af6-f576e8ad629a_1021x567.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:567,&quot;width&quot;:1021,&quot;resizeWidth&quot;:363,&quot;bytes&quot;:100860,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6210164-281e-40b7-8af6-f576e8ad629a_1021x567.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_!_pP4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6210164-281e-40b7-8af6-f576e8ad629a_1021x567.png 424w, https://substackcdn.com/image/fetch/$s_!_pP4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6210164-281e-40b7-8af6-f576e8ad629a_1021x567.png 848w, https://substackcdn.com/image/fetch/$s_!_pP4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6210164-281e-40b7-8af6-f576e8ad629a_1021x567.png 1272w, https://substackcdn.com/image/fetch/$s_!_pP4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6210164-281e-40b7-8af6-f576e8ad629a_1021x567.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption">Image Source: <a href="https://cses.fi/book/book.pdf">Competitive Programmer&#8217;s Handbook</a></figcaption></figure></div><p>Then, we need to perform several iterations of our algorithm, which finds paths from the source (node 1) to our sink (node 6) such that each edge within the path has a positive weight. For example, let&#8217;s choose the following path as our first iteration:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Zvxl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6e75dfe-b4cb-422f-92c9-1c3092b0abd1_1035x544.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Zvxl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6e75dfe-b4cb-422f-92c9-1c3092b0abd1_1035x544.png 424w, https://substackcdn.com/image/fetch/$s_!Zvxl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6e75dfe-b4cb-422f-92c9-1c3092b0abd1_1035x544.png 848w, https://substackcdn.com/image/fetch/$s_!Zvxl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6e75dfe-b4cb-422f-92c9-1c3092b0abd1_1035x544.png 1272w, https://substackcdn.com/image/fetch/$s_!Zvxl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6e75dfe-b4cb-422f-92c9-1c3092b0abd1_1035x544.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Zvxl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6e75dfe-b4cb-422f-92c9-1c3092b0abd1_1035x544.png" width="370" height="194.47342995169083" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b6e75dfe-b4cb-422f-92c9-1c3092b0abd1_1035x544.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:544,&quot;width&quot;:1035,&quot;resizeWidth&quot;:370,&quot;bytes&quot;:101849,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6e75dfe-b4cb-422f-92c9-1c3092b0abd1_1035x544.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_!Zvxl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6e75dfe-b4cb-422f-92c9-1c3092b0abd1_1035x544.png 424w, https://substackcdn.com/image/fetch/$s_!Zvxl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6e75dfe-b4cb-422f-92c9-1c3092b0abd1_1035x544.png 848w, https://substackcdn.com/image/fetch/$s_!Zvxl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6e75dfe-b4cb-422f-92c9-1c3092b0abd1_1035x544.png 1272w, https://substackcdn.com/image/fetch/$s_!Zvxl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6e75dfe-b4cb-422f-92c9-1c3092b0abd1_1035x544.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption">Image Source: <a href="https://cses.fi/book/book.pdf">Competitive Programmer&#8217;s Handbook</a></figcaption></figure></div><p>After choosing a path - we increase the flow by <strong>the smallest edge weight within our path. </strong>In the above instance - our smallest edge weight is 2, so the flow increases by 2 and the new graph is updated:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5muo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65352153-58df-4cf5-8f82-3cb34ecb035a_1057x546.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5muo!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65352153-58df-4cf5-8f82-3cb34ecb035a_1057x546.png 424w, https://substackcdn.com/image/fetch/$s_!5muo!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65352153-58df-4cf5-8f82-3cb34ecb035a_1057x546.png 848w, https://substackcdn.com/image/fetch/$s_!5muo!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65352153-58df-4cf5-8f82-3cb34ecb035a_1057x546.png 1272w, https://substackcdn.com/image/fetch/$s_!5muo!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65352153-58df-4cf5-8f82-3cb34ecb035a_1057x546.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5muo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65352153-58df-4cf5-8f82-3cb34ecb035a_1057x546.png" width="403" height="208.17218543046357" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/65352153-58df-4cf5-8f82-3cb34ecb035a_1057x546.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:546,&quot;width&quot;:1057,&quot;resizeWidth&quot;:403,&quot;bytes&quot;:99938,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65352153-58df-4cf5-8f82-3cb34ecb035a_1057x546.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_!5muo!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65352153-58df-4cf5-8f82-3cb34ecb035a_1057x546.png 424w, https://substackcdn.com/image/fetch/$s_!5muo!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65352153-58df-4cf5-8f82-3cb34ecb035a_1057x546.png 848w, https://substackcdn.com/image/fetch/$s_!5muo!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65352153-58df-4cf5-8f82-3cb34ecb035a_1057x546.png 1272w, https://substackcdn.com/image/fetch/$s_!5muo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65352153-58df-4cf5-8f82-3cb34ecb035a_1057x546.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption">Image Source: <a href="https://cses.fi/book/book.pdf">Competitive Programmer&#8217;s Handbook</a></figcaption></figure></div><p>The algorithm keeps increasing the flow as long as there is a path from the source to the sink through positive weight-edges &#8212; and also allows us to decrease the amount of flow that can go through certain edges if its beneficial to re-route the flow through another path.</p><p>The Ford-Fulkerson algorithm is important since it has many applications in various fields like network routing, supply chain optimization, and image segmentation.</p><div><hr></div><h3>String-Search Algorithms</h3><div><hr></div><p>I  was going to include an entire section overviewing some of the key string-search algorithms, but this post is already getting very long, so I decided to leave it out for now. If you&#8217;re interested in this, you can find a full overview here: <a href="https://photonlines.substack.com/p/a-walk-through-of-string-search-algorithms">A Walk-Through of String Search Algorithms</a>. </p><div><hr></div><h3>Compression and Encoding Algorithms</h3><div><hr></div><h4>Value Encoding</h4><p>Value encoding is a type of encoding which we can use to reduce storage requirements. It&#8217;s often used by columnar stores in order to reduce the memory requirements. Imagine that we have a column containing the price of various products, all stored as integer values. The column contains many different values, and to represent all of them, we need a defined number of bits. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Mk_Q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c958a-3f67-4e03-9a5d-d918475d929b_800x566.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Mk_Q!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c958a-3f67-4e03-9a5d-d918475d929b_800x566.png 424w, https://substackcdn.com/image/fetch/$s_!Mk_Q!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c958a-3f67-4e03-9a5d-d918475d929b_800x566.png 848w, https://substackcdn.com/image/fetch/$s_!Mk_Q!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c958a-3f67-4e03-9a5d-d918475d929b_800x566.png 1272w, https://substackcdn.com/image/fetch/$s_!Mk_Q!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c958a-3f67-4e03-9a5d-d918475d929b_800x566.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Mk_Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c958a-3f67-4e03-9a5d-d918475d929b_800x566.png" width="453" height="320.4975" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/431c958a-3f67-4e03-9a5d-d918475d929b_800x566.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:566,&quot;width&quot;:800,&quot;resizeWidth&quot;:453,&quot;bytes&quot;:143714,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Mk_Q!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c958a-3f67-4e03-9a5d-d918475d929b_800x566.png 424w, https://substackcdn.com/image/fetch/$s_!Mk_Q!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c958a-3f67-4e03-9a5d-d918475d929b_800x566.png 848w, https://substackcdn.com/image/fetch/$s_!Mk_Q!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c958a-3f67-4e03-9a5d-d918475d929b_800x566.png 1272w, https://substackcdn.com/image/fetch/$s_!Mk_Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c958a-3f67-4e03-9a5d-d918475d929b_800x566.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">Image Source: https://www.microsoftpressstore.com/articles/article.aspx?p=2449192&amp;seqNum=3 </figcaption></figure></div><p>In the figure above, we can see that the maximum value for the price is 216. Therefore, we will need at least 8 bits to store each value. Nevertheless, by using a simple mathematical operation, we can reduce the storage to 5 bits! By subtracting the minimum value (194) from all the values of the column, it could modify the range of the column, reducing it to a range from 0 to 22. Storing numbers up to 22 requires less bits than storing numbers up to 216. While 3 bits might seem a very small saving, when you multiply this for a few billion rows, it is easy to see that the difference can be an important one!</p><div><hr></div><h4>Dictionary Encoding</h4><p>Dictionary encoding is a technique which can be used to reduce the number of bits required to store columnar data. Dictionary encoding builds a dictionary of the distinct values of a column and then it replaces the column values with indexes to the dictionary.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Ehqq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72be0cd4-8a3f-4d44-96a4-ce9f05351de6_796x399.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Ehqq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72be0cd4-8a3f-4d44-96a4-ce9f05351de6_796x399.png 424w, https://substackcdn.com/image/fetch/$s_!Ehqq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72be0cd4-8a3f-4d44-96a4-ce9f05351de6_796x399.png 848w, https://substackcdn.com/image/fetch/$s_!Ehqq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72be0cd4-8a3f-4d44-96a4-ce9f05351de6_796x399.png 1272w, https://substackcdn.com/image/fetch/$s_!Ehqq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72be0cd4-8a3f-4d44-96a4-ce9f05351de6_796x399.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Ehqq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72be0cd4-8a3f-4d44-96a4-ce9f05351de6_796x399.png" width="583" height="292.2324120603015" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/72be0cd4-8a3f-4d44-96a4-ce9f05351de6_796x399.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:399,&quot;width&quot;:796,&quot;resizeWidth&quot;:583,&quot;bytes&quot;:102135,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Ehqq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72be0cd4-8a3f-4d44-96a4-ce9f05351de6_796x399.png 424w, https://substackcdn.com/image/fetch/$s_!Ehqq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72be0cd4-8a3f-4d44-96a4-ce9f05351de6_796x399.png 848w, https://substackcdn.com/image/fetch/$s_!Ehqq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72be0cd4-8a3f-4d44-96a4-ce9f05351de6_796x399.png 1272w, https://substackcdn.com/image/fetch/$s_!Ehqq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72be0cd4-8a3f-4d44-96a4-ce9f05351de6_796x399.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">Image Source: https://www.microsoftpressstore.com/articles/article.aspx?p=2449192&amp;seqNum=3 </figcaption></figure></div><div><hr></div><h4>Huffman Coding</h4><p>Huffman coding is a method of data compression that reduces the number of bits needed to represent data. It&#8217;s commonly used for compressing text, images, and audio files. The algorithm gives shorter binary codes to frequent symbols and longer codes to rare ones by 1) counting how often each character / symbol appears and 2) using this information to build a binary tree (called a Huffman tree) which assigns short codes to frequent symbols and longer codes to rare ones. You can find a more thorough overview of how exactly the algorithm works here: <a href="https://photonlines.substack.com/p/grokking-huffman-coding">Grokking Huffman Coding</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_!zqKR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad25b823-7eef-4c03-8c7b-bef8ccdd78f5_975x774.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zqKR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad25b823-7eef-4c03-8c7b-bef8ccdd78f5_975x774.png 424w, https://substackcdn.com/image/fetch/$s_!zqKR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad25b823-7eef-4c03-8c7b-bef8ccdd78f5_975x774.png 848w, https://substackcdn.com/image/fetch/$s_!zqKR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad25b823-7eef-4c03-8c7b-bef8ccdd78f5_975x774.png 1272w, https://substackcdn.com/image/fetch/$s_!zqKR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad25b823-7eef-4c03-8c7b-bef8ccdd78f5_975x774.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zqKR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad25b823-7eef-4c03-8c7b-bef8ccdd78f5_975x774.png" width="975" height="774" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ad25b823-7eef-4c03-8c7b-bef8ccdd78f5_975x774.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:774,&quot;width&quot;:975,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:42684,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!zqKR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad25b823-7eef-4c03-8c7b-bef8ccdd78f5_975x774.png 424w, https://substackcdn.com/image/fetch/$s_!zqKR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad25b823-7eef-4c03-8c7b-bef8ccdd78f5_975x774.png 848w, https://substackcdn.com/image/fetch/$s_!zqKR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad25b823-7eef-4c03-8c7b-bef8ccdd78f5_975x774.png 1272w, https://substackcdn.com/image/fetch/$s_!zqKR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad25b823-7eef-4c03-8c7b-bef8ccdd78f5_975x774.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></figure></div><p>An example construction of a valid Huffman tree (or encoding) is provided below:</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lC6b!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd041e358-b5ca-46ad-a01e-c4f806203efc_1292x869.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lC6b!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd041e358-b5ca-46ad-a01e-c4f806203efc_1292x869.png 424w, https://substackcdn.com/image/fetch/$s_!lC6b!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd041e358-b5ca-46ad-a01e-c4f806203efc_1292x869.png 848w, https://substackcdn.com/image/fetch/$s_!lC6b!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd041e358-b5ca-46ad-a01e-c4f806203efc_1292x869.png 1272w, https://substackcdn.com/image/fetch/$s_!lC6b!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd041e358-b5ca-46ad-a01e-c4f806203efc_1292x869.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lC6b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd041e358-b5ca-46ad-a01e-c4f806203efc_1292x869.png" width="727" height="488.98065015479875" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d041e358-b5ca-46ad-a01e-c4f806203efc_1292x869.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:869,&quot;width&quot;:1292,&quot;resizeWidth&quot;:727,&quot;bytes&quot;:89337,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lC6b!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd041e358-b5ca-46ad-a01e-c4f806203efc_1292x869.png 424w, https://substackcdn.com/image/fetch/$s_!lC6b!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd041e358-b5ca-46ad-a01e-c4f806203efc_1292x869.png 848w, https://substackcdn.com/image/fetch/$s_!lC6b!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd041e358-b5ca-46ad-a01e-c4f806203efc_1292x869.png 1272w, https://substackcdn.com/image/fetch/$s_!lC6b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd041e358-b5ca-46ad-a01e-c4f806203efc_1292x869.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></figure></div><div><hr></div><h4>Lempel-Ziv (LZ) Compression </h4><p>The Lempel-Ziv (LZ) algorithm is a lossless compression method that replaces repeated patterns with references to earlier occurrences. Unlike Huffman coding, which requires two passes&#8212;one to determine frequencies and another to encode&#8212;LZ builds its dictionary dynamically in a single pass, making it more efficient in some cases.</p><p>There are many variations of Lempel Ziv around, but they all follow the same basic idea. We&#8217;ll just concentrate on one of the simplest to explain and analyze, although in other versions will work somewhat better in practice. The idea is to parse the sequence into distinct phrases. The version we analyze does this greedily. Suppose, for example, we have the string:</p><p><code>AABABBBABAABABBBA</code></p><p>We start with the shortest phrase on the left that we haven&#8217;t seen before. This will always be a single letter, in this case A:</p><p><code>A|ABABBBABAABABBBA</code></p><p>We now take the next phrase we haven&#8217;t seen. We&#8217;ve already seen A, so we take AB:</p><p><code>A|AB|ABBBABAABABBBA</code></p><p>The next phrase we haven&#8217;t seen is ABB, as we&#8217;ve already seen AB. Continuing, we get B after that:</p><p><code>A|AB|ABB|B|ABAABABBBA</code></p><p>and you can check that the rest of the string parses into:</p><p><code>A|AB|ABB|B|ABA|ABAB|BB</code></p><p>Now, how do we encode this? For each phrase we see, we stick it in a dictionary. The next time we want to send it, we don&#8217;t send the entire phrase, but just the number of this phrase. Consider the following table:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2Q6M!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb710719e-2900-4667-9923-f53549482ba6_2130x225.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2Q6M!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb710719e-2900-4667-9923-f53549482ba6_2130x225.png 424w, https://substackcdn.com/image/fetch/$s_!2Q6M!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb710719e-2900-4667-9923-f53549482ba6_2130x225.png 848w, https://substackcdn.com/image/fetch/$s_!2Q6M!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb710719e-2900-4667-9923-f53549482ba6_2130x225.png 1272w, https://substackcdn.com/image/fetch/$s_!2Q6M!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb710719e-2900-4667-9923-f53549482ba6_2130x225.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2Q6M!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb710719e-2900-4667-9923-f53549482ba6_2130x225.png" width="593" height="62.72115384615385" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b710719e-2900-4667-9923-f53549482ba6_2130x225.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:154,&quot;width&quot;:1456,&quot;resizeWidth&quot;:593,&quot;bytes&quot;:32773,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb710719e-2900-4667-9923-f53549482ba6_2130x225.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_!2Q6M!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb710719e-2900-4667-9923-f53549482ba6_2130x225.png 424w, https://substackcdn.com/image/fetch/$s_!2Q6M!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb710719e-2900-4667-9923-f53549482ba6_2130x225.png 848w, https://substackcdn.com/image/fetch/$s_!2Q6M!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb710719e-2900-4667-9923-f53549482ba6_2130x225.png 1272w, https://substackcdn.com/image/fetch/$s_!2Q6M!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb710719e-2900-4667-9923-f53549482ba6_2130x225.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The second row gives the phrases, and the third row their encodings. That is, when we&#8217;re encoding the ABAB from the sixth phrase, we encode it as 5B. This maps to ABAB since the fifth phrase was ABA, and we add B to it. Here, the empty set &#8709; should be considered as the 0&#8217;th phrase and encoded by 0.</p><p>As mentioned before - there are other variations of this algorithm, including the LZ77 algorithm which <strong>uses a sliding window</strong> and <strong>triplets (offset, length, next character) </strong>to encode the information<strong>. </strong>A very simple example of how this algorithm works is also provided 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_!iU98!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F354285b6-51f5-4e0e-9f52-7d18b30b290b_1464x823.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iU98!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F354285b6-51f5-4e0e-9f52-7d18b30b290b_1464x823.png 424w, https://substackcdn.com/image/fetch/$s_!iU98!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F354285b6-51f5-4e0e-9f52-7d18b30b290b_1464x823.png 848w, https://substackcdn.com/image/fetch/$s_!iU98!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F354285b6-51f5-4e0e-9f52-7d18b30b290b_1464x823.png 1272w, https://substackcdn.com/image/fetch/$s_!iU98!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F354285b6-51f5-4e0e-9f52-7d18b30b290b_1464x823.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iU98!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F354285b6-51f5-4e0e-9f52-7d18b30b290b_1464x823.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/354285b6-51f5-4e0e-9f52-7d18b30b290b_1464x823.png&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;:453649,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F354285b6-51f5-4e0e-9f52-7d18b30b290b_1464x823.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_!iU98!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F354285b6-51f5-4e0e-9f52-7d18b30b290b_1464x823.png 424w, https://substackcdn.com/image/fetch/$s_!iU98!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F354285b6-51f5-4e0e-9f52-7d18b30b290b_1464x823.png 848w, https://substackcdn.com/image/fetch/$s_!iU98!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F354285b6-51f5-4e0e-9f52-7d18b30b290b_1464x823.png 1272w, https://substackcdn.com/image/fetch/$s_!iU98!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F354285b6-51f5-4e0e-9f52-7d18b30b290b_1464x823.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">Example taken from: https://slideplayer.com/slide/9312974/ </figcaption></figure></div><p>LZ77 is the basis for widely used compression methods like DEFLATE (used in ZIP, PNG, Gzip), LZW (used in GIF), and LZMA (used in 7z).</p><div><hr></div><h4>Bitmap Index (used for Column Compression) &amp; Run-Length Encoding</h4><p>A <strong>bitmap index</strong> is a way to compress and quickly search through columns of data in databases. For each unique value in a column, it creates a sequence of bits (0s and 1s) that indicate whether a row has that value.</p><p>For example, if a column has the values A, B, A the bitmaps would be:</p><ul><li><p>For A: 1, 0, 1</p></li><li><p>For B: 0, 1, 0</p></li></ul><p>Data warehouses use columnar storage (rather than row-level storage) to store data - which tends to save a lot of space since columns with many duplicate elements can be encoded in a more efficient way. A simple example showing how this columnar storage works is provided below (taken directly from a highly recommended book which I recommend every software developer read: <a href="https://www.oreilly.com/library/view/designing-data-intensive-applications/9781491903063/">Designing Data-Intensive Applications</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_!uvkw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1dfda89c-082a-402f-a77f-cd021f4f3cd7_827x623.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!uvkw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1dfda89c-082a-402f-a77f-cd021f4f3cd7_827x623.png 424w, https://substackcdn.com/image/fetch/$s_!uvkw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1dfda89c-082a-402f-a77f-cd021f4f3cd7_827x623.png 848w, https://substackcdn.com/image/fetch/$s_!uvkw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1dfda89c-082a-402f-a77f-cd021f4f3cd7_827x623.png 1272w, https://substackcdn.com/image/fetch/$s_!uvkw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1dfda89c-082a-402f-a77f-cd021f4f3cd7_827x623.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!uvkw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1dfda89c-082a-402f-a77f-cd021f4f3cd7_827x623.png" width="647" height="487.4014510278114" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1dfda89c-082a-402f-a77f-cd021f4f3cd7_827x623.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:623,&quot;width&quot;:827,&quot;resizeWidth&quot;:647,&quot;bytes&quot;:141265,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!uvkw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1dfda89c-082a-402f-a77f-cd021f4f3cd7_827x623.png 424w, https://substackcdn.com/image/fetch/$s_!uvkw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1dfda89c-082a-402f-a77f-cd021f4f3cd7_827x623.png 848w, https://substackcdn.com/image/fetch/$s_!uvkw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1dfda89c-082a-402f-a77f-cd021f4f3cd7_827x623.png 1272w, https://substackcdn.com/image/fetch/$s_!uvkw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1dfda89c-082a-402f-a77f-cd021f4f3cd7_827x623.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">Image Source: <a href="https://www.oreilly.com/library/view/designing-data-intensive-applications/9781491903063/">Designing Data-Intensive Applications</a></figcaption></figure></div><p><strong>Run-Length Encoding</strong> compresses data by replacing consecutive repeated values with a single value and the count of its repetitions. For example, if you have the data: AAAAABBBCC, it would be compressed as 5A 3B 2C. This is effective when there are long sequences of repeated values, reducing the amount of data stored.</p><p>Example of a compressed, bitmap-indexed storage of a single column:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Pv7F!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F125f9e01-c02b-499d-ad2e-4b7501d1729f_832x616.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Pv7F!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F125f9e01-c02b-499d-ad2e-4b7501d1729f_832x616.png 424w, https://substackcdn.com/image/fetch/$s_!Pv7F!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F125f9e01-c02b-499d-ad2e-4b7501d1729f_832x616.png 848w, https://substackcdn.com/image/fetch/$s_!Pv7F!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F125f9e01-c02b-499d-ad2e-4b7501d1729f_832x616.png 1272w, https://substackcdn.com/image/fetch/$s_!Pv7F!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F125f9e01-c02b-499d-ad2e-4b7501d1729f_832x616.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Pv7F!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F125f9e01-c02b-499d-ad2e-4b7501d1729f_832x616.png" width="583" height="431.6442307692308" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/125f9e01-c02b-499d-ad2e-4b7501d1729f_832x616.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:616,&quot;width&quot;:832,&quot;resizeWidth&quot;:583,&quot;bytes&quot;:124565,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Pv7F!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F125f9e01-c02b-499d-ad2e-4b7501d1729f_832x616.png 424w, https://substackcdn.com/image/fetch/$s_!Pv7F!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F125f9e01-c02b-499d-ad2e-4b7501d1729f_832x616.png 848w, https://substackcdn.com/image/fetch/$s_!Pv7F!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F125f9e01-c02b-499d-ad2e-4b7501d1729f_832x616.png 1272w, https://substackcdn.com/image/fetch/$s_!Pv7F!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F125f9e01-c02b-499d-ad2e-4b7501d1729f_832x616.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">Image Source: <a href="https://www.oreilly.com/library/view/designing-data-intensive-applications/9781491903063/">Designing Data-Intensive Applications</a></figcaption></figure></div><div><hr></div><h4>Burrows-Wheeler Transform</h4><p>The <strong>Burrows-Wheeler Transform (BWT)</strong> rearranges a string into a form that&#8217;s easier to compress by grouping similar characters together. Once applied, the transformed string is easier to compress using techniques like Run-Length Encoding (RLE) or Huffman Coding. </p><p>Imagine a messy shelf of books. The BWT is like grouping books of the same color together. While you don&#8217;t change the books themselves, organizing them makes it much easier to spot patterns, retrieve what you need, or pack them tightly. The BWT is a way of transforming a string into a new string that has the <strong>same characters</strong>, but in a rearranged order that groups similar patterns together. </p><p>To be more precise, it works by:</p><ol><li><p>Generating all rotations of the string.</p></li><li><p>Sorting these rotations lexicographically.</p></li><li><p>Taking the last column of the sorted rotations as the transformed string.</p></li></ol><div id="youtube2-4WRANhDiSHM" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;4WRANhDiSHM&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/4WRANhDiSHM?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><div><hr></div><h4>Fourier Transform (and Fast Fourier Transform (FFT))</h4><p>The Fourier Transform is crucial for analyzing and compressing signals in various fields, like audio processing, image analysis, and communications. In essence, it&#8217;s a mathematical tool that decomposes a signal into its constituent frequencies. It converts a time-domain signal (how a signal changes over time) into a frequency-domain representation (what frequencies make up the 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_!czbf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24b5026c-ed8f-453d-ae8b-9fddb09feba2_789x559.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!czbf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24b5026c-ed8f-453d-ae8b-9fddb09feba2_789x559.png 424w, https://substackcdn.com/image/fetch/$s_!czbf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24b5026c-ed8f-453d-ae8b-9fddb09feba2_789x559.png 848w, https://substackcdn.com/image/fetch/$s_!czbf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24b5026c-ed8f-453d-ae8b-9fddb09feba2_789x559.png 1272w, https://substackcdn.com/image/fetch/$s_!czbf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24b5026c-ed8f-453d-ae8b-9fddb09feba2_789x559.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!czbf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24b5026c-ed8f-453d-ae8b-9fddb09feba2_789x559.png" width="503" height="356.3713561470216" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/24b5026c-ed8f-453d-ae8b-9fddb09feba2_789x559.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:559,&quot;width&quot;:789,&quot;resizeWidth&quot;:503,&quot;bytes&quot;:231605,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;type&quot;:&quot;image/png&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!czbf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24b5026c-ed8f-453d-ae8b-9fddb09feba2_789x559.png 424w, https://substackcdn.com/image/fetch/$s_!czbf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24b5026c-ed8f-453d-ae8b-9fddb09feba2_789x559.png 848w, https://substackcdn.com/image/fetch/$s_!czbf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24b5026c-ed8f-453d-ae8b-9fddb09feba2_789x559.png 1272w, https://substackcdn.com/image/fetch/$s_!czbf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24b5026c-ed8f-453d-ae8b-9fddb09feba2_789x559.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">Image Source: https://devincody.github.io/Blog/post/an_intuitive_interpretation_of_the_fourier_transform/ </figcaption></figure></div><p>To put it in a simpler manner - any signal can be thought of as a combination of pure sine waves (waves with a smooth and repetitive pattern). The Fourier Transform can be thought of as a tool that helps us understand the "ingredients" of a signal breaking it down into these sine waves. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FLAG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f31985-26c5-4cc0-988f-24968b60a2ff_346x600.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FLAG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f31985-26c5-4cc0-988f-24968b60a2ff_346x600.png 424w, https://substackcdn.com/image/fetch/$s_!FLAG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f31985-26c5-4cc0-988f-24968b60a2ff_346x600.png 848w, https://substackcdn.com/image/fetch/$s_!FLAG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f31985-26c5-4cc0-988f-24968b60a2ff_346x600.png 1272w, https://substackcdn.com/image/fetch/$s_!FLAG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f31985-26c5-4cc0-988f-24968b60a2ff_346x600.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FLAG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f31985-26c5-4cc0-988f-24968b60a2ff_346x600.png" width="222" height="384.97109826589593" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/36f31985-26c5-4cc0-988f-24968b60a2ff_346x600.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:600,&quot;width&quot;:346,&quot;resizeWidth&quot;:222,&quot;bytes&quot;:61668,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;type&quot;:&quot;image/png&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!FLAG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f31985-26c5-4cc0-988f-24968b60a2ff_346x600.png 424w, https://substackcdn.com/image/fetch/$s_!FLAG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f31985-26c5-4cc0-988f-24968b60a2ff_346x600.png 848w, https://substackcdn.com/image/fetch/$s_!FLAG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f31985-26c5-4cc0-988f-24968b60a2ff_346x600.png 1272w, https://substackcdn.com/image/fetch/$s_!FLAG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f31985-26c5-4cc0-988f-24968b60a2ff_346x600.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">Image Source: https://news.mit.edu/2012/faster-fourier-transforms-0118 </figcaption></figure></div><p>How does it work? Imagine you have a signal, and you want to figure out what sine waves it&#8217;s made of:</p><ol><li><p><strong>Pick a frequency</strong>: Take a sine wave with a specific frequency.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xRZG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb493cd-fd43-4f41-b1dc-df284a838856_902x247.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xRZG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb493cd-fd43-4f41-b1dc-df284a838856_902x247.png 424w, https://substackcdn.com/image/fetch/$s_!xRZG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb493cd-fd43-4f41-b1dc-df284a838856_902x247.png 848w, https://substackcdn.com/image/fetch/$s_!xRZG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb493cd-fd43-4f41-b1dc-df284a838856_902x247.png 1272w, https://substackcdn.com/image/fetch/$s_!xRZG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb493cd-fd43-4f41-b1dc-df284a838856_902x247.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xRZG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb493cd-fd43-4f41-b1dc-df284a838856_902x247.png" width="472" height="129.25055432372505" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7cb493cd-fd43-4f41-b1dc-df284a838856_902x247.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:247,&quot;width&quot;:902,&quot;resizeWidth&quot;:472,&quot;bytes&quot;:76309,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;type&quot;:&quot;image/png&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!xRZG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb493cd-fd43-4f41-b1dc-df284a838856_902x247.png 424w, https://substackcdn.com/image/fetch/$s_!xRZG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb493cd-fd43-4f41-b1dc-df284a838856_902x247.png 848w, https://substackcdn.com/image/fetch/$s_!xRZG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb493cd-fd43-4f41-b1dc-df284a838856_902x247.png 1272w, https://substackcdn.com/image/fetch/$s_!xRZG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cb493cd-fd43-4f41-b1dc-df284a838856_902x247.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div></li><li><p><strong>Check its presence</strong>: Multiply this sine wave by the original signal and then add up the result (this process is called integration).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ARcc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe80e2b79-52cd-4449-ae10-502033fefe90_1131x734.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ARcc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe80e2b79-52cd-4449-ae10-502033fefe90_1131x734.png 424w, https://substackcdn.com/image/fetch/$s_!ARcc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe80e2b79-52cd-4449-ae10-502033fefe90_1131x734.png 848w, https://substackcdn.com/image/fetch/$s_!ARcc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe80e2b79-52cd-4449-ae10-502033fefe90_1131x734.png 1272w, https://substackcdn.com/image/fetch/$s_!ARcc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe80e2b79-52cd-4449-ae10-502033fefe90_1131x734.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ARcc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe80e2b79-52cd-4449-ae10-502033fefe90_1131x734.png" width="1131" height="734" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e80e2b79-52cd-4449-ae10-502033fefe90_1131x734.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:734,&quot;width&quot;:1131,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:150669,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;type&quot;:&quot;image/png&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!ARcc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe80e2b79-52cd-4449-ae10-502033fefe90_1131x734.png 424w, https://substackcdn.com/image/fetch/$s_!ARcc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe80e2b79-52cd-4449-ae10-502033fefe90_1131x734.png 848w, https://substackcdn.com/image/fetch/$s_!ARcc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe80e2b79-52cd-4449-ae10-502033fefe90_1131x734.png 1272w, https://substackcdn.com/image/fetch/$s_!ARcc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe80e2b79-52cd-4449-ae10-502033fefe90_1131x734.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"></figcaption></figure></div></li><li><p><strong>Repeat</strong>: Do this for many different sine waves with different frequencies. </p><p></p></li></ol><p>Now, the above process is a very inefficient one. How can we simplify it further and optimize it? This is where the FFT comes to the rescue. The <strong>Fast Fourier Transform (FFT)</strong> is an optimized algorithm for computing the Fourier Transform quickly. It works by:</p><ol><li><p>Dividing the signal into even-indexed and odd-indexed components. This step reduces the size of the problem recursively.</p></li><li><p>Computing smaller Fourier Transforms on the even and odd components. This divide-and-conquer approach continues until reaching base cases (like single points).</p></li><li><p>Combining the smaller transforms efficiently by using symmetry and periodicity properties of complex exponentials (roots of unity).</p></li></ol><p>The combined result gives the complete frequency representation of the original signal. If you&#8217;re interested in the full details - a great video explaining the FFT is provided below:</p><div id="youtube2-h7apO7q16V0" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;h7apO7q16V0&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/h7apO7q16V0?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><p>The FFT&#8217;s speed and versatility make it indispensable in both engineering and scientific fields where quick and accurate frequency analysis is essential for tasks such as real-time signal processing, image reconstruction in medical imaging (like MRI), seismic data analysis for geophysics, and the efficient simulation of physical systems in computational science.</p><div><hr></div><h4>Quantization</h4><p>Quantization is the process of taking a continuous signal or value and converting it into a set of discrete levels. It's like rounding real numbers to the nearest whole number but applied to things like sound, images, or data to make them easier to store and process. I won&#8217;t go into the full details of how quantization works here, but you can find a great visual focused overview here: <a href="http://A Visual Guide to Quantization">A Visual Guide to Quantization</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_!82kg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd21856b8-0b02-4332-b486-9689a07bc299_1707x1062.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!82kg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd21856b8-0b02-4332-b486-9689a07bc299_1707x1062.png 424w, https://substackcdn.com/image/fetch/$s_!82kg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd21856b8-0b02-4332-b486-9689a07bc299_1707x1062.png 848w, https://substackcdn.com/image/fetch/$s_!82kg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd21856b8-0b02-4332-b486-9689a07bc299_1707x1062.png 1272w, https://substackcdn.com/image/fetch/$s_!82kg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd21856b8-0b02-4332-b486-9689a07bc299_1707x1062.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!82kg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd21856b8-0b02-4332-b486-9689a07bc299_1707x1062.png" width="1456" height="906" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d21856b8-0b02-4332-b486-9689a07bc299_1707x1062.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:906,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:327162,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd21856b8-0b02-4332-b486-9689a07bc299_1707x1062.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_!82kg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd21856b8-0b02-4332-b486-9689a07bc299_1707x1062.png 424w, https://substackcdn.com/image/fetch/$s_!82kg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd21856b8-0b02-4332-b486-9689a07bc299_1707x1062.png 848w, https://substackcdn.com/image/fetch/$s_!82kg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd21856b8-0b02-4332-b486-9689a07bc299_1707x1062.png 1272w, https://substackcdn.com/image/fetch/$s_!82kg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd21856b8-0b02-4332-b486-9689a07bc299_1707x1062.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">Image Source: <a href="https://newsletter.maartengrootendorst.com/p/a-visual-guide-to-quantization">A Visual Guide to Quantization</a></figcaption></figure></div><div><hr></div><h4>Discrete Cosine Transform (DCT)</h4><p>The Discrete Cosine Transform (DCT) is similar to the Fourier Transform (where a signal is converted from its time-domain representation to its frequency-domain),  but DCT does it in a manner which leads to better information compression for real-world data sets. Some key differences between the Fourier transform and DCT are:</p><ol><li><p>DCT uses only real cosine functions, while the Fourier Transform uses both sine and cosine functions (complex exponentials). This makes the DCT more efficient for signals that are real-valued and symmetric.</p></li><li><p>DCT assumes the signal is even (symmetrical) at the boundaries, reducing high-frequency components and leading to better energy compaction. </p></li><li><p>DCT is <strong>discrete (</strong>i.e. the information is quantized) once again leading to better information compression. </p></li></ol><p>DCT is widely used in image and video compression (e.g., JPEG, MP3) and although I won&#8217;t go into the full details on how it works here - this Computerphile video does and excellent job of explaining how it works:</p><div id="youtube2-Q2aEzeMDHMA" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;Q2aEzeMDHMA&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/Q2aEzeMDHMA?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><div><hr></div><h4>Image Compression (JPEG)</h4><p>JPEG compression is a popular method for reducing image file sizes while maintaining good visual quality by removing less noticeable details. It exploits how humans perceive images, prioritizing brightness over color details and simplifying less significant information. Here&#8217;s an overview of how it works:</p><ol><li><p>The image is converted from RGB to YCbCr color space. This separates the image into luminance (brightness, Y) and chrominance (color, Cb and Cr), as humans are more sensitive to brightness than color details.</p></li><li><p>The image is divided into 8x8 pixel blocks for localized processing.</p></li><li><p>Each block undergoes DCT to convert spatial pixel values into frequency components. This step helps identify low-frequency (broad features) and high-frequency (fine detailed) components.</p></li><li><p>Frequency components are divided by a quantization matrix based on a quality factor. Higher-frequency details are significantly reduced or eliminated to save data while preserving visual quality.</p></li><li><p>The quantized data is compressed further using run-length encoding (compresses sequences of repeated values) and Huffman coding (assigns shorter codes to more frequent values in an optimal manner). </p></li></ol><p>This process is "lossy," meaning some data is permanently discarded. While this can lead to artifacts with very high compression levels, JPEG compression strikes a good balance between file size and image quality. If you want a better understanding of the key details, a great video explaining how this is done is provided below:</p><div id="youtube2-Kv1Hiv3ox8I" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;Kv1Hiv3ox8I&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/Kv1Hiv3ox8I?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><div><hr></div><h4>Video Compression &amp; Encoding</h4><p>A video is essentially a sequence of images, known as frames, captured over time. Frames are once again often converted from the RGB color model to a more compression-friendly format like YCbCr (which we covered in JPEG compression). Similar to JPEG, each individual frame (<strong>intra-frame</strong>) also undergoes spatial compression to reduce redundancy <strong>within</strong> the frame:</p><ol><li><p><strong>Block Partitioning</strong>: The frame is divided into small blocks (e.g., 8x8 pixels).</p></li><li><p><strong>Discrete Cosine Transform (DCT)</strong>: Each block is transformed from the spatial domain to the frequency domain using DCT, which helps separate image details based on their frequency components.</p></li><li><p><strong>Quantization</strong>: The frequency coefficients obtained from DCT are approximated to reduce precision, effectively reducing the amount of data. This step introduces some loss but is crucial for compression.</p></li></ol><p>Many sequential images within a video contain the same information, so our video also must undergo through <strong>inter-frame</strong> compression to get rid of any redundancies <strong>between</strong> consecutive frames:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!uncK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F548bf7c5-551b-4f35-ba44-de38f609a469_900x499.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!uncK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F548bf7c5-551b-4f35-ba44-de38f609a469_900x499.png 424w, https://substackcdn.com/image/fetch/$s_!uncK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F548bf7c5-551b-4f35-ba44-de38f609a469_900x499.png 848w, https://substackcdn.com/image/fetch/$s_!uncK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F548bf7c5-551b-4f35-ba44-de38f609a469_900x499.png 1272w, https://substackcdn.com/image/fetch/$s_!uncK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F548bf7c5-551b-4f35-ba44-de38f609a469_900x499.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!uncK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F548bf7c5-551b-4f35-ba44-de38f609a469_900x499.png" width="463" height="256.7077777777778" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/548bf7c5-551b-4f35-ba44-de38f609a469_900x499.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:499,&quot;width&quot;:900,&quot;resizeWidth&quot;:463,&quot;bytes&quot;:177760,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F548bf7c5-551b-4f35-ba44-de38f609a469_900x499.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_!uncK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F548bf7c5-551b-4f35-ba44-de38f609a469_900x499.png 424w, https://substackcdn.com/image/fetch/$s_!uncK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F548bf7c5-551b-4f35-ba44-de38f609a469_900x499.png 848w, https://substackcdn.com/image/fetch/$s_!uncK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F548bf7c5-551b-4f35-ba44-de38f609a469_900x499.png 1272w, https://substackcdn.com/image/fetch/$s_!uncK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F548bf7c5-551b-4f35-ba44-de38f609a469_900x499.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">Image Source: https://info.verkada.com/video-storage/Interframe-vs-Intraframe-Compression/ </figcaption></figure></div><p>The different frame types used within video-compression are outlined 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_!x7pV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e007ad9-9a05-46f6-bdda-2d7cd9e7ad3c_1953x1464.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!x7pV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e007ad9-9a05-46f6-bdda-2d7cd9e7ad3c_1953x1464.png 424w, https://substackcdn.com/image/fetch/$s_!x7pV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e007ad9-9a05-46f6-bdda-2d7cd9e7ad3c_1953x1464.png 848w, https://substackcdn.com/image/fetch/$s_!x7pV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e007ad9-9a05-46f6-bdda-2d7cd9e7ad3c_1953x1464.png 1272w, https://substackcdn.com/image/fetch/$s_!x7pV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e007ad9-9a05-46f6-bdda-2d7cd9e7ad3c_1953x1464.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!x7pV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e007ad9-9a05-46f6-bdda-2d7cd9e7ad3c_1953x1464.png" width="1456" height="1091" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9e007ad9-9a05-46f6-bdda-2d7cd9e7ad3c_1953x1464.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1091,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:129297,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e007ad9-9a05-46f6-bdda-2d7cd9e7ad3c_1953x1464.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_!x7pV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e007ad9-9a05-46f6-bdda-2d7cd9e7ad3c_1953x1464.png 424w, https://substackcdn.com/image/fetch/$s_!x7pV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e007ad9-9a05-46f6-bdda-2d7cd9e7ad3c_1953x1464.png 848w, https://substackcdn.com/image/fetch/$s_!x7pV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e007ad9-9a05-46f6-bdda-2d7cd9e7ad3c_1953x1464.png 1272w, https://substackcdn.com/image/fetch/$s_!x7pV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e007ad9-9a05-46f6-bdda-2d7cd9e7ad3c_1953x1464.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></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NnmQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7738680a-9277-4711-a0bf-139d6afd8362_2477x868.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NnmQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7738680a-9277-4711-a0bf-139d6afd8362_2477x868.png 424w, https://substackcdn.com/image/fetch/$s_!NnmQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7738680a-9277-4711-a0bf-139d6afd8362_2477x868.png 848w, https://substackcdn.com/image/fetch/$s_!NnmQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7738680a-9277-4711-a0bf-139d6afd8362_2477x868.png 1272w, https://substackcdn.com/image/fetch/$s_!NnmQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7738680a-9277-4711-a0bf-139d6afd8362_2477x868.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NnmQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7738680a-9277-4711-a0bf-139d6afd8362_2477x868.png" width="1456" height="510" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7738680a-9277-4711-a0bf-139d6afd8362_2477x868.png&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;:79715,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7738680a-9277-4711-a0bf-139d6afd8362_2477x868.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_!NnmQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7738680a-9277-4711-a0bf-139d6afd8362_2477x868.png 424w, https://substackcdn.com/image/fetch/$s_!NnmQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7738680a-9277-4711-a0bf-139d6afd8362_2477x868.png 848w, https://substackcdn.com/image/fetch/$s_!NnmQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7738680a-9277-4711-a0bf-139d6afd8362_2477x868.png 1272w, https://substackcdn.com/image/fetch/$s_!NnmQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7738680a-9277-4711-a0bf-139d6afd8362_2477x868.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></figure></div><p>In order to compress the inter-frame information - 2 key techniques are used:</p><ul><li><p><strong>Motion Estimation</strong>: The encoder identifies and predicts the movement of objects between frames, allowing it to represent changes efficiently.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!N9vG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb8367ff-a0c9-4136-966a-e80975935390_1176x1226.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!N9vG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb8367ff-a0c9-4136-966a-e80975935390_1176x1226.png 424w, https://substackcdn.com/image/fetch/$s_!N9vG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb8367ff-a0c9-4136-966a-e80975935390_1176x1226.png 848w, https://substackcdn.com/image/fetch/$s_!N9vG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb8367ff-a0c9-4136-966a-e80975935390_1176x1226.png 1272w, https://substackcdn.com/image/fetch/$s_!N9vG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb8367ff-a0c9-4136-966a-e80975935390_1176x1226.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!N9vG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb8367ff-a0c9-4136-966a-e80975935390_1176x1226.png" width="336" height="350.2857142857143" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/db8367ff-a0c9-4136-966a-e80975935390_1176x1226.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1226,&quot;width&quot;:1176,&quot;resizeWidth&quot;:336,&quot;bytes&quot;:235014,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb8367ff-a0c9-4136-966a-e80975935390_1176x1226.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_!N9vG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb8367ff-a0c9-4136-966a-e80975935390_1176x1226.png 424w, https://substackcdn.com/image/fetch/$s_!N9vG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb8367ff-a0c9-4136-966a-e80975935390_1176x1226.png 848w, https://substackcdn.com/image/fetch/$s_!N9vG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb8367ff-a0c9-4136-966a-e80975935390_1176x1226.png 1272w, https://substackcdn.com/image/fetch/$s_!N9vG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb8367ff-a0c9-4136-966a-e80975935390_1176x1226.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></figure></div><ul><li><p><strong>Motion Compensation</strong>: Using the motion information, only the differences (residuals) between the predicted and actual frames are encoded, rather than the entire frame.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RtBa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F003fd901-ba4c-4af5-8bd3-5e5e4f80c7d8_1242x391.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RtBa!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F003fd901-ba4c-4af5-8bd3-5e5e4f80c7d8_1242x391.png 424w, https://substackcdn.com/image/fetch/$s_!RtBa!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F003fd901-ba4c-4af5-8bd3-5e5e4f80c7d8_1242x391.png 848w, https://substackcdn.com/image/fetch/$s_!RtBa!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F003fd901-ba4c-4af5-8bd3-5e5e4f80c7d8_1242x391.png 1272w, https://substackcdn.com/image/fetch/$s_!RtBa!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F003fd901-ba4c-4af5-8bd3-5e5e4f80c7d8_1242x391.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RtBa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F003fd901-ba4c-4af5-8bd3-5e5e4f80c7d8_1242x391.png" width="645" height="203.05555555555554" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/003fd901-ba4c-4af5-8bd3-5e5e4f80c7d8_1242x391.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:391,&quot;width&quot;:1242,&quot;resizeWidth&quot;:645,&quot;bytes&quot;:95099,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F003fd901-ba4c-4af5-8bd3-5e5e4f80c7d8_1242x391.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_!RtBa!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F003fd901-ba4c-4af5-8bd3-5e5e4f80c7d8_1242x391.png 424w, https://substackcdn.com/image/fetch/$s_!RtBa!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F003fd901-ba4c-4af5-8bd3-5e5e4f80c7d8_1242x391.png 848w, https://substackcdn.com/image/fetch/$s_!RtBa!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F003fd901-ba4c-4af5-8bd3-5e5e4f80c7d8_1242x391.png 1272w, https://substackcdn.com/image/fetch/$s_!RtBa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F003fd901-ba4c-4af5-8bd3-5e5e4f80c7d8_1242x391.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption">Image Source: https://github.com/leandromoreira/digital_video_introduction </figcaption></figure></div><p></p><p>The quantized coefficients and motion information are further compressed using entropy coding techniques like Huffman coding or arithmetic coding, which assign shorter codes to more frequent patterns. Also - instead of storing the information from each image block separately, the encoder looks at previous frames to check if the current block already exists in an earlier frame (but possibly in a different position) and tries to utilize this info in encoding our data. Finally, all compressed data is packaged into a bitstream, following specific formatting rules defined by the video codec standard in use (e.g., H.264, H.265). </p><p>Digital video plays a very important role in our lives and although I&#8217;ve done my best to outline some of the higher-level details, you can find a much more thorough explanation here: <a href="https://github.com/leandromoreira/digital_video_introduction">Digital Video Introduction</a>.  </p><div><hr></div><h4>Ray Tracing</h4><p>Ray tracing is a computer graphics algorithm that simulates how light behaves to create highly realistic images. At its core, ray tracing works by tracing the path of light rays from the viewer's eye (or camera) back into the scene to determine what they intersect with. Each ray is cast into a 3D virtual scene, and whenever it hits an object, calculations are performed to determine the color of the object at that point. These calculations account for the surface&#8217;s material properties, light sources, and reflections or refractions, mimicking how light interacts with the real world. I won&#8217;t go through the whole process of how exactly this is done, but the video below does an outstanding job explaining the key details is provided below:</p><div id="youtube2-iOlehM5kNSk" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;iOlehM5kNSk&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/iOlehM5kNSk?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><div><hr></div><h3>Optimization Algorithms</h3><div><hr></div><h4>Simplex Method</h4><p>The simplex algorithm is the preeminent tool for solving some of the most important mathematical problems arising in business, science, and technology. These problems are called linear programs - and for them, we try to maximize (or minimize) a linear function subject to linear constraints. An example is the diet problem posed by the U.S. Air Force in 1947: find quantities of seventy-seven differently priced foodstuffs  to satisfy a man&#8217;s minimum daily requirements for nine nutrients (protein, iron, etc.) at least cost. George Dantzig invented the simplex algorithm in 1947 as a means of solving the Air Force&#8217;s diet problem and the word &#8220;program&#8221; was not yet used to mean computer code, but was a military term for a logistic plan or schedule. </p><p>The algorithm is based on the fact that if a linear programming (LP) problem has a solution, the <strong>optimal solution</strong> (best value) is always at a <strong>corner</strong> or <strong>vertex</strong> of the feasible region (the area where all constraints are satisfied). This feasible region is called a <strong>polytope</strong>, and since the shape resembles a "simplex" (a geometric shape), the algorithm gets its name from that.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Py-K!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5db79b-b505-4dcd-a0a4-10dfe29c5c8e_2594x1628.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Py-K!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5db79b-b505-4dcd-a0a4-10dfe29c5c8e_2594x1628.png 424w, https://substackcdn.com/image/fetch/$s_!Py-K!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5db79b-b505-4dcd-a0a4-10dfe29c5c8e_2594x1628.png 848w, https://substackcdn.com/image/fetch/$s_!Py-K!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5db79b-b505-4dcd-a0a4-10dfe29c5c8e_2594x1628.png 1272w, https://substackcdn.com/image/fetch/$s_!Py-K!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5db79b-b505-4dcd-a0a4-10dfe29c5c8e_2594x1628.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Py-K!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5db79b-b505-4dcd-a0a4-10dfe29c5c8e_2594x1628.png" width="1456" height="914" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bf5db79b-b505-4dcd-a0a4-10dfe29c5c8e_2594x1628.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:914,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:221094,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Py-K!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5db79b-b505-4dcd-a0a4-10dfe29c5c8e_2594x1628.png 424w, https://substackcdn.com/image/fetch/$s_!Py-K!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5db79b-b505-4dcd-a0a4-10dfe29c5c8e_2594x1628.png 848w, https://substackcdn.com/image/fetch/$s_!Py-K!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5db79b-b505-4dcd-a0a4-10dfe29c5c8e_2594x1628.png 1272w, https://substackcdn.com/image/fetch/$s_!Py-K!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbf5db79b-b505-4dcd-a0a4-10dfe29c5c8e_2594x1628.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></figure></div><p>A great and more elaborate example of using this method to solve a real problem is provided here: <a href="https://www.youtube.com/watch?v=gRgsT9BB5-8">The Simplex Method - Finding a Maximum / Word Problem Example</a>.</p><div><hr></div><h4>Integer Programming</h4><p>Integer programming (IP) is a type of optimization problem where the decision variables are restricted to integer values, typically representing counts or discrete choices. To solve an integer programming problem, you first write an <strong>objective function</strong> to optimize (e.g., maximize profit), and set <strong>constraints</strong> based on available resources (e.g., materials, time). A graph depicting an example integer program is provided 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_!v4M1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fe2a74-84b5-4fc6-af34-191281f669e1_1024x850.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!v4M1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fe2a74-84b5-4fc6-af34-191281f669e1_1024x850.png 424w, https://substackcdn.com/image/fetch/$s_!v4M1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fe2a74-84b5-4fc6-af34-191281f669e1_1024x850.png 848w, https://substackcdn.com/image/fetch/$s_!v4M1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fe2a74-84b5-4fc6-af34-191281f669e1_1024x850.png 1272w, https://substackcdn.com/image/fetch/$s_!v4M1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fe2a74-84b5-4fc6-af34-191281f669e1_1024x850.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!v4M1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fe2a74-84b5-4fc6-af34-191281f669e1_1024x850.png" width="406" height="337.01171875" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/19fe2a74-84b5-4fc6-af34-191281f669e1_1024x850.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:850,&quot;width&quot;:1024,&quot;resizeWidth&quot;:406,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;undefined&quot;,&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="undefined" title="undefined" srcset="https://substackcdn.com/image/fetch/$s_!v4M1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fe2a74-84b5-4fc6-af34-191281f669e1_1024x850.png 424w, https://substackcdn.com/image/fetch/$s_!v4M1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fe2a74-84b5-4fc6-af34-191281f669e1_1024x850.png 848w, https://substackcdn.com/image/fetch/$s_!v4M1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fe2a74-84b5-4fc6-af34-191281f669e1_1024x850.png 1272w, https://substackcdn.com/image/fetch/$s_!v4M1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19fe2a74-84b5-4fc6-af34-191281f669e1_1024x850.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">Image Source: https://en.wikipedia.org/wiki/Integer_programming#/media/File:IP_polytope_with_LP_relaxation.svg </figcaption></figure></div><p>After generating the objective function and constraints, you solve the problem by first relaxing the integer requirement and solving it as a normal linear programming problem (where variables can be fractional) and using certain techniques like <strong>branch and bound </strong>which involve<strong> </strong>splitting the problem into smaller parts (branches) by adding new conditions (like forcing a variable to be at least 3) and solving these smaller parts and eliminating the parts that we know won&#8217;t lead to an optimal solution.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IO-3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fbc846c-d1be-450a-9f6c-9d837eff060b_694x508.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IO-3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fbc846c-d1be-450a-9f6c-9d837eff060b_694x508.png 424w, https://substackcdn.com/image/fetch/$s_!IO-3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fbc846c-d1be-450a-9f6c-9d837eff060b_694x508.png 848w, https://substackcdn.com/image/fetch/$s_!IO-3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fbc846c-d1be-450a-9f6c-9d837eff060b_694x508.png 1272w, https://substackcdn.com/image/fetch/$s_!IO-3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fbc846c-d1be-450a-9f6c-9d837eff060b_694x508.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IO-3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fbc846c-d1be-450a-9f6c-9d837eff060b_694x508.png" width="470" height="344.0345821325648" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4fbc846c-d1be-450a-9f6c-9d837eff060b_694x508.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:508,&quot;width&quot;:694,&quot;resizeWidth&quot;:470,&quot;bytes&quot;:74350,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!IO-3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fbc846c-d1be-450a-9f6c-9d837eff060b_694x508.png 424w, https://substackcdn.com/image/fetch/$s_!IO-3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fbc846c-d1be-450a-9f6c-9d837eff060b_694x508.png 848w, https://substackcdn.com/image/fetch/$s_!IO-3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fbc846c-d1be-450a-9f6c-9d837eff060b_694x508.png 1272w, https://substackcdn.com/image/fetch/$s_!IO-3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fbc846c-d1be-450a-9f6c-9d837eff060b_694x508.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></figure></div><div><hr></div><h4>Newton's Method</h4><p>Newton's method is an optimization algorithm used to find the local minimum or maximum of a function. It uses the first and second derivatives (gradient and Hessian) to iteratively update the current guess for the minimum.</p><p>Here&#8217;s the process in a nutshell:</p><ul><li><p><strong>Start with a guess</strong> for the solution.</p></li><li><p><strong>Find the slope</strong> (gradient) and <strong>curvature</strong> (second derivative) of the function at that point.</p></li><li><p><strong>Update your guess</strong> using the slope and curvature to get closer to the minimum.</p></li><li><p><strong>Repeat</strong> until the guess doesn&#8217;t change much anymore.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1V9a!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0eb25194-2598-4473-a330-e3adee88e38b_586x503.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1V9a!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0eb25194-2598-4473-a330-e3adee88e38b_586x503.png 424w, https://substackcdn.com/image/fetch/$s_!1V9a!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0eb25194-2598-4473-a330-e3adee88e38b_586x503.png 848w, https://substackcdn.com/image/fetch/$s_!1V9a!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0eb25194-2598-4473-a330-e3adee88e38b_586x503.png 1272w, https://substackcdn.com/image/fetch/$s_!1V9a!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0eb25194-2598-4473-a330-e3adee88e38b_586x503.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1V9a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0eb25194-2598-4473-a330-e3adee88e38b_586x503.png" width="422" height="362.22866894197955" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0eb25194-2598-4473-a330-e3adee88e38b_586x503.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:503,&quot;width&quot;:586,&quot;resizeWidth&quot;:422,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Newton Raphson Method Calculation&quot;,&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="Newton Raphson Method Calculation" title="Newton Raphson Method Calculation" srcset="https://substackcdn.com/image/fetch/$s_!1V9a!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0eb25194-2598-4473-a330-e3adee88e38b_586x503.png 424w, https://substackcdn.com/image/fetch/$s_!1V9a!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0eb25194-2598-4473-a330-e3adee88e38b_586x503.png 848w, https://substackcdn.com/image/fetch/$s_!1V9a!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0eb25194-2598-4473-a330-e3adee88e38b_586x503.png 1272w, https://substackcdn.com/image/fetch/$s_!1V9a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0eb25194-2598-4473-a330-e3adee88e38b_586x503.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">Image Source: https://www.geeksforgeeks.org/newton-raphson-method/</figcaption></figure></div><p>I won&#8217;t go into the full details here, but you can find a more thorough explanation on Newton&#8217;s method here: <a href="https://photonlines.substack.com/p/understanding-optimization-algorithms">Understanding Optimization Algorithms: Newton's Method</a>.</p><div><hr></div><h4>Simulated Annealing</h4><p>Simulated Annealing is a probabilistic optimization algorithm inspired by the process of annealing in metallurgy. In annealing, metals are heated and then slowly cooled to remove defects in their structure:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Lb20!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a6ae6da-8a6f-4770-84bf-784123e372c3_1146x267.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Lb20!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a6ae6da-8a6f-4770-84bf-784123e372c3_1146x267.png 424w, https://substackcdn.com/image/fetch/$s_!Lb20!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a6ae6da-8a6f-4770-84bf-784123e372c3_1146x267.png 848w, https://substackcdn.com/image/fetch/$s_!Lb20!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a6ae6da-8a6f-4770-84bf-784123e372c3_1146x267.png 1272w, https://substackcdn.com/image/fetch/$s_!Lb20!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a6ae6da-8a6f-4770-84bf-784123e372c3_1146x267.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Lb20!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a6ae6da-8a6f-4770-84bf-784123e372c3_1146x267.png" width="1146" height="267" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3a6ae6da-8a6f-4770-84bf-784123e372c3_1146x267.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:267,&quot;width&quot;:1146,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:79385,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Lb20!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a6ae6da-8a6f-4770-84bf-784123e372c3_1146x267.png 424w, https://substackcdn.com/image/fetch/$s_!Lb20!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a6ae6da-8a6f-4770-84bf-784123e372c3_1146x267.png 848w, https://substackcdn.com/image/fetch/$s_!Lb20!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a6ae6da-8a6f-4770-84bf-784123e372c3_1146x267.png 1272w, https://substackcdn.com/image/fetch/$s_!Lb20!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a6ae6da-8a6f-4770-84bf-784123e372c3_1146x267.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption">Image Source: https://matthewstrom.com/writing/how-to-pick-the-least-wrong-colors/ </figcaption></figure></div><p>Similarly, the algorithm starts with a "high-energy" solution (a random guess) and iteratively improves it by exploring neighboring solutions. The key idea is to avoid getting stuck in local minima by allowing the possibility of accepting worse solutions at the beginning, then gradually reducing this acceptance as the algorithm progresses (like cooling the metal).</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GooT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca2a398-19cc-476d-97ab-ca7acb6cf648_1516x371.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GooT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca2a398-19cc-476d-97ab-ca7acb6cf648_1516x371.png 424w, https://substackcdn.com/image/fetch/$s_!GooT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca2a398-19cc-476d-97ab-ca7acb6cf648_1516x371.png 848w, https://substackcdn.com/image/fetch/$s_!GooT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca2a398-19cc-476d-97ab-ca7acb6cf648_1516x371.png 1272w, https://substackcdn.com/image/fetch/$s_!GooT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca2a398-19cc-476d-97ab-ca7acb6cf648_1516x371.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GooT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca2a398-19cc-476d-97ab-ca7acb6cf648_1516x371.png" width="1456" height="356" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4ca2a398-19cc-476d-97ab-ca7acb6cf648_1516x371.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:356,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:34008,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GooT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca2a398-19cc-476d-97ab-ca7acb6cf648_1516x371.png 424w, https://substackcdn.com/image/fetch/$s_!GooT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca2a398-19cc-476d-97ab-ca7acb6cf648_1516x371.png 848w, https://substackcdn.com/image/fetch/$s_!GooT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca2a398-19cc-476d-97ab-ca7acb6cf648_1516x371.png 1272w, https://substackcdn.com/image/fetch/$s_!GooT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca2a398-19cc-476d-97ab-ca7acb6cf648_1516x371.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption">Image Source: https://matthewstrom.com/writing/how-to-pick-the-least-wrong-colors/ </figcaption></figure></div><p>The key steps in the algorithm are provided below:</p><ul><li><p><strong>Start with a random solution</strong>: The algorithm begins with a random solution to the problem you're trying to solve.</p></li><li><p><strong>Explore neighboring solutions</strong>: At each step, it picks a neighboring solution (a small variation of the current solution). This could be done, for example, by slightly tweaking the current values.</p></li><li><p><strong>Accept the new solution</strong>: If the new solution is better (i.e., has a lower cost or higher score), it is accepted. However, if the new solution is worse, it may still be accepted with some probability. This probability decreases over time.</p></li><li><p><strong>Temperature schedule</strong>: The "temperature" in the algorithm controls how likely the algorithm is to accept worse solutions. Initially, the temperature is high, meaning worse solutions are more likely to be accepted. As the algorithm progresses, the temperature gradually decreases, and the system "settles" into a solution.</p></li><li><p><strong>Repeat</strong>: This process repeats until a stopping condition is met, such as reaching a predefined number of iterations or when the temperature is sufficiently low.</p></li></ul><div><hr></div><h3>Machine Learning &amp; Data Science Algorithms</h3><div><hr></div><h4>Regression (Linear, Logistic, and Polynomial)</h4><p>Regression is an algorithm that models the relationship between a dependent variable (target) and one or more independent variables (features). Regression is important in the real world because <strong>it helps us understand and predict relationships between variables</strong>, enabling informed decision-making in various fields by identifying trends, forecasting outcomes, and assessing the impact of different factors.</p><p><strong>Linear regression</strong> is a simple algorithm that models these relationship by fitting a linear equation. The goal is to minimize the error between the predicted and actual values.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JN5f!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd137851-7b9e-4d99-9ffa-438752f5d26b_2083x902.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JN5f!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd137851-7b9e-4d99-9ffa-438752f5d26b_2083x902.png 424w, https://substackcdn.com/image/fetch/$s_!JN5f!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd137851-7b9e-4d99-9ffa-438752f5d26b_2083x902.png 848w, https://substackcdn.com/image/fetch/$s_!JN5f!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd137851-7b9e-4d99-9ffa-438752f5d26b_2083x902.png 1272w, https://substackcdn.com/image/fetch/$s_!JN5f!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd137851-7b9e-4d99-9ffa-438752f5d26b_2083x902.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JN5f!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd137851-7b9e-4d99-9ffa-438752f5d26b_2083x902.png" width="613" height="265.24038461538464" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bd137851-7b9e-4d99-9ffa-438752f5d26b_2083x902.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:630,&quot;width&quot;:1456,&quot;resizeWidth&quot;:613,&quot;bytes&quot;:118187,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd137851-7b9e-4d99-9ffa-438752f5d26b_2083x902.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_!JN5f!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd137851-7b9e-4d99-9ffa-438752f5d26b_2083x902.png 424w, https://substackcdn.com/image/fetch/$s_!JN5f!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd137851-7b9e-4d99-9ffa-438752f5d26b_2083x902.png 848w, https://substackcdn.com/image/fetch/$s_!JN5f!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd137851-7b9e-4d99-9ffa-438752f5d26b_2083x902.png 1272w, https://substackcdn.com/image/fetch/$s_!JN5f!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd137851-7b9e-4d99-9ffa-438752f5d26b_2083x902.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></figure></div><p>It's widely used for predicting continuous outcomes, such as housing prices, stock market trends, and sales forecasting. Its simplicity makes it easy to understand and apply in many contexts.</p><p><strong>Logistic Regression </strong>is similar to linear regression, but it&#8217;s used to model the probability of a binary outcome instead of a linear function. This makes it great for tasks like fraud detection and medical diagnosis because it&#8217;s simple, fast, and easy to understand.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5CjH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F744924d7-e38e-48f5-bcc4-42b6ff39f3f6_2234x922.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5CjH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F744924d7-e38e-48f5-bcc4-42b6ff39f3f6_2234x922.png 424w, https://substackcdn.com/image/fetch/$s_!5CjH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F744924d7-e38e-48f5-bcc4-42b6ff39f3f6_2234x922.png 848w, https://substackcdn.com/image/fetch/$s_!5CjH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F744924d7-e38e-48f5-bcc4-42b6ff39f3f6_2234x922.png 1272w, https://substackcdn.com/image/fetch/$s_!5CjH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F744924d7-e38e-48f5-bcc4-42b6ff39f3f6_2234x922.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5CjH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F744924d7-e38e-48f5-bcc4-42b6ff39f3f6_2234x922.png" width="719" height="296.7850274725275" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/744924d7-e38e-48f5-bcc4-42b6ff39f3f6_2234x922.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:601,&quot;width&quot;:1456,&quot;resizeWidth&quot;:719,&quot;bytes&quot;:70230,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F744924d7-e38e-48f5-bcc4-42b6ff39f3f6_2234x922.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_!5CjH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F744924d7-e38e-48f5-bcc4-42b6ff39f3f6_2234x922.png 424w, https://substackcdn.com/image/fetch/$s_!5CjH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F744924d7-e38e-48f5-bcc4-42b6ff39f3f6_2234x922.png 848w, https://substackcdn.com/image/fetch/$s_!5CjH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F744924d7-e38e-48f5-bcc4-42b6ff39f3f6_2234x922.png 1272w, https://substackcdn.com/image/fetch/$s_!5CjH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F744924d7-e38e-48f5-bcc4-42b6ff39f3f6_2234x922.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></figure></div><p><strong>Polynomial Regression </strong>models relationship(s) between variables using a polynomial function (i.e. curved line<strong>)</strong> instead of a straight one and can thus do a better job of modelling more complex data-sets:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wES3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96a9ccde-2eed-4112-8438-d3d84dd064e3_2452x909.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wES3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96a9ccde-2eed-4112-8438-d3d84dd064e3_2452x909.png 424w, https://substackcdn.com/image/fetch/$s_!wES3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96a9ccde-2eed-4112-8438-d3d84dd064e3_2452x909.png 848w, https://substackcdn.com/image/fetch/$s_!wES3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96a9ccde-2eed-4112-8438-d3d84dd064e3_2452x909.png 1272w, https://substackcdn.com/image/fetch/$s_!wES3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96a9ccde-2eed-4112-8438-d3d84dd064e3_2452x909.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wES3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96a9ccde-2eed-4112-8438-d3d84dd064e3_2452x909.png" width="724" height="268.5164835164835" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/96a9ccde-2eed-4112-8438-d3d84dd064e3_2452x909.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:540,&quot;width&quot;:1456,&quot;resizeWidth&quot;:724,&quot;bytes&quot;:118369,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96a9ccde-2eed-4112-8438-d3d84dd064e3_2452x909.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_!wES3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96a9ccde-2eed-4112-8438-d3d84dd064e3_2452x909.png 424w, https://substackcdn.com/image/fetch/$s_!wES3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96a9ccde-2eed-4112-8438-d3d84dd064e3_2452x909.png 848w, https://substackcdn.com/image/fetch/$s_!wES3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96a9ccde-2eed-4112-8438-d3d84dd064e3_2452x909.png 1272w, https://substackcdn.com/image/fetch/$s_!wES3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96a9ccde-2eed-4112-8438-d3d84dd064e3_2452x909.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></figure></div><p>Polynomial regression is important because it helps model more complex relationships that linear regression cannot capture, making it useful in fields like finance, physics, and medicine.</p><div><hr></div><h4>Support Vector Machines (SVMs)</h4><p>Support Vector Machines (SVMs) are a machine learning algorithm used for classification and regression. They work by finding a hyperplane that best separates data into different classes. The goal is to maximize the margin between the classes, with the closest data points (called support vectors) helping to define this boundary.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1Vl7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2937ff9-560e-42e3-bd0d-261e39013f82_695x627.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1Vl7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2937ff9-560e-42e3-bd0d-261e39013f82_695x627.png 424w, https://substackcdn.com/image/fetch/$s_!1Vl7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2937ff9-560e-42e3-bd0d-261e39013f82_695x627.png 848w, https://substackcdn.com/image/fetch/$s_!1Vl7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2937ff9-560e-42e3-bd0d-261e39013f82_695x627.png 1272w, https://substackcdn.com/image/fetch/$s_!1Vl7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2937ff9-560e-42e3-bd0d-261e39013f82_695x627.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1Vl7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2937ff9-560e-42e3-bd0d-261e39013f82_695x627.png" width="325" height="293.2014388489209" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b2937ff9-560e-42e3-bd0d-261e39013f82_695x627.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:627,&quot;width&quot;:695,&quot;resizeWidth&quot;:325,&quot;bytes&quot;:180082,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2937ff9-560e-42e3-bd0d-261e39013f82_695x627.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_!1Vl7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2937ff9-560e-42e3-bd0d-261e39013f82_695x627.png 424w, https://substackcdn.com/image/fetch/$s_!1Vl7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2937ff9-560e-42e3-bd0d-261e39013f82_695x627.png 848w, https://substackcdn.com/image/fetch/$s_!1Vl7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2937ff9-560e-42e3-bd0d-261e39013f82_695x627.png 1272w, https://substackcdn.com/image/fetch/$s_!1Vl7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2937ff9-560e-42e3-bd0d-261e39013f82_695x627.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">Image Source: https://umeshchandra.in/2024/04/19/understanding-support-vector-machines-svm/ </figcaption></figure></div><p>SVMs are powerful because they perform well in both linear and non-linear data (using a technique called the kernel trick). They are good at generalizing and avoiding overfitting, and they work well in high-dimensional spaces.</p><div><hr></div><h4>Decision Trees (<strong>Random Forest &amp; Boosted Trees)</strong></h4><p>Decision Trees are classification algorithms that define a sequence of branches. At each branch intersection, the feature value is compared to a specific function, and the result determines which branch the algorithm follows. The way that decisions are made in regards to decision tree varies depending on the type of tree. </p><p>When the depth of a decision tree grows the error on validation data tends to increase a lot. One way to exploit a lot of data is to train multiple decision trees and average them. <strong>Random forests</strong> are an ensemble method that builds multiple decision trees using random subsets of the data and combines their predictions (through voting for classification or averaging for regression). The reason for the &#8220;forest&#8221; in the name is due to the fact that this algorithm doesn&#8217;t just depend on one decision tree - but many. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!USvI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe03380fc-c572-4a8e-a2ee-e9529c2d3faa_659x657.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!USvI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe03380fc-c572-4a8e-a2ee-e9529c2d3faa_659x657.png 424w, https://substackcdn.com/image/fetch/$s_!USvI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe03380fc-c572-4a8e-a2ee-e9529c2d3faa_659x657.png 848w, https://substackcdn.com/image/fetch/$s_!USvI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe03380fc-c572-4a8e-a2ee-e9529c2d3faa_659x657.png 1272w, https://substackcdn.com/image/fetch/$s_!USvI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe03380fc-c572-4a8e-a2ee-e9529c2d3faa_659x657.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!USvI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe03380fc-c572-4a8e-a2ee-e9529c2d3faa_659x657.png" width="587" height="585.2185128983308" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e03380fc-c572-4a8e-a2ee-e9529c2d3faa_659x657.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:657,&quot;width&quot;:659,&quot;resizeWidth&quot;:587,&quot;bytes&quot;:155551,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe03380fc-c572-4a8e-a2ee-e9529c2d3faa_659x657.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_!USvI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe03380fc-c572-4a8e-a2ee-e9529c2d3faa_659x657.png 424w, https://substackcdn.com/image/fetch/$s_!USvI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe03380fc-c572-4a8e-a2ee-e9529c2d3faa_659x657.png 848w, https://substackcdn.com/image/fetch/$s_!USvI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe03380fc-c572-4a8e-a2ee-e9529c2d3faa_659x657.png 1272w, https://substackcdn.com/image/fetch/$s_!USvI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe03380fc-c572-4a8e-a2ee-e9529c2d3faa_659x657.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">Image Source: https://pages.cms.hu-berlin.de/EOL/geo_rs/S08_Image_classification2.html</figcaption></figure></div><p><strong>Boosted Trees: </strong>Rather than randomly sampling from our data set and constructing trees based on this data (normally called <strong>bagging</strong>), we can also use a methodology called <strong>boosting</strong> which builds decision trees sequentially, where each new tree focuses on correcting the mistakes of the previous ones. Unlike bagging, which trains trees independently, boosting adjusts the weights of misclassified samples, so future trees give more attention to hard-to-predict cases. This step-by-step refinement process leads to a stronger predictive model, often outperforming bagging methods like random forests in tasks requiring fine-tuned accuracy. However, boosting is also more sensitive to noise and overfitting, requiring careful tuning of parameters like learning rate and tree depth.</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jV9z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe719301b-4cb1-44be-b511-b23d2d6d3181_884x544.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jV9z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe719301b-4cb1-44be-b511-b23d2d6d3181_884x544.png 424w, https://substackcdn.com/image/fetch/$s_!jV9z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe719301b-4cb1-44be-b511-b23d2d6d3181_884x544.png 848w, https://substackcdn.com/image/fetch/$s_!jV9z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe719301b-4cb1-44be-b511-b23d2d6d3181_884x544.png 1272w, https://substackcdn.com/image/fetch/$s_!jV9z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe719301b-4cb1-44be-b511-b23d2d6d3181_884x544.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jV9z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe719301b-4cb1-44be-b511-b23d2d6d3181_884x544.png" width="884" height="544" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e719301b-4cb1-44be-b511-b23d2d6d3181_884x544.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:544,&quot;width&quot;:884,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:199173,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe719301b-4cb1-44be-b511-b23d2d6d3181_884x544.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_!jV9z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe719301b-4cb1-44be-b511-b23d2d6d3181_884x544.png 424w, https://substackcdn.com/image/fetch/$s_!jV9z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe719301b-4cb1-44be-b511-b23d2d6d3181_884x544.png 848w, https://substackcdn.com/image/fetch/$s_!jV9z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe719301b-4cb1-44be-b511-b23d2d6d3181_884x544.png 1272w, https://substackcdn.com/image/fetch/$s_!jV9z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe719301b-4cb1-44be-b511-b23d2d6d3181_884x544.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">Image Source: https://www.researchgate.net/figure/The-architecture-of-Gradient-Boosting-Decision-Tree_fig2_356698772</figcaption></figure></div><p>Decision trees are important because they provide a simple yet powerful way to make decisions based on data, making them widely used in fields like finance, healthcare, marketing, and fraud detection. Their if-then structure is easy to interpret so they&#8217;re important in applications where understanding the reasoning behind predictions matters. They also handle both numerical and categorical data, work well with missing values, and can capture nonlinear relationships in data.</p><div><hr></div><h4>Gradient Descent &amp; Backpropagation</h4><p><strong>Gradient Descent</strong> is an optimization algorithm used to minimize a function by iteratively moving in the direction of its steepest descent, as defined by the negative of the gradient. In simpler terms, it helps find the lowest point of a function, which corresponds to the best solution in many optimization problems.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!AM9A!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca98897-7f1e-4be5-9140-184a45c818b3_795x385.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!AM9A!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca98897-7f1e-4be5-9140-184a45c818b3_795x385.png 424w, https://substackcdn.com/image/fetch/$s_!AM9A!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca98897-7f1e-4be5-9140-184a45c818b3_795x385.png 848w, https://substackcdn.com/image/fetch/$s_!AM9A!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca98897-7f1e-4be5-9140-184a45c818b3_795x385.png 1272w, https://substackcdn.com/image/fetch/$s_!AM9A!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca98897-7f1e-4be5-9140-184a45c818b3_795x385.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!AM9A!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca98897-7f1e-4be5-9140-184a45c818b3_795x385.png" width="628" height="304.12578616352204" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dca98897-7f1e-4be5-9140-184a45c818b3_795x385.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:385,&quot;width&quot;:795,&quot;resizeWidth&quot;:628,&quot;bytes&quot;:130424,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca98897-7f1e-4be5-9140-184a45c818b3_795x385.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_!AM9A!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca98897-7f1e-4be5-9140-184a45c818b3_795x385.png 424w, https://substackcdn.com/image/fetch/$s_!AM9A!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca98897-7f1e-4be5-9140-184a45c818b3_795x385.png 848w, https://substackcdn.com/image/fetch/$s_!AM9A!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca98897-7f1e-4be5-9140-184a45c818b3_795x385.png 1272w, https://substackcdn.com/image/fetch/$s_!AM9A!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca98897-7f1e-4be5-9140-184a45c818b3_795x385.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></figure></div><p>Gradient descent uses the gradient information (direction of steepest descent) to find the local minimum:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vfyf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf537c38-678b-4f00-bbe3-4fce814a7552_630x405.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vfyf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf537c38-678b-4f00-bbe3-4fce814a7552_630x405.png 424w, https://substackcdn.com/image/fetch/$s_!vfyf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf537c38-678b-4f00-bbe3-4fce814a7552_630x405.png 848w, https://substackcdn.com/image/fetch/$s_!vfyf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf537c38-678b-4f00-bbe3-4fce814a7552_630x405.png 1272w, https://substackcdn.com/image/fetch/$s_!vfyf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf537c38-678b-4f00-bbe3-4fce814a7552_630x405.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vfyf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf537c38-678b-4f00-bbe3-4fce814a7552_630x405.png" width="490" height="315" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/af537c38-678b-4f00-bbe3-4fce814a7552_630x405.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:405,&quot;width&quot;:630,&quot;resizeWidth&quot;:490,&quot;bytes&quot;:62058,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf537c38-678b-4f00-bbe3-4fce814a7552_630x405.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_!vfyf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf537c38-678b-4f00-bbe3-4fce814a7552_630x405.png 424w, https://substackcdn.com/image/fetch/$s_!vfyf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf537c38-678b-4f00-bbe3-4fce814a7552_630x405.png 848w, https://substackcdn.com/image/fetch/$s_!vfyf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf537c38-678b-4f00-bbe3-4fce814a7552_630x405.png 1272w, https://substackcdn.com/image/fetch/$s_!vfyf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf537c38-678b-4f00-bbe3-4fce814a7552_630x405.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">Image Source: https://blog.gopenai.com/understanding-of-gradient-descent-intuition-and-implementation-b1f98b3645ea</figcaption></figure></div><p>The choice for descent direction d is the direction of steepest descent. Following the direction of steepest descent is guaranteed to lead to improvement, provided that the objective function is smooth and the step size is sufficiently small. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jAAr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e68ff0-21e5-4336-a40d-1ac6aeb5d524_692x387.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jAAr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e68ff0-21e5-4336-a40d-1ac6aeb5d524_692x387.png 424w, https://substackcdn.com/image/fetch/$s_!jAAr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e68ff0-21e5-4336-a40d-1ac6aeb5d524_692x387.png 848w, https://substackcdn.com/image/fetch/$s_!jAAr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e68ff0-21e5-4336-a40d-1ac6aeb5d524_692x387.png 1272w, https://substackcdn.com/image/fetch/$s_!jAAr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e68ff0-21e5-4336-a40d-1ac6aeb5d524_692x387.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jAAr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e68ff0-21e5-4336-a40d-1ac6aeb5d524_692x387.png" width="466" height="260.6098265895954" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/52e68ff0-21e5-4336-a40d-1ac6aeb5d524_692x387.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:387,&quot;width&quot;:692,&quot;resizeWidth&quot;:466,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Gradient descent&quot;,&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="Gradient descent" title="Gradient descent" srcset="https://substackcdn.com/image/fetch/$s_!jAAr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e68ff0-21e5-4336-a40d-1ac6aeb5d524_692x387.png 424w, https://substackcdn.com/image/fetch/$s_!jAAr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e68ff0-21e5-4336-a40d-1ac6aeb5d524_692x387.png 848w, https://substackcdn.com/image/fetch/$s_!jAAr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e68ff0-21e5-4336-a40d-1ac6aeb5d524_692x387.png 1272w, https://substackcdn.com/image/fetch/$s_!jAAr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52e68ff0-21e5-4336-a40d-1ac6aeb5d524_692x387.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">Image Source: https://easyai.tech/en/ai-definition/gradient-descent/#google_vignette </figcaption></figure></div><p>Unlike brute-force methods, gradient descent scales well, making it practical for complex problems in AI, physics, finance, and engineering.</p><p><strong>Backpropagation</strong> is the foundation of training artificial neural networks. It is an algorithm that updates the weights of a neural network by minimizing the error (or loss) using gradient descent.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MPA6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0d793d-785d-42a9-ad35-f80b13bf1974_1617x1350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MPA6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0d793d-785d-42a9-ad35-f80b13bf1974_1617x1350.png 424w, https://substackcdn.com/image/fetch/$s_!MPA6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0d793d-785d-42a9-ad35-f80b13bf1974_1617x1350.png 848w, https://substackcdn.com/image/fetch/$s_!MPA6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0d793d-785d-42a9-ad35-f80b13bf1974_1617x1350.png 1272w, https://substackcdn.com/image/fetch/$s_!MPA6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0d793d-785d-42a9-ad35-f80b13bf1974_1617x1350.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MPA6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0d793d-785d-42a9-ad35-f80b13bf1974_1617x1350.png" width="593" height="495.25274725274727" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9b0d793d-785d-42a9-ad35-f80b13bf1974_1617x1350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1216,&quot;width&quot;:1456,&quot;resizeWidth&quot;:593,&quot;bytes&quot;:167683,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0d793d-785d-42a9-ad35-f80b13bf1974_1617x1350.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_!MPA6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0d793d-785d-42a9-ad35-f80b13bf1974_1617x1350.png 424w, https://substackcdn.com/image/fetch/$s_!MPA6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0d793d-785d-42a9-ad35-f80b13bf1974_1617x1350.png 848w, https://substackcdn.com/image/fetch/$s_!MPA6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0d793d-785d-42a9-ad35-f80b13bf1974_1617x1350.png 1272w, https://substackcdn.com/image/fetch/$s_!MPA6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0d793d-785d-42a9-ad35-f80b13bf1974_1617x1350.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></figure></div><p>The backpropagation algorithm was a major milestone in machine learning. Prior to it being discovered, tuning neural network weights was extremely inefficient and unsatisfactory. One popular method was to adjust the weights in a random, uninformed direction and see if the performance of the neural network increased, which obviously hindered the effectiveness of neural networks. Backpropagation revolutionized this by providing a systematic, efficient way to compute the gradients of the loss function with respect to each weight, enabling the network to learn from its mistakes and improve progressively through gradient descent. This allowed deep learning models to train on large datasets and achieve breakthroughs in fields like computer vision, natural language processing, and speech recognition, ultimately driving the current AI revolution.</p><div><hr></div><h4>Neural Networks</h4><p>Neural networks are a class of algorithms designed to mimic the human brain. They consist of layers of interconnected nodes, or "neurons," that process data by learning patterns and relationships. Each neuron receives inputs, applies weights, and passes the result through an activation function to determine its output. By adjusting these weights through training, neural networks improve their ability to recognize patterns, make predictions, and solve complex problems, such as image recognition, language processing, and game playing.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7MbE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76517370-06b0-4b97-bbda-ec5e74392543_709x359.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7MbE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76517370-06b0-4b97-bbda-ec5e74392543_709x359.png 424w, https://substackcdn.com/image/fetch/$s_!7MbE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76517370-06b0-4b97-bbda-ec5e74392543_709x359.png 848w, https://substackcdn.com/image/fetch/$s_!7MbE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76517370-06b0-4b97-bbda-ec5e74392543_709x359.png 1272w, https://substackcdn.com/image/fetch/$s_!7MbE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76517370-06b0-4b97-bbda-ec5e74392543_709x359.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7MbE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76517370-06b0-4b97-bbda-ec5e74392543_709x359.png" width="709" height="359" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/76517370-06b0-4b97-bbda-ec5e74392543_709x359.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:359,&quot;width&quot;:709,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:74486,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76517370-06b0-4b97-bbda-ec5e74392543_709x359.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_!7MbE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76517370-06b0-4b97-bbda-ec5e74392543_709x359.png 424w, https://substackcdn.com/image/fetch/$s_!7MbE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76517370-06b0-4b97-bbda-ec5e74392543_709x359.png 848w, https://substackcdn.com/image/fetch/$s_!7MbE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76517370-06b0-4b97-bbda-ec5e74392543_709x359.png 1272w, https://substackcdn.com/image/fetch/$s_!7MbE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76517370-06b0-4b97-bbda-ec5e74392543_709x359.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></figure></div><p>There are many different types of neural networks:</p><p><strong>Feedforward Neural Networks (FNNs)</strong>: These are the simplest type of neural networks, where data moves in one direction&#8212;from input to output&#8212;through layers of neurons. They&#8217;re commonly used for classification tasks and function approximation.</p><p><strong>Convolutional Neural Networks (CNNs)</strong>: Excellent for tasks like image classification and object recognition. They work by processing data through layers that automatically learn important features from the input, such as edges or shapes in images. The key layers in a CNN are the <strong>convolution layers</strong> and the <strong>pooling layers</strong>. The convolution layer uses small filters (or kernels) that slide over the input data (like a window), applying mathematical operations to detect features such as edges or textures. These filters help the network focus on important patterns, rather than on individual pixels. The pooling layer reduces the size of the data by taking the most important information from a region of the input (such as the maximum value or average value) to make the model more efficient and less prone to overfitting. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YNkq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8aafd1-3791-40fd-9ce8-913535257bb0_739x415.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YNkq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8aafd1-3791-40fd-9ce8-913535257bb0_739x415.png 424w, https://substackcdn.com/image/fetch/$s_!YNkq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8aafd1-3791-40fd-9ce8-913535257bb0_739x415.png 848w, https://substackcdn.com/image/fetch/$s_!YNkq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8aafd1-3791-40fd-9ce8-913535257bb0_739x415.png 1272w, https://substackcdn.com/image/fetch/$s_!YNkq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8aafd1-3791-40fd-9ce8-913535257bb0_739x415.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YNkq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8aafd1-3791-40fd-9ce8-913535257bb0_739x415.png" width="739" height="415" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4d8aafd1-3791-40fd-9ce8-913535257bb0_739x415.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:415,&quot;width&quot;:739,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:28004,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8aafd1-3791-40fd-9ce8-913535257bb0_739x415.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_!YNkq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8aafd1-3791-40fd-9ce8-913535257bb0_739x415.png 424w, https://substackcdn.com/image/fetch/$s_!YNkq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8aafd1-3791-40fd-9ce8-913535257bb0_739x415.png 848w, https://substackcdn.com/image/fetch/$s_!YNkq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8aafd1-3791-40fd-9ce8-913535257bb0_739x415.png 1272w, https://substackcdn.com/image/fetch/$s_!YNkq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8aafd1-3791-40fd-9ce8-913535257bb0_739x415.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">Original Image Source: https://talent500.com/blog/image-classification-using-convolutional-neural-networks-cnns-in-pytorch/</figcaption></figure></div><p><strong>Recurrent Neural Networks (RNNs)</strong>: RNNs are designed for sequential data, such as time-series analysis, natural language processing, and speech recognition. Unlike FNNs, RNNs have loops in their architecture, enabling them to retain information from previous inputs (memory), making them well-suited for tasks where context matters.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6aYh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe94953a-8fac-4164-bfb4-d604396e0280_1093x951.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6aYh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe94953a-8fac-4164-bfb4-d604396e0280_1093x951.png 424w, https://substackcdn.com/image/fetch/$s_!6aYh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe94953a-8fac-4164-bfb4-d604396e0280_1093x951.png 848w, https://substackcdn.com/image/fetch/$s_!6aYh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe94953a-8fac-4164-bfb4-d604396e0280_1093x951.png 1272w, https://substackcdn.com/image/fetch/$s_!6aYh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe94953a-8fac-4164-bfb4-d604396e0280_1093x951.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6aYh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe94953a-8fac-4164-bfb4-d604396e0280_1093x951.png" width="416" height="361.95425434583717" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/be94953a-8fac-4164-bfb4-d604396e0280_1093x951.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:951,&quot;width&quot;:1093,&quot;resizeWidth&quot;:416,&quot;bytes&quot;:313984,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe94953a-8fac-4164-bfb4-d604396e0280_1093x951.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_!6aYh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe94953a-8fac-4164-bfb4-d604396e0280_1093x951.png 424w, https://substackcdn.com/image/fetch/$s_!6aYh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe94953a-8fac-4164-bfb4-d604396e0280_1093x951.png 848w, https://substackcdn.com/image/fetch/$s_!6aYh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe94953a-8fac-4164-bfb4-d604396e0280_1093x951.png 1272w, https://substackcdn.com/image/fetch/$s_!6aYh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe94953a-8fac-4164-bfb4-d604396e0280_1093x951.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">Original Image Source: https://botpenguin.com/glossary/recurrent-neural-network</figcaption></figure></div><p><strong>Long Short-Term Memory (LSTM)</strong>: A specialized type of RNN, LSTMs are capable of remembering long-term dependencies. They are commonly used in language translation, speech recognition, and other applications that require understanding context over long sequences of data.</p><p><strong>Generative Adversarial Networks (GANs)</strong>: GANs consist of two networks&#8212;a generator and a discriminator&#8212;working in opposition. The generator creates fake data, and the discriminator tries to distinguish it from real data. This setup is popular in image generation, video creation, and even deepfake technology.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!d54N!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68b465b9-e0b8-4be0-9d42-9da110916e5e_577x189.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!d54N!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68b465b9-e0b8-4be0-9d42-9da110916e5e_577x189.png 424w, https://substackcdn.com/image/fetch/$s_!d54N!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68b465b9-e0b8-4be0-9d42-9da110916e5e_577x189.png 848w, https://substackcdn.com/image/fetch/$s_!d54N!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68b465b9-e0b8-4be0-9d42-9da110916e5e_577x189.png 1272w, https://substackcdn.com/image/fetch/$s_!d54N!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68b465b9-e0b8-4be0-9d42-9da110916e5e_577x189.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!d54N!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68b465b9-e0b8-4be0-9d42-9da110916e5e_577x189.png" width="577" height="189" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/68b465b9-e0b8-4be0-9d42-9da110916e5e_577x189.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:189,&quot;width&quot;:577,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:8865,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68b465b9-e0b8-4be0-9d42-9da110916e5e_577x189.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_!d54N!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68b465b9-e0b8-4be0-9d42-9da110916e5e_577x189.png 424w, https://substackcdn.com/image/fetch/$s_!d54N!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68b465b9-e0b8-4be0-9d42-9da110916e5e_577x189.png 848w, https://substackcdn.com/image/fetch/$s_!d54N!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68b465b9-e0b8-4be0-9d42-9da110916e5e_577x189.png 1272w, https://substackcdn.com/image/fetch/$s_!d54N!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68b465b9-e0b8-4be0-9d42-9da110916e5e_577x189.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption">Original Image Source: https://www.researchgate.net/figure/Architecture-of-the-generative-adversarial-network-GAN_fig1_373858845</figcaption></figure></div><p><strong>Autoencoders</strong>: These networks are trained to compress (encode) input data and then reconstruct it (decode) to match the original input. They&#8217;re frequently used in unsupervised learning for tasks like anomaly detection, data denoising, and dimensionality reduction.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FMG3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5b6fd94-f8ce-4752-8b66-67e28a01ec3d_786x447.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FMG3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5b6fd94-f8ce-4752-8b66-67e28a01ec3d_786x447.png 424w, https://substackcdn.com/image/fetch/$s_!FMG3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5b6fd94-f8ce-4752-8b66-67e28a01ec3d_786x447.png 848w, https://substackcdn.com/image/fetch/$s_!FMG3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5b6fd94-f8ce-4752-8b66-67e28a01ec3d_786x447.png 1272w, https://substackcdn.com/image/fetch/$s_!FMG3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5b6fd94-f8ce-4752-8b66-67e28a01ec3d_786x447.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FMG3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5b6fd94-f8ce-4752-8b66-67e28a01ec3d_786x447.png" width="512" height="291.17557251908397" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c5b6fd94-f8ce-4752-8b66-67e28a01ec3d_786x447.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:447,&quot;width&quot;:786,&quot;resizeWidth&quot;:512,&quot;bytes&quot;:32700,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5b6fd94-f8ce-4752-8b66-67e28a01ec3d_786x447.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_!FMG3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5b6fd94-f8ce-4752-8b66-67e28a01ec3d_786x447.png 424w, https://substackcdn.com/image/fetch/$s_!FMG3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5b6fd94-f8ce-4752-8b66-67e28a01ec3d_786x447.png 848w, https://substackcdn.com/image/fetch/$s_!FMG3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5b6fd94-f8ce-4752-8b66-67e28a01ec3d_786x447.png 1272w, https://substackcdn.com/image/fetch/$s_!FMG3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5b6fd94-f8ce-4752-8b66-67e28a01ec3d_786x447.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></figure></div><p><strong>Transformer Networks</strong>: If you&#8217;ve used ChatGPT or DeepSeek, you&#8217;re familiar with transformers. They&#8217;ve revolutionized natural language processing (NLP) and tasks like machine translation, text summarization, and sentiment analysis and use attention mechanisms to focus on important parts of input data, allowing them to handle long-range dependencies more effectively than RNNs.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CD6d!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe774228e-2ef0-4bf3-82e8-c0a1d531d2a9_1305x762.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CD6d!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe774228e-2ef0-4bf3-82e8-c0a1d531d2a9_1305x762.png 424w, https://substackcdn.com/image/fetch/$s_!CD6d!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe774228e-2ef0-4bf3-82e8-c0a1d531d2a9_1305x762.png 848w, https://substackcdn.com/image/fetch/$s_!CD6d!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe774228e-2ef0-4bf3-82e8-c0a1d531d2a9_1305x762.png 1272w, https://substackcdn.com/image/fetch/$s_!CD6d!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe774228e-2ef0-4bf3-82e8-c0a1d531d2a9_1305x762.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CD6d!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe774228e-2ef0-4bf3-82e8-c0a1d531d2a9_1305x762.png" width="1305" height="762" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e774228e-2ef0-4bf3-82e8-c0a1d531d2a9_1305x762.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:762,&quot;width&quot;:1305,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:154231,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe774228e-2ef0-4bf3-82e8-c0a1d531d2a9_1305x762.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_!CD6d!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe774228e-2ef0-4bf3-82e8-c0a1d531d2a9_1305x762.png 424w, https://substackcdn.com/image/fetch/$s_!CD6d!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe774228e-2ef0-4bf3-82e8-c0a1d531d2a9_1305x762.png 848w, https://substackcdn.com/image/fetch/$s_!CD6d!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe774228e-2ef0-4bf3-82e8-c0a1d531d2a9_1305x762.png 1272w, https://substackcdn.com/image/fetch/$s_!CD6d!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe774228e-2ef0-4bf3-82e8-c0a1d531d2a9_1305x762.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">Original Image Source: https://medium.com/@theaveragegal/transformer-architecture-simplified-3fb501d461c8</figcaption></figure></div><p>Of course, the above is a very, very high-level overview of the different types of neural networks. If you want more in depth details on how transformers work, I have a write up available here: <a href="https://photonlines.substack.com/p/intuitive-and-visual-guide-to-transformers">Intuitive and Visual Guide to Transformers and ChatGPT</a>. If you want a more in-depth explanations on how general feed-forward networks work, it&#8217;s available here: <a href="https://photonlines.substack.com/p/grokking-neural-networks">A Visual Introduction to Neural Networks</a>.</p><div><hr></div><h4>Reinforcement Learning (RL)</h4><p>Reinforcement learning is the backbone of autonomous systems, robotics, and recommendation systems. It powers self-learning systems like AlphaGo, video game AI, and personalized content recommendation and plays a huge role in large-language models (LLMs) like ChatGPT and DeepSeek. It involves an agent that interacts with an environment and learns through trial and error (much like how humans learn). The agent takes actions, receives feedback in the form of rewards or penalties, and adjusts its strategy over time to maximize the total reward. </p><p>At the core of RL is the <strong>reward signal</strong>, which tells the agent how good or bad an action was. The agent maintains a <strong>policy</strong>, which is its strategy for choosing actions based on its current state. The learning process involves estimating the value of states and actions, often using <strong>value functions</strong> (which predict future rewards) or <strong>policy-based methods</strong> (which directly optimize action selection).</p><p>Some key RL algorithms include:</p><p><strong>Q-Learning</strong> &#8211; A fundamental algorithm that learns an optimal action-value function, called the Q-function. The agent updates its Q-values using the <strong>Bellman equation</strong> and explores different actions through an <strong>exploration-exploitation tradeoff</strong> (e.g., using <strong>&#949;-greedy</strong> strategies). You can think of it as using a tabular approach (i.e. lookup tables) to select next actions based on discrete actions and values within its environment. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!045E!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0ea80cb-0e40-4415-8b10-97323ff3707c_2587x1662.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!045E!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0ea80cb-0e40-4415-8b10-97323ff3707c_2587x1662.png 424w, https://substackcdn.com/image/fetch/$s_!045E!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0ea80cb-0e40-4415-8b10-97323ff3707c_2587x1662.png 848w, https://substackcdn.com/image/fetch/$s_!045E!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0ea80cb-0e40-4415-8b10-97323ff3707c_2587x1662.png 1272w, https://substackcdn.com/image/fetch/$s_!045E!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0ea80cb-0e40-4415-8b10-97323ff3707c_2587x1662.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!045E!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0ea80cb-0e40-4415-8b10-97323ff3707c_2587x1662.png" width="1456" height="935" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e0ea80cb-0e40-4415-8b10-97323ff3707c_2587x1662.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:935,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:215539,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0ea80cb-0e40-4415-8b10-97323ff3707c_2587x1662.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_!045E!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0ea80cb-0e40-4415-8b10-97323ff3707c_2587x1662.png 424w, https://substackcdn.com/image/fetch/$s_!045E!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0ea80cb-0e40-4415-8b10-97323ff3707c_2587x1662.png 848w, https://substackcdn.com/image/fetch/$s_!045E!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0ea80cb-0e40-4415-8b10-97323ff3707c_2587x1662.png 1272w, https://substackcdn.com/image/fetch/$s_!045E!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0ea80cb-0e40-4415-8b10-97323ff3707c_2587x1662.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">Original Image Source: https://neptune.ai/blog/markov-decision-process-in-reinforcement-learning</figcaption></figure></div><p><strong>Deep Q-Networks (DQN)</strong> &#8211; An extension of Q-learning that uses deep neural networks to approximate Q-values, allowing RL to handle complex, high-dimensional environments like video games. </p><p>The main issue with regular Q-Learning is that it deals with training agents in environments with finite numbers of discrete states and actions. Most real world environments are not like this though, and DQN solves it by using neural networks as function approximators. Instead of a value table, we now apply a neural network that accepts state and outputs an estimated value function for each possible action. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-M_t!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d06685d-4c26-40d9-838b-61be9f008f1f_873x459.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-M_t!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d06685d-4c26-40d9-838b-61be9f008f1f_873x459.png 424w, https://substackcdn.com/image/fetch/$s_!-M_t!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d06685d-4c26-40d9-838b-61be9f008f1f_873x459.png 848w, https://substackcdn.com/image/fetch/$s_!-M_t!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d06685d-4c26-40d9-838b-61be9f008f1f_873x459.png 1272w, https://substackcdn.com/image/fetch/$s_!-M_t!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d06685d-4c26-40d9-838b-61be9f008f1f_873x459.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-M_t!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d06685d-4c26-40d9-838b-61be9f008f1f_873x459.png" width="561" height="294.9587628865979" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0d06685d-4c26-40d9-838b-61be9f008f1f_873x459.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:459,&quot;width&quot;:873,&quot;resizeWidth&quot;:561,&quot;bytes&quot;:229308,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d06685d-4c26-40d9-838b-61be9f008f1f_873x459.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_!-M_t!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d06685d-4c26-40d9-838b-61be9f008f1f_873x459.png 424w, https://substackcdn.com/image/fetch/$s_!-M_t!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d06685d-4c26-40d9-838b-61be9f008f1f_873x459.png 848w, https://substackcdn.com/image/fetch/$s_!-M_t!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d06685d-4c26-40d9-838b-61be9f008f1f_873x459.png 1272w, https://substackcdn.com/image/fetch/$s_!-M_t!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d06685d-4c26-40d9-838b-61be9f008f1f_873x459.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">Image Source: https://www.researchgate.net/figure/Deep-reinforcement-learning-scheme-A-deep-neural-network-learns-the-policy_fig1_360910430</figcaption></figure></div><p><strong>Policy Gradient Methods</strong> &#8211; Instead of learning a value function, these methods directly optimize the policy. A well-known algorithm in this category is <strong>REINFORCE</strong>, which updates the policy based on the rewards received.</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3ko1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca0126c2-3c29-402b-94db-962b708d5799_1050x339.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3ko1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca0126c2-3c29-402b-94db-962b708d5799_1050x339.png 424w, https://substackcdn.com/image/fetch/$s_!3ko1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca0126c2-3c29-402b-94db-962b708d5799_1050x339.png 848w, https://substackcdn.com/image/fetch/$s_!3ko1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca0126c2-3c29-402b-94db-962b708d5799_1050x339.png 1272w, https://substackcdn.com/image/fetch/$s_!3ko1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca0126c2-3c29-402b-94db-962b708d5799_1050x339.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3ko1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca0126c2-3c29-402b-94db-962b708d5799_1050x339.png" width="1050" height="339" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ca0126c2-3c29-402b-94db-962b708d5799_1050x339.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:339,&quot;width&quot;:1050,&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_!3ko1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca0126c2-3c29-402b-94db-962b708d5799_1050x339.png 424w, https://substackcdn.com/image/fetch/$s_!3ko1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca0126c2-3c29-402b-94db-962b708d5799_1050x339.png 848w, https://substackcdn.com/image/fetch/$s_!3ko1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca0126c2-3c29-402b-94db-962b708d5799_1050x339.png 1272w, https://substackcdn.com/image/fetch/$s_!3ko1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca0126c2-3c29-402b-94db-962b708d5799_1050x339.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">Image Source: https://www.sefidian.com/2021/03/01/policy-g/</figcaption></figure></div><p></p><p><strong>Actor-Critic Methods</strong> &#8211; A hybrid approach that combines policy-based and value-based methods. The <strong>actor</strong> selects actions while the <strong>critic</strong> evaluates them and provides feedback to improve learning.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5ZAn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37182174-6545-4b7f-959d-0c6ecde825fa_1047x392.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5ZAn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37182174-6545-4b7f-959d-0c6ecde825fa_1047x392.png 424w, https://substackcdn.com/image/fetch/$s_!5ZAn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37182174-6545-4b7f-959d-0c6ecde825fa_1047x392.png 848w, https://substackcdn.com/image/fetch/$s_!5ZAn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37182174-6545-4b7f-959d-0c6ecde825fa_1047x392.png 1272w, https://substackcdn.com/image/fetch/$s_!5ZAn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37182174-6545-4b7f-959d-0c6ecde825fa_1047x392.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5ZAn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37182174-6545-4b7f-959d-0c6ecde825fa_1047x392.png" width="637" height="238.49474689589303" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/37182174-6545-4b7f-959d-0c6ecde825fa_1047x392.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:392,&quot;width&quot;:1047,&quot;resizeWidth&quot;:637,&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_!5ZAn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37182174-6545-4b7f-959d-0c6ecde825fa_1047x392.png 424w, https://substackcdn.com/image/fetch/$s_!5ZAn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37182174-6545-4b7f-959d-0c6ecde825fa_1047x392.png 848w, https://substackcdn.com/image/fetch/$s_!5ZAn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37182174-6545-4b7f-959d-0c6ecde825fa_1047x392.png 1272w, https://substackcdn.com/image/fetch/$s_!5ZAn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37182174-6545-4b7f-959d-0c6ecde825fa_1047x392.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption">Original Source: https://roboticseabass.com/2020/08/15/introduction-to-deep-reinforcement-learning/</figcaption></figure></div><p><strong>Proximal Policy Optimization (PPO)</strong> &#8211; A widely used policy gradient method that stabilizes learning by preventing overly large updates, making it effective in real-world applications like robotics and self-driving cars. Natural policy gradients in the real world may involve second-order derivative matrices which makes them not very scalable for large scale problems &#8212; the computational complexity for computing the 2nd derivatives is far too high. PPO uses a slightly different approach: instead of imposing hard constraints, it formalizes the constraint as a penalty in the objective function. By not avoiding the constraint, it can use first-order optimizers and (like Gradient Descent) to optimize the objective. Although these algorithms may make some bad decisions once a while, they strike a good balance between speed and accuracy. </p><div><hr></div><h3>Security &amp; Cryptographic Algorithms</h3><div><hr></div><h4>SHA (Secure Hash Algorithms)</h4><p>SHA (Secure Hash Algorithm) is a cryptographic tool that takes any input&#8212;like a password, file, or message&#8212;and transforms it into a fixed-size string of characters called a hash. Think of it like a magic blender: no matter what you put in, it always produces a unique, same-sized output. The process involves chopping the input into chunks, mixing them through multiple rounds of mathematical operations, and amplifying even the tiniest changes to ensure the final hash is completely different from the original input. This makes SHA highly sensitive to alterations, so even a small change in the input creates a wildly different hash.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Phcx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46522a29-295f-4565-873e-0a3068d4855f_630x517.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Phcx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46522a29-295f-4565-873e-0a3068d4855f_630x517.png 424w, https://substackcdn.com/image/fetch/$s_!Phcx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46522a29-295f-4565-873e-0a3068d4855f_630x517.png 848w, https://substackcdn.com/image/fetch/$s_!Phcx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46522a29-295f-4565-873e-0a3068d4855f_630x517.png 1272w, https://substackcdn.com/image/fetch/$s_!Phcx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46522a29-295f-4565-873e-0a3068d4855f_630x517.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Phcx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46522a29-295f-4565-873e-0a3068d4855f_630x517.png" width="630" height="517" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/46522a29-295f-4565-873e-0a3068d4855f_630x517.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:517,&quot;width&quot;:630,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:94385,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46522a29-295f-4565-873e-0a3068d4855f_630x517.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_!Phcx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46522a29-295f-4565-873e-0a3068d4855f_630x517.png 424w, https://substackcdn.com/image/fetch/$s_!Phcx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46522a29-295f-4565-873e-0a3068d4855f_630x517.png 848w, https://substackcdn.com/image/fetch/$s_!Phcx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46522a29-295f-4565-873e-0a3068d4855f_630x517.png 1272w, https://substackcdn.com/image/fetch/$s_!Phcx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46522a29-295f-4565-873e-0a3068d4855f_630x517.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">Original Image Source: https://www.encryptionconsulting.com/education-center/sha-256/</figcaption></figure></div><p>SHA is incredibly useful for ensuring data integrity, securing passwords, and verifying authenticity. For example, websites store password hashes instead of the actual passwords, so hackers can&#8217;t easily find them. It&#8217;s also used to check if files have been tampered with&#8212;if the hash of a received file matches the original, the data is intact. Additionally, SHA helps create digital signatures, proving that a message or document comes from a trusted source. </p><div><hr></div><h4>RSA Algorithm</h4><p>RSA is a widely used encryption algorithm that allows secure communication over an insecure network. It&#8217;s important because it enables things like online banking, secure email, and safe web browsing by ensuring that only the intended recipient can read a message.</p><p>RSA is based on a simple mathematical trick: multiplying two large prime numbers is easy, but factoring their product is extremely hard. For example, it is easy to check that 31 and 37 multiply to 1147, but trying to find the factors of 1147 is a much longer process. </p><p>Let&#8217;s say that Alice wants to send Bob a valuable diamond, but if sent unsecured, it will be stolen. They each have padlocks, but their keys don&#8217;t open each other&#8217;s locks.</p><ol><li><p>Bob sends Alice an open padlock. Since only Bob has the key, he can share the unlocked padlock with anyone.</p></li><li><p>Alice locks the package with Bob&#8217;s padlock and sends it back.</p></li><li><p>Bob unlocks it with his key and retrieves the diamond.</p></li></ol><p>This mirrors public-key cryptography: Alice encrypts a message using Bob&#8217;s <strong>public key</strong>, which only Bob can <strong>decrypt</strong> with his <strong>private key</strong>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9FAk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4dfefce-7e96-4fef-bb2b-1ee91d870581_1302x519.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9FAk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4dfefce-7e96-4fef-bb2b-1ee91d870581_1302x519.png 424w, https://substackcdn.com/image/fetch/$s_!9FAk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4dfefce-7e96-4fef-bb2b-1ee91d870581_1302x519.png 848w, https://substackcdn.com/image/fetch/$s_!9FAk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4dfefce-7e96-4fef-bb2b-1ee91d870581_1302x519.png 1272w, https://substackcdn.com/image/fetch/$s_!9FAk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4dfefce-7e96-4fef-bb2b-1ee91d870581_1302x519.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9FAk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4dfefce-7e96-4fef-bb2b-1ee91d870581_1302x519.png" width="1302" height="519" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d4dfefce-7e96-4fef-bb2b-1ee91d870581_1302x519.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:519,&quot;width&quot;:1302,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:30997,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4dfefce-7e96-4fef-bb2b-1ee91d870581_1302x519.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_!9FAk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4dfefce-7e96-4fef-bb2b-1ee91d870581_1302x519.png 424w, https://substackcdn.com/image/fetch/$s_!9FAk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4dfefce-7e96-4fef-bb2b-1ee91d870581_1302x519.png 848w, https://substackcdn.com/image/fetch/$s_!9FAk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4dfefce-7e96-4fef-bb2b-1ee91d870581_1302x519.png 1272w, https://substackcdn.com/image/fetch/$s_!9FAk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4dfefce-7e96-4fef-bb2b-1ee91d870581_1302x519.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">Original Image Source: https://github.com/AbdullahAlhussein/RSA-Algorithm</figcaption></figure></div><p>In RSA, the <strong>public key</strong> is created by multiplying two large prime numbers. The <strong>private key</strong> is derived from them in a way that makes decryption easy for Bob but extremely difficult for anyone else.</p><p>Let&#8217;s go through a very simple example. Say that we have the message &#8220;HELLO&#8221; and that we want encrypt it. In order to do so - we need to transform it into a numeric value. We won&#8217;t go into the details of how this is done, but let&#8217;s say that it maps to the number 2 &#8212; a basic outline of how the algorithm works with the above information is provided 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_!hwSw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd22da2a0-7945-4f0e-b333-1cf99e014b19_1242x843.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hwSw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd22da2a0-7945-4f0e-b333-1cf99e014b19_1242x843.png 424w, https://substackcdn.com/image/fetch/$s_!hwSw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd22da2a0-7945-4f0e-b333-1cf99e014b19_1242x843.png 848w, https://substackcdn.com/image/fetch/$s_!hwSw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd22da2a0-7945-4f0e-b333-1cf99e014b19_1242x843.png 1272w, https://substackcdn.com/image/fetch/$s_!hwSw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd22da2a0-7945-4f0e-b333-1cf99e014b19_1242x843.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hwSw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd22da2a0-7945-4f0e-b333-1cf99e014b19_1242x843.png" width="1242" height="843" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d22da2a0-7945-4f0e-b333-1cf99e014b19_1242x843.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:843,&quot;width&quot;:1242,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:184281,&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://photonlines.substack.com/i/148512362?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd22da2a0-7945-4f0e-b333-1cf99e014b19_1242x843.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_!hwSw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd22da2a0-7945-4f0e-b333-1cf99e014b19_1242x843.png 424w, https://substackcdn.com/image/fetch/$s_!hwSw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd22da2a0-7945-4f0e-b333-1cf99e014b19_1242x843.png 848w, https://substackcdn.com/image/fetch/$s_!hwSw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd22da2a0-7945-4f0e-b333-1cf99e014b19_1242x843.png 1272w, https://substackcdn.com/image/fetch/$s_!hwSw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd22da2a0-7945-4f0e-b333-1cf99e014b19_1242x843.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">Original Image Source: https://hackernoon.com/how-does-rsa-work-f44918df914b</figcaption></figure></div><p>RSA protects online transactions, secures communications, and verifies identity, making it a fundamental part of modern cybersecurity. If you&#8217;re curious about the exact details on how the public and private keys are generated, this excellent write-up by HackerNoon does an excellent job in explaining the full details of how and why the algorithm works: <a href="https://hackernoon.com/how-does-rsa-work-f44918df914b">How does RSA work?</a></p><div><hr></div><h4>Diffie-Hellman (DH) Key Exchange</h4><p>Diffie-Hellman (DH), also known as an exponential key exchange, was published in 1976. DH key exchange is a key exchange protocol that allows the sender and receiver to communicate over a public channel to establish a mutual secret without being transmitted over the internet. The core idea is that both parties select a private number (which is never shared), then exchange public values based on these private numbers. Using these exchanged values and their own private numbers, both parties can independently compute the same shared secret. This shared secret can then be used to encrypt further communication, ensuring privacy and security even if the initial exchange happens over an insecure channel.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XIOG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90729c98-f662-46ca-b48f-76f28a383fed_781x791.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XIOG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90729c98-f662-46ca-b48f-76f28a383fed_781x791.png 424w, https://substackcdn.com/image/fetch/$s_!XIOG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90729c98-f662-46ca-b48f-76f28a383fed_781x791.png 848w, https://substackcdn.com/image/fetch/$s_!XIOG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90729c98-f662-46ca-b48f-76f28a383fed_781x791.png 1272w, https://substackcdn.com/image/fetch/$s_!XIOG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90729c98-f662-46ca-b48f-76f28a383fed_781x791.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XIOG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90729c98-f662-46ca-b48f-76f28a383fed_781x791.png" width="506" height="512.4788732394367" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/90729c98-f662-46ca-b48f-76f28a383fed_781x791.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:791,&quot;width&quot;:781,&quot;resizeWidth&quot;:506,&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_!XIOG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90729c98-f662-46ca-b48f-76f28a383fed_781x791.png 424w, https://substackcdn.com/image/fetch/$s_!XIOG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90729c98-f662-46ca-b48f-76f28a383fed_781x791.png 848w, https://substackcdn.com/image/fetch/$s_!XIOG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90729c98-f662-46ca-b48f-76f28a383fed_781x791.png 1272w, https://substackcdn.com/image/fetch/$s_!XIOG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90729c98-f662-46ca-b48f-76f28a383fed_781x791.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">Image Source: https://www.encryptionconsulting.com/diffie-hellman-key-exchange-vs-rsa/</figcaption></figure></div><p>The algorithm has a high processor overhead so it isn&#8217;t used for bulk or stream encryption but rather to create the initial session key for starting the encrypted session. Afterwards and under the protection of this generated session key, other cryptographic protocols negotiate and trade keys for the remainder of the encrypted session. Think of it as an expensive method of passing that initial secret. It&#8217;s widely used in secure communication protocols like TLS/SSL, SSH, and IPsec. I won&#8217;t dive into the complete details on how the algorithm works - but if you&#8217;re curious and want another intuitive and more in-depth explanation, the video below provides an excellent overview: </p><div id="youtube2-3QnD2c4Xovk" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;3QnD2c4Xovk&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/3QnD2c4Xovk?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><div><hr></div><h3>Interview Prep-Focused Material / Algorithms</h3><div><hr></div><p>Testing is now part of the regular developer experience. Many software engineers who are currently looking for a job at the moment might find some of the write-ups below useful, so I&#8217;m including it as part of the cheat sheet. </p><div><hr></div><h4>14 Patterns to Ace Any Coding Interview</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://hackernoon.com/14-patterns-to-ace-any-coding-interview-question-c5bb3357f6ed" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Zcl-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6204dd7-7045-46f0-83ff-fce654ec6350_882x591.png 424w, https://substackcdn.com/image/fetch/$s_!Zcl-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6204dd7-7045-46f0-83ff-fce654ec6350_882x591.png 848w, https://substackcdn.com/image/fetch/$s_!Zcl-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6204dd7-7045-46f0-83ff-fce654ec6350_882x591.png 1272w, https://substackcdn.com/image/fetch/$s_!Zcl-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6204dd7-7045-46f0-83ff-fce654ec6350_882x591.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Zcl-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6204dd7-7045-46f0-83ff-fce654ec6350_882x591.png" width="882" height="591" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a6204dd7-7045-46f0-83ff-fce654ec6350_882x591.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:591,&quot;width&quot;:882,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:955998,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://hackernoon.com/14-patterns-to-ace-any-coding-interview-question-c5bb3357f6ed&quot;,&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_!Zcl-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6204dd7-7045-46f0-83ff-fce654ec6350_882x591.png 424w, https://substackcdn.com/image/fetch/$s_!Zcl-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6204dd7-7045-46f0-83ff-fce654ec6350_882x591.png 848w, https://substackcdn.com/image/fetch/$s_!Zcl-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6204dd7-7045-46f0-83ff-fce654ec6350_882x591.png 1272w, https://substackcdn.com/image/fetch/$s_!Zcl-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6204dd7-7045-46f0-83ff-fce654ec6350_882x591.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></figure></div><div><hr></div><h4>Algorithms You Should Know Before Any Systems Design Interview</h4><div id="youtube2-xbgzl2maQUU" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;xbgzl2maQUU&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/xbgzl2maQUU?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><div><hr></div><h4>5 Simple Steps for Solving Dynamic Programming Problems</h4><div id="youtube2-aPQY__2H3tE" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;aPQY__2H3tE&quot;,&quot;startTime&quot;:&quot;82s&quot;,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/aPQY__2H3tE?start=82s&amp;rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><div><hr></div><h4>Mastering Dynamic Programming</h4><div id="youtube2-Hdr64lKQ3e4" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;Hdr64lKQ3e4&quot;,&quot;startTime&quot;:&quot;1s&quot;,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/Hdr64lKQ3e4?start=1s&amp;rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><div><hr></div><h3>Ending Note</h3><p>Thank you for being patient - it took me a much longer time to finish this write-up than I initially thought. As a reminder, this is an independent publications free of ads so if you like my content, please like a subscribe!!</p><div><hr></div><h3>References</h3><ul><li><p><a href="https://www.programming-books.io/essential/algorithms/heap-sort-basic-information-3193e2927dbe4c03bcbc5645fa66cf21">Heap Sort Basic Information</a></p></li><li><p><a href="https://www.drmaciver.com/2010/01/understanding-timsort-1adaptive-mergesort/">Understanding Timsort</a></p></li><li><p><a href="https://www.scholarhat.com/tutorial/datastructures/bellman-fords-algorithm">Bellman Ford&#8217;s Algorithm in Data Structures - Working, Example and Applications</a></p></li><li><p><a href="https://www.redblobgames.com/pathfinding/a-star/introduction.html">Introduction to the A* Algorithm</a></p></li><li><p><a href="http://What is an intuitive explanation of union-find?">What is an intuitive explanation of union find? (Quora)</a></p></li><li><p><a href="https://www.quora.com/What-is-an-intuitive-explanation-of-union-find">Quora: What is an intuitive explanation of union find?</a></p></li><li><p><a href="https://www.oreilly.com/library/view/designing-data-intensive-applications/9781491903063/">Designing Data-Intensive Applications</a></p></li><li><p><a href="https://www.microsoftpressstore.com/articles/article.aspx?p=2449192">The VertiPaq Engine in DAX</a> </p></li><li><p><a href="https://devincody.github.io/Blog/post/an_intuitive_interpretation_of_the_fourier_transform/">An Intuitive Interpretation of the Fourier Transform </a></p></li><li><p><a href="http://A Visual Guide to Quantization">A Visual Guide to Quantization</a></p></li><li><p><a href="https://www.youtube.com/watch?v=Q2aEzeMDHMA">JPEG DCT, Discrete Cosine Transform (JPEG Pt2)- Computerphile</a></p></li><li><p><a href="https://www.youtube.com/watch?v=h7apO7q16V0">The Fast Fourier Transform (FFT): Most Ingenious Algorithm Ever?</a></p></li><li><p><a href="https://cses.fi/book/book.pdf">Competitive Programmer&#8217;s Handbook</a></p></li><li><p><a href="https://github.com/leandromoreira/digital_video_introduction">Digital Video Introduction</a></p></li><li><p><a href="https://blog.gopenai.com/understanding-of-gradient-descent-intuition-and-implementation-b1f98b3645ea">Understanding of Gradient Descent: Intuition and Implementation</a></p></li><li><p><a href="https://easyai.tech/en/ai-definition/gradient-descent/">Gradient descent method-Gradient descent</a></p></li><li><p><a href="https://umeshchandra.in/2024/04/19/understanding-support-vector-machines-svm/">Understanding Support Vector Machines (SVM)</a></p></li><li><p><a href="https://pages.cms.hu-berlin.de/EOL/geo_rs/S08_Image_classification2.html">Image classification - Random Forests</a></p></li><li><p><a href="https://medium.com/@theaveragegal/transformer-architecture-simplified-3fb501d461c8">Transformer Architecture Simplified</a></p></li><li><p><a href="https://neptune.ai/blog/markov-decision-process-in-reinforcement-learning">Markov Decision Process in Reinforcement Learning: Everything You Need to Know</a></p></li><li><p><a href="https://www.sefidian.com/2021/03/01/policy-g/">REINFORCE Algorithm explained in Policy-Gradient based methods with Python Code</a></p></li><li><p><a href="https://roboticseabass.com/2020/08/15/introduction-to-deep-reinforcement-learning/">Introduction to Deep Reinforcement Learning</a></p></li><li><p><a href="https://jonathan-hui.medium.com/rl-proximal-policy-optimization-ppo-explained-77f014ec3f12">RL &#8212; Proximal Policy Optimization (PPO) Explained</a></p></li><li><p><a href="https://www.encryptionconsulting.com/education-center/sha-256/">What is SHA- 256?</a></p></li><li><p><a href="https://hackernoon.com/how-does-rsa-work-f44918df914b">How does RSA work?</a></p></li><li><p><a href="https://www.encryptionconsulting.com/diffie-hellman-key-exchange-vs-rsa/">Everything You Need To Know About Diffie-Hellman Key Exchange Vs. RSA</a></p></li><li><p><a href="https://hackernoon.com/14-patterns-to-ace-any-coding-interview-question-c5bb3357f6ed">14 Patterns to Ace Any Coding Interview</a></p></li><li><p><a href="https://www.youtube.com/watch?v=xbgzl2maQUU">Algorithms You Should Know Before System Design Interviews</a></p></li><li><p><a href="https://www.youtube.com/watch?v=aPQY__2H3tE">5 Simple Steps for Solving Dynamic Programming Problems</a></p></li><li><p><a href="https://www.youtube.com/watch?v=Hdr64lKQ3e4">Mastering Dynamic Programming</a></p><p></p></li></ul><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Photon-Lines Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[A Walk-Through of String Search Algorithms]]></title><description><![CDATA[A walk-through of how some of the popular string-search algorithms work with a focus on the well-known Boyer-Moore and Robin-Karp algorithms.]]></description><link>https://photonlines.substack.com/p/a-walk-through-of-string-search-algorithms</link><guid isPermaLink="false">https://photonlines.substack.com/p/a-walk-through-of-string-search-algorithms</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Fri, 22 Nov 2024 14:23:30 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!XURt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F404c2ef2-506c-428a-9ad7-bf687e18c911_1638x843.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We often don&#8217;t think about string-searching algorithms, but they play an incredibly important role in the real world. From searching keywords in a web browser to filtering spam emails, these algorithms power countless applications. Without efficient string-searching techniques, tasks we take for granted would be computationally expensive and time-consuming. Some of these algorithms form the backbone of modern computing, so we&#8217;ll dedicate this blog post to going through a few of them starting with my favorite: the Boyer-Moore algorithm. </p><p>Why do I love this algorithm so much? Well - this great explanation on why <a href="https://lists.freebsd.org/pipermail/freebsd-current/2010-August/019310.html">GNU grep is so fast</a> pretty much sums it up: </p><blockquote><p>Here's a quick summary of where GNU grep gets its speed. Hopefully you can carry these ideas over to BSD grep.</p><p>#1 trick: GNU grep is fast because it AVOIDS LOOKING AT EVERY INPUT BYTE.</p><p>#2 trick: GNU grep is fast because it EXECUTES VERY FEW INSTRUCTIONS FOR EACH BYTE that it *does* look at.</p><p>GNU grep uses the well-known Boyer-Moore algorithm, which looks first for the final letter of the target string, and uses a lookup table to tell it how far ahead it can skip in the input whenever it finds a non-matching character.</p><p>GNU grep also unrolls the inner loop of Boyer-Moore, and sets up the Boyer-Moore delta table entries in such a way that it doesn't need to do the loop exit test at every unrolled step. The result of this is that, in the limit, GNU grep averages fewer than 3 x86 instructions executed for each input byte it actually looks at (and it skips many bytes entirely).</p></blockquote><p>The linked post is relatively short and does a great job in summarizing why grep is lightning fast, so I recommend you read all of the content, but in sum - the Boyer-Moore algorithm plays a vital role in making the sub-string or string-search process efficient. It does this by avoiding unnecessary work. How exactly this is done is explained below.</p><div><hr></div><h2>The Boyer-Moore Algorithm</h2><p>Invented by Robert S. Boyer and J Strother Moore in 1977, this algorithm revolutionized string searching by introducing clever heuristics to drastically reduce the number of comparisons required. Unlike straightforward methods like the na&#239;ve approach (which checks every position in the text sequentially), the Boyer-Moore algorithm leverages mismatches to skip over large sections of the text. </p><p>The key insight behind the Boyer-Moore algorithm is founded on starting the pattern search at the <strong>last</strong> character rather than the <strong>first</strong>. Using this approach, it reduces the amount of work it has to do drastically. In addition to the tweak above, it also uses some key rules in how it processes the characters such that it can skip over large segments of text. Let&#8217;s go through a simple example in order to illustrate how it works.</p><h4>Simple Example</h4><p>Let's say our pattern p is the sequence of characters p<sub>1</sub>, p<sub>2</sub>, ..., p<sub>n</sub> and we are searching a string s:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XURt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F404c2ef2-506c-428a-9ad7-bf687e18c911_1638x843.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XURt!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F404c2ef2-506c-428a-9ad7-bf687e18c911_1638x843.png 424w, https://substackcdn.com/image/fetch/$s_!XURt!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F404c2ef2-506c-428a-9ad7-bf687e18c911_1638x843.png 848w, https://substackcdn.com/image/fetch/$s_!XURt!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F404c2ef2-506c-428a-9ad7-bf687e18c911_1638x843.png 1272w, https://substackcdn.com/image/fetch/$s_!XURt!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F404c2ef2-506c-428a-9ad7-bf687e18c911_1638x843.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XURt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F404c2ef2-506c-428a-9ad7-bf687e18c911_1638x843.png" width="1456" height="749" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/404c2ef2-506c-428a-9ad7-bf687e18c911_1638x843.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:749,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:39592,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!XURt!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F404c2ef2-506c-428a-9ad7-bf687e18c911_1638x843.png 424w, https://substackcdn.com/image/fetch/$s_!XURt!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F404c2ef2-506c-428a-9ad7-bf687e18c911_1638x843.png 848w, https://substackcdn.com/image/fetch/$s_!XURt!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F404c2ef2-506c-428a-9ad7-bf687e18c911_1638x843.png 1272w, https://substackcdn.com/image/fetch/$s_!XURt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F404c2ef2-506c-428a-9ad7-bf687e18c911_1638x843.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></figure></div><p>In the above instance, our pattern is &#8220;AT THAT&#8221; and our search space is &#8216;WHICH FINALLY HALTS. AT THAT POINT&#8230;&#8221;</p><p>First, we set our index to point to the last element in our pattern string (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_!gra0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7331db87-a3b2-4481-a693-0d954da95e99_1641x463.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gra0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7331db87-a3b2-4481-a693-0d954da95e99_1641x463.png 424w, https://substackcdn.com/image/fetch/$s_!gra0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7331db87-a3b2-4481-a693-0d954da95e99_1641x463.png 848w, https://substackcdn.com/image/fetch/$s_!gra0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7331db87-a3b2-4481-a693-0d954da95e99_1641x463.png 1272w, https://substackcdn.com/image/fetch/$s_!gra0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7331db87-a3b2-4481-a693-0d954da95e99_1641x463.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gra0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7331db87-a3b2-4481-a693-0d954da95e99_1641x463.png" width="1456" height="411" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7331db87-a3b2-4481-a693-0d954da95e99_1641x463.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:411,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:21773,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!gra0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7331db87-a3b2-4481-a693-0d954da95e99_1641x463.png 424w, https://substackcdn.com/image/fetch/$s_!gra0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7331db87-a3b2-4481-a693-0d954da95e99_1641x463.png 848w, https://substackcdn.com/image/fetch/$s_!gra0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7331db87-a3b2-4481-a693-0d954da95e99_1641x463.png 1272w, https://substackcdn.com/image/fetch/$s_!gra0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7331db87-a3b2-4481-a693-0d954da95e99_1641x463.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></figure></div><p>The Boyer-Moore algorithm uses the following rules to determine how far we can skip ahead:</p><h4><strong>Case 1:</strong> </h4><p>If we try matching a character that is not in p, we can jump forward n characters where n = the length of our pattern string.</p><p>We can see that in our above instance, our index compares character &#8216;T&#8217; in our pattern string to character &#8216;F&#8217; in our search string. We know that the 'F' character is not present anywhere in our pattern p, so we know that we can advance n characters:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9oX6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F419b731b-a5e7-4fc5-8390-e87beba934db_1021x260.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9oX6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F419b731b-a5e7-4fc5-8390-e87beba934db_1021x260.png 424w, https://substackcdn.com/image/fetch/$s_!9oX6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F419b731b-a5e7-4fc5-8390-e87beba934db_1021x260.png 848w, https://substackcdn.com/image/fetch/$s_!9oX6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F419b731b-a5e7-4fc5-8390-e87beba934db_1021x260.png 1272w, https://substackcdn.com/image/fetch/$s_!9oX6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F419b731b-a5e7-4fc5-8390-e87beba934db_1021x260.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9oX6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F419b731b-a5e7-4fc5-8390-e87beba934db_1021x260.png" width="1021" height="260" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/419b731b-a5e7-4fc5-8390-e87beba934db_1021x260.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:260,&quot;width&quot;:1021,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:16994,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!9oX6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F419b731b-a5e7-4fc5-8390-e87beba934db_1021x260.png 424w, https://substackcdn.com/image/fetch/$s_!9oX6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F419b731b-a5e7-4fc5-8390-e87beba934db_1021x260.png 848w, https://substackcdn.com/image/fetch/$s_!9oX6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F419b731b-a5e7-4fc5-8390-e87beba934db_1021x260.png 1272w, https://substackcdn.com/image/fetch/$s_!9oX6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F419b731b-a5e7-4fc5-8390-e87beba934db_1021x260.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></figure></div><h4><strong>Case 2:</strong> </h4><p>If we try matching a character whose last position is k from the end of p, we can then jump forward k characters.</p><p>In the above instance, our algorithm now compares the character &#8216;T&#8217; in our pattern to the blank space in our search string. We know that the white space character&#8217;s last position in our pattern is exactly 4 characters from the end, and so we advance 4 characters:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BIhl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0195ae4d-ddce-4d66-a879-9f65d27a164b_969x252.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BIhl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0195ae4d-ddce-4d66-a879-9f65d27a164b_969x252.png 424w, https://substackcdn.com/image/fetch/$s_!BIhl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0195ae4d-ddce-4d66-a879-9f65d27a164b_969x252.png 848w, https://substackcdn.com/image/fetch/$s_!BIhl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0195ae4d-ddce-4d66-a879-9f65d27a164b_969x252.png 1272w, https://substackcdn.com/image/fetch/$s_!BIhl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0195ae4d-ddce-4d66-a879-9f65d27a164b_969x252.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BIhl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0195ae4d-ddce-4d66-a879-9f65d27a164b_969x252.png" width="969" height="252" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0195ae4d-ddce-4d66-a879-9f65d27a164b_969x252.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:252,&quot;width&quot;:969,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:16631,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!BIhl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0195ae4d-ddce-4d66-a879-9f65d27a164b_969x252.png 424w, https://substackcdn.com/image/fetch/$s_!BIhl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0195ae4d-ddce-4d66-a879-9f65d27a164b_969x252.png 848w, https://substackcdn.com/image/fetch/$s_!BIhl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0195ae4d-ddce-4d66-a879-9f65d27a164b_969x252.png 1272w, https://substackcdn.com/image/fetch/$s_!BIhl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0195ae4d-ddce-4d66-a879-9f65d27a164b_969x252.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></figure></div><p>Now, we once again scan backwards from i until we either succeed or we hit a mismatch. If the mismatch occurs k characters from the start of p and the mismatched character is not in p, then we can advance at least k characters.</p><p>In our above example, we first compare our first pattern character to our search string. Since they match and they both contain the character &#8216;T&#8217;, we move backwards to the next index and we now compare our pattern character &#8216;A&#8217; to our search string character 'L'. Since the &#8216;L&#8217; character is not present anywhere in our pattern p, we&#8217;re now allowed to move at least 6 characters! How did we get 6? Well, we know that our pattern length is 7 characters long, but we&#8217;ve already compared one character and so we take this into account:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!eUhZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23b4597e-a8d6-48e9-a789-c2aaba6b9f57_996x251.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!eUhZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23b4597e-a8d6-48e9-a789-c2aaba6b9f57_996x251.png 424w, https://substackcdn.com/image/fetch/$s_!eUhZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23b4597e-a8d6-48e9-a789-c2aaba6b9f57_996x251.png 848w, https://substackcdn.com/image/fetch/$s_!eUhZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23b4597e-a8d6-48e9-a789-c2aaba6b9f57_996x251.png 1272w, https://substackcdn.com/image/fetch/$s_!eUhZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23b4597e-a8d6-48e9-a789-c2aaba6b9f57_996x251.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!eUhZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23b4597e-a8d6-48e9-a789-c2aaba6b9f57_996x251.png" width="996" height="251" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/23b4597e-a8d6-48e9-a789-c2aaba6b9f57_996x251.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:251,&quot;width&quot;:996,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:13342,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!eUhZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23b4597e-a8d6-48e9-a789-c2aaba6b9f57_996x251.png 424w, https://substackcdn.com/image/fetch/$s_!eUhZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23b4597e-a8d6-48e9-a789-c2aaba6b9f57_996x251.png 848w, https://substackcdn.com/image/fetch/$s_!eUhZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23b4597e-a8d6-48e9-a789-c2aaba6b9f57_996x251.png 1272w, https://substackcdn.com/image/fetch/$s_!eUhZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23b4597e-a8d6-48e9-a789-c2aaba6b9f57_996x251.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></figure></div><p>However, we can actually do better than this!</p><p>Let&#8217;s go back to our original 2<sup>nd</sup> case which shows what we need to do when we encounter a character in our search string which is contained within our pattern p. We need to note that we actually have 2 main sub-cases to consider whenever dealing with this condition, and they&#8217;re illustrated below:</p><h4><strong>Sub-Case 1:</strong></h4><p>The matching suffix occurs somewhere else in the pattern:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!B8yi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1a9ece1-a669-4174-8228-7a19b9f83cdb_823x466.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!B8yi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1a9ece1-a669-4174-8228-7a19b9f83cdb_823x466.png 424w, https://substackcdn.com/image/fetch/$s_!B8yi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1a9ece1-a669-4174-8228-7a19b9f83cdb_823x466.png 848w, https://substackcdn.com/image/fetch/$s_!B8yi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1a9ece1-a669-4174-8228-7a19b9f83cdb_823x466.png 1272w, https://substackcdn.com/image/fetch/$s_!B8yi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1a9ece1-a669-4174-8228-7a19b9f83cdb_823x466.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!B8yi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1a9ece1-a669-4174-8228-7a19b9f83cdb_823x466.png" width="823" height="466" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b1a9ece1-a669-4174-8228-7a19b9f83cdb_823x466.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:466,&quot;width&quot;:823,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:19856,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!B8yi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1a9ece1-a669-4174-8228-7a19b9f83cdb_823x466.png 424w, https://substackcdn.com/image/fetch/$s_!B8yi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1a9ece1-a669-4174-8228-7a19b9f83cdb_823x466.png 848w, https://substackcdn.com/image/fetch/$s_!B8yi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1a9ece1-a669-4174-8228-7a19b9f83cdb_823x466.png 1272w, https://substackcdn.com/image/fetch/$s_!B8yi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1a9ece1-a669-4174-8228-7a19b9f83cdb_823x466.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></figure></div><p>In the above instance, we know that the matching sub-string is present somewhere else within our pattern p, so we shift ahead to align our pattern to the next match.</p><h4><strong>Sub-Case 2:</strong></h4><p>Only a part of the matching suffix occurs at the beginning of the pattern:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HRrx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff24b1f1f-b679-4461-a8f2-6369e63a34f5_816x463.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HRrx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff24b1f1f-b679-4461-a8f2-6369e63a34f5_816x463.png 424w, https://substackcdn.com/image/fetch/$s_!HRrx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff24b1f1f-b679-4461-a8f2-6369e63a34f5_816x463.png 848w, https://substackcdn.com/image/fetch/$s_!HRrx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff24b1f1f-b679-4461-a8f2-6369e63a34f5_816x463.png 1272w, https://substackcdn.com/image/fetch/$s_!HRrx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff24b1f1f-b679-4461-a8f2-6369e63a34f5_816x463.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HRrx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff24b1f1f-b679-4461-a8f2-6369e63a34f5_816x463.png" width="816" height="463" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f24b1f1f-b679-4461-a8f2-6369e63a34f5_816x463.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:463,&quot;width&quot;:816,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:21552,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HRrx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff24b1f1f-b679-4461-a8f2-6369e63a34f5_816x463.png 424w, https://substackcdn.com/image/fetch/$s_!HRrx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff24b1f1f-b679-4461-a8f2-6369e63a34f5_816x463.png 848w, https://substackcdn.com/image/fetch/$s_!HRrx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff24b1f1f-b679-4461-a8f2-6369e63a34f5_816x463.png 1272w, https://substackcdn.com/image/fetch/$s_!HRrx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff24b1f1f-b679-4461-a8f2-6369e63a34f5_816x463.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></figure></div><p>In the case above, we check whether any of the matched suffix matches the beginning of pattern, and if it does, we need to move ahead by n - (# of matching characters)!</p><p>Let&#8217;s go back to our original example. Once again, notice that in sub-case 2, we need to check whether a part of the matched string is present within the prefix of our pattern string p! Here, we check whether &#8216;T&#8217; (our already matched character) is present at the beginning of our pattern. We see that it isn&#8217;t (our pattern starts with &#8216;A&#8217;, not &#8216;T&#8217;), so we know that we can actually jump forward by more than 6 characters! In this instance, we can actually advance ahead by 7, so that&#8217;s what we do instead:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!UTr6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34545e31-3481-4cab-ba81-360e70ceb7ef_989x250.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UTr6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34545e31-3481-4cab-ba81-360e70ceb7ef_989x250.png 424w, https://substackcdn.com/image/fetch/$s_!UTr6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34545e31-3481-4cab-ba81-360e70ceb7ef_989x250.png 848w, https://substackcdn.com/image/fetch/$s_!UTr6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34545e31-3481-4cab-ba81-360e70ceb7ef_989x250.png 1272w, https://substackcdn.com/image/fetch/$s_!UTr6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34545e31-3481-4cab-ba81-360e70ceb7ef_989x250.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!UTr6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34545e31-3481-4cab-ba81-360e70ceb7ef_989x250.png" width="989" height="250" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/34545e31-3481-4cab-ba81-360e70ceb7ef_989x250.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:250,&quot;width&quot;:989,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:16847,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!UTr6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34545e31-3481-4cab-ba81-360e70ceb7ef_989x250.png 424w, https://substackcdn.com/image/fetch/$s_!UTr6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34545e31-3481-4cab-ba81-360e70ceb7ef_989x250.png 848w, https://substackcdn.com/image/fetch/$s_!UTr6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34545e31-3481-4cab-ba81-360e70ceb7ef_989x250.png 1272w, https://substackcdn.com/image/fetch/$s_!UTr6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34545e31-3481-4cab-ba81-360e70ceb7ef_989x250.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></figure></div><p>At this point, we see that our index once again doesn&#8217;t have a match and that our pattern character &#8216;T&#8217; is not equal to the blank character in our search string, so we can once again use the rules we encountered previously to determine how far ahead we can advance. Once again, we know that the blank character&#8217;s last position in our pattern is exactly 4 characters from the end, and so we advance 4 characters:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!oOOT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbc2049f-20e5-4b47-8db7-0b41dee65333_1005x261.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!oOOT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbc2049f-20e5-4b47-8db7-0b41dee65333_1005x261.png 424w, https://substackcdn.com/image/fetch/$s_!oOOT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbc2049f-20e5-4b47-8db7-0b41dee65333_1005x261.png 848w, https://substackcdn.com/image/fetch/$s_!oOOT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbc2049f-20e5-4b47-8db7-0b41dee65333_1005x261.png 1272w, https://substackcdn.com/image/fetch/$s_!oOOT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbc2049f-20e5-4b47-8db7-0b41dee65333_1005x261.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!oOOT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbc2049f-20e5-4b47-8db7-0b41dee65333_1005x261.png" width="1005" height="261" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cbc2049f-20e5-4b47-8db7-0b41dee65333_1005x261.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:261,&quot;width&quot;:1005,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:16785,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!oOOT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbc2049f-20e5-4b47-8db7-0b41dee65333_1005x261.png 424w, https://substackcdn.com/image/fetch/$s_!oOOT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbc2049f-20e5-4b47-8db7-0b41dee65333_1005x261.png 848w, https://substackcdn.com/image/fetch/$s_!oOOT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbc2049f-20e5-4b47-8db7-0b41dee65333_1005x261.png 1272w, https://substackcdn.com/image/fetch/$s_!oOOT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbc2049f-20e5-4b47-8db7-0b41dee65333_1005x261.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></figure></div><p>We then once again start comparing our characters one-by-one and moving backwards through our string. In the above case, we have a match for all seven characters, so we know that we&#8217;ve finally found a match!</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Stle!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80957e4f-1f40-4325-8000-a6aaabcd0c4c_656x119.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Stle!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80957e4f-1f40-4325-8000-a6aaabcd0c4c_656x119.png 424w, https://substackcdn.com/image/fetch/$s_!Stle!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80957e4f-1f40-4325-8000-a6aaabcd0c4c_656x119.png 848w, https://substackcdn.com/image/fetch/$s_!Stle!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80957e4f-1f40-4325-8000-a6aaabcd0c4c_656x119.png 1272w, https://substackcdn.com/image/fetch/$s_!Stle!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80957e4f-1f40-4325-8000-a6aaabcd0c4c_656x119.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Stle!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80957e4f-1f40-4325-8000-a6aaabcd0c4c_656x119.png" width="656" height="119" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/80957e4f-1f40-4325-8000-a6aaabcd0c4c_656x119.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:119,&quot;width&quot;:656,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:10213,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Stle!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80957e4f-1f40-4325-8000-a6aaabcd0c4c_656x119.png 424w, https://substackcdn.com/image/fetch/$s_!Stle!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80957e4f-1f40-4325-8000-a6aaabcd0c4c_656x119.png 848w, https://substackcdn.com/image/fetch/$s_!Stle!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80957e4f-1f40-4325-8000-a6aaabcd0c4c_656x119.png 1272w, https://substackcdn.com/image/fetch/$s_!Stle!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80957e4f-1f40-4325-8000-a6aaabcd0c4c_656x119.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Notice that the Bayer Moore algorithm saved us a ton of time by following the rules which we outlined! We only needed to perform 4 character comparison operations prior to arriving at the index which contained our matching string. A regular brute force search would have had to deal with 23 comparisons prior to finding the match!</p><p>Boyer-Moore isn&#8217;t the only well-known algorithm - there are a wide array of algorithms which attempt to minimize the amount of work which needs to be done (including the Knuth-Morris-Pratt (KMP) algorithm which we will cover later), but the reason I love Boyer-Moore is because it&#8217;s incredibly simple, efficient, and elegant!! Noting this, let&#8217;s move on to another interesting one: the Robin-Karp algorithm. </p><h2>Robin-Karp Algorithm</h2><p>Developed by Michael O. Rabin and Richard M. Karp in 1987, this algorithm introduces a clever twist: instead of directly comparing every character of the pattern with the text, it uses <em>hashing</em>.</p><p>Hashing allows us to turn the pattern and chunks of the text into compact numerical representations, making it much faster to check for matches. By comparing these hash values instead of individual characters, the algorithm streamlines the search process. It&#8217;s especially useful in cases where multiple patterns need to be matched or when working with very large datasets.</p><p>The elegance of Rabin-Karp lies in its simplicity and its adaptability to scenarios requiring fast pattern matching, like plagiarism detection, network packet filtering, and digital forensics. Here&#8217;s the step-by-step breakdown:</p><p><strong>1. Hash the Pattern</strong>: First, compute a hash value for the pattern you&#8217;re searching for. A hash is a compact numerical representation of the pattern, designed so that different patterns typically result in different hash values.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Ycha!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0241c1a0-46f7-4af7-9ee7-32c46687c18b_1280x982.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Ycha!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0241c1a0-46f7-4af7-9ee7-32c46687c18b_1280x982.png 424w, https://substackcdn.com/image/fetch/$s_!Ycha!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0241c1a0-46f7-4af7-9ee7-32c46687c18b_1280x982.png 848w, https://substackcdn.com/image/fetch/$s_!Ycha!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0241c1a0-46f7-4af7-9ee7-32c46687c18b_1280x982.png 1272w, https://substackcdn.com/image/fetch/$s_!Ycha!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0241c1a0-46f7-4af7-9ee7-32c46687c18b_1280x982.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Ycha!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0241c1a0-46f7-4af7-9ee7-32c46687c18b_1280x982.png" width="1280" height="982" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0241c1a0-46f7-4af7-9ee7-32c46687c18b_1280x982.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:982,&quot;width&quot;:1280,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;undefined&quot;,&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="undefined" title="undefined" srcset="https://substackcdn.com/image/fetch/$s_!Ycha!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0241c1a0-46f7-4af7-9ee7-32c46687c18b_1280x982.png 424w, https://substackcdn.com/image/fetch/$s_!Ycha!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0241c1a0-46f7-4af7-9ee7-32c46687c18b_1280x982.png 848w, https://substackcdn.com/image/fetch/$s_!Ycha!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0241c1a0-46f7-4af7-9ee7-32c46687c18b_1280x982.png 1272w, https://substackcdn.com/image/fetch/$s_!Ycha!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0241c1a0-46f7-4af7-9ee7-32c46687c18b_1280x982.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">Image Source: https://en.wikipedia.org/wiki/Hash_function#/media/File:Hash_table_4_1_1_0_0_1_0_LL.svg </figcaption></figure></div><p>Let&#8217;s go through a very simple example. Let&#8217;s say that we&#8217;re searching for the string &#8216;<strong>test</strong>&#8217; within the text &#8220;<strong>this is a test text that contains test</strong>.&#8221; To generate hashes - we&#8217;re going to use a very simple algorithm: we&#8217;re simply going to add the sum of the ASCII values contained within the string. For &#8216;test&#8217;, our hash would thus result in:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FN2i!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ffb2e72-ffc7-4896-95a7-541bd3c172de_1030x332.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FN2i!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ffb2e72-ffc7-4896-95a7-541bd3c172de_1030x332.png 424w, https://substackcdn.com/image/fetch/$s_!FN2i!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ffb2e72-ffc7-4896-95a7-541bd3c172de_1030x332.png 848w, https://substackcdn.com/image/fetch/$s_!FN2i!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ffb2e72-ffc7-4896-95a7-541bd3c172de_1030x332.png 1272w, https://substackcdn.com/image/fetch/$s_!FN2i!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ffb2e72-ffc7-4896-95a7-541bd3c172de_1030x332.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FN2i!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ffb2e72-ffc7-4896-95a7-541bd3c172de_1030x332.png" width="1030" height="332" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4ffb2e72-ffc7-4896-95a7-541bd3c172de_1030x332.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:332,&quot;width&quot;:1030,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:25420,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FN2i!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ffb2e72-ffc7-4896-95a7-541bd3c172de_1030x332.png 424w, https://substackcdn.com/image/fetch/$s_!FN2i!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ffb2e72-ffc7-4896-95a7-541bd3c172de_1030x332.png 848w, https://substackcdn.com/image/fetch/$s_!FN2i!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ffb2e72-ffc7-4896-95a7-541bd3c172de_1030x332.png 1272w, https://substackcdn.com/image/fetch/$s_!FN2i!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ffb2e72-ffc7-4896-95a7-541bd3c172de_1030x332.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></figure></div><p>Our hash is thus 448. </p><p><strong>2. Hash Substrings of the Text</strong>: Slide a "window" of the same size as the pattern over the text and for each new position of the window, compute the hash of the substring within it.</p><p>Let&#8217;s go back to our prior example of searching for the string &#8216;<strong>test</strong>&#8217; within the text &#8220;<strong>this is a test text that contains test.</strong>&#8221; We&#8217;ve already generated a hash value for our test string and we know that the integer it hashes to is 448. Now, we need to compute the hash for the first window within our search text. Since our search pattern has 4 characters, we know that our initial window is simply going to be the word &#8220;this&#8221; which hashes to:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LViq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25567edb-f794-46ee-a35b-0ac14b7ecb8a_991x258.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LViq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25567edb-f794-46ee-a35b-0ac14b7ecb8a_991x258.png 424w, https://substackcdn.com/image/fetch/$s_!LViq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25567edb-f794-46ee-a35b-0ac14b7ecb8a_991x258.png 848w, https://substackcdn.com/image/fetch/$s_!LViq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25567edb-f794-46ee-a35b-0ac14b7ecb8a_991x258.png 1272w, https://substackcdn.com/image/fetch/$s_!LViq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25567edb-f794-46ee-a35b-0ac14b7ecb8a_991x258.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LViq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25567edb-f794-46ee-a35b-0ac14b7ecb8a_991x258.png" width="991" height="258" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/25567edb-f794-46ee-a35b-0ac14b7ecb8a_991x258.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:258,&quot;width&quot;:991,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:15937,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!LViq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25567edb-f794-46ee-a35b-0ac14b7ecb8a_991x258.png 424w, https://substackcdn.com/image/fetch/$s_!LViq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25567edb-f794-46ee-a35b-0ac14b7ecb8a_991x258.png 848w, https://substackcdn.com/image/fetch/$s_!LViq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25567edb-f794-46ee-a35b-0ac14b7ecb8a_991x258.png 1272w, https://substackcdn.com/image/fetch/$s_!LViq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25567edb-f794-46ee-a35b-0ac14b7ecb8a_991x258.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></figure></div><p>The hash for &#8220;this&#8221; is thus 440. </p><p><strong>3. Compare Hashes</strong>: As a next step, we simply compare the hash of the current substring to the hash of the pattern. If they match, we check the individual characters to confirm that the substring and the pattern are truly identical (since hash collisions can occur). Since we see that our hashes don&#8217;t match in the instance above (440 is not equal to 448), we slide our window by one position to the right and re-compute the new hash value. </p><p>We continue doing this until we find a match within our search string. Of course - re-computing each has for each string within our search string is incredibly inefficient, so we must find a way of computing these hash values without needing to do re-work. </p><p><strong>4. Efficient Hash Updates</strong>: Instead of recalculating the hash from scratch for every new position, the algorithm uses a rolling hash&#8212;a method that efficiently updates the hash value when the window moves. </p><p>Let&#8217;s once again use our earlier example. Assuming that we already checked the first window (i.e. &#8216;this&#8217; with hash 440) which resulted in a mismatch to our pattern match (i.e. &#8216;test with hash 448), we move on to generating a new hash for the next window. Notice though, that instead of re-computing a brand new hash from scratch &#8212; we can use the fact that our old window contains 3 of the same characters as our new 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_!wp5P!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268f0028-3a00-4e15-8e26-a0d4a6658ae8_963x420.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wp5P!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268f0028-3a00-4e15-8e26-a0d4a6658ae8_963x420.png 424w, https://substackcdn.com/image/fetch/$s_!wp5P!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268f0028-3a00-4e15-8e26-a0d4a6658ae8_963x420.png 848w, https://substackcdn.com/image/fetch/$s_!wp5P!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268f0028-3a00-4e15-8e26-a0d4a6658ae8_963x420.png 1272w, https://substackcdn.com/image/fetch/$s_!wp5P!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268f0028-3a00-4e15-8e26-a0d4a6658ae8_963x420.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wp5P!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268f0028-3a00-4e15-8e26-a0d4a6658ae8_963x420.png" width="963" height="420" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/268f0028-3a00-4e15-8e26-a0d4a6658ae8_963x420.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:420,&quot;width&quot;:963,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:25714,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wp5P!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268f0028-3a00-4e15-8e26-a0d4a6658ae8_963x420.png 424w, https://substackcdn.com/image/fetch/$s_!wp5P!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268f0028-3a00-4e15-8e26-a0d4a6658ae8_963x420.png 848w, https://substackcdn.com/image/fetch/$s_!wp5P!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268f0028-3a00-4e15-8e26-a0d4a6658ae8_963x420.png 1272w, https://substackcdn.com/image/fetch/$s_!wp5P!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268f0028-3a00-4e15-8e26-a0d4a6658ae8_963x420.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></figure></div><p></p><p>So - how can we use this information to save us time in generating a new hash? Well - to generate a new hash, we use the formula:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tmjO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb17a5a3-8ac3-4854-93dc-3355a603024a_759x257.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tmjO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb17a5a3-8ac3-4854-93dc-3355a603024a_759x257.png 424w, https://substackcdn.com/image/fetch/$s_!tmjO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb17a5a3-8ac3-4854-93dc-3355a603024a_759x257.png 848w, https://substackcdn.com/image/fetch/$s_!tmjO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb17a5a3-8ac3-4854-93dc-3355a603024a_759x257.png 1272w, https://substackcdn.com/image/fetch/$s_!tmjO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb17a5a3-8ac3-4854-93dc-3355a603024a_759x257.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tmjO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb17a5a3-8ac3-4854-93dc-3355a603024a_759x257.png" width="759" height="257" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/db17a5a3-8ac3-4854-93dc-3355a603024a_759x257.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:257,&quot;width&quot;:759,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:21025,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tmjO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb17a5a3-8ac3-4854-93dc-3355a603024a_759x257.png 424w, https://substackcdn.com/image/fetch/$s_!tmjO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb17a5a3-8ac3-4854-93dc-3355a603024a_759x257.png 848w, https://substackcdn.com/image/fetch/$s_!tmjO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb17a5a3-8ac3-4854-93dc-3355a603024a_759x257.png 1272w, https://substackcdn.com/image/fetch/$s_!tmjO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb17a5a3-8ac3-4854-93dc-3355a603024a_759x257.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></figure></div><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sSFf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f0e508-767e-4e35-8186-ac3db9043113_683x160.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sSFf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f0e508-767e-4e35-8186-ac3db9043113_683x160.png 424w, https://substackcdn.com/image/fetch/$s_!sSFf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f0e508-767e-4e35-8186-ac3db9043113_683x160.png 848w, https://substackcdn.com/image/fetch/$s_!sSFf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f0e508-767e-4e35-8186-ac3db9043113_683x160.png 1272w, https://substackcdn.com/image/fetch/$s_!sSFf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f0e508-767e-4e35-8186-ac3db9043113_683x160.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sSFf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f0e508-767e-4e35-8186-ac3db9043113_683x160.png" width="533" height="124.86090775988286" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a6f0e508-767e-4e35-8186-ac3db9043113_683x160.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:160,&quot;width&quot;:683,&quot;resizeWidth&quot;:533,&quot;bytes&quot;:16575,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sSFf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f0e508-767e-4e35-8186-ac3db9043113_683x160.png 424w, https://substackcdn.com/image/fetch/$s_!sSFf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f0e508-767e-4e35-8186-ac3db9043113_683x160.png 848w, https://substackcdn.com/image/fetch/$s_!sSFf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f0e508-767e-4e35-8186-ac3db9043113_683x160.png 1272w, https://substackcdn.com/image/fetch/$s_!sSFf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6f0e508-767e-4e35-8186-ac3db9043113_683x160.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>As an example, after computing the hash for &#8216;this&#8217; - the next pattern will be &#8216;his &#8217; and thus the new hash will be:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!cgyH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed21d7ae-01a5-4c4d-9074-05e09c8fb7d8_810x209.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cgyH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed21d7ae-01a5-4c4d-9074-05e09c8fb7d8_810x209.png 424w, https://substackcdn.com/image/fetch/$s_!cgyH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed21d7ae-01a5-4c4d-9074-05e09c8fb7d8_810x209.png 848w, https://substackcdn.com/image/fetch/$s_!cgyH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed21d7ae-01a5-4c4d-9074-05e09c8fb7d8_810x209.png 1272w, https://substackcdn.com/image/fetch/$s_!cgyH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed21d7ae-01a5-4c4d-9074-05e09c8fb7d8_810x209.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cgyH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed21d7ae-01a5-4c4d-9074-05e09c8fb7d8_810x209.png" width="631" height="162.81358024691357" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ed21d7ae-01a5-4c4d-9074-05e09c8fb7d8_810x209.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:209,&quot;width&quot;:810,&quot;resizeWidth&quot;:631,&quot;bytes&quot;:15268,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!cgyH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed21d7ae-01a5-4c4d-9074-05e09c8fb7d8_810x209.png 424w, https://substackcdn.com/image/fetch/$s_!cgyH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed21d7ae-01a5-4c4d-9074-05e09c8fb7d8_810x209.png 848w, https://substackcdn.com/image/fetch/$s_!cgyH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed21d7ae-01a5-4c4d-9074-05e09c8fb7d8_810x209.png 1272w, https://substackcdn.com/image/fetch/$s_!cgyH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed21d7ae-01a5-4c4d-9074-05e09c8fb7d8_810x209.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We thus save a ton of work! </p><p>That pretty much covers how the Robin-Karp algorithm works. It&#8217;s not particularly fast when it comes to regular string searches, but one of the reasons why it&#8217;s well-known is due to the fact that it can be generalized for other applications, such as searching for multiple patterns at once or performing fingerprinting in areas like document similarity detection. By leveraging hash functions, the Robin-Karp algorithm excels in scenarios where preprocessing multiple patterns or comparing large sets of data is necessary, making it a versatile tool beyond simple string matching.</p><h2>Some Other Interesting Algorithms</h2><h3>Knuth-Morris-Pratt (KMP)</h3><p>Another key algorithm is the Knuth-Morris-Pratt (KMP). Like the Boyer-Moore algorithm, KMP uses the structure of the pattern to avoid unnecessary comparisons, but it works in a slightly different way.</p><p>The key idea behind KMP is to preprocess the pattern to gain insight into where the pattern can be safely shifted after a mismatch. It does this by creating a <strong>prefix table</strong> (also called a "partial match table"). For each position in the pattern, the prefix table records the length of the longest prefix that is also a suffix. As the algorithm searches for the pattern in the text, it compares the pattern&#8217;s characters with the characters of the text one by one. When a mismatch occurs, KMP looks at the prefix table to determine how far to shift the pattern.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xVEg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f521d87-d837-4e32-8849-1a779edf3b13_700x700.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xVEg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f521d87-d837-4e32-8849-1a779edf3b13_700x700.png 424w, https://substackcdn.com/image/fetch/$s_!xVEg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f521d87-d837-4e32-8849-1a779edf3b13_700x700.png 848w, https://substackcdn.com/image/fetch/$s_!xVEg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f521d87-d837-4e32-8849-1a779edf3b13_700x700.png 1272w, https://substackcdn.com/image/fetch/$s_!xVEg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f521d87-d837-4e32-8849-1a779edf3b13_700x700.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xVEg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f521d87-d837-4e32-8849-1a779edf3b13_700x700.png" width="700" height="700" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5f521d87-d837-4e32-8849-1a779edf3b13_700x700.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:700,&quot;width&quot;:700,&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_!xVEg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f521d87-d837-4e32-8849-1a779edf3b13_700x700.png 424w, https://substackcdn.com/image/fetch/$s_!xVEg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f521d87-d837-4e32-8849-1a779edf3b13_700x700.png 848w, https://substackcdn.com/image/fetch/$s_!xVEg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f521d87-d837-4e32-8849-1a779edf3b13_700x700.png 1272w, https://substackcdn.com/image/fetch/$s_!xVEg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f521d87-d837-4e32-8849-1a779edf3b13_700x700.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">Image Source: https://yuminlee2.medium.com/knuth-morris-pratt-kmp-algorithm-string-matching-fb2a3ec6d682 </figcaption></figure></div><p>By shifting the pattern forward without re-examining previously matched characters, KMP ensures that every character of the text and pattern is checked only once, which leads to a linear time complexity.</p><h3>Aho-Corasick</h3><p>Aho-Corasick works by preprocessing all the patterns you want to search for into a special data structure called a trie (prefix tree). Then, it builds an automaton (a machine-like structure) from the trie, which allows it to quickly find all occurrences of any of the patterns in the text in one pass.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-jBr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0f6ed5-7e2f-45ca-ac81-65dc214192db_1257x573.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-jBr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0f6ed5-7e2f-45ca-ac81-65dc214192db_1257x573.png 424w, https://substackcdn.com/image/fetch/$s_!-jBr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0f6ed5-7e2f-45ca-ac81-65dc214192db_1257x573.png 848w, https://substackcdn.com/image/fetch/$s_!-jBr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0f6ed5-7e2f-45ca-ac81-65dc214192db_1257x573.png 1272w, https://substackcdn.com/image/fetch/$s_!-jBr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0f6ed5-7e2f-45ca-ac81-65dc214192db_1257x573.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-jBr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0f6ed5-7e2f-45ca-ac81-65dc214192db_1257x573.png" width="1257" height="573" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9b0f6ed5-7e2f-45ca-ac81-65dc214192db_1257x573.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:573,&quot;width&quot;:1257,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:614901,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-jBr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0f6ed5-7e2f-45ca-ac81-65dc214192db_1257x573.png 424w, https://substackcdn.com/image/fetch/$s_!-jBr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0f6ed5-7e2f-45ca-ac81-65dc214192db_1257x573.png 848w, https://substackcdn.com/image/fetch/$s_!-jBr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0f6ed5-7e2f-45ca-ac81-65dc214192db_1257x573.png 1272w, https://substackcdn.com/image/fetch/$s_!-jBr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b0f6ed5-7e2f-45ca-ac81-65dc214192db_1257x573.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">Image Source: https://slideplayer.com/slide/14996593/ </figcaption></figure></div><p>After the trie is built, the next step is to add <strong>failure links</strong> to it. These links are used to "fall back" to a previous state when a character mismatch occurs while searching the text. </p><p>For each character in the text:</p><ul><li><p>If the character matches a transition in the trie, it follows the link.</p></li><li><p>If there is a mismatch, the failure link is used to skip to a previous state and resume the search from there.</p></li></ul><p>At each step, the failure links guide us to the next possible matching state, so we never have to start over and all the matches are found efficiently. The trie and failure links allow the algorithm to quickly skip over unnecessary checks, making it much faster than checking each pattern one by one, especially when dealing with large texts and multiple patterns.</p><h3>Z-Algorithm</h3><p>The Z-algorithm is similar albeit a bit more efficient than the KMP algorithm. It finds matching substrings by building an array that tells it how much of the string matches its own prefix, starting from each position. This array is called the <strong>Z-array</strong>. For each position in the string, the value in the Z-array represents the length of the longest substring that starts at that position and matches the beginning of the string.</p><p>To build the Z-array, the algorithm uses two main ideas: it looks at the matches starting from the current position and uses information from previous matches to avoid redundant comparisons. A quick and straight-to-the-point overview of how to construct a z-array is provided below:</p><div id="youtube2-Tg1w-0a1xew" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;Tg1w-0a1xew&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/Tg1w-0a1xew?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><p>Let&#8217;s go through a simple example to show how the algorithm works:</p><ol><li><p><strong>Concatenate the pattern and text: </strong>As an example, let&#8217;s go through a pattern and text shown below:</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mc7P!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb94746-ef78-444e-babc-04c3b3b2f0bf_668x120.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mc7P!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb94746-ef78-444e-babc-04c3b3b2f0bf_668x120.png 424w, https://substackcdn.com/image/fetch/$s_!mc7P!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb94746-ef78-444e-babc-04c3b3b2f0bf_668x120.png 848w, https://substackcdn.com/image/fetch/$s_!mc7P!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb94746-ef78-444e-babc-04c3b3b2f0bf_668x120.png 1272w, https://substackcdn.com/image/fetch/$s_!mc7P!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb94746-ef78-444e-babc-04c3b3b2f0bf_668x120.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mc7P!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb94746-ef78-444e-babc-04c3b3b2f0bf_668x120.png" width="548" height="98.44311377245509" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3cb94746-ef78-444e-babc-04c3b3b2f0bf_668x120.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:120,&quot;width&quot;:668,&quot;resizeWidth&quot;:548,&quot;bytes&quot;:5687,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mc7P!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb94746-ef78-444e-babc-04c3b3b2f0bf_668x120.png 424w, https://substackcdn.com/image/fetch/$s_!mc7P!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb94746-ef78-444e-babc-04c3b3b2f0bf_668x120.png 848w, https://substackcdn.com/image/fetch/$s_!mc7P!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb94746-ef78-444e-babc-04c3b3b2f0bf_668x120.png 1272w, https://substackcdn.com/image/fetch/$s_!mc7P!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb94746-ef78-444e-babc-04c3b3b2f0bf_668x120.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We use the special character &#8216;$&#8217; to separate our pattern from the text and the resultant string is:</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!f6Yp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8e8ad8-213a-4fa0-b336-095c37658f07_387x80.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!f6Yp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8e8ad8-213a-4fa0-b336-095c37658f07_387x80.png 424w, https://substackcdn.com/image/fetch/$s_!f6Yp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8e8ad8-213a-4fa0-b336-095c37658f07_387x80.png 848w, https://substackcdn.com/image/fetch/$s_!f6Yp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8e8ad8-213a-4fa0-b336-095c37658f07_387x80.png 1272w, https://substackcdn.com/image/fetch/$s_!f6Yp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8e8ad8-213a-4fa0-b336-095c37658f07_387x80.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!f6Yp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8e8ad8-213a-4fa0-b336-095c37658f07_387x80.png" width="305" height="63.049095607235145" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9b8e8ad8-213a-4fa0-b336-095c37658f07_387x80.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:80,&quot;width&quot;:387,&quot;resizeWidth&quot;:305,&quot;bytes&quot;:3887,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!f6Yp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8e8ad8-213a-4fa0-b336-095c37658f07_387x80.png 424w, https://substackcdn.com/image/fetch/$s_!f6Yp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8e8ad8-213a-4fa0-b336-095c37658f07_387x80.png 848w, https://substackcdn.com/image/fetch/$s_!f6Yp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8e8ad8-213a-4fa0-b336-095c37658f07_387x80.png 1272w, https://substackcdn.com/image/fetch/$s_!f6Yp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b8e8ad8-213a-4fa0-b336-095c37658f07_387x80.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p><p>This is the string we will compute our Z-array for. </p></li><li><p><strong>Initialize the Z-array: </strong>Now we compute the Z-array for our concatenated string:</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8l66!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa4382f0-05ca-4deb-8c02-3f39db9ab0cc_925x526.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8l66!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa4382f0-05ca-4deb-8c02-3f39db9ab0cc_925x526.png 424w, https://substackcdn.com/image/fetch/$s_!8l66!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa4382f0-05ca-4deb-8c02-3f39db9ab0cc_925x526.png 848w, https://substackcdn.com/image/fetch/$s_!8l66!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa4382f0-05ca-4deb-8c02-3f39db9ab0cc_925x526.png 1272w, https://substackcdn.com/image/fetch/$s_!8l66!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa4382f0-05ca-4deb-8c02-3f39db9ab0cc_925x526.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8l66!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa4382f0-05ca-4deb-8c02-3f39db9ab0cc_925x526.png" width="925" height="526" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fa4382f0-05ca-4deb-8c02-3f39db9ab0cc_925x526.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:526,&quot;width&quot;:925,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:58430,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8l66!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa4382f0-05ca-4deb-8c02-3f39db9ab0cc_925x526.png 424w, https://substackcdn.com/image/fetch/$s_!8l66!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa4382f0-05ca-4deb-8c02-3f39db9ab0cc_925x526.png 848w, https://substackcdn.com/image/fetch/$s_!8l66!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa4382f0-05ca-4deb-8c02-3f39db9ab0cc_925x526.png 1272w, https://substackcdn.com/image/fetch/$s_!8l66!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa4382f0-05ca-4deb-8c02-3f39db9ab0cc_925x526.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></figure></div><h4><strong>Our z-array is thus [10, 1, 0, 0, 0, 3, 1, 0, 2, 1].</strong></h4><p></p></li><li><p><strong>Use the Z-array: </strong>The goal of the Z-algorithm is often to find where the pattern <code>P</code> occurs in the text <code>T. </code>To do this, we  look at the Z-array values starting after the separator $ (which is at position 3). We know the length of the pattern <strong>P = "aab"</strong> is 3 &#8212; so we check for Z-values that are equal to or greater than 3, as they indicate a match of the pattern starting at those positions in the text. Since we see <strong>Z[5] = 3</strong>, we know that our pattern occurs within the substring.</p></li></ol><p>That pretty much summarizes how it works. </p><p>The Z-algorithm is efficient because it computes the Z-array in linear time. It&#8217;s often used for efficiently searching for multiple patterns within the search text, as well as when solving problems like rotations and palindromic substrings. For simpler single-match tasks or short patterns, the Boyer-Moore algorithms still reigns supreme. </p><p>I&#8217;m going to end this post here, as it&#8217;s already incredibly long &#8212; but I highly recommend anyone who&#8217;s interested in this area to take a more in-depth look at each of the algorithms I overviewed above. If you liked enjoyed reading this post, please like and subscribe!</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Photon-Lines Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Algorithms for Optimization (Explained Simply): Part 2 - Line Search and the Trust Region Method]]></title><description><![CDATA[A visual-focused and intuitive overview of important optimization algorithms. This blog post focuses explaining the details behind the line search and the trust region method.]]></description><link>https://photonlines.substack.com/p/algorithms-for-optimization-explained-f26</link><guid isPermaLink="false">https://photonlines.substack.com/p/algorithms-for-optimization-explained-f26</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Fri, 25 Oct 2024 15:52:50 GMT</pubDate><enclosure url="https://substackcdn.com/image/youtube/w_728,c_limit/3d6DsjIBzJ4" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let&#8217;s continue on with our overview and series focused on optimization algorithms. If you haven&#8217;t read <a href="https://photonlines.substack.com/p/algorithms-for-optimization-explained">part 1</a>, I highly recommend you go through it since it introduces some key concepts which we&#8217;ll need to familiarize yourself with in order to understand this section. Once again, a lot of this content is inspired by the book <a href="https://algorithmsbook.com/optimization/files/optimization.pdf">Algorithms for Optimization</a> which I highly recommend. </p><p>In this section, we&#8217;ll go over some key algorithms which actually use <strong>local models </strong>(like the derivative) to incrementally improve a design by making small adjustments. We start with methods that pick a direction to move in (based on local information) and then decide how far to move. </p><h3>Line Search</h3><p>Line search method is an iterative approach of finding a local minimum which basically:</p><ol><li><p>Chooses a direction to step into. Since we are searching for a minimum, this is a <strong>descent direction </strong>and we compute it using local gradient / derivative / Taylor approximation values of our function.</p></li><li><p>Chooses an appropriate step size to move into.</p></li><li><p>Repeats steps 1 and 2 until the terminal conditions are met (i.e. we are close or at a local minimum &amp; the derivative or gradient vectors are close to 0).</p></li></ol><p>That&#8217;s pretty much it. Although some implementation details will differ (like computing our direction / step size) &#8211; the gist is basically the same. All we&#8217;re doing is using local information to compute appropriate step sizes and directions and walking into these directions. </p><div><hr></div><h3>Knowledge Review </h3><h4><strong>Taylor Approximation:</strong></h4><p>A Taylor approximation is a way to estimate the value of a function near a specific point using the derivatives or derivative values located close to that point. It's basically using the local properties of an area around a function point to approximate the shape of the actual function. The key steps for this are outlined below:</p><ol><li><p>Pick a point p where you want to approximate the function.</p></li><li><p>Use Derivatives: Use the value of the function and its derivatives at that point to create the approximation.</p></li><li><p>Build the Polynomial: Combine these values into a polynomial. The more terms (derivatives) you use, the better the approximation.</p></li></ol><p>You can find a great intuition and explanation of Taylor series here (courtesy of 3Blue1Brown / Grant Sanderson):</p><div id="youtube2-3d6DsjIBzJ4" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;3d6DsjIBzJ4&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/3d6DsjIBzJ4?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><h4><strong>Gradient:</strong></h4><p>The <strong>gradient </strong>is the generalization of the derivative and gives us the direction of steepest increase of a function. In the instance of a scalar function 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_!ua8a!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96256137-5c28-4648-b844-3a913cbc74aa_599x425.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ua8a!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96256137-5c28-4648-b844-3a913cbc74aa_599x425.png 424w, https://substackcdn.com/image/fetch/$s_!ua8a!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96256137-5c28-4648-b844-3a913cbc74aa_599x425.png 848w, https://substackcdn.com/image/fetch/$s_!ua8a!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96256137-5c28-4648-b844-3a913cbc74aa_599x425.png 1272w, https://substackcdn.com/image/fetch/$s_!ua8a!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96256137-5c28-4648-b844-3a913cbc74aa_599x425.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ua8a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96256137-5c28-4648-b844-3a913cbc74aa_599x425.png" width="459" height="325.6677796327212" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/96256137-5c28-4648-b844-3a913cbc74aa_599x425.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:425,&quot;width&quot;:599,&quot;resizeWidth&quot;:459,&quot;bytes&quot;:149545,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ua8a!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96256137-5c28-4648-b844-3a913cbc74aa_599x425.png 424w, https://substackcdn.com/image/fetch/$s_!ua8a!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96256137-5c28-4648-b844-3a913cbc74aa_599x425.png 848w, https://substackcdn.com/image/fetch/$s_!ua8a!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96256137-5c28-4648-b844-3a913cbc74aa_599x425.png 1272w, https://substackcdn.com/image/fetch/$s_!ua8a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96256137-5c28-4648-b844-3a913cbc74aa_599x425.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></figure></div><p>The gradient plotted over its surface is:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Xk1U!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e6410b-f448-4fb4-b2bd-6bb41bda4965_941x601.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Xk1U!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e6410b-f448-4fb4-b2bd-6bb41bda4965_941x601.png 424w, https://substackcdn.com/image/fetch/$s_!Xk1U!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e6410b-f448-4fb4-b2bd-6bb41bda4965_941x601.png 848w, https://substackcdn.com/image/fetch/$s_!Xk1U!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e6410b-f448-4fb4-b2bd-6bb41bda4965_941x601.png 1272w, https://substackcdn.com/image/fetch/$s_!Xk1U!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e6410b-f448-4fb4-b2bd-6bb41bda4965_941x601.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Xk1U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e6410b-f448-4fb4-b2bd-6bb41bda4965_941x601.png" width="513" height="327.643995749203" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/11e6410b-f448-4fb4-b2bd-6bb41bda4965_941x601.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:601,&quot;width&quot;:941,&quot;resizeWidth&quot;:513,&quot;bytes&quot;:276265,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Xk1U!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e6410b-f448-4fb4-b2bd-6bb41bda4965_941x601.png 424w, https://substackcdn.com/image/fetch/$s_!Xk1U!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e6410b-f448-4fb4-b2bd-6bb41bda4965_941x601.png 848w, https://substackcdn.com/image/fetch/$s_!Xk1U!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e6410b-f448-4fb4-b2bd-6bb41bda4965_941x601.png 1272w, https://substackcdn.com/image/fetch/$s_!Xk1U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e6410b-f448-4fb4-b2bd-6bb41bda4965_941x601.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></figure></div><p></p><p>The <strong>gradient </strong>of f at x is written &#8711; f(x) and each component of the resulting gradient vector is the partial derivative of f with respect to that component:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lviz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bc1fdb0-fd51-45b5-bfc8-f43451b32483_553x92.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lviz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bc1fdb0-fd51-45b5-bfc8-f43451b32483_553x92.png 424w, https://substackcdn.com/image/fetch/$s_!lviz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bc1fdb0-fd51-45b5-bfc8-f43451b32483_553x92.png 848w, https://substackcdn.com/image/fetch/$s_!lviz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bc1fdb0-fd51-45b5-bfc8-f43451b32483_553x92.png 1272w, https://substackcdn.com/image/fetch/$s_!lviz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bc1fdb0-fd51-45b5-bfc8-f43451b32483_553x92.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lviz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bc1fdb0-fd51-45b5-bfc8-f43451b32483_553x92.png" width="485" height="80.6871609403255" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2bc1fdb0-fd51-45b5-bfc8-f43451b32483_553x92.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:92,&quot;width&quot;:553,&quot;resizeWidth&quot;:485,&quot;bytes&quot;:34320,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lviz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bc1fdb0-fd51-45b5-bfc8-f43451b32483_553x92.png 424w, https://substackcdn.com/image/fetch/$s_!lviz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bc1fdb0-fd51-45b5-bfc8-f43451b32483_553x92.png 848w, https://substackcdn.com/image/fetch/$s_!lviz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bc1fdb0-fd51-45b5-bfc8-f43451b32483_553x92.png 1272w, https://substackcdn.com/image/fetch/$s_!lviz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bc1fdb0-fd51-45b5-bfc8-f43451b32483_553x92.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>In the above instance, we&#8217;re simply computing the partial derivative of x with regards to its variables and putting it in vector form. Once again &#8211; this give us a directional vector which points in the direction where the function increases most (which we can also denote as the &#8216;steepness&#8217; of the function). To approach a minimum or downward direction, we simply have to follow take the opposite vector &#8211; another great example showing the gradient of a 2-dimensional function (a function composed of 2 independent variables) is provided 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_!2tfG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b9a83f3-ce7c-46c3-b4d2-de4c3c7c348b_1581x1300.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2tfG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b9a83f3-ce7c-46c3-b4d2-de4c3c7c348b_1581x1300.png 424w, https://substackcdn.com/image/fetch/$s_!2tfG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b9a83f3-ce7c-46c3-b4d2-de4c3c7c348b_1581x1300.png 848w, https://substackcdn.com/image/fetch/$s_!2tfG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b9a83f3-ce7c-46c3-b4d2-de4c3c7c348b_1581x1300.png 1272w, https://substackcdn.com/image/fetch/$s_!2tfG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b9a83f3-ce7c-46c3-b4d2-de4c3c7c348b_1581x1300.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2tfG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b9a83f3-ce7c-46c3-b4d2-de4c3c7c348b_1581x1300.png" width="485" height="398.72596153846155" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9b9a83f3-ce7c-46c3-b4d2-de4c3c7c348b_1581x1300.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1197,&quot;width&quot;:1456,&quot;resizeWidth&quot;:485,&quot;bytes&quot;:787723,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!2tfG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b9a83f3-ce7c-46c3-b4d2-de4c3c7c348b_1581x1300.png 424w, https://substackcdn.com/image/fetch/$s_!2tfG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b9a83f3-ce7c-46c3-b4d2-de4c3c7c348b_1581x1300.png 848w, https://substackcdn.com/image/fetch/$s_!2tfG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b9a83f3-ce7c-46c3-b4d2-de4c3c7c348b_1581x1300.png 1272w, https://substackcdn.com/image/fetch/$s_!2tfG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b9a83f3-ce7c-46c3-b4d2-de4c3c7c348b_1581x1300.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></figure></div><div><hr></div><h4>Python Based Example</h4><p>Let&#8217;s get back to our line-search algorithm and outline a simple example which will show us the details of how line search can be implemented (using Python).</p><p>The function which we will attempt to minimize is provided below:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TUlB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a6a56a9-bf9f-44a5-990b-5b11a12e9d54_740x84.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TUlB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a6a56a9-bf9f-44a5-990b-5b11a12e9d54_740x84.png 424w, https://substackcdn.com/image/fetch/$s_!TUlB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a6a56a9-bf9f-44a5-990b-5b11a12e9d54_740x84.png 848w, https://substackcdn.com/image/fetch/$s_!TUlB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a6a56a9-bf9f-44a5-990b-5b11a12e9d54_740x84.png 1272w, https://substackcdn.com/image/fetch/$s_!TUlB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a6a56a9-bf9f-44a5-990b-5b11a12e9d54_740x84.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TUlB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a6a56a9-bf9f-44a5-990b-5b11a12e9d54_740x84.png" width="619" height="70.26486486486486" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9a6a56a9-bf9f-44a5-990b-5b11a12e9d54_740x84.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:84,&quot;width&quot;:740,&quot;resizeWidth&quot;:619,&quot;bytes&quot;:6244,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TUlB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a6a56a9-bf9f-44a5-990b-5b11a12e9d54_740x84.png 424w, https://substackcdn.com/image/fetch/$s_!TUlB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a6a56a9-bf9f-44a5-990b-5b11a12e9d54_740x84.png 848w, https://substackcdn.com/image/fetch/$s_!TUlB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a6a56a9-bf9f-44a5-990b-5b11a12e9d54_740x84.png 1272w, https://substackcdn.com/image/fetch/$s_!TUlB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a6a56a9-bf9f-44a5-990b-5b11a12e9d54_740x84.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The position we want to start on is <strong>(1, 2, 3)</strong> and our direction is <strong>[0, -1, -1]</strong>.</p><p>Let&#8217;s start off by writing some Python code:</p><pre><code>import numpy as np

# Define the original function
def original_function(x1, x2, x3):
    """Original function to minimize, given three variables."""
    return np.sin(x1 * x2) + np.exp(x2 + x3) - x3


# Initial point and direction
initial_point = np.array([1, 2, 3])
direction = np.array([0, -1, -1])</code></pre><p>Next, let&#8217;s redefine our original function into a single parameter optimization based on a computed step size and direction. To do this, we simply substitute our initial (x1, x2, x3) values (1,2,3) and sub in an appropriate step parameter for each one of our 3 independent variables (which will once again be in the step direction [0, -1, -1]). Our new objective function will be:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!w10q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4cb1f3d-7661-4302-84b6-05023ce2ca32_982x286.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!w10q!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4cb1f3d-7661-4302-84b6-05023ce2ca32_982x286.png 424w, https://substackcdn.com/image/fetch/$s_!w10q!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4cb1f3d-7661-4302-84b6-05023ce2ca32_982x286.png 848w, https://substackcdn.com/image/fetch/$s_!w10q!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4cb1f3d-7661-4302-84b6-05023ce2ca32_982x286.png 1272w, https://substackcdn.com/image/fetch/$s_!w10q!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4cb1f3d-7661-4302-84b6-05023ce2ca32_982x286.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!w10q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4cb1f3d-7661-4302-84b6-05023ce2ca32_982x286.png" width="692" height="201.5397148676171" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4cb1f3d-7661-4302-84b6-05023ce2ca32_982x286.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:286,&quot;width&quot;:982,&quot;resizeWidth&quot;:692,&quot;bytes&quot;:22960,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!w10q!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4cb1f3d-7661-4302-84b6-05023ce2ca32_982x286.png 424w, https://substackcdn.com/image/fetch/$s_!w10q!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4cb1f3d-7661-4302-84b6-05023ce2ca32_982x286.png 848w, https://substackcdn.com/image/fetch/$s_!w10q!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4cb1f3d-7661-4302-84b6-05023ce2ca32_982x286.png 1272w, https://substackcdn.com/image/fetch/$s_!w10q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4cb1f3d-7661-4302-84b6-05023ce2ca32_982x286.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We can determine the re-parametrized values of our (x1, x2, x3) variables which will now be:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-u6Z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9740e54-45e9-4b8f-96d1-c7d7e601f825_403x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-u6Z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9740e54-45e9-4b8f-96d1-c7d7e601f825_403x500.png 424w, https://substackcdn.com/image/fetch/$s_!-u6Z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9740e54-45e9-4b8f-96d1-c7d7e601f825_403x500.png 848w, https://substackcdn.com/image/fetch/$s_!-u6Z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9740e54-45e9-4b8f-96d1-c7d7e601f825_403x500.png 1272w, https://substackcdn.com/image/fetch/$s_!-u6Z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9740e54-45e9-4b8f-96d1-c7d7e601f825_403x500.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-u6Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9740e54-45e9-4b8f-96d1-c7d7e601f825_403x500.png" width="279" height="346.15384615384613" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c9740e54-45e9-4b8f-96d1-c7d7e601f825_403x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:403,&quot;resizeWidth&quot;:279,&quot;bytes&quot;:17570,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-u6Z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9740e54-45e9-4b8f-96d1-c7d7e601f825_403x500.png 424w, https://substackcdn.com/image/fetch/$s_!-u6Z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9740e54-45e9-4b8f-96d1-c7d7e601f825_403x500.png 848w, https://substackcdn.com/image/fetch/$s_!-u6Z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9740e54-45e9-4b8f-96d1-c7d7e601f825_403x500.png 1272w, https://substackcdn.com/image/fetch/$s_!-u6Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9740e54-45e9-4b8f-96d1-c7d7e601f825_403x500.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></figure></div><p>We sub in these values to get:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MImi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff78c20d6-8c39-42a1-9d8a-e6c37201c4d7_1096x229.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MImi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff78c20d6-8c39-42a1-9d8a-e6c37201c4d7_1096x229.png 424w, https://substackcdn.com/image/fetch/$s_!MImi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff78c20d6-8c39-42a1-9d8a-e6c37201c4d7_1096x229.png 848w, https://substackcdn.com/image/fetch/$s_!MImi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff78c20d6-8c39-42a1-9d8a-e6c37201c4d7_1096x229.png 1272w, https://substackcdn.com/image/fetch/$s_!MImi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff78c20d6-8c39-42a1-9d8a-e6c37201c4d7_1096x229.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MImi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff78c20d6-8c39-42a1-9d8a-e6c37201c4d7_1096x229.png" width="728" height="152.1094890510949" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f78c20d6-8c39-42a1-9d8a-e6c37201c4d7_1096x229.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:229,&quot;width&quot;:1096,&quot;resizeWidth&quot;:728,&quot;bytes&quot;:27793,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MImi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff78c20d6-8c39-42a1-9d8a-e6c37201c4d7_1096x229.png 424w, https://substackcdn.com/image/fetch/$s_!MImi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff78c20d6-8c39-42a1-9d8a-e6c37201c4d7_1096x229.png 848w, https://substackcdn.com/image/fetch/$s_!MImi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff78c20d6-8c39-42a1-9d8a-e6c37201c4d7_1096x229.png 1272w, https://substackcdn.com/image/fetch/$s_!MImi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff78c20d6-8c39-42a1-9d8a-e6c37201c4d7_1096x229.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We can simplify the above to get:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!e8qv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00ae42fe-5c7f-449c-a6d3-4268af397fb3_926x123.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!e8qv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00ae42fe-5c7f-449c-a6d3-4268af397fb3_926x123.png 424w, https://substackcdn.com/image/fetch/$s_!e8qv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00ae42fe-5c7f-449c-a6d3-4268af397fb3_926x123.png 848w, https://substackcdn.com/image/fetch/$s_!e8qv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00ae42fe-5c7f-449c-a6d3-4268af397fb3_926x123.png 1272w, https://substackcdn.com/image/fetch/$s_!e8qv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00ae42fe-5c7f-449c-a6d3-4268af397fb3_926x123.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!e8qv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00ae42fe-5c7f-449c-a6d3-4268af397fb3_926x123.png" width="654" height="86.87041036717062" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/00ae42fe-5c7f-449c-a6d3-4268af397fb3_926x123.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:123,&quot;width&quot;:926,&quot;resizeWidth&quot;:654,&quot;bytes&quot;:10452,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!e8qv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00ae42fe-5c7f-449c-a6d3-4268af397fb3_926x123.png 424w, https://substackcdn.com/image/fetch/$s_!e8qv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00ae42fe-5c7f-449c-a6d3-4268af397fb3_926x123.png 848w, https://substackcdn.com/image/fetch/$s_!e8qv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00ae42fe-5c7f-449c-a6d3-4268af397fb3_926x123.png 1272w, https://substackcdn.com/image/fetch/$s_!e8qv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F00ae42fe-5c7f-449c-a6d3-4268af397fb3_926x123.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Converting the above into python we get:</p><pre><code># Define the simplified objective function
def simplified_objective(step_size):
    """Objective function to minimize with respect to the step size."""
    return np.sin(2 - step_size) + np.exp(5 - 2 * step_size) + step_size - 3</code></pre><p>Finally we define our line search function and use it to find the optimal step size and our the minimal value present at this step:</p><pre><code># Line search algorithm
def line_search(original_func, initial_point, direction):

    # Define the objective function for line search
    def objective(step_size):
        # Compute the new point based on alpha and direction
        new_point = initial_point + step_size * direction
        # Returns a scalar by evaluating the original function at the new point
        return original_func(new_point[0], new_point[1], new_point[2])

    # Minimize the objective function
    from scipy.optimize import minimize_scalar
    result = minimize_scalar(objective)
    optimal_step_size = result.x

    # Compute the new point using the optimal alpha
    new_point = initial_point + optimal_step_size * direction

    return new_point, optimal_step_size


# Perform line search
new_point, optimal_step_size = line_search(original_function, initial_point, direction)

# Print the results
print(f"Optimal step_size: {optimal_step_size}")
print(f"New point after line search: {new_point}")

# Verify by evaluating the function at the new point
new_function_value = original_function(new_point[0], new_point[1], new_point[2])
print(f"Function value at new point: {new_function_value}")</code></pre><p>The final result which we get when we execute this is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NqSI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6781543-51a1-49bb-972e-97bb38f77600_1003x185.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NqSI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6781543-51a1-49bb-972e-97bb38f77600_1003x185.png 424w, https://substackcdn.com/image/fetch/$s_!NqSI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6781543-51a1-49bb-972e-97bb38f77600_1003x185.png 848w, https://substackcdn.com/image/fetch/$s_!NqSI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6781543-51a1-49bb-972e-97bb38f77600_1003x185.png 1272w, https://substackcdn.com/image/fetch/$s_!NqSI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6781543-51a1-49bb-972e-97bb38f77600_1003x185.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NqSI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6781543-51a1-49bb-972e-97bb38f77600_1003x185.png" width="646" height="119.15254237288136" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b6781543-51a1-49bb-972e-97bb38f77600_1003x185.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:185,&quot;width&quot;:1003,&quot;resizeWidth&quot;:646,&quot;bytes&quot;:22665,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!NqSI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6781543-51a1-49bb-972e-97bb38f77600_1003x185.png 424w, https://substackcdn.com/image/fetch/$s_!NqSI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6781543-51a1-49bb-972e-97bb38f77600_1003x185.png 848w, https://substackcdn.com/image/fetch/$s_!NqSI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6781543-51a1-49bb-972e-97bb38f77600_1003x185.png 1272w, https://substackcdn.com/image/fetch/$s_!NqSI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6781543-51a1-49bb-972e-97bb38f77600_1003x185.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>which is as expected.</p><h4>Another Example</h4><p>The above example may be a bit-convoluted for anyone not familiar with Python or programming, so let&#8217;s go through another example which is simpler and which doesn&#8217;t use any code.</p><p>Let&#8217;s say that we want to minimize the following function:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!cS5Q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a5b5649-40b6-493a-8f4a-8f6600fef2f8_334x63.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cS5Q!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a5b5649-40b6-493a-8f4a-8f6600fef2f8_334x63.png 424w, https://substackcdn.com/image/fetch/$s_!cS5Q!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a5b5649-40b6-493a-8f4a-8f6600fef2f8_334x63.png 848w, https://substackcdn.com/image/fetch/$s_!cS5Q!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a5b5649-40b6-493a-8f4a-8f6600fef2f8_334x63.png 1272w, https://substackcdn.com/image/fetch/$s_!cS5Q!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a5b5649-40b6-493a-8f4a-8f6600fef2f8_334x63.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cS5Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a5b5649-40b6-493a-8f4a-8f6600fef2f8_334x63.png" width="256" height="48.287425149700596" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3a5b5649-40b6-493a-8f4a-8f6600fef2f8_334x63.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:63,&quot;width&quot;:334,&quot;resizeWidth&quot;:256,&quot;bytes&quot;:3707,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!cS5Q!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a5b5649-40b6-493a-8f4a-8f6600fef2f8_334x63.png 424w, https://substackcdn.com/image/fetch/$s_!cS5Q!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a5b5649-40b6-493a-8f4a-8f6600fef2f8_334x63.png 848w, https://substackcdn.com/image/fetch/$s_!cS5Q!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a5b5649-40b6-493a-8f4a-8f6600fef2f8_334x63.png 1272w, https://substackcdn.com/image/fetch/$s_!cS5Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a5b5649-40b6-493a-8f4a-8f6600fef2f8_334x63.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Step 1: </strong>first, we need to choose our <strong>initial point. </strong>Here, we&#8217;ll start with 0:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!EVVR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F005f998b-032d-48c0-8be4-4b3fb93165ef_118x69.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!EVVR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F005f998b-032d-48c0-8be4-4b3fb93165ef_118x69.png 424w, https://substackcdn.com/image/fetch/$s_!EVVR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F005f998b-032d-48c0-8be4-4b3fb93165ef_118x69.png 848w, https://substackcdn.com/image/fetch/$s_!EVVR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F005f998b-032d-48c0-8be4-4b3fb93165ef_118x69.png 1272w, https://substackcdn.com/image/fetch/$s_!EVVR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F005f998b-032d-48c0-8be4-4b3fb93165ef_118x69.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!EVVR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F005f998b-032d-48c0-8be4-4b3fb93165ef_118x69.png" width="92" height="53.79661016949152" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/005f998b-032d-48c0-8be4-4b3fb93165ef_118x69.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:69,&quot;width&quot;:118,&quot;resizeWidth&quot;:92,&quot;bytes&quot;:1588,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!EVVR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F005f998b-032d-48c0-8be4-4b3fb93165ef_118x69.png 424w, https://substackcdn.com/image/fetch/$s_!EVVR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F005f998b-032d-48c0-8be4-4b3fb93165ef_118x69.png 848w, https://substackcdn.com/image/fetch/$s_!EVVR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F005f998b-032d-48c0-8be4-4b3fb93165ef_118x69.png 1272w, https://substackcdn.com/image/fetch/$s_!EVVR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F005f998b-032d-48c0-8be4-4b3fb93165ef_118x69.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Step 2: </strong>We choose a search direction (which we label as p<sub>k</sub>). In this case, we can use the <strong>negative gradient</strong> as our search direction (since we&#8217;re trying to minimize our function and the gradient points in the steepest direction). We can obtain the gradient by taking the derivative of our original function f(x) = (x &#8211; 2)<sup>2</sup> + 1 which results in:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qgLi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12d21044-5013-4e56-8d84-ddf407b12221_340x84.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qgLi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12d21044-5013-4e56-8d84-ddf407b12221_340x84.png 424w, https://substackcdn.com/image/fetch/$s_!qgLi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12d21044-5013-4e56-8d84-ddf407b12221_340x84.png 848w, https://substackcdn.com/image/fetch/$s_!qgLi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12d21044-5013-4e56-8d84-ddf407b12221_340x84.png 1272w, https://substackcdn.com/image/fetch/$s_!qgLi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12d21044-5013-4e56-8d84-ddf407b12221_340x84.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qgLi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12d21044-5013-4e56-8d84-ddf407b12221_340x84.png" width="262" height="64.72941176470589" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/12d21044-5013-4e56-8d84-ddf407b12221_340x84.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:84,&quot;width&quot;:340,&quot;resizeWidth&quot;:262,&quot;bytes&quot;:4019,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qgLi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12d21044-5013-4e56-8d84-ddf407b12221_340x84.png 424w, https://substackcdn.com/image/fetch/$s_!qgLi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12d21044-5013-4e56-8d84-ddf407b12221_340x84.png 848w, https://substackcdn.com/image/fetch/$s_!qgLi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12d21044-5013-4e56-8d84-ddf407b12221_340x84.png 1272w, https://substackcdn.com/image/fetch/$s_!qgLi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12d21044-5013-4e56-8d84-ddf407b12221_340x84.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>At x<sub>0</sub>, the gradient is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!G7ah!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b223d6b-0a34-4a75-b759-c78dff5e7a47_436x87.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!G7ah!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b223d6b-0a34-4a75-b759-c78dff5e7a47_436x87.png 424w, https://substackcdn.com/image/fetch/$s_!G7ah!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b223d6b-0a34-4a75-b759-c78dff5e7a47_436x87.png 848w, https://substackcdn.com/image/fetch/$s_!G7ah!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b223d6b-0a34-4a75-b759-c78dff5e7a47_436x87.png 1272w, https://substackcdn.com/image/fetch/$s_!G7ah!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b223d6b-0a34-4a75-b759-c78dff5e7a47_436x87.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!G7ah!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b223d6b-0a34-4a75-b759-c78dff5e7a47_436x87.png" width="314" height="62.65596330275229" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2b223d6b-0a34-4a75-b759-c78dff5e7a47_436x87.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:87,&quot;width&quot;:436,&quot;resizeWidth&quot;:314,&quot;bytes&quot;:4770,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!G7ah!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b223d6b-0a34-4a75-b759-c78dff5e7a47_436x87.png 424w, https://substackcdn.com/image/fetch/$s_!G7ah!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b223d6b-0a34-4a75-b759-c78dff5e7a47_436x87.png 848w, https://substackcdn.com/image/fetch/$s_!G7ah!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b223d6b-0a34-4a75-b759-c78dff5e7a47_436x87.png 1272w, https://substackcdn.com/image/fetch/$s_!G7ah!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b223d6b-0a34-4a75-b759-c78dff5e7a47_436x87.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>So, since we want to negate the gradient we get -(-4) = 4 and he search direction is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6Zy8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb506aa4b-5f9e-4e5b-be12-2081c328f383_299x78.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6Zy8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb506aa4b-5f9e-4e5b-be12-2081c328f383_299x78.png 424w, https://substackcdn.com/image/fetch/$s_!6Zy8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb506aa4b-5f9e-4e5b-be12-2081c328f383_299x78.png 848w, https://substackcdn.com/image/fetch/$s_!6Zy8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb506aa4b-5f9e-4e5b-be12-2081c328f383_299x78.png 1272w, https://substackcdn.com/image/fetch/$s_!6Zy8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb506aa4b-5f9e-4e5b-be12-2081c328f383_299x78.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6Zy8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb506aa4b-5f9e-4e5b-be12-2081c328f383_299x78.png" width="205" height="53.47826086956522" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b506aa4b-5f9e-4e5b-be12-2081c328f383_299x78.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:78,&quot;width&quot;:299,&quot;resizeWidth&quot;:205,&quot;bytes&quot;:3669,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6Zy8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb506aa4b-5f9e-4e5b-be12-2081c328f383_299x78.png 424w, https://substackcdn.com/image/fetch/$s_!6Zy8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb506aa4b-5f9e-4e5b-be12-2081c328f383_299x78.png 848w, https://substackcdn.com/image/fetch/$s_!6Zy8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb506aa4b-5f9e-4e5b-be12-2081c328f383_299x78.png 1272w, https://substackcdn.com/image/fetch/$s_!6Zy8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb506aa4b-5f9e-4e5b-be12-2081c328f383_299x78.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Step 3:</strong> Perform a line search to find the step length (which we denote as &#945;). To do this, we have to solve the problem of finding the step length &#945; that minimizes:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!u8Sy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2131a781-48e4-447e-96a2-d562e93964c2_207x74.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!u8Sy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2131a781-48e4-447e-96a2-d562e93964c2_207x74.png 424w, https://substackcdn.com/image/fetch/$s_!u8Sy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2131a781-48e4-447e-96a2-d562e93964c2_207x74.png 848w, https://substackcdn.com/image/fetch/$s_!u8Sy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2131a781-48e4-447e-96a2-d562e93964c2_207x74.png 1272w, https://substackcdn.com/image/fetch/$s_!u8Sy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2131a781-48e4-447e-96a2-d562e93964c2_207x74.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!u8Sy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2131a781-48e4-447e-96a2-d562e93964c2_207x74.png" width="161" height="57.55555555555556" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2131a781-48e4-447e-96a2-d562e93964c2_207x74.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:74,&quot;width&quot;:207,&quot;resizeWidth&quot;:161,&quot;bytes&quot;:3449,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!u8Sy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2131a781-48e4-447e-96a2-d562e93964c2_207x74.png 424w, https://substackcdn.com/image/fetch/$s_!u8Sy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2131a781-48e4-447e-96a2-d562e93964c2_207x74.png 848w, https://substackcdn.com/image/fetch/$s_!u8Sy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2131a781-48e4-447e-96a2-d562e93964c2_207x74.png 1272w, https://substackcdn.com/image/fetch/$s_!u8Sy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2131a781-48e4-447e-96a2-d562e93964c2_207x74.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This means solving:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lA5X!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55f368be-f28a-4767-8f01-472e68617b26_592x93.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lA5X!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55f368be-f28a-4767-8f01-472e68617b26_592x93.png 424w, https://substackcdn.com/image/fetch/$s_!lA5X!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55f368be-f28a-4767-8f01-472e68617b26_592x93.png 848w, https://substackcdn.com/image/fetch/$s_!lA5X!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55f368be-f28a-4767-8f01-472e68617b26_592x93.png 1272w, https://substackcdn.com/image/fetch/$s_!lA5X!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55f368be-f28a-4767-8f01-472e68617b26_592x93.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lA5X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55f368be-f28a-4767-8f01-472e68617b26_592x93.png" width="422" height="66.29391891891892" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/55f368be-f28a-4767-8f01-472e68617b26_592x93.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:93,&quot;width&quot;:592,&quot;resizeWidth&quot;:422,&quot;bytes&quot;:7146,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lA5X!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55f368be-f28a-4767-8f01-472e68617b26_592x93.png 424w, https://substackcdn.com/image/fetch/$s_!lA5X!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55f368be-f28a-4767-8f01-472e68617b26_592x93.png 848w, https://substackcdn.com/image/fetch/$s_!lA5X!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55f368be-f28a-4767-8f01-472e68617b26_592x93.png 1272w, https://substackcdn.com/image/fetch/$s_!lA5X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55f368be-f28a-4767-8f01-472e68617b26_592x93.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We can expand and simplify the expression (by subbing in 4&#945; into our x variable) and we get:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1PB7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F623a2f32-9374-4d2a-a2a0-e8f7e7ddb6f9_715x78.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1PB7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F623a2f32-9374-4d2a-a2a0-e8f7e7ddb6f9_715x78.png 424w, https://substackcdn.com/image/fetch/$s_!1PB7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F623a2f32-9374-4d2a-a2a0-e8f7e7ddb6f9_715x78.png 848w, https://substackcdn.com/image/fetch/$s_!1PB7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F623a2f32-9374-4d2a-a2a0-e8f7e7ddb6f9_715x78.png 1272w, https://substackcdn.com/image/fetch/$s_!1PB7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F623a2f32-9374-4d2a-a2a0-e8f7e7ddb6f9_715x78.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1PB7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F623a2f32-9374-4d2a-a2a0-e8f7e7ddb6f9_715x78.png" width="519" height="56.61818181818182" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/623a2f32-9374-4d2a-a2a0-e8f7e7ddb6f9_715x78.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:78,&quot;width&quot;:715,&quot;resizeWidth&quot;:519,&quot;bytes&quot;:7417,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1PB7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F623a2f32-9374-4d2a-a2a0-e8f7e7ddb6f9_715x78.png 424w, https://substackcdn.com/image/fetch/$s_!1PB7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F623a2f32-9374-4d2a-a2a0-e8f7e7ddb6f9_715x78.png 848w, https://substackcdn.com/image/fetch/$s_!1PB7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F623a2f32-9374-4d2a-a2a0-e8f7e7ddb6f9_715x78.png 1272w, https://substackcdn.com/image/fetch/$s_!1PB7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F623a2f32-9374-4d2a-a2a0-e8f7e7ddb6f9_715x78.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Now, we take the derivative of this with respect to our step length (&#945;) to find the minimum:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ksrc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1daf75b2-7fa2-46f8-8e0f-359c663c3f53_392x121.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ksrc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1daf75b2-7fa2-46f8-8e0f-359c663c3f53_392x121.png 424w, https://substackcdn.com/image/fetch/$s_!ksrc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1daf75b2-7fa2-46f8-8e0f-359c663c3f53_392x121.png 848w, https://substackcdn.com/image/fetch/$s_!ksrc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1daf75b2-7fa2-46f8-8e0f-359c663c3f53_392x121.png 1272w, https://substackcdn.com/image/fetch/$s_!ksrc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1daf75b2-7fa2-46f8-8e0f-359c663c3f53_392x121.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ksrc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1daf75b2-7fa2-46f8-8e0f-359c663c3f53_392x121.png" width="272" height="83.95918367346938" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1daf75b2-7fa2-46f8-8e0f-359c663c3f53_392x121.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:121,&quot;width&quot;:392,&quot;resizeWidth&quot;:272,&quot;bytes&quot;:5944,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ksrc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1daf75b2-7fa2-46f8-8e0f-359c663c3f53_392x121.png 424w, https://substackcdn.com/image/fetch/$s_!ksrc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1daf75b2-7fa2-46f8-8e0f-359c663c3f53_392x121.png 848w, https://substackcdn.com/image/fetch/$s_!ksrc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1daf75b2-7fa2-46f8-8e0f-359c663c3f53_392x121.png 1272w, https://substackcdn.com/image/fetch/$s_!ksrc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1daf75b2-7fa2-46f8-8e0f-359c663c3f53_392x121.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Setting the derivative equal to zero to find the critical point:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!K9df!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe175975d-3c22-438f-acf7-b6b895702b7f_286x199.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!K9df!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe175975d-3c22-438f-acf7-b6b895702b7f_286x199.png 424w, https://substackcdn.com/image/fetch/$s_!K9df!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe175975d-3c22-438f-acf7-b6b895702b7f_286x199.png 848w, https://substackcdn.com/image/fetch/$s_!K9df!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe175975d-3c22-438f-acf7-b6b895702b7f_286x199.png 1272w, https://substackcdn.com/image/fetch/$s_!K9df!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe175975d-3c22-438f-acf7-b6b895702b7f_286x199.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!K9df!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe175975d-3c22-438f-acf7-b6b895702b7f_286x199.png" width="202" height="140.55244755244755" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e175975d-3c22-438f-acf7-b6b895702b7f_286x199.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:199,&quot;width&quot;:286,&quot;resizeWidth&quot;:202,&quot;bytes&quot;:6949,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!K9df!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe175975d-3c22-438f-acf7-b6b895702b7f_286x199.png 424w, https://substackcdn.com/image/fetch/$s_!K9df!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe175975d-3c22-438f-acf7-b6b895702b7f_286x199.png 848w, https://substackcdn.com/image/fetch/$s_!K9df!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe175975d-3c22-438f-acf7-b6b895702b7f_286x199.png 1272w, https://substackcdn.com/image/fetch/$s_!K9df!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe175975d-3c22-438f-acf7-b6b895702b7f_286x199.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We now know that our optimal step size is 0.5. </p><p><strong>Step 4:</strong> Update the next iterate / point (which we denote as x<sub>1</sub>):</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GH9r!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde1325ad-b00f-4b0a-855b-6021887e4ab5_596x99.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GH9r!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde1325ad-b00f-4b0a-855b-6021887e4ab5_596x99.png 424w, https://substackcdn.com/image/fetch/$s_!GH9r!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde1325ad-b00f-4b0a-855b-6021887e4ab5_596x99.png 848w, https://substackcdn.com/image/fetch/$s_!GH9r!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde1325ad-b00f-4b0a-855b-6021887e4ab5_596x99.png 1272w, https://substackcdn.com/image/fetch/$s_!GH9r!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde1325ad-b00f-4b0a-855b-6021887e4ab5_596x99.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GH9r!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde1325ad-b00f-4b0a-855b-6021887e4ab5_596x99.png" width="442" height="73.41946308724832" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/de1325ad-b00f-4b0a-855b-6021887e4ab5_596x99.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:99,&quot;width&quot;:596,&quot;resizeWidth&quot;:442,&quot;bytes&quot;:6128,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GH9r!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde1325ad-b00f-4b0a-855b-6021887e4ab5_596x99.png 424w, https://substackcdn.com/image/fetch/$s_!GH9r!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde1325ad-b00f-4b0a-855b-6021887e4ab5_596x99.png 848w, https://substackcdn.com/image/fetch/$s_!GH9r!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde1325ad-b00f-4b0a-855b-6021887e4ab5_596x99.png 1272w, https://substackcdn.com/image/fetch/$s_!GH9r!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde1325ad-b00f-4b0a-855b-6021887e4ab5_596x99.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Step 5:</strong> Repeat the process. At x<sub>1</sub> = 2, the gradient is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GvdO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a28c08e-8043-4521-b2a8-c1b8af9a5657_385x77.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GvdO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a28c08e-8043-4521-b2a8-c1b8af9a5657_385x77.png 424w, https://substackcdn.com/image/fetch/$s_!GvdO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a28c08e-8043-4521-b2a8-c1b8af9a5657_385x77.png 848w, https://substackcdn.com/image/fetch/$s_!GvdO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a28c08e-8043-4521-b2a8-c1b8af9a5657_385x77.png 1272w, https://substackcdn.com/image/fetch/$s_!GvdO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a28c08e-8043-4521-b2a8-c1b8af9a5657_385x77.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GvdO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a28c08e-8043-4521-b2a8-c1b8af9a5657_385x77.png" width="271" height="54.2" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2a28c08e-8043-4521-b2a8-c1b8af9a5657_385x77.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:77,&quot;width&quot;:385,&quot;resizeWidth&quot;:271,&quot;bytes&quot;:4673,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GvdO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a28c08e-8043-4521-b2a8-c1b8af9a5657_385x77.png 424w, https://substackcdn.com/image/fetch/$s_!GvdO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a28c08e-8043-4521-b2a8-c1b8af9a5657_385x77.png 848w, https://substackcdn.com/image/fetch/$s_!GvdO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a28c08e-8043-4521-b2a8-c1b8af9a5657_385x77.png 1272w, https://substackcdn.com/image/fetch/$s_!GvdO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a28c08e-8043-4521-b2a8-c1b8af9a5657_385x77.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Since the gradient is 0, we know that we&#8217;ve found the minimum and we are finished. </p><p>Our 2 examples both used derivative information to come up with exact step-sizes, but in practice, you would approximate the step length rather than solving it exactly. You could do this by using trial values until you find a good enough reduction in the function. This is where the approximate line search algorithm comes in handy. </p><h3>Approximate Line Search</h3><p>It is often more computationally efficient to perform more iterations of a descent method than to do exact line search at each iteration, especially if the function and derivative calculations are expensive. Approximate line search gives us a way to move in the correct direction without overshooting or undershooting too much. This is done without having to calculate the optimal step size. It does this by finding a good enough step size quickly and by steadily moving towards our goal.</p><p>A general intuition for this algorithm can be obtained by imagining that you're blindfolded and trying to walk downhill. You can't see the whole slope, but you can feel with your feet whether you're going up or down. You take careful steps, feeling the ground, and stop when you feel like you've reached a point where going further might make you start going uphill again. You may ask yourself though: how do we calculate our step size using the above approach?</p><p>Well, this is where backtracking line search comes in handy: when you&#8217;re walking down the slope, you take a big step &#8211; but prior to doing so, you check if the step size takes you to a point which decreases your elevation by a <strong>sufficient decrease</strong> (i.e. your elevation or objective function must go down by a conditional value). If it feels like you might have overshot, you take a smaller step and try again until you find a step that feels just right. To be exact, in the algorithm:</p><ol><li><p>You begin by taking a large step in the direction that you believe will reduce the function's value.</p></li><li><p>After taking the step, you check if the function's value has decreased enough compared to the starting point.</p></li><li><p>If the decrease isn't sufficient, you reduce the step size (by multiplying it by a constant less than 1) and try again.</p></li><li><p>You continue this process, reducing the step size each time, until you find a step that gives a satisfactory decrease in the function's value.</p></li></ol><p>The algorithm outlined in Python is provided below:</p><pre><code>def backtracking_line_search(f, grad_f, x, descent_direction, max_step_size, reduction_factor=0.5, wolfe_condition_param=1e-4):

    y = f(x)
    gradient = grad_f(x)

    # This gives rate of change of function in the direction of the descent.
    while f(x + max_step_size * descent_direction) 
          &gt; y + wolfe_condition_param * max_step_size * (
            # Dot product between the gradient and the descent direction
            gradient @ descent_direction):

        max_step_size *= reduction_factor

    return max_step_size</code></pre><h4>Backtracking Line Search Example</h4><p>Let&#8217;s go through an example to illustrate how our backtracking algorithm works by using the same example which we overviewed for our regular line search algorithm. The function which we are aiming to minimize here is provided below:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Qcxe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ce136a-89e2-4e65-881a-bf45b22d22aa_421x93.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Qcxe!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ce136a-89e2-4e65-881a-bf45b22d22aa_421x93.png 424w, https://substackcdn.com/image/fetch/$s_!Qcxe!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ce136a-89e2-4e65-881a-bf45b22d22aa_421x93.png 848w, https://substackcdn.com/image/fetch/$s_!Qcxe!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ce136a-89e2-4e65-881a-bf45b22d22aa_421x93.png 1272w, https://substackcdn.com/image/fetch/$s_!Qcxe!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ce136a-89e2-4e65-881a-bf45b22d22aa_421x93.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Qcxe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ce136a-89e2-4e65-881a-bf45b22d22aa_421x93.png" width="269" height="59.42280285035629" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/70ce136a-89e2-4e65-881a-bf45b22d22aa_421x93.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:93,&quot;width&quot;:421,&quot;resizeWidth&quot;:269,&quot;bytes&quot;:20522,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Qcxe!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ce136a-89e2-4e65-881a-bf45b22d22aa_421x93.png 424w, https://substackcdn.com/image/fetch/$s_!Qcxe!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ce136a-89e2-4e65-881a-bf45b22d22aa_421x93.png 848w, https://substackcdn.com/image/fetch/$s_!Qcxe!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ce136a-89e2-4e65-881a-bf45b22d22aa_421x93.png 1272w, https://substackcdn.com/image/fetch/$s_!Qcxe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ce136a-89e2-4e65-881a-bf45b22d22aa_421x93.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong> Step 1</strong>: Choose an initial point x<sub>0</sub>. Here - we&#8217;ll once again use 0:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!h8NF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde0a9c49-6bc1-4096-b53e-7597735e7bdb_118x59.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!h8NF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde0a9c49-6bc1-4096-b53e-7597735e7bdb_118x59.png 424w, https://substackcdn.com/image/fetch/$s_!h8NF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde0a9c49-6bc1-4096-b53e-7597735e7bdb_118x59.png 848w, https://substackcdn.com/image/fetch/$s_!h8NF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde0a9c49-6bc1-4096-b53e-7597735e7bdb_118x59.png 1272w, https://substackcdn.com/image/fetch/$s_!h8NF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde0a9c49-6bc1-4096-b53e-7597735e7bdb_118x59.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!h8NF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde0a9c49-6bc1-4096-b53e-7597735e7bdb_118x59.png" width="86" height="43" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/de0a9c49-6bc1-4096-b53e-7597735e7bdb_118x59.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:59,&quot;width&quot;:118,&quot;resizeWidth&quot;:86,&quot;bytes&quot;:1546,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!h8NF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde0a9c49-6bc1-4096-b53e-7597735e7bdb_118x59.png 424w, https://substackcdn.com/image/fetch/$s_!h8NF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde0a9c49-6bc1-4096-b53e-7597735e7bdb_118x59.png 848w, https://substackcdn.com/image/fetch/$s_!h8NF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde0a9c49-6bc1-4096-b53e-7597735e7bdb_118x59.png 1272w, https://substackcdn.com/image/fetch/$s_!h8NF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde0a9c49-6bc1-4096-b53e-7597735e7bdb_118x59.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Step 2</strong>: Choose a search direction p<sub>k</sub>&#8203;. Here, we&#8217;ll once again use our negative gradient information (from our earlier example) and to get 4 as our direction:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!C6KL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F292093bb-a7cc-4320-971b-4aa9d9944bb9_325x85.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!C6KL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F292093bb-a7cc-4320-971b-4aa9d9944bb9_325x85.png 424w, https://substackcdn.com/image/fetch/$s_!C6KL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F292093bb-a7cc-4320-971b-4aa9d9944bb9_325x85.png 848w, https://substackcdn.com/image/fetch/$s_!C6KL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F292093bb-a7cc-4320-971b-4aa9d9944bb9_325x85.png 1272w, https://substackcdn.com/image/fetch/$s_!C6KL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F292093bb-a7cc-4320-971b-4aa9d9944bb9_325x85.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!C6KL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F292093bb-a7cc-4320-971b-4aa9d9944bb9_325x85.png" width="223" height="58.323076923076925" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/292093bb-a7cc-4320-971b-4aa9d9944bb9_325x85.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:85,&quot;width&quot;:325,&quot;resizeWidth&quot;:223,&quot;bytes&quot;:4006,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!C6KL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F292093bb-a7cc-4320-971b-4aa9d9944bb9_325x85.png 424w, https://substackcdn.com/image/fetch/$s_!C6KL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F292093bb-a7cc-4320-971b-4aa9d9944bb9_325x85.png 848w, https://substackcdn.com/image/fetch/$s_!C6KL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F292093bb-a7cc-4320-971b-4aa9d9944bb9_325x85.png 1272w, https://substackcdn.com/image/fetch/$s_!C6KL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F292093bb-a7cc-4320-971b-4aa9d9944bb9_325x85.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!UZok!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3ecc8f00-e61e-44a4-979b-d4b2429bbc24_242x80.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UZok!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3ecc8f00-e61e-44a4-979b-d4b2429bbc24_242x80.png 424w, https://substackcdn.com/image/fetch/$s_!UZok!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3ecc8f00-e61e-44a4-979b-d4b2429bbc24_242x80.png 848w, https://substackcdn.com/image/fetch/$s_!UZok!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3ecc8f00-e61e-44a4-979b-d4b2429bbc24_242x80.png 1272w, https://substackcdn.com/image/fetch/$s_!UZok!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3ecc8f00-e61e-44a4-979b-d4b2429bbc24_242x80.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!UZok!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3ecc8f00-e61e-44a4-979b-d4b2429bbc24_242x80.png" width="160" height="52.892561983471076" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3ecc8f00-e61e-44a4-979b-d4b2429bbc24_242x80.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:80,&quot;width&quot;:242,&quot;resizeWidth&quot;:160,&quot;bytes&quot;:2851,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!UZok!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3ecc8f00-e61e-44a4-979b-d4b2429bbc24_242x80.png 424w, https://substackcdn.com/image/fetch/$s_!UZok!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3ecc8f00-e61e-44a4-979b-d4b2429bbc24_242x80.png 848w, https://substackcdn.com/image/fetch/$s_!UZok!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3ecc8f00-e61e-44a4-979b-d4b2429bbc24_242x80.png 1272w, https://substackcdn.com/image/fetch/$s_!UZok!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3ecc8f00-e61e-44a4-979b-d4b2429bbc24_242x80.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WVok!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F883909e3-d04f-49ff-9943-51fb8ebf472e_114x56.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WVok!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F883909e3-d04f-49ff-9943-51fb8ebf472e_114x56.png 424w, https://substackcdn.com/image/fetch/$s_!WVok!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F883909e3-d04f-49ff-9943-51fb8ebf472e_114x56.png 848w, https://substackcdn.com/image/fetch/$s_!WVok!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F883909e3-d04f-49ff-9943-51fb8ebf472e_114x56.png 1272w, https://substackcdn.com/image/fetch/$s_!WVok!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F883909e3-d04f-49ff-9943-51fb8ebf472e_114x56.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WVok!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F883909e3-d04f-49ff-9943-51fb8ebf472e_114x56.png" width="82" height="40.280701754385966" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/883909e3-d04f-49ff-9943-51fb8ebf472e_114x56.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:56,&quot;width&quot;:114,&quot;resizeWidth&quot;:82,&quot;bytes&quot;:1457,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WVok!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F883909e3-d04f-49ff-9943-51fb8ebf472e_114x56.png 424w, https://substackcdn.com/image/fetch/$s_!WVok!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F883909e3-d04f-49ff-9943-51fb8ebf472e_114x56.png 848w, https://substackcdn.com/image/fetch/$s_!WVok!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F883909e3-d04f-49ff-9943-51fb8ebf472e_114x56.png 1272w, https://substackcdn.com/image/fetch/$s_!WVok!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F883909e3-d04f-49ff-9943-51fb8ebf472e_114x56.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Step 3</strong>: Perform <strong>backtracking line search</strong>.</p><p>Backtracking line search involves choosing an initial step length &#945; (usually &#945; = 1) and then reducing it by multiplying by a factor &#946; (e.g., &#946; = 0.5) until a sufficient decrease in the function value is observed.</p><p>Parameters for backtracking line search:</p><ul><li><p>Initial step length &#945;<sub>0</sub> = 1.</p></li><li><p>Reduction factor &#946; = 0.5.</p></li><li><p>Condition parameter c = 0.5.</p></li></ul><p>We want to find the largest step length &#945; such that the function value decreases enough. Specifically, we want &#945; to satisfy:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ryCf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc573fa80-fd92-4091-83b6-8ad4ec18919a_638x88.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ryCf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc573fa80-fd92-4091-83b6-8ad4ec18919a_638x88.png 424w, https://substackcdn.com/image/fetch/$s_!ryCf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc573fa80-fd92-4091-83b6-8ad4ec18919a_638x88.png 848w, https://substackcdn.com/image/fetch/$s_!ryCf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc573fa80-fd92-4091-83b6-8ad4ec18919a_638x88.png 1272w, https://substackcdn.com/image/fetch/$s_!ryCf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc573fa80-fd92-4091-83b6-8ad4ec18919a_638x88.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ryCf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc573fa80-fd92-4091-83b6-8ad4ec18919a_638x88.png" width="458" height="63.172413793103445" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c573fa80-fd92-4091-83b6-8ad4ec18919a_638x88.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:88,&quot;width&quot;:638,&quot;resizeWidth&quot;:458,&quot;bytes&quot;:8430,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ryCf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc573fa80-fd92-4091-83b6-8ad4ec18919a_638x88.png 424w, https://substackcdn.com/image/fetch/$s_!ryCf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc573fa80-fd92-4091-83b6-8ad4ec18919a_638x88.png 848w, https://substackcdn.com/image/fetch/$s_!ryCf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc573fa80-fd92-4091-83b6-8ad4ec18919a_638x88.png 1272w, https://substackcdn.com/image/fetch/$s_!ryCf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc573fa80-fd92-4091-83b6-8ad4ec18919a_638x88.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This condition ensures that the new function value is smaller than the current function value, but by at least a fraction of the step size.</p><p><strong>Step 3.1</strong>: Evaluate the function at &#945; = 1. First, we compute f(0 + 1&#8901;4) = f(4). The function value at x = 4 is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!viEc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6576078-2114-42e0-a2e9-870dd4271f7d_430x88.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!viEc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6576078-2114-42e0-a2e9-870dd4271f7d_430x88.png 424w, https://substackcdn.com/image/fetch/$s_!viEc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6576078-2114-42e0-a2e9-870dd4271f7d_430x88.png 848w, https://substackcdn.com/image/fetch/$s_!viEc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6576078-2114-42e0-a2e9-870dd4271f7d_430x88.png 1272w, https://substackcdn.com/image/fetch/$s_!viEc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6576078-2114-42e0-a2e9-870dd4271f7d_430x88.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!viEc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6576078-2114-42e0-a2e9-870dd4271f7d_430x88.png" width="282" height="57.711627906976744" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f6576078-2114-42e0-a2e9-870dd4271f7d_430x88.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:88,&quot;width&quot;:430,&quot;resizeWidth&quot;:282,&quot;bytes&quot;:4494,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!viEc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6576078-2114-42e0-a2e9-870dd4271f7d_430x88.png 424w, https://substackcdn.com/image/fetch/$s_!viEc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6576078-2114-42e0-a2e9-870dd4271f7d_430x88.png 848w, https://substackcdn.com/image/fetch/$s_!viEc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6576078-2114-42e0-a2e9-870dd4271f7d_430x88.png 1272w, https://substackcdn.com/image/fetch/$s_!viEc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6576078-2114-42e0-a2e9-870dd4271f7d_430x88.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Next, we check if this satisfies the backtracking condition:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Ex5a!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffaa008f5-56c2-4501-bea9-7ff2752a2d88_628x165.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Ex5a!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffaa008f5-56c2-4501-bea9-7ff2752a2d88_628x165.png 424w, https://substackcdn.com/image/fetch/$s_!Ex5a!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffaa008f5-56c2-4501-bea9-7ff2752a2d88_628x165.png 848w, https://substackcdn.com/image/fetch/$s_!Ex5a!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffaa008f5-56c2-4501-bea9-7ff2752a2d88_628x165.png 1272w, https://substackcdn.com/image/fetch/$s_!Ex5a!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffaa008f5-56c2-4501-bea9-7ff2752a2d88_628x165.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Ex5a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffaa008f5-56c2-4501-bea9-7ff2752a2d88_628x165.png" width="410" height="107.72292993630573" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/faa008f5-56c2-4501-bea9-7ff2752a2d88_628x165.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:165,&quot;width&quot;:628,&quot;resizeWidth&quot;:410,&quot;bytes&quot;:12127,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Ex5a!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffaa008f5-56c2-4501-bea9-7ff2752a2d88_628x165.png 424w, https://substackcdn.com/image/fetch/$s_!Ex5a!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffaa008f5-56c2-4501-bea9-7ff2752a2d88_628x165.png 848w, https://substackcdn.com/image/fetch/$s_!Ex5a!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffaa008f5-56c2-4501-bea9-7ff2752a2d88_628x165.png 1272w, https://substackcdn.com/image/fetch/$s_!Ex5a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffaa008f5-56c2-4501-bea9-7ff2752a2d88_628x165.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Since 5 is not less than -3, we need to reduce our step length. </p><p><strong>Step 3.2</strong>: Reduce the step length by &#946; = 0.5. </p><p>First - we evaluate: </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0MyB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F255db0b1-3038-48ed-a362-b1b742fb4e42_347x70.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0MyB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F255db0b1-3038-48ed-a362-b1b742fb4e42_347x70.png 424w, https://substackcdn.com/image/fetch/$s_!0MyB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F255db0b1-3038-48ed-a362-b1b742fb4e42_347x70.png 848w, https://substackcdn.com/image/fetch/$s_!0MyB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F255db0b1-3038-48ed-a362-b1b742fb4e42_347x70.png 1272w, https://substackcdn.com/image/fetch/$s_!0MyB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F255db0b1-3038-48ed-a362-b1b742fb4e42_347x70.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0MyB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F255db0b1-3038-48ed-a362-b1b742fb4e42_347x70.png" width="219" height="44.178674351585016" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/255db0b1-3038-48ed-a362-b1b742fb4e42_347x70.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:70,&quot;width&quot;:347,&quot;resizeWidth&quot;:219,&quot;bytes&quot;:4726,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!0MyB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F255db0b1-3038-48ed-a362-b1b742fb4e42_347x70.png 424w, https://substackcdn.com/image/fetch/$s_!0MyB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F255db0b1-3038-48ed-a362-b1b742fb4e42_347x70.png 848w, https://substackcdn.com/image/fetch/$s_!0MyB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F255db0b1-3038-48ed-a362-b1b742fb4e42_347x70.png 1272w, https://substackcdn.com/image/fetch/$s_!0MyB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F255db0b1-3038-48ed-a362-b1b742fb4e42_347x70.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!UrtM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccf84dd1-c4a3-4509-a488-eb6c993bc2b2_431x85.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UrtM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccf84dd1-c4a3-4509-a488-eb6c993bc2b2_431x85.png 424w, https://substackcdn.com/image/fetch/$s_!UrtM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccf84dd1-c4a3-4509-a488-eb6c993bc2b2_431x85.png 848w, https://substackcdn.com/image/fetch/$s_!UrtM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccf84dd1-c4a3-4509-a488-eb6c993bc2b2_431x85.png 1272w, https://substackcdn.com/image/fetch/$s_!UrtM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccf84dd1-c4a3-4509-a488-eb6c993bc2b2_431x85.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!UrtM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccf84dd1-c4a3-4509-a488-eb6c993bc2b2_431x85.png" width="289" height="56.9953596287703" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ccf84dd1-c4a3-4509-a488-eb6c993bc2b2_431x85.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:85,&quot;width&quot;:431,&quot;resizeWidth&quot;:289,&quot;bytes&quot;:4184,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!UrtM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccf84dd1-c4a3-4509-a488-eb6c993bc2b2_431x85.png 424w, https://substackcdn.com/image/fetch/$s_!UrtM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccf84dd1-c4a3-4509-a488-eb6c993bc2b2_431x85.png 848w, https://substackcdn.com/image/fetch/$s_!UrtM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccf84dd1-c4a3-4509-a488-eb6c993bc2b2_431x85.png 1272w, https://substackcdn.com/image/fetch/$s_!UrtM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fccf84dd1-c4a3-4509-a488-eb6c993bc2b2_431x85.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Next, we check our backtracking condition:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!aGSb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70e76ebd-a46b-4551-9392-cc86da1fc4fc_573x179.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!aGSb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70e76ebd-a46b-4551-9392-cc86da1fc4fc_573x179.png 424w, https://substackcdn.com/image/fetch/$s_!aGSb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70e76ebd-a46b-4551-9392-cc86da1fc4fc_573x179.png 848w, https://substackcdn.com/image/fetch/$s_!aGSb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70e76ebd-a46b-4551-9392-cc86da1fc4fc_573x179.png 1272w, https://substackcdn.com/image/fetch/$s_!aGSb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70e76ebd-a46b-4551-9392-cc86da1fc4fc_573x179.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!aGSb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70e76ebd-a46b-4551-9392-cc86da1fc4fc_573x179.png" width="419" height="130.891797556719" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/70e76ebd-a46b-4551-9392-cc86da1fc4fc_573x179.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:179,&quot;width&quot;:573,&quot;resizeWidth&quot;:419,&quot;bytes&quot;:12371,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!aGSb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70e76ebd-a46b-4551-9392-cc86da1fc4fc_573x179.png 424w, https://substackcdn.com/image/fetch/$s_!aGSb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70e76ebd-a46b-4551-9392-cc86da1fc4fc_573x179.png 848w, https://substackcdn.com/image/fetch/$s_!aGSb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70e76ebd-a46b-4551-9392-cc86da1fc4fc_573x179.png 1272w, https://substackcdn.com/image/fetch/$s_!aGSb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70e76ebd-a46b-4551-9392-cc86da1fc4fc_573x179.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Since 1 is less than or equal to 1, our condition is satisfied!</p><p><strong>Step 4</strong>: Update the point x<sub>1</sub>&#8203; to once again obtain 2 (which is our minimal point):</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dott!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa46915f0-b48b-4dcb-aa0a-0815fdddabc5_568x92.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dott!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa46915f0-b48b-4dcb-aa0a-0815fdddabc5_568x92.png 424w, https://substackcdn.com/image/fetch/$s_!dott!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa46915f0-b48b-4dcb-aa0a-0815fdddabc5_568x92.png 848w, https://substackcdn.com/image/fetch/$s_!dott!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa46915f0-b48b-4dcb-aa0a-0815fdddabc5_568x92.png 1272w, https://substackcdn.com/image/fetch/$s_!dott!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa46915f0-b48b-4dcb-aa0a-0815fdddabc5_568x92.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dott!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa46915f0-b48b-4dcb-aa0a-0815fdddabc5_568x92.png" width="434" height="70.29577464788733" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a46915f0-b48b-4dcb-aa0a-0815fdddabc5_568x92.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:92,&quot;width&quot;:568,&quot;resizeWidth&quot;:434,&quot;bytes&quot;:5900,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!dott!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa46915f0-b48b-4dcb-aa0a-0815fdddabc5_568x92.png 424w, https://substackcdn.com/image/fetch/$s_!dott!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa46915f0-b48b-4dcb-aa0a-0815fdddabc5_568x92.png 848w, https://substackcdn.com/image/fetch/$s_!dott!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa46915f0-b48b-4dcb-aa0a-0815fdddabc5_568x92.png 1272w, https://substackcdn.com/image/fetch/$s_!dott!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa46915f0-b48b-4dcb-aa0a-0815fdddabc5_568x92.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Step 5</strong>: Repeat the process. This is similar to our original line search. Since we know that our gradient at x = 2 is 0, we know that we&#8217;ve found the minimum and we end our search. </p><p>This ends our example. Hopefully you understand why the line search algorithm is so powerful. Next, we&#8217;ll overview an algorithm which is called the <strong>trust region method</strong>. The key advantage of this method over backtracking or regular line search is its ability to adaptively control the step size by constructing a local quadratic model of the function. This helps handle highly nonlinear or irregular functions more effectively. </p><h3>Trust Region Method</h3><p>Descent methods can sometimes place a bit too much trust in first or second order information, which can result in extremely large steps / premature convergence. The trust region method avoids this by limiting the step taken and trying to predict the improvement associated with the step and comparing it with the actual improvement. This local &#8216;predictive&#8217; model or local landscape we tend to call the <strong>trust region</strong>. If our predicted improvement is accurate, we expand this trust region &#8211;- otherwise, we know that our local model is inaccurate so we shrink / contract it. Trust region methods first choose the maximum step size and then the step direction, which is in contrast with line search methods which first choose a step direction and then optimize the step size.</p><p>A good intuition for this algorithm is to imagine that you're walking through fog in a hilly area, trying to find the lowest point. Instead of picking a certain direction and attempting to take a step, you first try to create a local model of the area that&#8217;s directly around you. To check if your internal mental model matches reality, you take a small step within that local area and if the predicted elevation doesn&#8217;t match what you think is there &#8211; you &#8216;shrink&#8217; the step size and keep repeating this process until you have a good mental image of the area surrounding you. Once your prediction does match the outcome, you then pick the appropriate direction and move towards it. After all - you don't want to make big, risky leaps because you can't see far ahead. Instead, you take careful, small steps within an area you feel confident about. If the ground seems to be sloping downward nicely and matches your internal mental model, you might get more confident and take larger steps. But if you stumble or the ground feels uncertain, you shrink your steps and proceed with more caution.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!facv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34a90d00-ff07-4258-89bd-3323aa03a455_520x379.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!facv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34a90d00-ff07-4258-89bd-3323aa03a455_520x379.png 424w, https://substackcdn.com/image/fetch/$s_!facv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34a90d00-ff07-4258-89bd-3323aa03a455_520x379.png 848w, https://substackcdn.com/image/fetch/$s_!facv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34a90d00-ff07-4258-89bd-3323aa03a455_520x379.png 1272w, https://substackcdn.com/image/fetch/$s_!facv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34a90d00-ff07-4258-89bd-3323aa03a455_520x379.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!facv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34a90d00-ff07-4258-89bd-3323aa03a455_520x379.png" width="520" height="379" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/34a90d00-ff07-4258-89bd-3323aa03a455_520x379.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:379,&quot;width&quot;:520,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:73519,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!facv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34a90d00-ff07-4258-89bd-3323aa03a455_520x379.png 424w, https://substackcdn.com/image/fetch/$s_!facv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34a90d00-ff07-4258-89bd-3323aa03a455_520x379.png 848w, https://substackcdn.com/image/fetch/$s_!facv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34a90d00-ff07-4258-89bd-3323aa03a455_520x379.png 1272w, https://substackcdn.com/image/fetch/$s_!facv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34a90d00-ff07-4258-89bd-3323aa03a455_520x379.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>Trust region methods constrain the next step to lie within a local region. The trusted region is expanded and contracted based on the predictive performance of models of the objective function.</em></figcaption></figure></div><p>The heuristic steps used in this algorithm are provided below:</p><ol><li><p><strong>Start with a Guess</strong>: You begin at an initial guess for the solution. This is like starting at a certain point on a hilly landscape if you&#8217;re trying to find the lowest valley.</p></li><li><p><strong>Define a Trust Region</strong>: Around your current guess, you define a small region (like drawing a circle around yourself). This region is called the "trust region." The idea is that within this small area, you trust that the function behaves somewhat like a simpler model (often a quadratic function).</p></li><li><p><strong>Optimize Within the Trust Region</strong>: You look for the best direction and step size to move within this trust region. This is like carefully walking within the circle to see if you can find a lower point.</p></li><li><p><strong>Check and Adjust</strong>:</p></li></ol><ul><li><p>If the move you make within the trust region significantly improves your position (i.e., lowers the function value), you trust the model more and possibly expand the trust region to allow for bigger steps.</p></li><li><p>If the move doesn&#8217;t improve much or makes things worse, you shrink the trust region and take smaller steps.</p></li></ul><ol start="5"><li><p><strong>Iterate</strong>: You repeat this process&#8212;moving, checking, and adjusting&#8212;until you find the minimum or maximum value you&#8217;re looking for.</p></li></ol><p>Let&#8217;s go through an example to illustrate how the trust region method works.</p><h4>Trust Region Method Example</h4><p>Let&#8217;s use the same example we used in our prior 2 algorithms / methods. Once again, we&#8217;re trying to minimize below:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!n5Fk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F480ca203-bd34-436d-897c-fa2f23c43dd5_332x92.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!n5Fk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F480ca203-bd34-436d-897c-fa2f23c43dd5_332x92.png 424w, https://substackcdn.com/image/fetch/$s_!n5Fk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F480ca203-bd34-436d-897c-fa2f23c43dd5_332x92.png 848w, https://substackcdn.com/image/fetch/$s_!n5Fk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F480ca203-bd34-436d-897c-fa2f23c43dd5_332x92.png 1272w, https://substackcdn.com/image/fetch/$s_!n5Fk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F480ca203-bd34-436d-897c-fa2f23c43dd5_332x92.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!n5Fk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F480ca203-bd34-436d-897c-fa2f23c43dd5_332x92.png" width="262" height="72.60240963855422" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/480ca203-bd34-436d-897c-fa2f23c43dd5_332x92.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:92,&quot;width&quot;:332,&quot;resizeWidth&quot;:262,&quot;bytes&quot;:3451,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!n5Fk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F480ca203-bd34-436d-897c-fa2f23c43dd5_332x92.png 424w, https://substackcdn.com/image/fetch/$s_!n5Fk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F480ca203-bd34-436d-897c-fa2f23c43dd5_332x92.png 848w, https://substackcdn.com/image/fetch/$s_!n5Fk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F480ca203-bd34-436d-897c-fa2f23c43dd5_332x92.png 1272w, https://substackcdn.com/image/fetch/$s_!n5Fk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F480ca203-bd34-436d-897c-fa2f23c43dd5_332x92.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Step 1</strong>: Choose an initial point x<sub>0</sub>. </p><p>Here we once again use 0:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_6v8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624e876f-099e-40d8-ae1f-6d5d9b6f8210_104x55.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_6v8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624e876f-099e-40d8-ae1f-6d5d9b6f8210_104x55.png 424w, https://substackcdn.com/image/fetch/$s_!_6v8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624e876f-099e-40d8-ae1f-6d5d9b6f8210_104x55.png 848w, https://substackcdn.com/image/fetch/$s_!_6v8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624e876f-099e-40d8-ae1f-6d5d9b6f8210_104x55.png 1272w, https://substackcdn.com/image/fetch/$s_!_6v8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624e876f-099e-40d8-ae1f-6d5d9b6f8210_104x55.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_6v8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624e876f-099e-40d8-ae1f-6d5d9b6f8210_104x55.png" width="90" height="47.59615384615385" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/624e876f-099e-40d8-ae1f-6d5d9b6f8210_104x55.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:55,&quot;width&quot;:104,&quot;resizeWidth&quot;:90,&quot;bytes&quot;:1326,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_6v8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624e876f-099e-40d8-ae1f-6d5d9b6f8210_104x55.png 424w, https://substackcdn.com/image/fetch/$s_!_6v8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624e876f-099e-40d8-ae1f-6d5d9b6f8210_104x55.png 848w, https://substackcdn.com/image/fetch/$s_!_6v8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624e876f-099e-40d8-ae1f-6d5d9b6f8210_104x55.png 1272w, https://substackcdn.com/image/fetch/$s_!_6v8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F624e876f-099e-40d8-ae1f-6d5d9b6f8210_104x55.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Step 2: </strong>Set up the trust region. </p><p>The <strong>trust region</strong> is a region around the current point within which we trust a quadratic approximation of the function. We'll assume an initial trust region that has a radius of 1:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!89yp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefcc1515-f7b2-422b-ad03-9b85241db8fd_132x49.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!89yp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefcc1515-f7b2-422b-ad03-9b85241db8fd_132x49.png 424w, https://substackcdn.com/image/fetch/$s_!89yp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefcc1515-f7b2-422b-ad03-9b85241db8fd_132x49.png 848w, https://substackcdn.com/image/fetch/$s_!89yp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefcc1515-f7b2-422b-ad03-9b85241db8fd_132x49.png 1272w, https://substackcdn.com/image/fetch/$s_!89yp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefcc1515-f7b2-422b-ad03-9b85241db8fd_132x49.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!89yp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefcc1515-f7b2-422b-ad03-9b85241db8fd_132x49.png" width="112" height="41.57575757575758" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/efcc1515-f7b2-422b-ad03-9b85241db8fd_132x49.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:49,&quot;width&quot;:132,&quot;resizeWidth&quot;:112,&quot;bytes&quot;:1042,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!89yp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefcc1515-f7b2-422b-ad03-9b85241db8fd_132x49.png 424w, https://substackcdn.com/image/fetch/$s_!89yp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefcc1515-f7b2-422b-ad03-9b85241db8fd_132x49.png 848w, https://substackcdn.com/image/fetch/$s_!89yp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefcc1515-f7b2-422b-ad03-9b85241db8fd_132x49.png 1272w, https://substackcdn.com/image/fetch/$s_!89yp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefcc1515-f7b2-422b-ad03-9b85241db8fd_132x49.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Step 3: </strong>Construct a quadratic model of the function. </p><p>For trust region methods, we approximate the objective function using a quadratic model. The quadratic model at x<sub>0 </sub>is based on the <strong>Taylor expansion</strong> of the function around x<sub>0</sub>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!90FY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ee4566b-eeac-4f47-bbfb-32cbffb570b3_746x445.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!90FY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ee4566b-eeac-4f47-bbfb-32cbffb570b3_746x445.png 424w, https://substackcdn.com/image/fetch/$s_!90FY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ee4566b-eeac-4f47-bbfb-32cbffb570b3_746x445.png 848w, https://substackcdn.com/image/fetch/$s_!90FY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ee4566b-eeac-4f47-bbfb-32cbffb570b3_746x445.png 1272w, https://substackcdn.com/image/fetch/$s_!90FY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ee4566b-eeac-4f47-bbfb-32cbffb570b3_746x445.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!90FY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ee4566b-eeac-4f47-bbfb-32cbffb570b3_746x445.png" width="594" height="354.32975871313675" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2ee4566b-eeac-4f47-bbfb-32cbffb570b3_746x445.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:445,&quot;width&quot;:746,&quot;resizeWidth&quot;:594,&quot;bytes&quot;:28696,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!90FY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ee4566b-eeac-4f47-bbfb-32cbffb570b3_746x445.png 424w, https://substackcdn.com/image/fetch/$s_!90FY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ee4566b-eeac-4f47-bbfb-32cbffb570b3_746x445.png 848w, https://substackcdn.com/image/fetch/$s_!90FY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ee4566b-eeac-4f47-bbfb-32cbffb570b3_746x445.png 1272w, https://substackcdn.com/image/fetch/$s_!90FY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ee4566b-eeac-4f47-bbfb-32cbffb570b3_746x445.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></figure></div><p>For our original function, we know that the gradient (derivative is):</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Um9J!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcefd0b73-2267-4153-ad4a-16d9d860ee4c_290x77.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Um9J!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcefd0b73-2267-4153-ad4a-16d9d860ee4c_290x77.png 424w, https://substackcdn.com/image/fetch/$s_!Um9J!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcefd0b73-2267-4153-ad4a-16d9d860ee4c_290x77.png 848w, https://substackcdn.com/image/fetch/$s_!Um9J!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcefd0b73-2267-4153-ad4a-16d9d860ee4c_290x77.png 1272w, https://substackcdn.com/image/fetch/$s_!Um9J!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcefd0b73-2267-4153-ad4a-16d9d860ee4c_290x77.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Um9J!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcefd0b73-2267-4153-ad4a-16d9d860ee4c_290x77.png" width="222" height="58.9448275862069" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cefd0b73-2267-4153-ad4a-16d9d860ee4c_290x77.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:77,&quot;width&quot;:290,&quot;resizeWidth&quot;:222,&quot;bytes&quot;:3643,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Um9J!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcefd0b73-2267-4153-ad4a-16d9d860ee4c_290x77.png 424w, https://substackcdn.com/image/fetch/$s_!Um9J!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcefd0b73-2267-4153-ad4a-16d9d860ee4c_290x77.png 848w, https://substackcdn.com/image/fetch/$s_!Um9J!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcefd0b73-2267-4153-ad4a-16d9d860ee4c_290x77.png 1272w, https://substackcdn.com/image/fetch/$s_!Um9J!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcefd0b73-2267-4153-ad4a-16d9d860ee4c_290x77.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>To obtain the Hessian is rather easy - we simply take the derivative of our above function (2x - 2) and we get a constant (2 &#8212; since the derivative of 2x is exactly 2):</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hpmq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcd7199d-8c97-4ec7-af40-5bac7199512d_144x72.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hpmq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcd7199d-8c97-4ec7-af40-5bac7199512d_144x72.png 424w, https://substackcdn.com/image/fetch/$s_!hpmq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcd7199d-8c97-4ec7-af40-5bac7199512d_144x72.png 848w, https://substackcdn.com/image/fetch/$s_!hpmq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcd7199d-8c97-4ec7-af40-5bac7199512d_144x72.png 1272w, https://substackcdn.com/image/fetch/$s_!hpmq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcd7199d-8c97-4ec7-af40-5bac7199512d_144x72.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hpmq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcd7199d-8c97-4ec7-af40-5bac7199512d_144x72.png" width="112" height="56" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bcd7199d-8c97-4ec7-af40-5bac7199512d_144x72.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:72,&quot;width&quot;:144,&quot;resizeWidth&quot;:112,&quot;bytes&quot;:1233,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hpmq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcd7199d-8c97-4ec7-af40-5bac7199512d_144x72.png 424w, https://substackcdn.com/image/fetch/$s_!hpmq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcd7199d-8c97-4ec7-af40-5bac7199512d_144x72.png 848w, https://substackcdn.com/image/fetch/$s_!hpmq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcd7199d-8c97-4ec7-af40-5bac7199512d_144x72.png 1272w, https://substackcdn.com/image/fetch/$s_!hpmq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbcd7199d-8c97-4ec7-af40-5bac7199512d_144x72.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>At x<sub>0</sub> the gradient is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hpda!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7ed4ba1-a4ec-491d-a3c2-6e36b5d16874_214x69.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hpda!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7ed4ba1-a4ec-491d-a3c2-6e36b5d16874_214x69.png 424w, https://substackcdn.com/image/fetch/$s_!hpda!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7ed4ba1-a4ec-491d-a3c2-6e36b5d16874_214x69.png 848w, https://substackcdn.com/image/fetch/$s_!hpda!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7ed4ba1-a4ec-491d-a3c2-6e36b5d16874_214x69.png 1272w, https://substackcdn.com/image/fetch/$s_!hpda!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7ed4ba1-a4ec-491d-a3c2-6e36b5d16874_214x69.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hpda!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7ed4ba1-a4ec-491d-a3c2-6e36b5d16874_214x69.png" width="160" height="51.58878504672897" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f7ed4ba1-a4ec-491d-a3c2-6e36b5d16874_214x69.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:69,&quot;width&quot;:214,&quot;resizeWidth&quot;:160,&quot;bytes&quot;:2401,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hpda!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7ed4ba1-a4ec-491d-a3c2-6e36b5d16874_214x69.png 424w, https://substackcdn.com/image/fetch/$s_!hpda!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7ed4ba1-a4ec-491d-a3c2-6e36b5d16874_214x69.png 848w, https://substackcdn.com/image/fetch/$s_!hpda!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7ed4ba1-a4ec-491d-a3c2-6e36b5d16874_214x69.png 1272w, https://substackcdn.com/image/fetch/$s_!hpda!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7ed4ba1-a4ec-491d-a3c2-6e36b5d16874_214x69.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>So, subbing this into our original quadratic equation gives us:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XLa8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F039a3c85-a6a7-4cde-88b8-02521e11d35d_537x172.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XLa8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F039a3c85-a6a7-4cde-88b8-02521e11d35d_537x172.png 424w, https://substackcdn.com/image/fetch/$s_!XLa8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F039a3c85-a6a7-4cde-88b8-02521e11d35d_537x172.png 848w, https://substackcdn.com/image/fetch/$s_!XLa8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F039a3c85-a6a7-4cde-88b8-02521e11d35d_537x172.png 1272w, https://substackcdn.com/image/fetch/$s_!XLa8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F039a3c85-a6a7-4cde-88b8-02521e11d35d_537x172.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XLa8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F039a3c85-a6a7-4cde-88b8-02521e11d35d_537x172.png" width="419" height="134.2048417132216" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/039a3c85-a6a7-4cde-88b8-02521e11d35d_537x172.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:172,&quot;width&quot;:537,&quot;resizeWidth&quot;:419,&quot;bytes&quot;:10271,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!XLa8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F039a3c85-a6a7-4cde-88b8-02521e11d35d_537x172.png 424w, https://substackcdn.com/image/fetch/$s_!XLa8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F039a3c85-a6a7-4cde-88b8-02521e11d35d_537x172.png 848w, https://substackcdn.com/image/fetch/$s_!XLa8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F039a3c85-a6a7-4cde-88b8-02521e11d35d_537x172.png 1272w, https://substackcdn.com/image/fetch/$s_!XLa8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F039a3c85-a6a7-4cde-88b8-02521e11d35d_537x172.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Fantastic!! We can now use this model for our next step!</p><p><strong>Step 4: Minimize the model within the trust region.</strong></p><p>We minimize the quadratic model m<sub>0</sub>(s) but <strong>subject to the constraint</strong> that the step size (s) must lie within the trust region. The trust region constraint is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ybVv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ce6e355-6540-4820-8e87-7ca8c7124d27_221x64.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ybVv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ce6e355-6540-4820-8e87-7ca8c7124d27_221x64.png 424w, https://substackcdn.com/image/fetch/$s_!ybVv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ce6e355-6540-4820-8e87-7ca8c7124d27_221x64.png 848w, https://substackcdn.com/image/fetch/$s_!ybVv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ce6e355-6540-4820-8e87-7ca8c7124d27_221x64.png 1272w, https://substackcdn.com/image/fetch/$s_!ybVv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ce6e355-6540-4820-8e87-7ca8c7124d27_221x64.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ybVv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ce6e355-6540-4820-8e87-7ca8c7124d27_221x64.png" width="179" height="51.83710407239819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0ce6e355-6540-4820-8e87-7ca8c7124d27_221x64.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:64,&quot;width&quot;:221,&quot;resizeWidth&quot;:179,&quot;bytes&quot;:1894,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ybVv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ce6e355-6540-4820-8e87-7ca8c7124d27_221x64.png 424w, https://substackcdn.com/image/fetch/$s_!ybVv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ce6e355-6540-4820-8e87-7ca8c7124d27_221x64.png 848w, https://substackcdn.com/image/fetch/$s_!ybVv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ce6e355-6540-4820-8e87-7ca8c7124d27_221x64.png 1272w, https://substackcdn.com/image/fetch/$s_!ybVv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ce6e355-6540-4820-8e87-7ca8c7124d27_221x64.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We now minimize the quadratic model we obtained earlier (i.e. <strong>5 &#8722; 4s + s<sup>2</sup></strong>), and we do this by simply taking its derivative:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!exvN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feecf1492-7a1e-46bc-accd-974419820045_334x105.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!exvN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feecf1492-7a1e-46bc-accd-974419820045_334x105.png 424w, https://substackcdn.com/image/fetch/$s_!exvN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feecf1492-7a1e-46bc-accd-974419820045_334x105.png 848w, https://substackcdn.com/image/fetch/$s_!exvN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feecf1492-7a1e-46bc-accd-974419820045_334x105.png 1272w, https://substackcdn.com/image/fetch/$s_!exvN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feecf1492-7a1e-46bc-accd-974419820045_334x105.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!exvN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feecf1492-7a1e-46bc-accd-974419820045_334x105.png" width="264" height="82.9940119760479" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eecf1492-7a1e-46bc-accd-974419820045_334x105.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:105,&quot;width&quot;:334,&quot;resizeWidth&quot;:264,&quot;bytes&quot;:4476,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!exvN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feecf1492-7a1e-46bc-accd-974419820045_334x105.png 424w, https://substackcdn.com/image/fetch/$s_!exvN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feecf1492-7a1e-46bc-accd-974419820045_334x105.png 848w, https://substackcdn.com/image/fetch/$s_!exvN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feecf1492-7a1e-46bc-accd-974419820045_334x105.png 1272w, https://substackcdn.com/image/fetch/$s_!exvN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feecf1492-7a1e-46bc-accd-974419820045_334x105.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Setting this equal to zero gives the critical point:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!19tA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f28430c-41c5-4e19-91de-0c6118ac0b8a_425x73.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!19tA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f28430c-41c5-4e19-91de-0c6118ac0b8a_425x73.png 424w, https://substackcdn.com/image/fetch/$s_!19tA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f28430c-41c5-4e19-91de-0c6118ac0b8a_425x73.png 848w, https://substackcdn.com/image/fetch/$s_!19tA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f28430c-41c5-4e19-91de-0c6118ac0b8a_425x73.png 1272w, https://substackcdn.com/image/fetch/$s_!19tA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f28430c-41c5-4e19-91de-0c6118ac0b8a_425x73.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!19tA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f28430c-41c5-4e19-91de-0c6118ac0b8a_425x73.png" width="349" height="59.945882352941176" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0f28430c-41c5-4e19-91de-0c6118ac0b8a_425x73.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:73,&quot;width&quot;:425,&quot;resizeWidth&quot;:349,&quot;bytes&quot;:3065,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!19tA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f28430c-41c5-4e19-91de-0c6118ac0b8a_425x73.png 424w, https://substackcdn.com/image/fetch/$s_!19tA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f28430c-41c5-4e19-91de-0c6118ac0b8a_425x73.png 848w, https://substackcdn.com/image/fetch/$s_!19tA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f28430c-41c5-4e19-91de-0c6118ac0b8a_425x73.png 1272w, https://substackcdn.com/image/fetch/$s_!19tA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f28430c-41c5-4e19-91de-0c6118ac0b8a_425x73.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>However, this step is <strong>outside the trust region </strong>since our we defined this region to be a equal to 1 (in step 2). In other words - we cannot take a step size of 2 so we simple take a step defined by our boundary and simply set s = 1 instead. </p><p><strong>Step 5: </strong>Evaluate the new point.</p><p>At s = 1, the new point is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Yuwz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9990b4d1-bdf9-4828-a027-80c6a2c97b03_370x65.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Yuwz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9990b4d1-bdf9-4828-a027-80c6a2c97b03_370x65.png 424w, https://substackcdn.com/image/fetch/$s_!Yuwz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9990b4d1-bdf9-4828-a027-80c6a2c97b03_370x65.png 848w, https://substackcdn.com/image/fetch/$s_!Yuwz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9990b4d1-bdf9-4828-a027-80c6a2c97b03_370x65.png 1272w, https://substackcdn.com/image/fetch/$s_!Yuwz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9990b4d1-bdf9-4828-a027-80c6a2c97b03_370x65.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Yuwz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9990b4d1-bdf9-4828-a027-80c6a2c97b03_370x65.png" width="312" height="54.810810810810814" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9990b4d1-bdf9-4828-a027-80c6a2c97b03_370x65.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:65,&quot;width&quot;:370,&quot;resizeWidth&quot;:312,&quot;bytes&quot;:2900,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Yuwz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9990b4d1-bdf9-4828-a027-80c6a2c97b03_370x65.png 424w, https://substackcdn.com/image/fetch/$s_!Yuwz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9990b4d1-bdf9-4828-a027-80c6a2c97b03_370x65.png 848w, https://substackcdn.com/image/fetch/$s_!Yuwz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9990b4d1-bdf9-4828-a027-80c6a2c97b03_370x65.png 1272w, https://substackcdn.com/image/fetch/$s_!Yuwz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9990b4d1-bdf9-4828-a027-80c6a2c97b03_370x65.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The function value at x = 1 is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mz1H!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f4b2e3-0210-4388-a3ec-7380d9f79475_375x78.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mz1H!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f4b2e3-0210-4388-a3ec-7380d9f79475_375x78.png 424w, https://substackcdn.com/image/fetch/$s_!mz1H!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f4b2e3-0210-4388-a3ec-7380d9f79475_375x78.png 848w, https://substackcdn.com/image/fetch/$s_!mz1H!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f4b2e3-0210-4388-a3ec-7380d9f79475_375x78.png 1272w, https://substackcdn.com/image/fetch/$s_!mz1H!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f4b2e3-0210-4388-a3ec-7380d9f79475_375x78.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mz1H!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f4b2e3-0210-4388-a3ec-7380d9f79475_375x78.png" width="295" height="61.36" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/50f4b2e3-0210-4388-a3ec-7380d9f79475_375x78.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:78,&quot;width&quot;:375,&quot;resizeWidth&quot;:295,&quot;bytes&quot;:3617,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mz1H!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f4b2e3-0210-4388-a3ec-7380d9f79475_375x78.png 424w, https://substackcdn.com/image/fetch/$s_!mz1H!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f4b2e3-0210-4388-a3ec-7380d9f79475_375x78.png 848w, https://substackcdn.com/image/fetch/$s_!mz1H!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f4b2e3-0210-4388-a3ec-7380d9f79475_375x78.png 1272w, https://substackcdn.com/image/fetch/$s_!mz1H!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50f4b2e3-0210-4388-a3ec-7380d9f79475_375x78.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Step 6:</strong> Adjust the trust region.</p><p>Now, we check whether the quadratic model predicted the function value accurately. The predicted reduction in the model is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Sb_s!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66068e53-db96-4d29-9d57-6ca3f419da86_317x73.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Sb_s!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66068e53-db96-4d29-9d57-6ca3f419da86_317x73.png 424w, https://substackcdn.com/image/fetch/$s_!Sb_s!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66068e53-db96-4d29-9d57-6ca3f419da86_317x73.png 848w, https://substackcdn.com/image/fetch/$s_!Sb_s!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66068e53-db96-4d29-9d57-6ca3f419da86_317x73.png 1272w, https://substackcdn.com/image/fetch/$s_!Sb_s!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66068e53-db96-4d29-9d57-6ca3f419da86_317x73.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Sb_s!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66068e53-db96-4d29-9d57-6ca3f419da86_317x73.png" width="249" height="57.34069400630915" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/66068e53-db96-4d29-9d57-6ca3f419da86_317x73.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:73,&quot;width&quot;:317,&quot;resizeWidth&quot;:249,&quot;bytes&quot;:3505,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Sb_s!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66068e53-db96-4d29-9d57-6ca3f419da86_317x73.png 424w, https://substackcdn.com/image/fetch/$s_!Sb_s!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66068e53-db96-4d29-9d57-6ca3f419da86_317x73.png 848w, https://substackcdn.com/image/fetch/$s_!Sb_s!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66068e53-db96-4d29-9d57-6ca3f419da86_317x73.png 1272w, https://substackcdn.com/image/fetch/$s_!Sb_s!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66068e53-db96-4d29-9d57-6ca3f419da86_317x73.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>At s = 0 we have:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!g8WJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F088178ce-26ea-4f06-8a40-fa89cb097524_454x82.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!g8WJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F088178ce-26ea-4f06-8a40-fa89cb097524_454x82.png 424w, https://substackcdn.com/image/fetch/$s_!g8WJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F088178ce-26ea-4f06-8a40-fa89cb097524_454x82.png 848w, https://substackcdn.com/image/fetch/$s_!g8WJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F088178ce-26ea-4f06-8a40-fa89cb097524_454x82.png 1272w, https://substackcdn.com/image/fetch/$s_!g8WJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F088178ce-26ea-4f06-8a40-fa89cb097524_454x82.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!g8WJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F088178ce-26ea-4f06-8a40-fa89cb097524_454x82.png" width="358" height="64.66079295154185" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/088178ce-26ea-4f06-8a40-fa89cb097524_454x82.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:82,&quot;width&quot;:454,&quot;resizeWidth&quot;:358,&quot;bytes&quot;:4926,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!g8WJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F088178ce-26ea-4f06-8a40-fa89cb097524_454x82.png 424w, https://substackcdn.com/image/fetch/$s_!g8WJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F088178ce-26ea-4f06-8a40-fa89cb097524_454x82.png 848w, https://substackcdn.com/image/fetch/$s_!g8WJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F088178ce-26ea-4f06-8a40-fa89cb097524_454x82.png 1272w, https://substackcdn.com/image/fetch/$s_!g8WJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F088178ce-26ea-4f06-8a40-fa89cb097524_454x82.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>At s = 1 we have:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!APB_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b2cccae-c3b8-4cf0-8456-8935ff4bc31c_636x70.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!APB_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b2cccae-c3b8-4cf0-8456-8935ff4bc31c_636x70.png 424w, https://substackcdn.com/image/fetch/$s_!APB_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b2cccae-c3b8-4cf0-8456-8935ff4bc31c_636x70.png 848w, https://substackcdn.com/image/fetch/$s_!APB_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b2cccae-c3b8-4cf0-8456-8935ff4bc31c_636x70.png 1272w, https://substackcdn.com/image/fetch/$s_!APB_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b2cccae-c3b8-4cf0-8456-8935ff4bc31c_636x70.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!APB_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b2cccae-c3b8-4cf0-8456-8935ff4bc31c_636x70.png" width="480" height="52.83018867924528" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2b2cccae-c3b8-4cf0-8456-8935ff4bc31c_636x70.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:70,&quot;width&quot;:636,&quot;resizeWidth&quot;:480,&quot;bytes&quot;:5557,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!APB_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b2cccae-c3b8-4cf0-8456-8935ff4bc31c_636x70.png 424w, https://substackcdn.com/image/fetch/$s_!APB_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b2cccae-c3b8-4cf0-8456-8935ff4bc31c_636x70.png 848w, https://substackcdn.com/image/fetch/$s_!APB_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b2cccae-c3b8-4cf0-8456-8935ff4bc31c_636x70.png 1272w, https://substackcdn.com/image/fetch/$s_!APB_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b2cccae-c3b8-4cf0-8456-8935ff4bc31c_636x70.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The <strong>predicted reduction</strong> there for is simply the difference between these two, so its equal to 5 - 2 = 3. </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JJFK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F021e5136-354b-4930-9481-9a33f76e9dd0_756x76.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JJFK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F021e5136-354b-4930-9481-9a33f76e9dd0_756x76.png 424w, https://substackcdn.com/image/fetch/$s_!JJFK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F021e5136-354b-4930-9481-9a33f76e9dd0_756x76.png 848w, https://substackcdn.com/image/fetch/$s_!JJFK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F021e5136-354b-4930-9481-9a33f76e9dd0_756x76.png 1272w, https://substackcdn.com/image/fetch/$s_!JJFK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F021e5136-354b-4930-9481-9a33f76e9dd0_756x76.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JJFK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F021e5136-354b-4930-9481-9a33f76e9dd0_756x76.png" width="570" height="57.301587301587304" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/021e5136-354b-4930-9481-9a33f76e9dd0_756x76.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:76,&quot;width&quot;:756,&quot;resizeWidth&quot;:570,&quot;bytes&quot;:8056,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!JJFK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F021e5136-354b-4930-9481-9a33f76e9dd0_756x76.png 424w, https://substackcdn.com/image/fetch/$s_!JJFK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F021e5136-354b-4930-9481-9a33f76e9dd0_756x76.png 848w, https://substackcdn.com/image/fetch/$s_!JJFK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F021e5136-354b-4930-9481-9a33f76e9dd0_756x76.png 1272w, https://substackcdn.com/image/fetch/$s_!JJFK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F021e5136-354b-4930-9481-9a33f76e9dd0_756x76.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>And - checking this by actually subbing in these values into our <strong>real function </strong>we get:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!b0_j!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F994ec5ea-f3f4-40d0-b1bd-ddf2d18faa28_324x75.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!b0_j!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F994ec5ea-f3f4-40d0-b1bd-ddf2d18faa28_324x75.png 424w, https://substackcdn.com/image/fetch/$s_!b0_j!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F994ec5ea-f3f4-40d0-b1bd-ddf2d18faa28_324x75.png 848w, https://substackcdn.com/image/fetch/$s_!b0_j!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F994ec5ea-f3f4-40d0-b1bd-ddf2d18faa28_324x75.png 1272w, https://substackcdn.com/image/fetch/$s_!b0_j!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F994ec5ea-f3f4-40d0-b1bd-ddf2d18faa28_324x75.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!b0_j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F994ec5ea-f3f4-40d0-b1bd-ddf2d18faa28_324x75.png" width="254" height="58.7962962962963" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/994ec5ea-f3f4-40d0-b1bd-ddf2d18faa28_324x75.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:75,&quot;width&quot;:324,&quot;resizeWidth&quot;:254,&quot;bytes&quot;:3285,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!b0_j!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F994ec5ea-f3f4-40d0-b1bd-ddf2d18faa28_324x75.png 424w, https://substackcdn.com/image/fetch/$s_!b0_j!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F994ec5ea-f3f4-40d0-b1bd-ddf2d18faa28_324x75.png 848w, https://substackcdn.com/image/fetch/$s_!b0_j!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F994ec5ea-f3f4-40d0-b1bd-ddf2d18faa28_324x75.png 1272w, https://substackcdn.com/image/fetch/$s_!b0_j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F994ec5ea-f3f4-40d0-b1bd-ddf2d18faa28_324x75.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5Tox!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1388ae1d-1950-410f-9065-30c8b3122103_503x63.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5Tox!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1388ae1d-1950-410f-9065-30c8b3122103_503x63.png 424w, https://substackcdn.com/image/fetch/$s_!5Tox!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1388ae1d-1950-410f-9065-30c8b3122103_503x63.png 848w, https://substackcdn.com/image/fetch/$s_!5Tox!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1388ae1d-1950-410f-9065-30c8b3122103_503x63.png 1272w, https://substackcdn.com/image/fetch/$s_!5Tox!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1388ae1d-1950-410f-9065-30c8b3122103_503x63.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5Tox!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1388ae1d-1950-410f-9065-30c8b3122103_503x63.png" width="393" height="49.22266401590457" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1388ae1d-1950-410f-9065-30c8b3122103_503x63.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:63,&quot;width&quot;:503,&quot;resizeWidth&quot;:393,&quot;bytes&quot;:4520,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5Tox!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1388ae1d-1950-410f-9065-30c8b3122103_503x63.png 424w, https://substackcdn.com/image/fetch/$s_!5Tox!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1388ae1d-1950-410f-9065-30c8b3122103_503x63.png 848w, https://substackcdn.com/image/fetch/$s_!5Tox!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1388ae1d-1950-410f-9065-30c8b3122103_503x63.png 1272w, https://substackcdn.com/image/fetch/$s_!5Tox!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1388ae1d-1950-410f-9065-30c8b3122103_503x63.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8A2a!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8496d29-7846-46e8-9a87-56e65a472564_494x70.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8A2a!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8496d29-7846-46e8-9a87-56e65a472564_494x70.png 424w, https://substackcdn.com/image/fetch/$s_!8A2a!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8496d29-7846-46e8-9a87-56e65a472564_494x70.png 848w, https://substackcdn.com/image/fetch/$s_!8A2a!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8496d29-7846-46e8-9a87-56e65a472564_494x70.png 1272w, https://substackcdn.com/image/fetch/$s_!8A2a!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8496d29-7846-46e8-9a87-56e65a472564_494x70.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8A2a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8496d29-7846-46e8-9a87-56e65a472564_494x70.png" width="382" height="54.12955465587044" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b8496d29-7846-46e8-9a87-56e65a472564_494x70.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:70,&quot;width&quot;:494,&quot;resizeWidth&quot;:382,&quot;bytes&quot;:3987,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8A2a!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8496d29-7846-46e8-9a87-56e65a472564_494x70.png 424w, https://substackcdn.com/image/fetch/$s_!8A2a!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8496d29-7846-46e8-9a87-56e65a472564_494x70.png 848w, https://substackcdn.com/image/fetch/$s_!8A2a!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8496d29-7846-46e8-9a87-56e65a472564_494x70.png 1272w, https://substackcdn.com/image/fetch/$s_!8A2a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8496d29-7846-46e8-9a87-56e65a472564_494x70.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!guVn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2fce428-f8fd-462f-8a79-fe0a2e4e19fb_395x73.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!guVn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2fce428-f8fd-462f-8a79-fe0a2e4e19fb_395x73.png 424w, https://substackcdn.com/image/fetch/$s_!guVn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2fce428-f8fd-462f-8a79-fe0a2e4e19fb_395x73.png 848w, https://substackcdn.com/image/fetch/$s_!guVn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2fce428-f8fd-462f-8a79-fe0a2e4e19fb_395x73.png 1272w, https://substackcdn.com/image/fetch/$s_!guVn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2fce428-f8fd-462f-8a79-fe0a2e4e19fb_395x73.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!guVn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2fce428-f8fd-462f-8a79-fe0a2e4e19fb_395x73.png" width="297" height="54.88860759493671" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b2fce428-f8fd-462f-8a79-fe0a2e4e19fb_395x73.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:73,&quot;width&quot;:395,&quot;resizeWidth&quot;:297,&quot;bytes&quot;:3603,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!guVn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2fce428-f8fd-462f-8a79-fe0a2e4e19fb_395x73.png 424w, https://substackcdn.com/image/fetch/$s_!guVn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2fce428-f8fd-462f-8a79-fe0a2e4e19fb_395x73.png 848w, https://substackcdn.com/image/fetch/$s_!guVn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2fce428-f8fd-462f-8a79-fe0a2e4e19fb_395x73.png 1272w, https://substackcdn.com/image/fetch/$s_!guVn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2fce428-f8fd-462f-8a79-fe0a2e4e19fb_395x73.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Since the model accurately predicted the reduction (3 = 3), we can <strong>increase the trust region radius</strong> for the next iteration. Let&#8217;s increase our step radius to now equal to 2:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Shde!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb840416-f222-4fcb-80c2-a620c86002b6_113x48.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Shde!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb840416-f222-4fcb-80c2-a620c86002b6_113x48.png 424w, https://substackcdn.com/image/fetch/$s_!Shde!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb840416-f222-4fcb-80c2-a620c86002b6_113x48.png 848w, https://substackcdn.com/image/fetch/$s_!Shde!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb840416-f222-4fcb-80c2-a620c86002b6_113x48.png 1272w, https://substackcdn.com/image/fetch/$s_!Shde!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb840416-f222-4fcb-80c2-a620c86002b6_113x48.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Shde!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb840416-f222-4fcb-80c2-a620c86002b6_113x48.png" width="91" height="38.65486725663717" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cb840416-f222-4fcb-80c2-a620c86002b6_113x48.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:48,&quot;width&quot;:113,&quot;resizeWidth&quot;:91,&quot;bytes&quot;:1130,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Shde!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb840416-f222-4fcb-80c2-a620c86002b6_113x48.png 424w, https://substackcdn.com/image/fetch/$s_!Shde!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb840416-f222-4fcb-80c2-a620c86002b6_113x48.png 848w, https://substackcdn.com/image/fetch/$s_!Shde!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb840416-f222-4fcb-80c2-a620c86002b6_113x48.png 1272w, https://substackcdn.com/image/fetch/$s_!Shde!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb840416-f222-4fcb-80c2-a620c86002b6_113x48.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Step 7:</strong> Repeat the process.</p><p>At x = 1, the gradient is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pRdE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e4e482b-5812-43e9-917e-32f2f44b5c82_299x75.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pRdE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e4e482b-5812-43e9-917e-32f2f44b5c82_299x75.png 424w, https://substackcdn.com/image/fetch/$s_!pRdE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e4e482b-5812-43e9-917e-32f2f44b5c82_299x75.png 848w, https://substackcdn.com/image/fetch/$s_!pRdE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e4e482b-5812-43e9-917e-32f2f44b5c82_299x75.png 1272w, https://substackcdn.com/image/fetch/$s_!pRdE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e4e482b-5812-43e9-917e-32f2f44b5c82_299x75.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pRdE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e4e482b-5812-43e9-917e-32f2f44b5c82_299x75.png" width="235" height="58.94648829431438" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e4e482b-5812-43e9-917e-32f2f44b5c82_299x75.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:75,&quot;width&quot;:299,&quot;resizeWidth&quot;:235,&quot;bytes&quot;:3655,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!pRdE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e4e482b-5812-43e9-917e-32f2f44b5c82_299x75.png 424w, https://substackcdn.com/image/fetch/$s_!pRdE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e4e482b-5812-43e9-917e-32f2f44b5c82_299x75.png 848w, https://substackcdn.com/image/fetch/$s_!pRdE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e4e482b-5812-43e9-917e-32f2f44b5c82_299x75.png 1272w, https://substackcdn.com/image/fetch/$s_!pRdE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e4e482b-5812-43e9-917e-32f2f44b5c82_299x75.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!q5rW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ba1dc9-15ce-4b25-a151-918a0d08c0f2_375x75.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!q5rW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ba1dc9-15ce-4b25-a151-918a0d08c0f2_375x75.png 424w, https://substackcdn.com/image/fetch/$s_!q5rW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ba1dc9-15ce-4b25-a151-918a0d08c0f2_375x75.png 848w, https://substackcdn.com/image/fetch/$s_!q5rW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ba1dc9-15ce-4b25-a151-918a0d08c0f2_375x75.png 1272w, https://substackcdn.com/image/fetch/$s_!q5rW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ba1dc9-15ce-4b25-a151-918a0d08c0f2_375x75.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!q5rW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ba1dc9-15ce-4b25-a151-918a0d08c0f2_375x75.png" width="295" height="59" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/54ba1dc9-15ce-4b25-a151-918a0d08c0f2_375x75.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:75,&quot;width&quot;:375,&quot;resizeWidth&quot;:295,&quot;bytes&quot;:3558,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!q5rW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ba1dc9-15ce-4b25-a151-918a0d08c0f2_375x75.png 424w, https://substackcdn.com/image/fetch/$s_!q5rW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ba1dc9-15ce-4b25-a151-918a0d08c0f2_375x75.png 848w, https://substackcdn.com/image/fetch/$s_!q5rW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ba1dc9-15ce-4b25-a151-918a0d08c0f2_375x75.png 1272w, https://substackcdn.com/image/fetch/$s_!q5rW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ba1dc9-15ce-4b25-a151-918a0d08c0f2_375x75.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We also know that the Hessian of our function is equal to 2 - so regardless of the input, the Hessian of our value is still equal to 2:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!D0Mu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591ace49-7446-4b28-b61a-746f2d31c135_345x112.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!D0Mu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591ace49-7446-4b28-b61a-746f2d31c135_345x112.png 424w, https://substackcdn.com/image/fetch/$s_!D0Mu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591ace49-7446-4b28-b61a-746f2d31c135_345x112.png 848w, https://substackcdn.com/image/fetch/$s_!D0Mu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591ace49-7446-4b28-b61a-746f2d31c135_345x112.png 1272w, https://substackcdn.com/image/fetch/$s_!D0Mu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591ace49-7446-4b28-b61a-746f2d31c135_345x112.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!D0Mu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591ace49-7446-4b28-b61a-746f2d31c135_345x112.png" width="281" height="91.2231884057971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/591ace49-7446-4b28-b61a-746f2d31c135_345x112.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:112,&quot;width&quot;:345,&quot;resizeWidth&quot;:281,&quot;bytes&quot;:4972,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!D0Mu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591ace49-7446-4b28-b61a-746f2d31c135_345x112.png 424w, https://substackcdn.com/image/fetch/$s_!D0Mu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591ace49-7446-4b28-b61a-746f2d31c135_345x112.png 848w, https://substackcdn.com/image/fetch/$s_!D0Mu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591ace49-7446-4b28-b61a-746f2d31c135_345x112.png 1272w, https://substackcdn.com/image/fetch/$s_!D0Mu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591ace49-7446-4b28-b61a-746f2d31c135_345x112.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Knowing these 2 values, we can construct our new quadratic model: </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5YCN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9964c100-4c08-4c5a-91e5-5c5696730619_549x96.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5YCN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9964c100-4c08-4c5a-91e5-5c5696730619_549x96.png 424w, https://substackcdn.com/image/fetch/$s_!5YCN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9964c100-4c08-4c5a-91e5-5c5696730619_549x96.png 848w, https://substackcdn.com/image/fetch/$s_!5YCN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9964c100-4c08-4c5a-91e5-5c5696730619_549x96.png 1272w, https://substackcdn.com/image/fetch/$s_!5YCN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9964c100-4c08-4c5a-91e5-5c5696730619_549x96.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5YCN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9964c100-4c08-4c5a-91e5-5c5696730619_549x96.png" width="417" height="72.91803278688525" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9964c100-4c08-4c5a-91e5-5c5696730619_549x96.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:96,&quot;width&quot;:549,&quot;resizeWidth&quot;:417,&quot;bytes&quot;:6836,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5YCN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9964c100-4c08-4c5a-91e5-5c5696730619_549x96.png 424w, https://substackcdn.com/image/fetch/$s_!5YCN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9964c100-4c08-4c5a-91e5-5c5696730619_549x96.png 848w, https://substackcdn.com/image/fetch/$s_!5YCN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9964c100-4c08-4c5a-91e5-5c5696730619_549x96.png 1272w, https://substackcdn.com/image/fetch/$s_!5YCN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9964c100-4c08-4c5a-91e5-5c5696730619_549x96.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qzLP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F700bcdfd-2b5a-443f-b6d7-f9d95438b481_449x92.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qzLP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F700bcdfd-2b5a-443f-b6d7-f9d95438b481_449x92.png 424w, https://substackcdn.com/image/fetch/$s_!qzLP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F700bcdfd-2b5a-443f-b6d7-f9d95438b481_449x92.png 848w, https://substackcdn.com/image/fetch/$s_!qzLP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F700bcdfd-2b5a-443f-b6d7-f9d95438b481_449x92.png 1272w, https://substackcdn.com/image/fetch/$s_!qzLP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F700bcdfd-2b5a-443f-b6d7-f9d95438b481_449x92.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qzLP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F700bcdfd-2b5a-443f-b6d7-f9d95438b481_449x92.png" width="359" height="73.55902004454343" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/700bcdfd-2b5a-443f-b6d7-f9d95438b481_449x92.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:92,&quot;width&quot;:449,&quot;resizeWidth&quot;:359,&quot;bytes&quot;:5123,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qzLP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F700bcdfd-2b5a-443f-b6d7-f9d95438b481_449x92.png 424w, https://substackcdn.com/image/fetch/$s_!qzLP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F700bcdfd-2b5a-443f-b6d7-f9d95438b481_449x92.png 848w, https://substackcdn.com/image/fetch/$s_!qzLP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F700bcdfd-2b5a-443f-b6d7-f9d95438b481_449x92.png 1272w, https://substackcdn.com/image/fetch/$s_!qzLP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F700bcdfd-2b5a-443f-b6d7-f9d95438b481_449x92.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!E-N2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F497bef4d-338b-4e69-b0ed-008e1d315820_336x73.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!E-N2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F497bef4d-338b-4e69-b0ed-008e1d315820_336x73.png 424w, https://substackcdn.com/image/fetch/$s_!E-N2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F497bef4d-338b-4e69-b0ed-008e1d315820_336x73.png 848w, https://substackcdn.com/image/fetch/$s_!E-N2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F497bef4d-338b-4e69-b0ed-008e1d315820_336x73.png 1272w, https://substackcdn.com/image/fetch/$s_!E-N2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F497bef4d-338b-4e69-b0ed-008e1d315820_336x73.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!E-N2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F497bef4d-338b-4e69-b0ed-008e1d315820_336x73.png" width="268" height="58.226190476190474" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/497bef4d-338b-4e69-b0ed-008e1d315820_336x73.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:73,&quot;width&quot;:336,&quot;resizeWidth&quot;:268,&quot;bytes&quot;:3461,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!E-N2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F497bef4d-338b-4e69-b0ed-008e1d315820_336x73.png 424w, https://substackcdn.com/image/fetch/$s_!E-N2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F497bef4d-338b-4e69-b0ed-008e1d315820_336x73.png 848w, https://substackcdn.com/image/fetch/$s_!E-N2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F497bef4d-338b-4e69-b0ed-008e1d315820_336x73.png 1272w, https://substackcdn.com/image/fetch/$s_!E-N2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F497bef4d-338b-4e69-b0ed-008e1d315820_336x73.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This is the quadratic model we will use for x = 1. We need to minimize this function in order to get our next step &#8212; and once again, in order to do this, we take the derivative and set it to 0 to find the critical points:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NMeG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8433c2-ecbe-4bf2-bac1-5d16395ae7f0_605x99.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NMeG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8433c2-ecbe-4bf2-bac1-5d16395ae7f0_605x99.png 424w, https://substackcdn.com/image/fetch/$s_!NMeG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8433c2-ecbe-4bf2-bac1-5d16395ae7f0_605x99.png 848w, https://substackcdn.com/image/fetch/$s_!NMeG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8433c2-ecbe-4bf2-bac1-5d16395ae7f0_605x99.png 1272w, https://substackcdn.com/image/fetch/$s_!NMeG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8433c2-ecbe-4bf2-bac1-5d16395ae7f0_605x99.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NMeG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8433c2-ecbe-4bf2-bac1-5d16395ae7f0_605x99.png" width="479" height="78.38181818181818" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fd8433c2-ecbe-4bf2-bac1-5d16395ae7f0_605x99.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:99,&quot;width&quot;:605,&quot;resizeWidth&quot;:479,&quot;bytes&quot;:5846,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!NMeG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8433c2-ecbe-4bf2-bac1-5d16395ae7f0_605x99.png 424w, https://substackcdn.com/image/fetch/$s_!NMeG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8433c2-ecbe-4bf2-bac1-5d16395ae7f0_605x99.png 848w, https://substackcdn.com/image/fetch/$s_!NMeG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8433c2-ecbe-4bf2-bac1-5d16395ae7f0_605x99.png 1272w, https://substackcdn.com/image/fetch/$s_!NMeG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd8433c2-ecbe-4bf2-bac1-5d16395ae7f0_605x99.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The next step size (s) is equal to 1, and since this falls within our trust region (the size is smaller than 2) &#8212; we can proceed with evaluating our next point. We know that x<sub>1</sub> = 1 and we sub this in to get our next x value:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!w5J_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e912aec-184b-40bf-ae5d-71d1fd659d0f_276x64.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!w5J_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e912aec-184b-40bf-ae5d-71d1fd659d0f_276x64.png 424w, https://substackcdn.com/image/fetch/$s_!w5J_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e912aec-184b-40bf-ae5d-71d1fd659d0f_276x64.png 848w, https://substackcdn.com/image/fetch/$s_!w5J_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e912aec-184b-40bf-ae5d-71d1fd659d0f_276x64.png 1272w, https://substackcdn.com/image/fetch/$s_!w5J_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e912aec-184b-40bf-ae5d-71d1fd659d0f_276x64.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!w5J_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e912aec-184b-40bf-ae5d-71d1fd659d0f_276x64.png" width="218" height="50.55072463768116" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3e912aec-184b-40bf-ae5d-71d1fd659d0f_276x64.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:64,&quot;width&quot;:276,&quot;resizeWidth&quot;:218,&quot;bytes&quot;:2043,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!w5J_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e912aec-184b-40bf-ae5d-71d1fd659d0f_276x64.png 424w, https://substackcdn.com/image/fetch/$s_!w5J_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e912aec-184b-40bf-ae5d-71d1fd659d0f_276x64.png 848w, https://substackcdn.com/image/fetch/$s_!w5J_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e912aec-184b-40bf-ae5d-71d1fd659d0f_276x64.png 1272w, https://substackcdn.com/image/fetch/$s_!w5J_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e912aec-184b-40bf-ae5d-71d1fd659d0f_276x64.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The function value at this point is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PQ-N!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e21b770-5044-4022-8100-ab7d6c51ba71_378x65.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PQ-N!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e21b770-5044-4022-8100-ab7d6c51ba71_378x65.png 424w, https://substackcdn.com/image/fetch/$s_!PQ-N!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e21b770-5044-4022-8100-ab7d6c51ba71_378x65.png 848w, https://substackcdn.com/image/fetch/$s_!PQ-N!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e21b770-5044-4022-8100-ab7d6c51ba71_378x65.png 1272w, https://substackcdn.com/image/fetch/$s_!PQ-N!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e21b770-5044-4022-8100-ab7d6c51ba71_378x65.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PQ-N!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e21b770-5044-4022-8100-ab7d6c51ba71_378x65.png" width="280" height="48.148148148148145" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5e21b770-5044-4022-8100-ab7d6c51ba71_378x65.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:65,&quot;width&quot;:378,&quot;resizeWidth&quot;:280,&quot;bytes&quot;:3598,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!PQ-N!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e21b770-5044-4022-8100-ab7d6c51ba71_378x65.png 424w, https://substackcdn.com/image/fetch/$s_!PQ-N!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e21b770-5044-4022-8100-ab7d6c51ba71_378x65.png 848w, https://substackcdn.com/image/fetch/$s_!PQ-N!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e21b770-5044-4022-8100-ab7d6c51ba71_378x65.png 1272w, https://substackcdn.com/image/fetch/$s_!PQ-N!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e21b770-5044-4022-8100-ab7d6c51ba71_378x65.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We can see that the above method leads us to our minimum (x = 2) in only two iterations. </p><p>The main difference between this method from and the approximate line search is that in this case, we only moved as far as the model was trustworthy and adjusted the region size dynamically based on the model prediction accuracy. Unlike approximate line search, which adjusts step lengths along a search direction through trial and error, the trust region method adjusted the step size in a much more calculated way. This methodology of adjusting the step size usually leads to more robust convergence, especially when dealing with complex functions or poor initial search directions. It balances making progress toward the solution while avoiding risky or uncertain moves. </p><p>This ends the outline for our algorithms &#8212; in the next section, we discuss some key methodologies which are used in deciding when to terminate our algorithm(s). Up until now, we assumed that we had a clear cut answer, but in the real-world, things tend to be a bit more complex. </p><h3>Termination Conditions</h3><p>There are four common termination conditions for descent direction methods:</p><ol><li><p><strong>Maximum Number of Iterations</strong>: This is a practical condition that stops the optimization process after a predetermined number of iterations, even if the other conditions haven't been met. This is useful for preventing the algorithm from running indefinitely, especially in cases where convergence is slow or uncertain.</p></li><li><p><strong>Absolute Improvement (i.e. small change in objective function value): </strong>This condition monitors the change in the value of the objective function (the function you're trying to minimize or maximize) between iterations. If the change is very small, it suggests that further steps are unlikely to significantly improve the solution. A small change in the objective function value indicates that further iterations aren't making meaningful improvements, so the process can be stopped.</p><p>Imagine that you're iteratively adjusting a recipe to get the perfect taste. After several tweaks, the taste changes very little with each adjustment. At this point, you decide that it's "good enough" and stop making further changes.</p></li><li><p><strong>Relative Improvement (i.e. small step size): </strong>This condition checks if the step size taken in the descent direction is very small. If the algorithm is only making tiny steps, it might mean that the function is nearly flat around the current point, and significant progress isn't possible.</p><p>A great intuiting for this is imagining that you&#8217;re adjusting a thermostat to find the perfect room temperature. Eventually, you find yourself only making tiny adjustments and realize that the temperature doesn't change much with each tweak, so you know you're already close to the ideal temperature and you stop adjusting.</p></li><li><p><strong>Gradient magnitude</strong>: This condition checks whether the gradient of the function is close to zero. The gradient represents the direction and rate of the steepest ascent. In descent methods, we move in the opposite direction (downhill), so if the gradient magnitude is very small, we know that the slope is nearly flat and that we&#8217;re close to a local minimum so we stop iterating at this point.</p><p>A great intuition for this is imaging that you're walking down a hill. As you approach the bottom, the ground becomes less steep. When the slope is almost flat, you know that further movement in any direction won't significantly lower your position and so you stop.</p></li></ol><div><hr></div><p>This ends Part 2 of this series. In Part 3, we will continue our dive into more optimization algorithms. Below is a section summary discussing the key points which we went over for anyone needing a review. </p><div><hr></div><h3>Section Summary</h3><ul><li><p><strong>Descent direction methods incrementally descend toward a local optimum</strong>: the don&#8217;t guarantee finding the global minimum or maximum, but they are effective in finding a local optimum by progressively moving in the direction that most reduces a function&#8217;s value.</p></li><li><p><strong>Approximate line search can be used to identify appropriate descent step sizes</strong>: Exact line search methods can be time-consuming because they require finding the precise best step size. Approximate line search offers a quicker alternative by finding a "good enough" step size that reduces the function value sufficiently without needing to be perfect. Approximate line search strikes a balance between accuracy and efficiency, making it a practical choice for selecting step sizes in optimization algorithms.</p></li><li><p><strong>Trust region methods constrain the step to lie within a local region</strong> <strong>that expands or contracts based on predictive accuracy</strong>: Trust region methods involve limiting your steps to a local area (the "trust region") where the function is well-behaved and easier to model. The size of this region adjusts dynamically based on how accurately your model predicts changes in the function's value. They help maintain control over the optimization process by adapting the step size based on how well your predictions match reality, reducing the risk of making large, inaccurate steps.</p></li><li><p><strong>Termination conditions for descent methods can be based on criteria such as the change in the objective function value or the magnitude of the gradient</strong>: Termination conditions determine when to stop the optimization process, and 4 key ones used in descent methods are provided below:</p><ul><li><p><strong>Maximum Number of Iterations</strong>: Stop after a fixed number of steps to prevent the algorithm from running indefinitely.</p></li><li><p><strong>Small Change in Objective Function Value</strong>: Stop when further changes to the function value are insignificant.</p></li><li><p><strong>Small Step Size</strong>: Stop when the algorithm is taking tiny steps, suggesting convergence.</p></li><li><p><strong>Small Gradient Magnitude</strong>: Stop when the slope is nearly flat, indicating you're close to a local optimum.</p></li></ul></li></ul><div><hr></div><p>I&#8217;m currently working on a a visual-focused cheat sheet dealing with algorithms which I&#8217;ll try to make available soon. This will be a continuation of my <a href="https://photonlines.substack.com/p/visual-data-structures-cheat-sheet">Visual Data Structures Cheat Sheet</a>. If you enjoyed reading this, please like an subscribe and thank you!</p>]]></content:encoded></item><item><title><![CDATA[Visual Data Structures Cheat-Sheet]]></title><description><![CDATA[A visual overview of some of the key data-structures used in the real world.]]></description><link>https://photonlines.substack.com/p/visual-data-structures-cheat-sheet</link><guid isPermaLink="false">https://photonlines.substack.com/p/visual-data-structures-cheat-sheet</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Wed, 14 Aug 2024 12:19:55 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!jArn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16770499-04eb-403c-838c-9914bd4cfcbe_1096x684.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I love learning about concepts visually &#8211; so I decided to come up with a &#8216;cheat sheet&#8217; which helps explain and grok some of the main data-structures used in computer science and which have applications in the real world. This cheat-sheet helps me review the ones I find to be the most important. I usually like to use these to prepare for interviews, so hopefully it helps others who want a visual overview of some key concepts. Below are the results. </p><p><strong>Note</strong>: If you&#8217;re comfortable with data structures and want to see a similar cheat-sheet but specifically tailored towards algorithms, you can reference my <a href="https://photonlines.substack.com/p/visual-focused-algorithms-cheat-sheet">Visual-Focused Algorithms Cheat Sheet</a>. </p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Photon-Lines Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div><hr></div><h3><strong>Performance Review (and Why it Matters)</strong></h3><h4><strong>Big O Complexity:</strong></h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jArn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16770499-04eb-403c-838c-9914bd4cfcbe_1096x684.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jArn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16770499-04eb-403c-838c-9914bd4cfcbe_1096x684.png 424w, https://substackcdn.com/image/fetch/$s_!jArn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16770499-04eb-403c-838c-9914bd4cfcbe_1096x684.png 848w, https://substackcdn.com/image/fetch/$s_!jArn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16770499-04eb-403c-838c-9914bd4cfcbe_1096x684.png 1272w, https://substackcdn.com/image/fetch/$s_!jArn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16770499-04eb-403c-838c-9914bd4cfcbe_1096x684.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jArn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16770499-04eb-403c-838c-9914bd4cfcbe_1096x684.png" width="1096" height="684" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/16770499-04eb-403c-838c-9914bd4cfcbe_1096x684.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:684,&quot;width&quot;:1096,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:62778,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!jArn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16770499-04eb-403c-838c-9914bd4cfcbe_1096x684.png 424w, https://substackcdn.com/image/fetch/$s_!jArn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16770499-04eb-403c-838c-9914bd4cfcbe_1096x684.png 848w, https://substackcdn.com/image/fetch/$s_!jArn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16770499-04eb-403c-838c-9914bd4cfcbe_1096x684.png 1272w, https://substackcdn.com/image/fetch/$s_!jArn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16770499-04eb-403c-838c-9914bd4cfcbe_1096x684.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></figure></div><p><strong>Why Big-O Complexity is Important: </strong>for small data-sets, algorithm complexity may not play a very important role, but as our data gets larger &#8211; the performance impact of our algorithm has a drastic effect on the response time. Paying attention to complexity therefore plays a vital role in program quality within any application domains which have reasonable scale.</p><p>Let&#8217;s assume that our data-set has 1 million (1,000,000) elements:</p><ul><li><p>An O(1) algorithm will cost 1 operation.</p></li><li><p>An O(log(n)) algorithm will cost 14 operations.</p></li><li><p>An O(n) algorithm will cost 1,000,000 operations.</p></li><li><p>An O(n * log(n)) algorithm will cost 14,000,000 operations.</p></li><li><p>An O(n<sup>2</sup>) algorithm will cost 1 trillion (1,000,000,000,000) operations.</p></li></ul><p>You should be able to see why algorithm complexity matters.</p><h4><strong>Latency numbers every programmer should know:</strong></h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MTnQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f346952-d4b0-4428-965d-b4018bbde9a8_1529x607.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MTnQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f346952-d4b0-4428-965d-b4018bbde9a8_1529x607.png 424w, https://substackcdn.com/image/fetch/$s_!MTnQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f346952-d4b0-4428-965d-b4018bbde9a8_1529x607.png 848w, https://substackcdn.com/image/fetch/$s_!MTnQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f346952-d4b0-4428-965d-b4018bbde9a8_1529x607.png 1272w, https://substackcdn.com/image/fetch/$s_!MTnQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f346952-d4b0-4428-965d-b4018bbde9a8_1529x607.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MTnQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f346952-d4b0-4428-965d-b4018bbde9a8_1529x607.png" width="1456" height="578" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3f346952-d4b0-4428-965d-b4018bbde9a8_1529x607.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:578,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:162522,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MTnQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f346952-d4b0-4428-965d-b4018bbde9a8_1529x607.png 424w, https://substackcdn.com/image/fetch/$s_!MTnQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f346952-d4b0-4428-965d-b4018bbde9a8_1529x607.png 848w, https://substackcdn.com/image/fetch/$s_!MTnQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f346952-d4b0-4428-965d-b4018bbde9a8_1529x607.png 1272w, https://substackcdn.com/image/fetch/$s_!MTnQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f346952-d4b0-4428-965d-b4018bbde9a8_1529x607.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></figure></div><p></p><p><strong>Source and Full Overview: </strong><a href="https://colin-scott.github.io/personal_website/research/interactive_latency.html">https://colin-scott.github.io/personal_website/research/interactive_latency.html</a> </p><h4>The RUM Trade-off</h4><p>Another important aspect to pay attention to when it comes to choosing a data-structure is the RUM tradeoff:</p><ul><li><p><strong>Read Efficiency (R):</strong> How quickly you can retrieve or access data from the data structure.</p></li><li><p><strong>Update Efficiency (U):</strong> How quickly you can insert, delete, or modify data in the data structure.</p></li><li><p><strong>Memory Efficiency (M):</strong> How much memory or space the data structure uses.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Dy97!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b9ea745-28ad-4226-a945-aaa6ced9c4c5_1796x1406.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Dy97!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b9ea745-28ad-4226-a945-aaa6ced9c4c5_1796x1406.png 424w, https://substackcdn.com/image/fetch/$s_!Dy97!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b9ea745-28ad-4226-a945-aaa6ced9c4c5_1796x1406.png 848w, https://substackcdn.com/image/fetch/$s_!Dy97!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b9ea745-28ad-4226-a945-aaa6ced9c4c5_1796x1406.png 1272w, https://substackcdn.com/image/fetch/$s_!Dy97!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b9ea745-28ad-4226-a945-aaa6ced9c4c5_1796x1406.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Dy97!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b9ea745-28ad-4226-a945-aaa6ced9c4c5_1796x1406.png" width="563" height="440.81043956043953" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2b9ea745-28ad-4226-a945-aaa6ced9c4c5_1796x1406.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1140,&quot;width&quot;:1456,&quot;resizeWidth&quot;:563,&quot;bytes&quot;:243950,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Dy97!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b9ea745-28ad-4226-a945-aaa6ced9c4c5_1796x1406.png 424w, https://substackcdn.com/image/fetch/$s_!Dy97!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b9ea745-28ad-4226-a945-aaa6ced9c4c5_1796x1406.png 848w, https://substackcdn.com/image/fetch/$s_!Dy97!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b9ea745-28ad-4226-a945-aaa6ced9c4c5_1796x1406.png 1272w, https://substackcdn.com/image/fetch/$s_!Dy97!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b9ea745-28ad-4226-a945-aaa6ced9c4c5_1796x1406.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></figure></div><p></p><p>Now that we provided a basic overview of some key performance characteristics to pay attention to, let&#8217;s continue on and get to our key focus: data structures. </p><div><hr></div><h3><strong>Important Data Structures</strong></h3><div><hr></div><h4><strong>Array &amp; Linked List</strong></h4><p>An <strong>array</strong> is stored contiguously in memory and is known for having fast lookup but slow update/write times while a <strong>linked list</strong> is stored non-contiguously and is known for fast updates/writes but slow lookups<strong>:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WzxN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ec1b5d0-c538-4f26-bb81-e676a9cf992d_1057x691.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WzxN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ec1b5d0-c538-4f26-bb81-e676a9cf992d_1057x691.png 424w, https://substackcdn.com/image/fetch/$s_!WzxN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ec1b5d0-c538-4f26-bb81-e676a9cf992d_1057x691.png 848w, https://substackcdn.com/image/fetch/$s_!WzxN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ec1b5d0-c538-4f26-bb81-e676a9cf992d_1057x691.png 1272w, https://substackcdn.com/image/fetch/$s_!WzxN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ec1b5d0-c538-4f26-bb81-e676a9cf992d_1057x691.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WzxN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ec1b5d0-c538-4f26-bb81-e676a9cf992d_1057x691.png" width="1057" height="691" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8ec1b5d0-c538-4f26-bb81-e676a9cf992d_1057x691.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:691,&quot;width&quot;:1057,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:15978,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WzxN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ec1b5d0-c538-4f26-bb81-e676a9cf992d_1057x691.png 424w, https://substackcdn.com/image/fetch/$s_!WzxN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ec1b5d0-c538-4f26-bb81-e676a9cf992d_1057x691.png 848w, https://substackcdn.com/image/fetch/$s_!WzxN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ec1b5d0-c538-4f26-bb81-e676a9cf992d_1057x691.png 1272w, https://substackcdn.com/image/fetch/$s_!WzxN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ec1b5d0-c538-4f26-bb81-e676a9cf992d_1057x691.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></figure></div><div><hr></div><h4><strong>Queue </strong></h4><p>A linear data structure that follows the First-In-First-Out (FIFO) principle<strong>:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fssS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9d7d4d-846a-49df-a7a7-255827951691_1234x569.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fssS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9d7d4d-846a-49df-a7a7-255827951691_1234x569.png 424w, https://substackcdn.com/image/fetch/$s_!fssS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9d7d4d-846a-49df-a7a7-255827951691_1234x569.png 848w, https://substackcdn.com/image/fetch/$s_!fssS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9d7d4d-846a-49df-a7a7-255827951691_1234x569.png 1272w, https://substackcdn.com/image/fetch/$s_!fssS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9d7d4d-846a-49df-a7a7-255827951691_1234x569.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fssS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9d7d4d-846a-49df-a7a7-255827951691_1234x569.png" width="1234" height="569" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5b9d7d4d-846a-49df-a7a7-255827951691_1234x569.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:569,&quot;width&quot;:1234,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:14372,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fssS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9d7d4d-846a-49df-a7a7-255827951691_1234x569.png 424w, https://substackcdn.com/image/fetch/$s_!fssS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9d7d4d-846a-49df-a7a7-255827951691_1234x569.png 848w, https://substackcdn.com/image/fetch/$s_!fssS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9d7d4d-846a-49df-a7a7-255827951691_1234x569.png 1272w, https://substackcdn.com/image/fetch/$s_!fssS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b9d7d4d-846a-49df-a7a7-255827951691_1234x569.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></figure></div><div><hr></div><h4><strong>Stack</strong></h4><p>Follows the Last-In-First-Out (LIFO) principle, where elements are added and removed from the top:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6nHT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72edf5c8-6c19-4fed-b458-5c4b11237f99_859x360.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6nHT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72edf5c8-6c19-4fed-b458-5c4b11237f99_859x360.png 424w, https://substackcdn.com/image/fetch/$s_!6nHT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72edf5c8-6c19-4fed-b458-5c4b11237f99_859x360.png 848w, https://substackcdn.com/image/fetch/$s_!6nHT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72edf5c8-6c19-4fed-b458-5c4b11237f99_859x360.png 1272w, https://substackcdn.com/image/fetch/$s_!6nHT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72edf5c8-6c19-4fed-b458-5c4b11237f99_859x360.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6nHT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72edf5c8-6c19-4fed-b458-5c4b11237f99_859x360.png" width="859" height="360" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/72edf5c8-6c19-4fed-b458-5c4b11237f99_859x360.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:360,&quot;width&quot;:859,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:18946,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6nHT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72edf5c8-6c19-4fed-b458-5c4b11237f99_859x360.png 424w, https://substackcdn.com/image/fetch/$s_!6nHT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72edf5c8-6c19-4fed-b458-5c4b11237f99_859x360.png 848w, https://substackcdn.com/image/fetch/$s_!6nHT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72edf5c8-6c19-4fed-b458-5c4b11237f99_859x360.png 1272w, https://substackcdn.com/image/fetch/$s_!6nHT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72edf5c8-6c19-4fed-b458-5c4b11237f99_859x360.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></figure></div><div><hr></div><h4><strong>Hash Map</strong></h4><p>Provides almost instant access to elements and accomplishes this by creating key-value pairs using a hash-function. O(1) time complexity for insertions, deletions, and look-ups albeit trade-off is memory utilization &#8211; full description is <a href="https://photonlines.substack.com/p/introduction-to-hash-tables">available here</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_!TToh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42b150ac-0feb-4893-b535-eb21a37463b7_1622x1325.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TToh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42b150ac-0feb-4893-b535-eb21a37463b7_1622x1325.png 424w, https://substackcdn.com/image/fetch/$s_!TToh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42b150ac-0feb-4893-b535-eb21a37463b7_1622x1325.png 848w, https://substackcdn.com/image/fetch/$s_!TToh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42b150ac-0feb-4893-b535-eb21a37463b7_1622x1325.png 1272w, https://substackcdn.com/image/fetch/$s_!TToh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42b150ac-0feb-4893-b535-eb21a37463b7_1622x1325.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TToh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42b150ac-0feb-4893-b535-eb21a37463b7_1622x1325.png" width="1456" height="1189" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/42b150ac-0feb-4893-b535-eb21a37463b7_1622x1325.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1189,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:201570,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TToh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42b150ac-0feb-4893-b535-eb21a37463b7_1622x1325.png 424w, https://substackcdn.com/image/fetch/$s_!TToh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42b150ac-0feb-4893-b535-eb21a37463b7_1622x1325.png 848w, https://substackcdn.com/image/fetch/$s_!TToh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42b150ac-0feb-4893-b535-eb21a37463b7_1622x1325.png 1272w, https://substackcdn.com/image/fetch/$s_!TToh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42b150ac-0feb-4893-b535-eb21a37463b7_1622x1325.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></figure></div><div><hr></div><h3><strong>Tree Based Data Structures</strong></h3><p><strong>(used in data-intensive applications)</strong></p><p>Prior to listing all of the data-structures, we first have to review one important <strong>algorithm </strong>which plays a vital role within trees - the binary search algorithm.</p><div><hr></div><h4><strong>Binary Search </strong></h4><p>This is a search through a sorted block of elements and it&#8217;s done by continually sub-dividing the search-space in half. It&#8217;s like opening a dictionary by locating the middle page within it - checking to see if our search-word is to the left / right half of our dictionary and continually repeating this process until we find our element. Allows for efficient O(log(n)) lookup<strong>:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6huF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5554030b-7351-4119-a6bf-94f52ab588c3_828x744.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6huF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5554030b-7351-4119-a6bf-94f52ab588c3_828x744.png 424w, https://substackcdn.com/image/fetch/$s_!6huF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5554030b-7351-4119-a6bf-94f52ab588c3_828x744.png 848w, https://substackcdn.com/image/fetch/$s_!6huF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5554030b-7351-4119-a6bf-94f52ab588c3_828x744.png 1272w, https://substackcdn.com/image/fetch/$s_!6huF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5554030b-7351-4119-a6bf-94f52ab588c3_828x744.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6huF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5554030b-7351-4119-a6bf-94f52ab588c3_828x744.png" width="477" height="428.60869565217394" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5554030b-7351-4119-a6bf-94f52ab588c3_828x744.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:744,&quot;width&quot;:828,&quot;resizeWidth&quot;:477,&quot;bytes&quot;:5654,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6huF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5554030b-7351-4119-a6bf-94f52ab588c3_828x744.png 424w, https://substackcdn.com/image/fetch/$s_!6huF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5554030b-7351-4119-a6bf-94f52ab588c3_828x744.png 848w, https://substackcdn.com/image/fetch/$s_!6huF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5554030b-7351-4119-a6bf-94f52ab588c3_828x744.png 1272w, https://substackcdn.com/image/fetch/$s_!6huF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5554030b-7351-4119-a6bf-94f52ab588c3_828x744.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></figure></div><div><hr></div><h4><strong>Binary-Search Tree:</strong></h4><p>A tree where each node has at most 2 children and the left child has a smaller value than the parent &amp; the right child has a larger one. Allows for efficient O(log(n)) lookup if the binary search tree is <strong>balanced </strong>(amount of nodes located on the left don&#8217;t exceed the right-hand nodes by a large factor). This works due to the fact that we cut our search space in half as we transverse the tree (go from parent to child):</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_Yl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc92650aa-c340-4132-bd46-3e68e8c44bed_820x614.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Z_Yl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc92650aa-c340-4132-bd46-3e68e8c44bed_820x614.png 424w, https://substackcdn.com/image/fetch/$s_!Z_Yl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc92650aa-c340-4132-bd46-3e68e8c44bed_820x614.png 848w, https://substackcdn.com/image/fetch/$s_!Z_Yl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc92650aa-c340-4132-bd46-3e68e8c44bed_820x614.png 1272w, https://substackcdn.com/image/fetch/$s_!Z_Yl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc92650aa-c340-4132-bd46-3e68e8c44bed_820x614.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Z_Yl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc92650aa-c340-4132-bd46-3e68e8c44bed_820x614.png" width="439" height="328.71463414634144" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c92650aa-c340-4132-bd46-3e68e8c44bed_820x614.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:614,&quot;width&quot;:820,&quot;resizeWidth&quot;:439,&quot;bytes&quot;:49628,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Z_Yl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc92650aa-c340-4132-bd46-3e68e8c44bed_820x614.png 424w, https://substackcdn.com/image/fetch/$s_!Z_Yl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc92650aa-c340-4132-bd46-3e68e8c44bed_820x614.png 848w, https://substackcdn.com/image/fetch/$s_!Z_Yl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc92650aa-c340-4132-bd46-3e68e8c44bed_820x614.png 1272w, https://substackcdn.com/image/fetch/$s_!Z_Yl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc92650aa-c340-4132-bd46-3e68e8c44bed_820x614.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></figure></div><div><hr></div><h4><strong>Red-Black Tree </strong></h4><p>A binary search tree which maintains its balance by assigning nodes to colors (red or black) and by following a set of rules which ensure that it stays balanced<strong>:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LfKp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe300f8e2-0881-48ea-99d5-72435260b96f_937x666.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LfKp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe300f8e2-0881-48ea-99d5-72435260b96f_937x666.png 424w, https://substackcdn.com/image/fetch/$s_!LfKp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe300f8e2-0881-48ea-99d5-72435260b96f_937x666.png 848w, https://substackcdn.com/image/fetch/$s_!LfKp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe300f8e2-0881-48ea-99d5-72435260b96f_937x666.png 1272w, https://substackcdn.com/image/fetch/$s_!LfKp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe300f8e2-0881-48ea-99d5-72435260b96f_937x666.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LfKp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe300f8e2-0881-48ea-99d5-72435260b96f_937x666.png" width="937" height="666" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e300f8e2-0881-48ea-99d5-72435260b96f_937x666.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:666,&quot;width&quot;:937,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:63888,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!LfKp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe300f8e2-0881-48ea-99d5-72435260b96f_937x666.png 424w, https://substackcdn.com/image/fetch/$s_!LfKp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe300f8e2-0881-48ea-99d5-72435260b96f_937x666.png 848w, https://substackcdn.com/image/fetch/$s_!LfKp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe300f8e2-0881-48ea-99d5-72435260b96f_937x666.png 1272w, https://substackcdn.com/image/fetch/$s_!LfKp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe300f8e2-0881-48ea-99d5-72435260b96f_937x666.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></figure></div><div><hr></div><h4><strong>AVL Tree</strong></h4><p>A self-balancing binary search tree which achieves balance by making sure that its <strong>balance factor </strong>(difference in height between all left and right sub-trees) is at most equal to one. Automatically re-balances itself through <strong>rotations</strong> during insertions and deletions. Full write-up and explanation is <a href="https://photonlines.substack.com/p/grokking-avl-and-ravl-trees">available here</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_!LR9y!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf07779b-ca41-4ada-b787-fdc2ee48a477_1790x1534.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LR9y!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf07779b-ca41-4ada-b787-fdc2ee48a477_1790x1534.png 424w, https://substackcdn.com/image/fetch/$s_!LR9y!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf07779b-ca41-4ada-b787-fdc2ee48a477_1790x1534.png 848w, https://substackcdn.com/image/fetch/$s_!LR9y!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf07779b-ca41-4ada-b787-fdc2ee48a477_1790x1534.png 1272w, https://substackcdn.com/image/fetch/$s_!LR9y!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf07779b-ca41-4ada-b787-fdc2ee48a477_1790x1534.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LR9y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf07779b-ca41-4ada-b787-fdc2ee48a477_1790x1534.png" width="659" height="564.8571428571429" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/df07779b-ca41-4ada-b787-fdc2ee48a477_1790x1534.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1248,&quot;width&quot;:1456,&quot;resizeWidth&quot;:659,&quot;bytes&quot;:204345,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!LR9y!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf07779b-ca41-4ada-b787-fdc2ee48a477_1790x1534.png 424w, https://substackcdn.com/image/fetch/$s_!LR9y!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf07779b-ca41-4ada-b787-fdc2ee48a477_1790x1534.png 848w, https://substackcdn.com/image/fetch/$s_!LR9y!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf07779b-ca41-4ada-b787-fdc2ee48a477_1790x1534.png 1272w, https://substackcdn.com/image/fetch/$s_!LR9y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf07779b-ca41-4ada-b787-fdc2ee48a477_1790x1534.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></figure></div><div><hr></div><h4><strong>Heap</strong></h4><p>Tree where each parent node is either greater than or equal to (<strong>max-heap</strong>) its child nodes or less than or equal to (<strong>min-heap</strong>) its child nodes. Allows for efficient retrieval of minimum or maximum values &amp; commonly used in implementing priority queues.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3b_k!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7157043-7859-4b1b-8ab8-3abfa4b4df62_642x264.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3b_k!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7157043-7859-4b1b-8ab8-3abfa4b4df62_642x264.png 424w, https://substackcdn.com/image/fetch/$s_!3b_k!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7157043-7859-4b1b-8ab8-3abfa4b4df62_642x264.png 848w, https://substackcdn.com/image/fetch/$s_!3b_k!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7157043-7859-4b1b-8ab8-3abfa4b4df62_642x264.png 1272w, https://substackcdn.com/image/fetch/$s_!3b_k!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7157043-7859-4b1b-8ab8-3abfa4b4df62_642x264.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3b_k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7157043-7859-4b1b-8ab8-3abfa4b4df62_642x264.png" width="642" height="264" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f7157043-7859-4b1b-8ab8-3abfa4b4df62_642x264.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:264,&quot;width&quot;:642,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:32935,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3b_k!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7157043-7859-4b1b-8ab8-3abfa4b4df62_642x264.png 424w, https://substackcdn.com/image/fetch/$s_!3b_k!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7157043-7859-4b1b-8ab8-3abfa4b4df62_642x264.png 848w, https://substackcdn.com/image/fetch/$s_!3b_k!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7157043-7859-4b1b-8ab8-3abfa4b4df62_642x264.png 1272w, https://substackcdn.com/image/fetch/$s_!3b_k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7157043-7859-4b1b-8ab8-3abfa4b4df62_642x264.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></figure></div><p></p><div><hr></div><h4><strong>Skip List </strong></h4><p>A skip list is an extension of a linked list that allows for faster search, insertion, and deletion operations by using multiple levels of lists. It does this by allowing you to &#8216;skip&#8217; many linked elements by traversing down from the parent list to the appropriate child. It&#8217;s similar to a binary search tree albeit you can think of it as a search tree with randomization thrown in. Great explanation <a href="https://igoro.com/archive/skip-lists-are-fascinating/">available here</a><strong>:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7deJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47dbcee2-aee7-4ac5-91a9-1cd1943278a6_1165x381.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7deJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47dbcee2-aee7-4ac5-91a9-1cd1943278a6_1165x381.png 424w, https://substackcdn.com/image/fetch/$s_!7deJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47dbcee2-aee7-4ac5-91a9-1cd1943278a6_1165x381.png 848w, https://substackcdn.com/image/fetch/$s_!7deJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47dbcee2-aee7-4ac5-91a9-1cd1943278a6_1165x381.png 1272w, https://substackcdn.com/image/fetch/$s_!7deJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47dbcee2-aee7-4ac5-91a9-1cd1943278a6_1165x381.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7deJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47dbcee2-aee7-4ac5-91a9-1cd1943278a6_1165x381.png" width="1165" height="381" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/47dbcee2-aee7-4ac5-91a9-1cd1943278a6_1165x381.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:381,&quot;width&quot;:1165,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:28238,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!7deJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47dbcee2-aee7-4ac5-91a9-1cd1943278a6_1165x381.png 424w, https://substackcdn.com/image/fetch/$s_!7deJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47dbcee2-aee7-4ac5-91a9-1cd1943278a6_1165x381.png 848w, https://substackcdn.com/image/fetch/$s_!7deJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47dbcee2-aee7-4ac5-91a9-1cd1943278a6_1165x381.png 1272w, https://substackcdn.com/image/fetch/$s_!7deJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47dbcee2-aee7-4ac5-91a9-1cd1943278a6_1165x381.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></figure></div><div><hr></div><h4><strong>B+ Trees</strong> </h4><p>Are often used for database storage. A B+ tree is a balanced tree where all data is stored in the leaf nodes which are linked together in a sorted order for quick sequential access<strong>:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Ny-9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc05b28b4-6fc6-41a5-bbeb-776eb33239ab_1674x1689.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Ny-9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc05b28b4-6fc6-41a5-bbeb-776eb33239ab_1674x1689.png 424w, https://substackcdn.com/image/fetch/$s_!Ny-9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc05b28b4-6fc6-41a5-bbeb-776eb33239ab_1674x1689.png 848w, https://substackcdn.com/image/fetch/$s_!Ny-9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc05b28b4-6fc6-41a5-bbeb-776eb33239ab_1674x1689.png 1272w, https://substackcdn.com/image/fetch/$s_!Ny-9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc05b28b4-6fc6-41a5-bbeb-776eb33239ab_1674x1689.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Ny-9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc05b28b4-6fc6-41a5-bbeb-776eb33239ab_1674x1689.png" width="635" height="640.6696428571429" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c05b28b4-6fc6-41a5-bbeb-776eb33239ab_1674x1689.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1469,&quot;width&quot;:1456,&quot;resizeWidth&quot;:635,&quot;bytes&quot;:195193,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Ny-9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc05b28b4-6fc6-41a5-bbeb-776eb33239ab_1674x1689.png 424w, https://substackcdn.com/image/fetch/$s_!Ny-9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc05b28b4-6fc6-41a5-bbeb-776eb33239ab_1674x1689.png 848w, https://substackcdn.com/image/fetch/$s_!Ny-9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc05b28b4-6fc6-41a5-bbeb-776eb33239ab_1674x1689.png 1272w, https://substackcdn.com/image/fetch/$s_!Ny-9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc05b28b4-6fc6-41a5-bbeb-776eb33239ab_1674x1689.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></figure></div><div><hr></div><h4><strong>LSM (Log-Structured Merge) Tree</strong></h4><p>Write-optimized trees commonly used in data applications.</p><p>In order to understand LSM-trees, we need to get familiar with 2 other data structures: <strong>Memtables</strong> (in memory tables) and <strong>SSTables</strong> (sorted-string tables).</p><h4><strong>Memtable</strong></h4><p>Initially, data is written to an in-memory structure called a Memtable. This Memtable holds the data in memory until it reaches a certain size and is usually implemented by using balanced search-trees (like a red-black tree), skip-lists or hash tables in order to provide efficient read access. When the Memtable becomes full, its contents are written to disk as a new SSTable. This process is called <strong>flushing</strong>.</p><h4><strong>SSTable</strong></h4><p>SSTables store data in a sorted order <strong>based on keys</strong>. Each SSTable consists of a sequence of key-value pairs where keys are in a sorted order. Once an SSTable is created, it is not modified. Instead, new data updates are written to new SSTables.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xtJP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8db8a9e4-8b0b-4275-ac9d-c14de6375a55_1578x1193.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xtJP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8db8a9e4-8b0b-4275-ac9d-c14de6375a55_1578x1193.png 424w, https://substackcdn.com/image/fetch/$s_!xtJP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8db8a9e4-8b0b-4275-ac9d-c14de6375a55_1578x1193.png 848w, https://substackcdn.com/image/fetch/$s_!xtJP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8db8a9e4-8b0b-4275-ac9d-c14de6375a55_1578x1193.png 1272w, https://substackcdn.com/image/fetch/$s_!xtJP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8db8a9e4-8b0b-4275-ac9d-c14de6375a55_1578x1193.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xtJP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8db8a9e4-8b0b-4275-ac9d-c14de6375a55_1578x1193.png" width="433" height="327.426510989011" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8db8a9e4-8b0b-4275-ac9d-c14de6375a55_1578x1193.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1101,&quot;width&quot;:1456,&quot;resizeWidth&quot;:433,&quot;bytes&quot;:72074,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!xtJP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8db8a9e4-8b0b-4275-ac9d-c14de6375a55_1578x1193.png 424w, https://substackcdn.com/image/fetch/$s_!xtJP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8db8a9e4-8b0b-4275-ac9d-c14de6375a55_1578x1193.png 848w, https://substackcdn.com/image/fetch/$s_!xtJP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8db8a9e4-8b0b-4275-ac9d-c14de6375a55_1578x1193.png 1272w, https://substackcdn.com/image/fetch/$s_!xtJP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8db8a9e4-8b0b-4275-ac9d-c14de6375a55_1578x1193.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></figure></div><p>SSTables often use auxiliary data structures like Bloom filters and sparse indexes to quickly determine if a key is present in the SSTable or to locate the value.</p><p>Over time, multiple SSTables may be created due to frequent updates. To optimize performance and reclaim space, SSTables are periodically merged and <strong>compacted</strong>. This involves combining data from multiple SSTables into a smaller number of new SSTables, while discarding obsolete entries.</p><p>A simplified and full visual of how all of this is implemented is provided 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_!FO86!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9623078-5560-4fd2-907d-df1983c6d132_2260x1700.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FO86!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9623078-5560-4fd2-907d-df1983c6d132_2260x1700.png 424w, https://substackcdn.com/image/fetch/$s_!FO86!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9623078-5560-4fd2-907d-df1983c6d132_2260x1700.png 848w, https://substackcdn.com/image/fetch/$s_!FO86!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9623078-5560-4fd2-907d-df1983c6d132_2260x1700.png 1272w, https://substackcdn.com/image/fetch/$s_!FO86!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9623078-5560-4fd2-907d-df1983c6d132_2260x1700.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FO86!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9623078-5560-4fd2-907d-df1983c6d132_2260x1700.png" width="1456" height="1095" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c9623078-5560-4fd2-907d-df1983c6d132_2260x1700.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1095,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:142905,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FO86!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9623078-5560-4fd2-907d-df1983c6d132_2260x1700.png 424w, https://substackcdn.com/image/fetch/$s_!FO86!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9623078-5560-4fd2-907d-df1983c6d132_2260x1700.png 848w, https://substackcdn.com/image/fetch/$s_!FO86!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9623078-5560-4fd2-907d-df1983c6d132_2260x1700.png 1272w, https://substackcdn.com/image/fetch/$s_!FO86!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9623078-5560-4fd2-907d-df1983c6d132_2260x1700.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></figure></div><div><hr></div><h4><strong>Binary Index Tree / Fenwick Tree</strong></h4><p>A compact and efficient data structure for handling dynamic cumulative frequency tables / prefix sums. In other words: it&#8217;s great for range queries.</p><p>The tree structure is stored in an array. Each index which is a power of 2 in the array contains the cumulative sum of all elements prior to it. As an example, the 4<sup>th</sup> element (2<sup>2</sup>) stores the sum of the first 4 elements. To get the sub-array sums for each range in this tree &#8211; we use bit-shifting operations and reduce each update / read times to log(n) time for range queries<strong>:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!q_SA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3748b4c2-5200-4434-be89-0608a592d731_507x356.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!q_SA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3748b4c2-5200-4434-be89-0608a592d731_507x356.png 424w, https://substackcdn.com/image/fetch/$s_!q_SA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3748b4c2-5200-4434-be89-0608a592d731_507x356.png 848w, https://substackcdn.com/image/fetch/$s_!q_SA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3748b4c2-5200-4434-be89-0608a592d731_507x356.png 1272w, https://substackcdn.com/image/fetch/$s_!q_SA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3748b4c2-5200-4434-be89-0608a592d731_507x356.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!q_SA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3748b4c2-5200-4434-be89-0608a592d731_507x356.png" width="507" height="356" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3748b4c2-5200-4434-be89-0608a592d731_507x356.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:356,&quot;width&quot;:507,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:11035,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!q_SA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3748b4c2-5200-4434-be89-0608a592d731_507x356.png 424w, https://substackcdn.com/image/fetch/$s_!q_SA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3748b4c2-5200-4434-be89-0608a592d731_507x356.png 848w, https://substackcdn.com/image/fetch/$s_!q_SA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3748b4c2-5200-4434-be89-0608a592d731_507x356.png 1272w, https://substackcdn.com/image/fetch/$s_!q_SA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3748b4c2-5200-4434-be89-0608a592d731_507x356.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></figure></div><div><hr></div><h3><strong>Graph Data Structures</strong></h3><div><hr></div><h4><strong>Adjacency List vs Adjacency Matrix Graph Representation</strong></h4><p>An <strong>adjacency list</strong> represents a graph as a collection of lists &#8211; each node has a collection of nodes that it&#8217;s connected to. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Lqje!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bd0648c-39f8-4f78-9086-8b16b9d132e5_473x549.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Lqje!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bd0648c-39f8-4f78-9086-8b16b9d132e5_473x549.png 424w, https://substackcdn.com/image/fetch/$s_!Lqje!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bd0648c-39f8-4f78-9086-8b16b9d132e5_473x549.png 848w, https://substackcdn.com/image/fetch/$s_!Lqje!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bd0648c-39f8-4f78-9086-8b16b9d132e5_473x549.png 1272w, https://substackcdn.com/image/fetch/$s_!Lqje!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bd0648c-39f8-4f78-9086-8b16b9d132e5_473x549.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Lqje!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bd0648c-39f8-4f78-9086-8b16b9d132e5_473x549.png" width="315" height="365.61310782241014" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4bd0648c-39f8-4f78-9086-8b16b9d132e5_473x549.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:549,&quot;width&quot;:473,&quot;resizeWidth&quot;:315,&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_!Lqje!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bd0648c-39f8-4f78-9086-8b16b9d132e5_473x549.png 424w, https://substackcdn.com/image/fetch/$s_!Lqje!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bd0648c-39f8-4f78-9086-8b16b9d132e5_473x549.png 848w, https://substackcdn.com/image/fetch/$s_!Lqje!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bd0648c-39f8-4f78-9086-8b16b9d132e5_473x549.png 1272w, https://substackcdn.com/image/fetch/$s_!Lqje!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bd0648c-39f8-4f78-9086-8b16b9d132e5_473x549.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></figure></div><p>An <strong>adjacency matrix</strong> represents a graph as a 2-D matrix. If our graph has N nodes, we will have an N by N matrix where each cell (i, j) indicates whether there is an edge between vertex i and vertex j. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zO1M!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe2c5d19-3129-4bcb-8cb6-90d5559014b5_531x496.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zO1M!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe2c5d19-3129-4bcb-8cb6-90d5559014b5_531x496.png 424w, https://substackcdn.com/image/fetch/$s_!zO1M!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe2c5d19-3129-4bcb-8cb6-90d5559014b5_531x496.png 848w, https://substackcdn.com/image/fetch/$s_!zO1M!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe2c5d19-3129-4bcb-8cb6-90d5559014b5_531x496.png 1272w, https://substackcdn.com/image/fetch/$s_!zO1M!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe2c5d19-3129-4bcb-8cb6-90d5559014b5_531x496.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zO1M!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe2c5d19-3129-4bcb-8cb6-90d5559014b5_531x496.png" width="331" height="309.18267419962336" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/be2c5d19-3129-4bcb-8cb6-90d5559014b5_531x496.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:496,&quot;width&quot;:531,&quot;resizeWidth&quot;:331,&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_!zO1M!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe2c5d19-3129-4bcb-8cb6-90d5559014b5_531x496.png 424w, https://substackcdn.com/image/fetch/$s_!zO1M!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe2c5d19-3129-4bcb-8cb6-90d5559014b5_531x496.png 848w, https://substackcdn.com/image/fetch/$s_!zO1M!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe2c5d19-3129-4bcb-8cb6-90d5559014b5_531x496.png 1272w, https://substackcdn.com/image/fetch/$s_!zO1M!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe2c5d19-3129-4bcb-8cb6-90d5559014b5_531x496.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></figure></div><p><strong>Example Graph:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!son8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3025da43-e4f9-471a-b907-eb373939e639_1072x784.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!son8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3025da43-e4f9-471a-b907-eb373939e639_1072x784.png 424w, https://substackcdn.com/image/fetch/$s_!son8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3025da43-e4f9-471a-b907-eb373939e639_1072x784.png 848w, https://substackcdn.com/image/fetch/$s_!son8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3025da43-e4f9-471a-b907-eb373939e639_1072x784.png 1272w, https://substackcdn.com/image/fetch/$s_!son8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3025da43-e4f9-471a-b907-eb373939e639_1072x784.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!son8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3025da43-e4f9-471a-b907-eb373939e639_1072x784.png" width="1072" height="784" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3025da43-e4f9-471a-b907-eb373939e639_1072x784.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:784,&quot;width&quot;:1072,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:65954,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!son8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3025da43-e4f9-471a-b907-eb373939e639_1072x784.png 424w, https://substackcdn.com/image/fetch/$s_!son8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3025da43-e4f9-471a-b907-eb373939e639_1072x784.png 848w, https://substackcdn.com/image/fetch/$s_!son8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3025da43-e4f9-471a-b907-eb373939e639_1072x784.png 1272w, https://substackcdn.com/image/fetch/$s_!son8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3025da43-e4f9-471a-b907-eb373939e639_1072x784.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></figure></div><div><hr></div><h3><strong>String-Search Data Structures</strong></h3><div><hr></div><h4><strong>Trie</strong></h4><p>A trie is a tree-like data structure used for efficient searching of strings where each node represents a character, with advantages including fast prefix-based queries and insertions. A great overview and intro to tries is <a href="https://medium.com/basecs/trying-to-understand-tries-3ec6bede0014">available here</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_!CCBb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8659af8-3f80-44e7-b158-411300dd7d48_787x712.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CCBb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8659af8-3f80-44e7-b158-411300dd7d48_787x712.png 424w, https://substackcdn.com/image/fetch/$s_!CCBb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8659af8-3f80-44e7-b158-411300dd7d48_787x712.png 848w, https://substackcdn.com/image/fetch/$s_!CCBb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8659af8-3f80-44e7-b158-411300dd7d48_787x712.png 1272w, https://substackcdn.com/image/fetch/$s_!CCBb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8659af8-3f80-44e7-b158-411300dd7d48_787x712.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CCBb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8659af8-3f80-44e7-b158-411300dd7d48_787x712.png" width="557" height="503.91867852604827" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c8659af8-3f80-44e7-b158-411300dd7d48_787x712.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:712,&quot;width&quot;:787,&quot;resizeWidth&quot;:557,&quot;bytes&quot;:218475,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!CCBb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8659af8-3f80-44e7-b158-411300dd7d48_787x712.png 424w, https://substackcdn.com/image/fetch/$s_!CCBb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8659af8-3f80-44e7-b158-411300dd7d48_787x712.png 848w, https://substackcdn.com/image/fetch/$s_!CCBb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8659af8-3f80-44e7-b158-411300dd7d48_787x712.png 1272w, https://substackcdn.com/image/fetch/$s_!CCBb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8659af8-3f80-44e7-b158-411300dd7d48_787x712.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></figure></div><div><hr></div><h4><strong>Radix Tree</strong></h4><p>It can also be thought of as a <strong>compact trie. </strong>Although tries are fantastic, they can take up a lot of memory. Redix trees fix this by combining nodes with common prefixes. Great overview and intro to radix trees is <a href="https://medium.com/basecs/compressing-radix-trees-without-too-many-tears-a2e658adb9a0">available here</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_!OmyI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47d00bbb-61dd-4200-b736-fd3f6b22cbcc_1745x1055.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OmyI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47d00bbb-61dd-4200-b736-fd3f6b22cbcc_1745x1055.png 424w, https://substackcdn.com/image/fetch/$s_!OmyI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47d00bbb-61dd-4200-b736-fd3f6b22cbcc_1745x1055.png 848w, https://substackcdn.com/image/fetch/$s_!OmyI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47d00bbb-61dd-4200-b736-fd3f6b22cbcc_1745x1055.png 1272w, https://substackcdn.com/image/fetch/$s_!OmyI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47d00bbb-61dd-4200-b736-fd3f6b22cbcc_1745x1055.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OmyI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47d00bbb-61dd-4200-b736-fd3f6b22cbcc_1745x1055.png" width="1456" height="880" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/47d00bbb-61dd-4200-b736-fd3f6b22cbcc_1745x1055.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:880,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:534639,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OmyI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47d00bbb-61dd-4200-b736-fd3f6b22cbcc_1745x1055.png 424w, https://substackcdn.com/image/fetch/$s_!OmyI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47d00bbb-61dd-4200-b736-fd3f6b22cbcc_1745x1055.png 848w, https://substackcdn.com/image/fetch/$s_!OmyI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47d00bbb-61dd-4200-b736-fd3f6b22cbcc_1745x1055.png 1272w, https://substackcdn.com/image/fetch/$s_!OmyI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47d00bbb-61dd-4200-b736-fd3f6b22cbcc_1745x1055.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></figure></div><div><hr></div><h4><strong>Splay Tree</strong></h4><p>A splay tree is just a binary search tree that has excellent performance in the cases where some data is accessed more frequently than others. The tree self-adjusts after lookup, insert and delete operations. After you access an item in the tree, the tree rearranges itself so that the accessed item is moved to the top (the root). This makes future accesses to that item faster. Splay trees particularly useful in <strong>caching</strong>. A great write-up and overview of this data-structure is <a href="https://www.cs.cmu.edu/afs/cs/academic/class/15750-s18/ScribeNotes/lecture5.pdf">available here</a>. </p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!X-Wy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F672350c9-2517-425c-9e31-8814220a7683_630x570.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!X-Wy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F672350c9-2517-425c-9e31-8814220a7683_630x570.png 424w, https://substackcdn.com/image/fetch/$s_!X-Wy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F672350c9-2517-425c-9e31-8814220a7683_630x570.png 848w, https://substackcdn.com/image/fetch/$s_!X-Wy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F672350c9-2517-425c-9e31-8814220a7683_630x570.png 1272w, https://substackcdn.com/image/fetch/$s_!X-Wy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F672350c9-2517-425c-9e31-8814220a7683_630x570.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!X-Wy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F672350c9-2517-425c-9e31-8814220a7683_630x570.png" width="630" height="570" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/672350c9-2517-425c-9e31-8814220a7683_630x570.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:570,&quot;width&quot;:630,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:39327,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!X-Wy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F672350c9-2517-425c-9e31-8814220a7683_630x570.png 424w, https://substackcdn.com/image/fetch/$s_!X-Wy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F672350c9-2517-425c-9e31-8814220a7683_630x570.png 848w, https://substackcdn.com/image/fetch/$s_!X-Wy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F672350c9-2517-425c-9e31-8814220a7683_630x570.png 1272w, https://substackcdn.com/image/fetch/$s_!X-Wy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F672350c9-2517-425c-9e31-8814220a7683_630x570.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></figure></div><p></p><div><hr></div><h3>Spatial Trees</h3><p>Spatial trees are data structures designed to efficiently manage and query spatial data, such as points, rectangles, and polygons, in multidimensional space (such as geographical information systems (GIS)). </p><div><hr></div><h4><strong>Quadtree</strong></h4><p>A quadtree is a spatial data structure that recursively divides a two-dimensional space into four quadrants, making it efficient for managing and querying spatial data like points or regions. If a node contains too many points, it is subdivided into four child nodes. Quadtrees are commonly used in handling collision detection.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!z8wc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ab888dd-4e08-408b-b1ca-5fe69d6a4205_1584x1249.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!z8wc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ab888dd-4e08-408b-b1ca-5fe69d6a4205_1584x1249.png 424w, https://substackcdn.com/image/fetch/$s_!z8wc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ab888dd-4e08-408b-b1ca-5fe69d6a4205_1584x1249.png 848w, https://substackcdn.com/image/fetch/$s_!z8wc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ab888dd-4e08-408b-b1ca-5fe69d6a4205_1584x1249.png 1272w, https://substackcdn.com/image/fetch/$s_!z8wc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ab888dd-4e08-408b-b1ca-5fe69d6a4205_1584x1249.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!z8wc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ab888dd-4e08-408b-b1ca-5fe69d6a4205_1584x1249.png" width="551" height="434.4423076923077" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6ab888dd-4e08-408b-b1ca-5fe69d6a4205_1584x1249.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1148,&quot;width&quot;:1456,&quot;resizeWidth&quot;:551,&quot;bytes&quot;:90381,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!z8wc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ab888dd-4e08-408b-b1ca-5fe69d6a4205_1584x1249.png 424w, https://substackcdn.com/image/fetch/$s_!z8wc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ab888dd-4e08-408b-b1ca-5fe69d6a4205_1584x1249.png 848w, https://substackcdn.com/image/fetch/$s_!z8wc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ab888dd-4e08-408b-b1ca-5fe69d6a4205_1584x1249.png 1272w, https://substackcdn.com/image/fetch/$s_!z8wc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ab888dd-4e08-408b-b1ca-5fe69d6a4205_1584x1249.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></figure></div><div><hr></div><h4><strong>KD Tree</strong></h4><p>A binary tree where each node represents a point in k-dimensional space. The tree is constructed by recursively splitting the space along one of its dimensions. At each level of the tree, data is split based on one dimension, with each subsequent level having alternating dimensions. This makes it efficient for range queries and nearest-neighbor searches.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!uZ5X!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F611b1453-236b-40f9-83be-6af2f769251d_2045x1090.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!uZ5X!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F611b1453-236b-40f9-83be-6af2f769251d_2045x1090.png 424w, https://substackcdn.com/image/fetch/$s_!uZ5X!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F611b1453-236b-40f9-83be-6af2f769251d_2045x1090.png 848w, https://substackcdn.com/image/fetch/$s_!uZ5X!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F611b1453-236b-40f9-83be-6af2f769251d_2045x1090.png 1272w, https://substackcdn.com/image/fetch/$s_!uZ5X!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F611b1453-236b-40f9-83be-6af2f769251d_2045x1090.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!uZ5X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F611b1453-236b-40f9-83be-6af2f769251d_2045x1090.png" width="1456" height="776" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/611b1453-236b-40f9-83be-6af2f769251d_2045x1090.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:776,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:221278,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!uZ5X!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F611b1453-236b-40f9-83be-6af2f769251d_2045x1090.png 424w, https://substackcdn.com/image/fetch/$s_!uZ5X!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F611b1453-236b-40f9-83be-6af2f769251d_2045x1090.png 848w, https://substackcdn.com/image/fetch/$s_!uZ5X!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F611b1453-236b-40f9-83be-6af2f769251d_2045x1090.png 1272w, https://substackcdn.com/image/fetch/$s_!uZ5X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F611b1453-236b-40f9-83be-6af2f769251d_2045x1090.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></figure></div><div><hr></div><h4><strong>R-Tree</strong></h4><p><strong>R-trees</strong> are a tree data structure used for efficiently indexing multi-dimensional spatial data. They organize data into minimum bounding rectangles (MBRs), which are grouped hierarchically, with each node's MBR encompassing the MBRs of its children. A fantastic write-up and overview for KD &amp; R-Trees is <a href="https://blog.mapbox.com/a-dive-into-spatial-search-algorithms-ebd0c5e39d2a">available here</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_!bUq6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac5bd91-3a43-43ad-9433-c1b28922e7d3_1600x800.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bUq6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac5bd91-3a43-43ad-9433-c1b28922e7d3_1600x800.png 424w, https://substackcdn.com/image/fetch/$s_!bUq6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac5bd91-3a43-43ad-9433-c1b28922e7d3_1600x800.png 848w, https://substackcdn.com/image/fetch/$s_!bUq6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac5bd91-3a43-43ad-9433-c1b28922e7d3_1600x800.png 1272w, https://substackcdn.com/image/fetch/$s_!bUq6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac5bd91-3a43-43ad-9433-c1b28922e7d3_1600x800.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bUq6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac5bd91-3a43-43ad-9433-c1b28922e7d3_1600x800.png" width="1456" height="728" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5ac5bd91-3a43-43ad-9433-c1b28922e7d3_1600x800.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;:388321,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!bUq6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac5bd91-3a43-43ad-9433-c1b28922e7d3_1600x800.png 424w, https://substackcdn.com/image/fetch/$s_!bUq6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac5bd91-3a43-43ad-9433-c1b28922e7d3_1600x800.png 848w, https://substackcdn.com/image/fetch/$s_!bUq6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac5bd91-3a43-43ad-9433-c1b28922e7d3_1600x800.png 1272w, https://substackcdn.com/image/fetch/$s_!bUq6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac5bd91-3a43-43ad-9433-c1b28922e7d3_1600x800.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></figure></div><p></p><div><hr></div><h3>Other Data Structures &amp; Diagrams</h3><p>These data structures may not belong to a specific category - here I&#8217;m simply including some which are either very useful or which I think are fantastically interesting - along with some of my favorite visuals.</p><div><hr></div><h4>Bloom Filter</h4><p>A Bloom filter is a space-efficient probabilistic data structure used to test whether an element is a member of a set which is usually used to reduce expensive disk (or network) lookups for non-existent keys. It can yield false positives (reporting that an element is in the set when it&#8217;s not) but never false negatives (it will never incorrectly report that an element isn&#8217;t in the set if it actually is). </p><p>It uses a bit array to store data. To map a key to an appropriate bit &#8211; it uses uses a number of independent hash functions, each of which maps the key to a different bit location within the bit-array. A great overview of bloom filters is <a href="https://www.jasondavies.com/bloomfilter/">available here</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_!TdA7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04dafbfb-116a-493c-9e2f-20ef7348d90f_2777x1689.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TdA7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04dafbfb-116a-493c-9e2f-20ef7348d90f_2777x1689.png 424w, https://substackcdn.com/image/fetch/$s_!TdA7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04dafbfb-116a-493c-9e2f-20ef7348d90f_2777x1689.png 848w, https://substackcdn.com/image/fetch/$s_!TdA7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04dafbfb-116a-493c-9e2f-20ef7348d90f_2777x1689.png 1272w, https://substackcdn.com/image/fetch/$s_!TdA7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04dafbfb-116a-493c-9e2f-20ef7348d90f_2777x1689.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TdA7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04dafbfb-116a-493c-9e2f-20ef7348d90f_2777x1689.png" width="1456" height="886" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/04dafbfb-116a-493c-9e2f-20ef7348d90f_2777x1689.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:886,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:426116,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TdA7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04dafbfb-116a-493c-9e2f-20ef7348d90f_2777x1689.png 424w, https://substackcdn.com/image/fetch/$s_!TdA7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04dafbfb-116a-493c-9e2f-20ef7348d90f_2777x1689.png 848w, https://substackcdn.com/image/fetch/$s_!TdA7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04dafbfb-116a-493c-9e2f-20ef7348d90f_2777x1689.png 1272w, https://substackcdn.com/image/fetch/$s_!TdA7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04dafbfb-116a-493c-9e2f-20ef7348d90f_2777x1689.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></figure></div><p></p><div><hr></div><h4><strong>Binomial Heap</strong></h4><p>A <strong>binomial heap</strong> is a type of data structure that efficiently manages a collection of elements, supporting quick insertion, minimum extraction, and merging of heaps. It&#8217;s particularly useful when you need to handle a dynamic set of elements where you frequently perform these operations. </p><p>A binomial heap is made up of a collection of <strong>binomial trees</strong>, which are special trees that are linked together. </p><h4>Binomial trees of order 0 to 3:</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PIYe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4860990-d5ac-48fd-8d9e-a8574ca4de24_834x444.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PIYe!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4860990-d5ac-48fd-8d9e-a8574ca4de24_834x444.png 424w, https://substackcdn.com/image/fetch/$s_!PIYe!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4860990-d5ac-48fd-8d9e-a8574ca4de24_834x444.png 848w, https://substackcdn.com/image/fetch/$s_!PIYe!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4860990-d5ac-48fd-8d9e-a8574ca4de24_834x444.png 1272w, https://substackcdn.com/image/fetch/$s_!PIYe!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4860990-d5ac-48fd-8d9e-a8574ca4de24_834x444.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PIYe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4860990-d5ac-48fd-8d9e-a8574ca4de24_834x444.png" width="834" height="444" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a4860990-d5ac-48fd-8d9e-a8574ca4de24_834x444.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:444,&quot;width&quot;:834,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:20569,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!PIYe!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4860990-d5ac-48fd-8d9e-a8574ca4de24_834x444.png 424w, https://substackcdn.com/image/fetch/$s_!PIYe!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4860990-d5ac-48fd-8d9e-a8574ca4de24_834x444.png 848w, https://substackcdn.com/image/fetch/$s_!PIYe!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4860990-d5ac-48fd-8d9e-a8574ca4de24_834x444.png 1272w, https://substackcdn.com/image/fetch/$s_!PIYe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4860990-d5ac-48fd-8d9e-a8574ca4de24_834x444.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></figure></div><p>Each binomial tree in a heap obeys the minimum-heap property: the key of a node is greater than or equal to the key of its parent. Also, there can only be either one or zero binomial trees for each order, including zero order.</p><h4>Example binomial heap containing 13 nodes:</h4><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!htFm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3243f7c0-0073-4ed8-bbeb-35fd3dfa54c4_866x430.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!htFm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3243f7c0-0073-4ed8-bbeb-35fd3dfa54c4_866x430.png 424w, https://substackcdn.com/image/fetch/$s_!htFm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3243f7c0-0073-4ed8-bbeb-35fd3dfa54c4_866x430.png 848w, https://substackcdn.com/image/fetch/$s_!htFm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3243f7c0-0073-4ed8-bbeb-35fd3dfa54c4_866x430.png 1272w, https://substackcdn.com/image/fetch/$s_!htFm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3243f7c0-0073-4ed8-bbeb-35fd3dfa54c4_866x430.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!htFm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3243f7c0-0073-4ed8-bbeb-35fd3dfa54c4_866x430.png" width="866" height="430" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3243f7c0-0073-4ed8-bbeb-35fd3dfa54c4_866x430.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:430,&quot;width&quot;:866,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:74892,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!htFm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3243f7c0-0073-4ed8-bbeb-35fd3dfa54c4_866x430.png 424w, https://substackcdn.com/image/fetch/$s_!htFm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3243f7c0-0073-4ed8-bbeb-35fd3dfa54c4_866x430.png 848w, https://substackcdn.com/image/fetch/$s_!htFm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3243f7c0-0073-4ed8-bbeb-35fd3dfa54c4_866x430.png 1272w, https://substackcdn.com/image/fetch/$s_!htFm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3243f7c0-0073-4ed8-bbeb-35fd3dfa54c4_866x430.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></figure></div><p></p><p>Binomial heaps are useful in scenarios like implementing priority queues, where you need to frequently merge heaps or perform other operations on a set of elements.</p><div><hr></div><h4><strong>Hash Array Mapped Trie (HAMT)</strong></h4><p>A Hash Array Mapped Trie (HAMT) is a data structure that combines the benefits of hash tables and tries to efficiently store and retrieve key-value pairs. It is commonly used in computer science to implement associative arrays or dictionaries. In a HAMT, keys are hashed to determine their storage location within an array, called a hash array. Each entry in the hash array can store multiple key-value pairs, allowing efficient memory utilization. If multiple keys hash to the same array index, a trie-like structure is used to resolve collisions. A full write-up and explanation of how HAMTs work is <a href="https://photonlines.substack.com/p/grokking-hash-array-mapped-tries">available here</a>. </p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!i5Vx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1335e7cc-cf62-4d77-81a3-db7d11865c8d_1840x1672.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!i5Vx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1335e7cc-cf62-4d77-81a3-db7d11865c8d_1840x1672.png 424w, https://substackcdn.com/image/fetch/$s_!i5Vx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1335e7cc-cf62-4d77-81a3-db7d11865c8d_1840x1672.png 848w, https://substackcdn.com/image/fetch/$s_!i5Vx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1335e7cc-cf62-4d77-81a3-db7d11865c8d_1840x1672.png 1272w, https://substackcdn.com/image/fetch/$s_!i5Vx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1335e7cc-cf62-4d77-81a3-db7d11865c8d_1840x1672.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!i5Vx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1335e7cc-cf62-4d77-81a3-db7d11865c8d_1840x1672.png" width="1456" height="1323" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1335e7cc-cf62-4d77-81a3-db7d11865c8d_1840x1672.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1323,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:147531,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!i5Vx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1335e7cc-cf62-4d77-81a3-db7d11865c8d_1840x1672.png 424w, https://substackcdn.com/image/fetch/$s_!i5Vx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1335e7cc-cf62-4d77-81a3-db7d11865c8d_1840x1672.png 848w, https://substackcdn.com/image/fetch/$s_!i5Vx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1335e7cc-cf62-4d77-81a3-db7d11865c8d_1840x1672.png 1272w, https://substackcdn.com/image/fetch/$s_!i5Vx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1335e7cc-cf62-4d77-81a3-db7d11865c8d_1840x1672.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></figure></div><div><hr></div><h4><strong>Merkle Tree</strong></h4><p>Helps verify large sets of data efficiently and securely. It works by organizing data into a tree where each leaf contains a hash of a data block, and each non-leaf node is a hash of its two child nodes, all the way up to the Merkle root at the top. This structure is widely used in blockchain and other systems to ensure data integrity. A fantastic summary and overview of Merkle trees is <a href="https://hackernoon.com/an-intro-to-merkel-tree-what-is-it-and-how-does-it-work">available here</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_!WT9Y!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83a3a70a-1050-49f4-a61d-42c7dfdd5793_1112x712.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WT9Y!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83a3a70a-1050-49f4-a61d-42c7dfdd5793_1112x712.png 424w, https://substackcdn.com/image/fetch/$s_!WT9Y!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83a3a70a-1050-49f4-a61d-42c7dfdd5793_1112x712.png 848w, https://substackcdn.com/image/fetch/$s_!WT9Y!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83a3a70a-1050-49f4-a61d-42c7dfdd5793_1112x712.png 1272w, https://substackcdn.com/image/fetch/$s_!WT9Y!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83a3a70a-1050-49f4-a61d-42c7dfdd5793_1112x712.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WT9Y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83a3a70a-1050-49f4-a61d-42c7dfdd5793_1112x712.png" width="555" height="355.35971223021585" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/83a3a70a-1050-49f4-a61d-42c7dfdd5793_1112x712.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:712,&quot;width&quot;:1112,&quot;resizeWidth&quot;:555,&quot;bytes&quot;:52733,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WT9Y!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83a3a70a-1050-49f4-a61d-42c7dfdd5793_1112x712.png 424w, https://substackcdn.com/image/fetch/$s_!WT9Y!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83a3a70a-1050-49f4-a61d-42c7dfdd5793_1112x712.png 848w, https://substackcdn.com/image/fetch/$s_!WT9Y!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83a3a70a-1050-49f4-a61d-42c7dfdd5793_1112x712.png 1272w, https://substackcdn.com/image/fetch/$s_!WT9Y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83a3a70a-1050-49f4-a61d-42c7dfdd5793_1112x712.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></figure></div><div><hr></div><h4><strong>Bonus: 8 Data Structures Which Power Your Database </strong></h4><p>Full credit for this one goes to <a href="https://blog.bytebytego.com/">ByteByteGo </a>and is <a href="https://github.com/ByteByteGoHq/system-design-101/blob/main/images/8-ds-db.jpg">available here</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_!97F6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde3da6a8-13b9-4db9-bb8e-072d5bb45107_3882x4044.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!97F6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde3da6a8-13b9-4db9-bb8e-072d5bb45107_3882x4044.jpeg 424w, https://substackcdn.com/image/fetch/$s_!97F6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde3da6a8-13b9-4db9-bb8e-072d5bb45107_3882x4044.jpeg 848w, https://substackcdn.com/image/fetch/$s_!97F6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde3da6a8-13b9-4db9-bb8e-072d5bb45107_3882x4044.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!97F6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde3da6a8-13b9-4db9-bb8e-072d5bb45107_3882x4044.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!97F6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde3da6a8-13b9-4db9-bb8e-072d5bb45107_3882x4044.jpeg" width="1456" height="1517" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/de3da6a8-13b9-4db9-bb8e-072d5bb45107_3882x4044.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1517,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;8-ds-db.jpg&quot;,&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="8-ds-db.jpg" title="8-ds-db.jpg" srcset="https://substackcdn.com/image/fetch/$s_!97F6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde3da6a8-13b9-4db9-bb8e-072d5bb45107_3882x4044.jpeg 424w, https://substackcdn.com/image/fetch/$s_!97F6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde3da6a8-13b9-4db9-bb8e-072d5bb45107_3882x4044.jpeg 848w, https://substackcdn.com/image/fetch/$s_!97F6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde3da6a8-13b9-4db9-bb8e-072d5bb45107_3882x4044.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!97F6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde3da6a8-13b9-4db9-bb8e-072d5bb45107_3882x4044.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><div><hr></div><p>This ends my write-up. I&#8217;m going to include a Part 2 soon which is purely algorithm focused. If you liked this overview and the visuals &amp; illustrations, please like and subscribe. Thank you for reading. </p><div><hr></div><h3>References</h3><p></p><ul><li><p><a href="https://colin-scott.github.io/personal_website/research/interactive_latency.html">Latency Numbers Every Programmer Should Know</a></p></li><li><p><a href="https://cs-people.bu.edu/mathan/publications/fnt23-athanassoulis.pdf">Data Structures for Data-Intensive Applications: Tradeoffs and Design Guidelines</a></p></li><li><p><a href="https://cses.fi/book/book.pdf">Competitive Programmer&#8217;s Handbook</a></p></li><li><p><a href="https://www.cs.usfca.edu/~galles/visualization/Algorithms.html">Data Structure Visualizations</a></p></li><li><p><a href="https://domino.ai/data-science-dictionary/hash-table">What are hash tables?</a></p></li><li><p><a href="https://igoro.com/archive/skip-lists-are-fascinating/">Skip lists are fascinating!</a></p></li><li><p><a href="http://www.cburch.com/cs/340/reading/btree/index.html">What is a B+ tree? </a></p></li><li><p><a href="https://jyotinder.substack.com/p/building-a-write-optimized-database-part-3">Building a Write-Optimized Database Engine: Sorted String Tables (Part 3)</a></p></li><li><p><a href="https://medium.com/basecs/trying-to-understand-tries-3ec6bede0014">Trying to Understand Tries</a></p></li><li><p><a href="https://medium.com/basecs/compressing-radix-trees-without-too-many-tears-a2e658adb9a0">Compressing Radix Trees Without (Too Many) Tears</a></p></li><li><p><a href="https://blog.mapbox.com/a-dive-into-spatial-search-algorithms-ebd0c5e39d2a">A dive into spatial search algorithms</a></p></li><li><p><a href="https://www.jasondavies.com/bloomfilter/">Bloom Filters</a></p></li><li><p><a href="https://cs.lmu.edu/~ray/notes/splaytrees/">Splay Trees</a></p></li><li><p><a href="https://en.wikipedia.org/wiki/Binomial_heap">Binomial Heap (Wikipedia)</a></p></li><li><p><a href="https://hackernoon.com/an-intro-to-merkel-tree-what-is-it-and-how-does-it-work">An Intro to Merkel Tree: What is it and How Does it Work?</a></p></li><li><p><a href="https://github.com/ByteByteGoHq/system-design-101/blob/main/images/8-ds-db.jpg">8 Data Structures That Power Your Databases</a></p></li></ul><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Photon-Lines Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Algorithms for Optimization (Explained Simply): Part 1]]></title><description><![CDATA[A visual and example-focused guide to algorithms used for solving optimization problems.]]></description><link>https://photonlines.substack.com/p/algorithms-for-optimization-explained</link><guid isPermaLink="false">https://photonlines.substack.com/p/algorithms-for-optimization-explained</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Fri, 19 Jul 2024 12:30:32 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!4Af2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9355eaf4-5cc5-4097-9d43-48b3d72062a9_325x315.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In this series of blog posts, I&#8217;m going to provide a higher-level overview of the landscape of algorithms used for solving optimization problems. Some of the visuals and explanations are taken directly from the book <a href="https://mitpress.mit.edu/9780262039420/algorithms-for-optimization/">Algorithms for Optimization</a> which I highly recommend. We&#8217;ll start off by focusing on single-variable optimization problems in part 1 and part 2 of this series. Later on, we&#8217;ll continue by discussing more advanced algorithms involving multivariate functions. Noting this, let&#8217;s begin.</p><h3>Introduction (Derivatives and Gradients)</h3><p>Optimization is concerned with finding the design point that minimizes (or maximizes) an objective function. Many of these problems also contain constraints, and each constraint sets limits on the set of possible solutions which we can use to solve our problem. An example problem with constraints is provided below:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TGGt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce8d6b6-35f6-49fb-88a0-0f5622df5cfa_302x205.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TGGt!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce8d6b6-35f6-49fb-88a0-0f5622df5cfa_302x205.png 424w, https://substackcdn.com/image/fetch/$s_!TGGt!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce8d6b6-35f6-49fb-88a0-0f5622df5cfa_302x205.png 848w, https://substackcdn.com/image/fetch/$s_!TGGt!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce8d6b6-35f6-49fb-88a0-0f5622df5cfa_302x205.png 1272w, https://substackcdn.com/image/fetch/$s_!TGGt!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce8d6b6-35f6-49fb-88a0-0f5622df5cfa_302x205.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TGGt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce8d6b6-35f6-49fb-88a0-0f5622df5cfa_302x205.png" width="302" height="205" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8ce8d6b6-35f6-49fb-88a0-0f5622df5cfa_302x205.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:205,&quot;width&quot;:302,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:11950,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TGGt!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce8d6b6-35f6-49fb-88a0-0f5622df5cfa_302x205.png 424w, https://substackcdn.com/image/fetch/$s_!TGGt!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce8d6b6-35f6-49fb-88a0-0f5622df5cfa_302x205.png 848w, https://substackcdn.com/image/fetch/$s_!TGGt!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce8d6b6-35f6-49fb-88a0-0f5622df5cfa_302x205.png 1272w, https://substackcdn.com/image/fetch/$s_!TGGt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce8d6b6-35f6-49fb-88a0-0f5622df5cfa_302x205.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><p>A pictorial view of the above problem is provided 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_!4Af2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9355eaf4-5cc5-4097-9d43-48b3d72062a9_325x315.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4Af2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9355eaf4-5cc5-4097-9d43-48b3d72062a9_325x315.png 424w, https://substackcdn.com/image/fetch/$s_!4Af2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9355eaf4-5cc5-4097-9d43-48b3d72062a9_325x315.png 848w, https://substackcdn.com/image/fetch/$s_!4Af2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9355eaf4-5cc5-4097-9d43-48b3d72062a9_325x315.png 1272w, https://substackcdn.com/image/fetch/$s_!4Af2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9355eaf4-5cc5-4097-9d43-48b3d72062a9_325x315.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4Af2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9355eaf4-5cc5-4097-9d43-48b3d72062a9_325x315.png" width="325" height="315" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9355eaf4-5cc5-4097-9d43-48b3d72062a9_325x315.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:315,&quot;width&quot;:325,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:10768,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4Af2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9355eaf4-5cc5-4097-9d43-48b3d72062a9_325x315.png 424w, https://substackcdn.com/image/fetch/$s_!4Af2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9355eaf4-5cc5-4097-9d43-48b3d72062a9_325x315.png 848w, https://substackcdn.com/image/fetch/$s_!4Af2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9355eaf4-5cc5-4097-9d43-48b3d72062a9_325x315.png 1272w, https://substackcdn.com/image/fetch/$s_!4Af2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9355eaf4-5cc5-4097-9d43-48b3d72062a9_325x315.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></figure></div><p>Knowing how the value of a function changes as its input is varied is useful because it tells us in which direction we can move to improve on previous points. To do this, we can use the concept of the <strong>derivative</strong> (in one dimension) and the <strong>gradient</strong> (in multiple dimensions), and we use these in order to find the<strong> critical points</strong> for our problem or function.</p><div><hr></div><p><strong>Critical points: </strong>in simple terms, critical points of a function are points where the derivative(s) of the function are 0:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!W4zh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5e8c639-bf19-4792-b07f-13c447dbac7b_687x442.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!W4zh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5e8c639-bf19-4792-b07f-13c447dbac7b_687x442.png 424w, https://substackcdn.com/image/fetch/$s_!W4zh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5e8c639-bf19-4792-b07f-13c447dbac7b_687x442.png 848w, https://substackcdn.com/image/fetch/$s_!W4zh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5e8c639-bf19-4792-b07f-13c447dbac7b_687x442.png 1272w, https://substackcdn.com/image/fetch/$s_!W4zh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5e8c639-bf19-4792-b07f-13c447dbac7b_687x442.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!W4zh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5e8c639-bf19-4792-b07f-13c447dbac7b_687x442.png" width="523" height="336.48617176128096" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e5e8c639-bf19-4792-b07f-13c447dbac7b_687x442.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:442,&quot;width&quot;:687,&quot;resizeWidth&quot;:523,&quot;bytes&quot;:25399,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!W4zh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5e8c639-bf19-4792-b07f-13c447dbac7b_687x442.png 424w, https://substackcdn.com/image/fetch/$s_!W4zh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5e8c639-bf19-4792-b07f-13c447dbac7b_687x442.png 848w, https://substackcdn.com/image/fetch/$s_!W4zh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5e8c639-bf19-4792-b07f-13c447dbac7b_687x442.png 1272w, https://substackcdn.com/image/fetch/$s_!W4zh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5e8c639-bf19-4792-b07f-13c447dbac7b_687x442.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></figure></div><div><hr></div><p><strong>The Derivative</strong>: the derivative of a function f(x) tells us how the output of the function varies with an infinitely small change in the input (which we denote as dx). In visual terms, this simply means that we&#8217;re measuring the tangent of the function at point (x, f(x)):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XnvW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5b21080-0e71-46c0-8e6d-205460044c53_780x633.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XnvW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5b21080-0e71-46c0-8e6d-205460044c53_780x633.png 424w, https://substackcdn.com/image/fetch/$s_!XnvW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5b21080-0e71-46c0-8e6d-205460044c53_780x633.png 848w, https://substackcdn.com/image/fetch/$s_!XnvW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5b21080-0e71-46c0-8e6d-205460044c53_780x633.png 1272w, https://substackcdn.com/image/fetch/$s_!XnvW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5b21080-0e71-46c0-8e6d-205460044c53_780x633.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XnvW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5b21080-0e71-46c0-8e6d-205460044c53_780x633.png" width="442" height="358.7" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f5b21080-0e71-46c0-8e6d-205460044c53_780x633.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:633,&quot;width&quot;:780,&quot;resizeWidth&quot;:442,&quot;bytes&quot;:63244,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!XnvW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5b21080-0e71-46c0-8e6d-205460044c53_780x633.png 424w, https://substackcdn.com/image/fetch/$s_!XnvW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5b21080-0e71-46c0-8e6d-205460044c53_780x633.png 848w, https://substackcdn.com/image/fetch/$s_!XnvW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5b21080-0e71-46c0-8e6d-205460044c53_780x633.png 1272w, https://substackcdn.com/image/fetch/$s_!XnvW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5b21080-0e71-46c0-8e6d-205460044c53_780x633.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></figure></div><p>Using the above perspective, we should be able to notice something about derivatives:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!p4Mx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa759ea3b-2d74-41a0-9133-7663d7ffd878_622x317.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!p4Mx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa759ea3b-2d74-41a0-9133-7663d7ffd878_622x317.png 424w, https://substackcdn.com/image/fetch/$s_!p4Mx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa759ea3b-2d74-41a0-9133-7663d7ffd878_622x317.png 848w, https://substackcdn.com/image/fetch/$s_!p4Mx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa759ea3b-2d74-41a0-9133-7663d7ffd878_622x317.png 1272w, https://substackcdn.com/image/fetch/$s_!p4Mx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa759ea3b-2d74-41a0-9133-7663d7ffd878_622x317.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!p4Mx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa759ea3b-2d74-41a0-9133-7663d7ffd878_622x317.png" width="536" height="273.17041800643085" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a759ea3b-2d74-41a0-9133-7663d7ffd878_622x317.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:317,&quot;width&quot;:622,&quot;resizeWidth&quot;:536,&quot;bytes&quot;:49146,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!p4Mx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa759ea3b-2d74-41a0-9133-7663d7ffd878_622x317.png 424w, https://substackcdn.com/image/fetch/$s_!p4Mx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa759ea3b-2d74-41a0-9133-7663d7ffd878_622x317.png 848w, https://substackcdn.com/image/fetch/$s_!p4Mx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa759ea3b-2d74-41a0-9133-7663d7ffd878_622x317.png 1272w, https://substackcdn.com/image/fetch/$s_!p4Mx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa759ea3b-2d74-41a0-9133-7663d7ffd878_622x317.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></figure></div><p>Indeed &#8211; we can see from our visuals that each of our local or global minima / maxima lie where our <strong>derivative (tangent) is 0</strong>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!F-2u!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7a452d5-4ade-4ea8-99bf-986dd6230c4c_968x530.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!F-2u!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7a452d5-4ade-4ea8-99bf-986dd6230c4c_968x530.png 424w, https://substackcdn.com/image/fetch/$s_!F-2u!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7a452d5-4ade-4ea8-99bf-986dd6230c4c_968x530.png 848w, https://substackcdn.com/image/fetch/$s_!F-2u!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7a452d5-4ade-4ea8-99bf-986dd6230c4c_968x530.png 1272w, https://substackcdn.com/image/fetch/$s_!F-2u!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7a452d5-4ade-4ea8-99bf-986dd6230c4c_968x530.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!F-2u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7a452d5-4ade-4ea8-99bf-986dd6230c4c_968x530.png" width="566" height="309.89669421487605" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d7a452d5-4ade-4ea8-99bf-986dd6230c4c_968x530.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:530,&quot;width&quot;:968,&quot;resizeWidth&quot;:566,&quot;bytes&quot;:43003,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!F-2u!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7a452d5-4ade-4ea8-99bf-986dd6230c4c_968x530.png 424w, https://substackcdn.com/image/fetch/$s_!F-2u!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7a452d5-4ade-4ea8-99bf-986dd6230c4c_968x530.png 848w, https://substackcdn.com/image/fetch/$s_!F-2u!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7a452d5-4ade-4ea8-99bf-986dd6230c4c_968x530.png 1272w, https://substackcdn.com/image/fetch/$s_!F-2u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7a452d5-4ade-4ea8-99bf-986dd6230c4c_968x530.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></figure></div><div><hr></div><p><strong>The Second Derivative: </strong>The second derivative of a function tells us the rate at which our <strong>derivative changes.</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6_eg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54da5b7c-8769-4cbe-a211-e62b52730953_483x418.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6_eg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54da5b7c-8769-4cbe-a211-e62b52730953_483x418.png 424w, https://substackcdn.com/image/fetch/$s_!6_eg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54da5b7c-8769-4cbe-a211-e62b52730953_483x418.png 848w, https://substackcdn.com/image/fetch/$s_!6_eg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54da5b7c-8769-4cbe-a211-e62b52730953_483x418.png 1272w, https://substackcdn.com/image/fetch/$s_!6_eg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54da5b7c-8769-4cbe-a211-e62b52730953_483x418.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6_eg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54da5b7c-8769-4cbe-a211-e62b52730953_483x418.png" width="381" height="329.72670807453414" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/54da5b7c-8769-4cbe-a211-e62b52730953_483x418.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:418,&quot;width&quot;:483,&quot;resizeWidth&quot;:381,&quot;bytes&quot;:22632,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6_eg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54da5b7c-8769-4cbe-a211-e62b52730953_483x418.png 424w, https://substackcdn.com/image/fetch/$s_!6_eg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54da5b7c-8769-4cbe-a211-e62b52730953_483x418.png 848w, https://substackcdn.com/image/fetch/$s_!6_eg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54da5b7c-8769-4cbe-a211-e62b52730953_483x418.png 1272w, https://substackcdn.com/image/fetch/$s_!6_eg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54da5b7c-8769-4cbe-a211-e62b52730953_483x418.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></figure></div><p>In the above example, we can see that the slope of our tangent is changing from negative to positive as we move from left to right in our x (<strong>horizontal)</strong> direction, so our second derivative is <strong>increasing </strong>and is thus <strong>positive </strong>in this case. We can also state that our function is<strong> concave up</strong> in this region.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SfgW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7cdaee4-19a5-4669-8aec-0e3bed899b57_493x459.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SfgW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7cdaee4-19a5-4669-8aec-0e3bed899b57_493x459.png 424w, https://substackcdn.com/image/fetch/$s_!SfgW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7cdaee4-19a5-4669-8aec-0e3bed899b57_493x459.png 848w, https://substackcdn.com/image/fetch/$s_!SfgW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7cdaee4-19a5-4669-8aec-0e3bed899b57_493x459.png 1272w, https://substackcdn.com/image/fetch/$s_!SfgW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7cdaee4-19a5-4669-8aec-0e3bed899b57_493x459.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SfgW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7cdaee4-19a5-4669-8aec-0e3bed899b57_493x459.png" width="389" height="362.17241379310343" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a7cdaee4-19a5-4669-8aec-0e3bed899b57_493x459.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:459,&quot;width&quot;:493,&quot;resizeWidth&quot;:389,&quot;bytes&quot;:24977,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!SfgW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7cdaee4-19a5-4669-8aec-0e3bed899b57_493x459.png 424w, https://substackcdn.com/image/fetch/$s_!SfgW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7cdaee4-19a5-4669-8aec-0e3bed899b57_493x459.png 848w, https://substackcdn.com/image/fetch/$s_!SfgW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7cdaee4-19a5-4669-8aec-0e3bed899b57_493x459.png 1272w, https://substackcdn.com/image/fetch/$s_!SfgW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7cdaee4-19a5-4669-8aec-0e3bed899b57_493x459.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></figure></div><p>In the above image, we have the opposite effect occurring: as our x (input) increases (goes from left to right), the tangent line (derivative) is <strong>decreasing</strong> and thus our second derivative is thus <strong>negative </strong>in the above instance. Alternatively, we can also state the our function is<strong> concave down</strong> at this region.</p><div><hr></div><p><strong>The Gradient: </strong>The <strong>gradient</strong> is the generalization of the derivative mapped onto multivariate functions. As with the derivative, it captures the local slope of the function, allowing us to predict the effect of taking a small step from a point in any direction.</p><p>For scalar fields, <strong>the gradient of a scalar field f represents the direction of fastest ascent</strong>. As an example, if we take the scalar field / function plotted 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_!dFH9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4365c03f-002b-4b12-a69e-a4a903b3f899_599x425.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dFH9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4365c03f-002b-4b12-a69e-a4a903b3f899_599x425.png 424w, https://substackcdn.com/image/fetch/$s_!dFH9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4365c03f-002b-4b12-a69e-a4a903b3f899_599x425.png 848w, https://substackcdn.com/image/fetch/$s_!dFH9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4365c03f-002b-4b12-a69e-a4a903b3f899_599x425.png 1272w, https://substackcdn.com/image/fetch/$s_!dFH9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4365c03f-002b-4b12-a69e-a4a903b3f899_599x425.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dFH9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4365c03f-002b-4b12-a69e-a4a903b3f899_599x425.png" width="487" height="345.534223706177" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4365c03f-002b-4b12-a69e-a4a903b3f899_599x425.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:425,&quot;width&quot;:599,&quot;resizeWidth&quot;:487,&quot;bytes&quot;:147198,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!dFH9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4365c03f-002b-4b12-a69e-a4a903b3f899_599x425.png 424w, https://substackcdn.com/image/fetch/$s_!dFH9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4365c03f-002b-4b12-a69e-a4a903b3f899_599x425.png 848w, https://substackcdn.com/image/fetch/$s_!dFH9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4365c03f-002b-4b12-a69e-a4a903b3f899_599x425.png 1272w, https://substackcdn.com/image/fetch/$s_!dFH9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4365c03f-002b-4b12-a69e-a4a903b3f899_599x425.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></figure></div><p>The gradient plotted over its surface is:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XWr-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46163a78-3d0b-4890-af29-277350699812_941x601.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XWr-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46163a78-3d0b-4890-af29-277350699812_941x601.png 424w, https://substackcdn.com/image/fetch/$s_!XWr-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46163a78-3d0b-4890-af29-277350699812_941x601.png 848w, https://substackcdn.com/image/fetch/$s_!XWr-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46163a78-3d0b-4890-af29-277350699812_941x601.png 1272w, https://substackcdn.com/image/fetch/$s_!XWr-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46163a78-3d0b-4890-af29-277350699812_941x601.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XWr-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46163a78-3d0b-4890-af29-277350699812_941x601.png" width="582" height="371.71307120085015" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/46163a78-3d0b-4890-af29-277350699812_941x601.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:601,&quot;width&quot;:941,&quot;resizeWidth&quot;:582,&quot;bytes&quot;:219613,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!XWr-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46163a78-3d0b-4890-af29-277350699812_941x601.png 424w, https://substackcdn.com/image/fetch/$s_!XWr-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46163a78-3d0b-4890-af29-277350699812_941x601.png 848w, https://substackcdn.com/image/fetch/$s_!XWr-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46163a78-3d0b-4890-af29-277350699812_941x601.png 1272w, https://substackcdn.com/image/fetch/$s_!XWr-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46163a78-3d0b-4890-af29-277350699812_941x601.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></figure></div><p>The <strong>gradient</strong> of f at x is written &#8711; f(x) and each component of the resulting gradient vector is the partial derivative of f with respect to that component:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!InKK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed506a5-c6ac-48aa-b1c5-b96a2660c297_553x92.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!InKK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed506a5-c6ac-48aa-b1c5-b96a2660c297_553x92.png 424w, https://substackcdn.com/image/fetch/$s_!InKK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed506a5-c6ac-48aa-b1c5-b96a2660c297_553x92.png 848w, https://substackcdn.com/image/fetch/$s_!InKK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed506a5-c6ac-48aa-b1c5-b96a2660c297_553x92.png 1272w, https://substackcdn.com/image/fetch/$s_!InKK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed506a5-c6ac-48aa-b1c5-b96a2660c297_553x92.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!InKK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed506a5-c6ac-48aa-b1c5-b96a2660c297_553x92.png" width="553" height="92" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1ed506a5-c6ac-48aa-b1c5-b96a2660c297_553x92.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:92,&quot;width&quot;:553,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:7969,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!InKK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed506a5-c6ac-48aa-b1c5-b96a2660c297_553x92.png 424w, https://substackcdn.com/image/fetch/$s_!InKK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed506a5-c6ac-48aa-b1c5-b96a2660c297_553x92.png 848w, https://substackcdn.com/image/fetch/$s_!InKK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed506a5-c6ac-48aa-b1c5-b96a2660c297_553x92.png 1272w, https://substackcdn.com/image/fetch/$s_!InKK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed506a5-c6ac-48aa-b1c5-b96a2660c297_553x92.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div><hr></div><h4><strong>What does this all mean?</strong></h4><p>As already mentioned, since many optimization problems require us to search for a local or global optimum (maximum or minimum), derivatives and gradients play a vital role in optimization problems and in directing our search for local and global points of interest. Once our search is completed, certain conditions must hold so that we know that the point or region is in fact a minimum, and we&#8217;ll go over these conditions below.</p><p>For functions which have one variable (which we call<strong> univariate</strong> functions), to confirm that a point is a strong <strong>local</strong> minimum (a low point in the function near one region), two conditions must be met:</p><ol><li><p>The first derivative (slope) at that point must be zero (meaning the function isn't increasing or decreasing at that point).</p></li><li><p>The second derivative (curvature) at that point must be positive (meaning the function is curving upwards, like the bottom of a bowl &#8211; or in alternative terms, we say that the function must be concave up at this point).</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ebXL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5052a18-e177-4d1e-9b84-6c150f37aec3_536x482.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ebXL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5052a18-e177-4d1e-9b84-6c150f37aec3_536x482.png 424w, https://substackcdn.com/image/fetch/$s_!ebXL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5052a18-e177-4d1e-9b84-6c150f37aec3_536x482.png 848w, https://substackcdn.com/image/fetch/$s_!ebXL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5052a18-e177-4d1e-9b84-6c150f37aec3_536x482.png 1272w, https://substackcdn.com/image/fetch/$s_!ebXL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5052a18-e177-4d1e-9b84-6c150f37aec3_536x482.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ebXL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5052a18-e177-4d1e-9b84-6c150f37aec3_536x482.png" width="422" height="379.4850746268657" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a5052a18-e177-4d1e-9b84-6c150f37aec3_536x482.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:482,&quot;width&quot;:536,&quot;resizeWidth&quot;:422,&quot;bytes&quot;:17332,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ebXL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5052a18-e177-4d1e-9b84-6c150f37aec3_536x482.png 424w, https://substackcdn.com/image/fetch/$s_!ebXL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5052a18-e177-4d1e-9b84-6c150f37aec3_536x482.png 848w, https://substackcdn.com/image/fetch/$s_!ebXL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5052a18-e177-4d1e-9b84-6c150f37aec3_536x482.png 1272w, https://substackcdn.com/image/fetch/$s_!ebXL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5052a18-e177-4d1e-9b84-6c150f37aec3_536x482.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></figure></div><p>For functions with more than one variable (<strong>multivariate</strong> functions), the below conditions must be met for a point x to be a local minimum of the function f:</p><ol><li><p>The gradient (&#8711;f(x)) at that point must be zero, meaning the function is flat there (no increase or decrease in any direction).</p></li><li><p>The Hessian matrix (&#8711;&#178;f(x)) at that point must be positive semi-definite, meaning the function curves upwards or is flat in all directions around that point (indicating a minimum or a flat point, but not a maximum).</p></li></ol><p><strong>In simpler terms: </strong>for x to be a local minimum, the gradient / slope must be 0 at x and the surface must be curving upwards or &#8216;in a bowl&#8217; at that point (as pictured 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_!T198!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3f10d6-0b09-4699-95d4-17dcb6085b45_383x358.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!T198!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3f10d6-0b09-4699-95d4-17dcb6085b45_383x358.png 424w, https://substackcdn.com/image/fetch/$s_!T198!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3f10d6-0b09-4699-95d4-17dcb6085b45_383x358.png 848w, https://substackcdn.com/image/fetch/$s_!T198!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3f10d6-0b09-4699-95d4-17dcb6085b45_383x358.png 1272w, https://substackcdn.com/image/fetch/$s_!T198!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3f10d6-0b09-4699-95d4-17dcb6085b45_383x358.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!T198!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3f10d6-0b09-4699-95d4-17dcb6085b45_383x358.png" width="309" height="288.8302872062663" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6a3f10d6-0b09-4699-95d4-17dcb6085b45_383x358.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:358,&quot;width&quot;:383,&quot;resizeWidth&quot;:309,&quot;bytes&quot;:36667,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!T198!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3f10d6-0b09-4699-95d4-17dcb6085b45_383x358.png 424w, https://substackcdn.com/image/fetch/$s_!T198!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3f10d6-0b09-4699-95d4-17dcb6085b45_383x358.png 848w, https://substackcdn.com/image/fetch/$s_!T198!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3f10d6-0b09-4699-95d4-17dcb6085b45_383x358.png 1272w, https://substackcdn.com/image/fetch/$s_!T198!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3f10d6-0b09-4699-95d4-17dcb6085b45_383x358.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></figure></div><div><hr></div><p><strong>The Hessian: </strong>the Hessian is a matrix of second derivatives that tells us how a multi-variable function bends or curves in different directions around a point. This helps us identify if we're at a minimum, maximum, or saddle 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_!3DH1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5392c6ea-8707-4567-a54b-a28c2d3481a1_918x250.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3DH1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5392c6ea-8707-4567-a54b-a28c2d3481a1_918x250.png 424w, https://substackcdn.com/image/fetch/$s_!3DH1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5392c6ea-8707-4567-a54b-a28c2d3481a1_918x250.png 848w, https://substackcdn.com/image/fetch/$s_!3DH1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5392c6ea-8707-4567-a54b-a28c2d3481a1_918x250.png 1272w, https://substackcdn.com/image/fetch/$s_!3DH1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5392c6ea-8707-4567-a54b-a28c2d3481a1_918x250.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3DH1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5392c6ea-8707-4567-a54b-a28c2d3481a1_918x250.png" width="918" height="250" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5392c6ea-8707-4567-a54b-a28c2d3481a1_918x250.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:250,&quot;width&quot;:918,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:88989,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3DH1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5392c6ea-8707-4567-a54b-a28c2d3481a1_918x250.png 424w, https://substackcdn.com/image/fetch/$s_!3DH1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5392c6ea-8707-4567-a54b-a28c2d3481a1_918x250.png 848w, https://substackcdn.com/image/fetch/$s_!3DH1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5392c6ea-8707-4567-a54b-a28c2d3481a1_918x250.png 1272w, https://substackcdn.com/image/fetch/$s_!3DH1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5392c6ea-8707-4567-a54b-a28c2d3481a1_918x250.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></figure></div><ul><li><p>If the Hessian is positive definite (all positive eigenvalues), the function curves upwards in all directions, indicating a local minimum.</p></li><li><p>If the Hessian is negative definite (all negative eigenvalues), the function curves downwards in all directions, indicating a local maximum.</p></li><li><p>If the Hessian is indefinite (mixed positive and negative eigenvalues), the function has a saddle point (curves up in some directions and down in others).</p></li></ul><p>It is written as &#8711;&#178;f(x) and is conceptualized as a matrix containing all of the second derivative of function f with respect to its inputs:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9hS5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc74578ba-f419-4be4-84a0-bb31e9b53db7_609x196.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9hS5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc74578ba-f419-4be4-84a0-bb31e9b53db7_609x196.png 424w, https://substackcdn.com/image/fetch/$s_!9hS5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc74578ba-f419-4be4-84a0-bb31e9b53db7_609x196.png 848w, https://substackcdn.com/image/fetch/$s_!9hS5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc74578ba-f419-4be4-84a0-bb31e9b53db7_609x196.png 1272w, https://substackcdn.com/image/fetch/$s_!9hS5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc74578ba-f419-4be4-84a0-bb31e9b53db7_609x196.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9hS5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc74578ba-f419-4be4-84a0-bb31e9b53db7_609x196.png" width="609" height="196" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c74578ba-f419-4be4-84a0-bb31e9b53db7_609x196.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:196,&quot;width&quot;:609,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:14274,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!9hS5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc74578ba-f419-4be4-84a0-bb31e9b53db7_609x196.png 424w, https://substackcdn.com/image/fetch/$s_!9hS5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc74578ba-f419-4be4-84a0-bb31e9b53db7_609x196.png 848w, https://substackcdn.com/image/fetch/$s_!9hS5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc74578ba-f419-4be4-84a0-bb31e9b53db7_609x196.png 1272w, https://substackcdn.com/image/fetch/$s_!9hS5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc74578ba-f419-4be4-84a0-bb31e9b53db7_609x196.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div><hr></div><p>Oftentimes, derivatives are not known analytically and cannot be directly derived, so we are forced to either estimate them numerically or via automatic differentiation techniques. Let&#8217;s go through and outline some methods of estimating derivatives, starting with the finite difference method.</p><h3><strong>Finite Difference Method</strong></h3><p>This is a numerical method of differentiation where the derivative is approximated by computing how the function value changes with small changes to its input. Think of it like trying to figure out the steepness of a hill by measuring how much higher or lower you are when you take a small step forward or backward.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!oi4x!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ffe7536-e839-4b1b-943d-5f9a4400c7ab_685x460.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!oi4x!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ffe7536-e839-4b1b-943d-5f9a4400c7ab_685x460.png 424w, https://substackcdn.com/image/fetch/$s_!oi4x!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ffe7536-e839-4b1b-943d-5f9a4400c7ab_685x460.png 848w, https://substackcdn.com/image/fetch/$s_!oi4x!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ffe7536-e839-4b1b-943d-5f9a4400c7ab_685x460.png 1272w, https://substackcdn.com/image/fetch/$s_!oi4x!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ffe7536-e839-4b1b-943d-5f9a4400c7ab_685x460.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!oi4x!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ffe7536-e839-4b1b-943d-5f9a4400c7ab_685x460.png" width="369" height="247.79562043795622" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9ffe7536-e839-4b1b-943d-5f9a4400c7ab_685x460.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:460,&quot;width&quot;:685,&quot;resizeWidth&quot;:369,&quot;bytes&quot;:23679,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!oi4x!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ffe7536-e839-4b1b-943d-5f9a4400c7ab_685x460.png 424w, https://substackcdn.com/image/fetch/$s_!oi4x!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ffe7536-e839-4b1b-943d-5f9a4400c7ab_685x460.png 848w, https://substackcdn.com/image/fetch/$s_!oi4x!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ffe7536-e839-4b1b-943d-5f9a4400c7ab_685x460.png 1272w, https://substackcdn.com/image/fetch/$s_!oi4x!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ffe7536-e839-4b1b-943d-5f9a4400c7ab_685x460.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></figure></div><p>Here's how it usually works:</p><ol><li><p><strong>Choose a Small Step (h)</strong>: This is a tiny change in the input value (x).</p></li><li><p><strong>Calculate Function Values</strong>: Find the function values at the points slightly before and after the point of interest (x). For example, if you want the derivative at x, look at f(x+h) and f(x&#8722;h).</p></li><li><p><strong>Compute the Slope</strong>: Use these function values to approximate the slope (derivative) at x. For a more accurate estimate, use the central difference formula:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8inS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ccb7f48-cde0-4122-a357-f7b0ae88d6e8_478x135.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8inS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ccb7f48-cde0-4122-a357-f7b0ae88d6e8_478x135.png 424w, https://substackcdn.com/image/fetch/$s_!8inS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ccb7f48-cde0-4122-a357-f7b0ae88d6e8_478x135.png 848w, https://substackcdn.com/image/fetch/$s_!8inS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ccb7f48-cde0-4122-a357-f7b0ae88d6e8_478x135.png 1272w, https://substackcdn.com/image/fetch/$s_!8inS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ccb7f48-cde0-4122-a357-f7b0ae88d6e8_478x135.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8inS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ccb7f48-cde0-4122-a357-f7b0ae88d6e8_478x135.png" width="414" height="116.92468619246861" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7ccb7f48-cde0-4122-a357-f7b0ae88d6e8_478x135.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:135,&quot;width&quot;:478,&quot;resizeWidth&quot;:414,&quot;bytes&quot;:8122,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8inS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ccb7f48-cde0-4122-a357-f7b0ae88d6e8_478x135.png 424w, https://substackcdn.com/image/fetch/$s_!8inS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ccb7f48-cde0-4122-a357-f7b0ae88d6e8_478x135.png 848w, https://substackcdn.com/image/fetch/$s_!8inS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ccb7f48-cde0-4122-a357-f7b0ae88d6e8_478x135.png 1272w, https://substackcdn.com/image/fetch/$s_!8inS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ccb7f48-cde0-4122-a357-f7b0ae88d6e8_478x135.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div></li></ol><p>Let's write a simple Python program to demonstrate the finite difference method. Here, we&#8217;ll define the function to be f(x) = x<sup>2 </sup>and compute its derivative using the finite difference method:</p><pre><code>INPUT_X = 2.0
STEP_SIZE = 0.00001

def finite_difference(function, x, step_size = 0.00001):
    # Central difference formula
    return (function(x + step_size) - function(x - step_size)) / (2 * step_size)

# Define the function f(x) = x^2
def x_squared(x):
    return x * x

# Estimate the derivative using the finite difference method at x = 2
derivative_estimate = finite_difference(
    function = x_squared
    # Input point we want to calculate the derivative for
    , x = INPUT_X
    # We choose an extremely small step size
    , step_size = STEP_SIZE
)

print(f"The estimated derivative of f(x) at {INPUT_X} is {round(derivative_estimate, 4)}.")</code></pre><p>In the above example, the output we get is: </p><h4>&#8216;The estimated derivative of f(x) at 2.0 is 4.0.&#8217; </h4><p>This is correct since the derivative of x<sup>2</sup> is 2x and for x = 2, 2x is equal to 2(2) = 4.</p><p>The finite difference method is very simple and a great way to obtain derivative numerically, but we can run into issues. Oftentimes, the step size for our derivative estimate needs to be small enough to provide a good estimate for the derivative near that region, but if the step size is too small, it can lead to numerical subtractive cancellation issues. </p><p>The above may sound complicated, but let&#8217;s go through a very simple example to illustrate what we&#8217;re talking about: let&#8217;s take a real step f&#8217;(x) = f(x + h) &#8211; f(x) / h where h is unreasonably small and represents our step size. For a small h, f(x + h) is very close to f(x). This could cause what we termed earlier as subtractive cancellation whereby rounding errors and other issues cause our results to be inaccurate. In order to remedy these issues, the <strong>complex step method</strong> is a great alternative to the finite difference method.</p><h3><strong>The Complex Step Method</strong></h3><p>Instead of taking function steps close to an input and computing multiple outputs for the function in question &#8211; here we simply use an imaginary number (a 2-dimensional number built out of a real and imaginary component) and use the real number component as our input while we use the imaginary component as our &#8216;step.&#8217; This way &#8211; the cancellation issues we touched upon earlier are resolved and we simplify our process: instead of having to compute multiple function outputs, we simply evaluate the function <strong>once</strong>.</p><div><hr></div><p><strong>Complex Number: </strong>These are numbers that include the imaginary unit <br>&#119894;, where &#119894; is defined as the square root of -1. When we add a tiny imaginary part to a real number, we can still perform regular arithmetic operations but with a special property that helps in derivative calculations.</p><p>'</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GEcx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1e44c86-1a11-40c6-9ad9-bf8d0ef3184d_961x787.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GEcx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1e44c86-1a11-40c6-9ad9-bf8d0ef3184d_961x787.png 424w, https://substackcdn.com/image/fetch/$s_!GEcx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1e44c86-1a11-40c6-9ad9-bf8d0ef3184d_961x787.png 848w, https://substackcdn.com/image/fetch/$s_!GEcx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1e44c86-1a11-40c6-9ad9-bf8d0ef3184d_961x787.png 1272w, https://substackcdn.com/image/fetch/$s_!GEcx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1e44c86-1a11-40c6-9ad9-bf8d0ef3184d_961x787.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GEcx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1e44c86-1a11-40c6-9ad9-bf8d0ef3184d_961x787.png" width="608" height="497.9146722164412" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c1e44c86-1a11-40c6-9ad9-bf8d0ef3184d_961x787.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:787,&quot;width&quot;:961,&quot;resizeWidth&quot;:608,&quot;bytes&quot;:131892,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GEcx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1e44c86-1a11-40c6-9ad9-bf8d0ef3184d_961x787.png 424w, https://substackcdn.com/image/fetch/$s_!GEcx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1e44c86-1a11-40c6-9ad9-bf8d0ef3184d_961x787.png 848w, https://substackcdn.com/image/fetch/$s_!GEcx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1e44c86-1a11-40c6-9ad9-bf8d0ef3184d_961x787.png 1272w, https://substackcdn.com/image/fetch/$s_!GEcx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1e44c86-1a11-40c6-9ad9-bf8d0ef3184d_961x787.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></figure></div><div><hr></div><p>By adding an imaginary step ih to our real component, we only need to use one function evaluation to find the derivative. The formula is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MJpW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d462872-2d53-46e4-948b-86ec1034c50a_584x108.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MJpW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d462872-2d53-46e4-948b-86ec1034c50a_584x108.png 424w, https://substackcdn.com/image/fetch/$s_!MJpW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d462872-2d53-46e4-948b-86ec1034c50a_584x108.png 848w, https://substackcdn.com/image/fetch/$s_!MJpW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d462872-2d53-46e4-948b-86ec1034c50a_584x108.png 1272w, https://substackcdn.com/image/fetch/$s_!MJpW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d462872-2d53-46e4-948b-86ec1034c50a_584x108.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MJpW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d462872-2d53-46e4-948b-86ec1034c50a_584x108.png" width="464" height="85.8082191780822" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4d462872-2d53-46e4-948b-86ec1034c50a_584x108.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:108,&quot;width&quot;:584,&quot;resizeWidth&quot;:464,&quot;bytes&quot;:10541,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MJpW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d462872-2d53-46e4-948b-86ec1034c50a_584x108.png 424w, https://substackcdn.com/image/fetch/$s_!MJpW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d462872-2d53-46e4-948b-86ec1034c50a_584x108.png 848w, https://substackcdn.com/image/fetch/$s_!MJpW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d462872-2d53-46e4-948b-86ec1034c50a_584x108.png 1272w, https://substackcdn.com/image/fetch/$s_!MJpW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d462872-2d53-46e4-948b-86ec1034c50a_584x108.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Adding a tiny imaginary part doesn&#8217;t affect the real part of the function much, so we don&#8217;t lose significant digits. The imaginary part provides a direct and precise way to calculate the derivative. This imaginary step in other words allows us to algebraically model our solution without having to discard information and gets rid of any cancellation issues.</p><p>Let&#8217;s take a real example which we already used involving the function f(x) = x<sup>2</sup>. For derivative for this function at x = 2 using a real step can be computed using the following formula: f(2 + h) &#8211; f(2) / h for a very small h, but if the h is too small, we may get precision loss.</p><p>Using complex numbers and complex arithmetic though, we can use:</p><h4>x = 2 + ih</h4><p>We use this to estimate our derivative (where h represents our step size). Using this form / representation, we get:</p><h4>f(x) = x<sup>2</sup></h4><h4>f(2 + ih) = (2 + ih)<sup>2 </sup>= 4 + 4ih &#8722; h<sup>2</sup></h4><p>We should be able to see from the above result that our <strong>imaginary </strong>component is <strong>4ih. </strong>Since we know that the derivative in our complex step method results in:</p><h4>Derivative = Imaginary Part / h<br>= 4h / h<br>= 4</h4><p>We can see that our derivative at this point is 4, which is indeed correct! </p><p>We once again produce a Python example / code to illustrate our results in order to make things more clear:</p><pre><code>import numpy as np

INPUT_X = 2.0
STEP_SIZE = 0.00001

def complex_step_derivative(function, x, step_size = 0.00001):
    # Evaluate the function at x + ih
    result = function(x + step_size*1j)
    # The derivative is the imaginary part and divide it by our step size
    return np.imag(result) / step_size

# Define the function f(x) = x^2
def x_squared(x):
    return x * x

# Estimate the derivative using the complex step method
derivative_estimate = complex_step_derivative(
    function=x_squared
    # Input point we want to calculate the derivative for
    , x=INPUT_X
    # We choose an appropriate step size
    , step_size=STEP_SIZE
)

print(f"The estimated derivative of f(x) at {INPUT_X} using the complex step method is {derivative_estimate}.")</code></pre><p>Using the above methodology, we once again obtain the correct output and result: </p><h4>&#8216;The estimated derivative of f(x) at 2.0 using the complex step method is 4.0.&#8217;</h4><p>As you can see, adding a tiny imaginary part doesn&#8217;t affect the real part of the function and we don&#8217;t lose significant digits.</p><h3><strong>Automatic Differentiation</strong></h3><p>This method computes derivatives automatically and accurately by using a special structure called a computational graph. A computational graph is a way to visually and systematically represent the calculations involved in a function. The nodes in the graph represent the operations (like add, multiply, etc...) while the edges (lines connecting the nodes) represent the input-output relations. </p><p>Let's consider the function:</p><h4>f(x, y) = (x+2y)<sup>2</sup> + sin(y)</h4><p></p><p>The computational graph for this is provided 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_!p9iG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f19a24-4be2-4852-a4c2-da81be031fbd_821x875.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!p9iG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f19a24-4be2-4852-a4c2-da81be031fbd_821x875.png 424w, https://substackcdn.com/image/fetch/$s_!p9iG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f19a24-4be2-4852-a4c2-da81be031fbd_821x875.png 848w, https://substackcdn.com/image/fetch/$s_!p9iG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f19a24-4be2-4852-a4c2-da81be031fbd_821x875.png 1272w, https://substackcdn.com/image/fetch/$s_!p9iG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f19a24-4be2-4852-a4c2-da81be031fbd_821x875.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!p9iG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f19a24-4be2-4852-a4c2-da81be031fbd_821x875.png" width="442" height="471.0718635809988" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/76f19a24-4be2-4852-a4c2-da81be031fbd_821x875.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:875,&quot;width&quot;:821,&quot;resizeWidth&quot;:442,&quot;bytes&quot;:52982,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!p9iG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f19a24-4be2-4852-a4c2-da81be031fbd_821x875.png 424w, https://substackcdn.com/image/fetch/$s_!p9iG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f19a24-4be2-4852-a4c2-da81be031fbd_821x875.png 848w, https://substackcdn.com/image/fetch/$s_!p9iG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f19a24-4be2-4852-a4c2-da81be031fbd_821x875.png 1272w, https://substackcdn.com/image/fetch/$s_!p9iG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f19a24-4be2-4852-a4c2-da81be031fbd_821x875.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></figure></div><p>There are two methods for automatically differentiating f(x, y) using its computational graph. The <strong>forward accumulation</strong> method traverses the tree from inputs to outputs, whereas <strong>reverse accumulation</strong> requires a backwards pass through the graph.</p><p>Let&#8217;s go through the example we provided above to illustrate how we would use the 2 different accumulation methods to compute the derivatives for this graph.</p><h3><strong>Forward Mode Accumulation</strong></h3><p>Once again, the example function which we will go through is provided below:</p><h4>f(x, y) = (x+2y)<sup>2</sup> + sin(y)</h4><p></p><p>In order to aid us, we&#8217;ll introduce a few intermediate variables within our graph:</p><h4>z = x + 2y</h4><h4>w = z<sup>2</sup></h4><h4>v = sin(y)</h4><p></p><p>The output of our function we label as f and denote as:</p><h4>f = w + v</h4><p></p><p>Our updated graph with the intermediate variables is provided 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_!SKZ8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ae39c37-1306-44b7-9f31-5e3c8256c514_737x847.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SKZ8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ae39c37-1306-44b7-9f31-5e3c8256c514_737x847.png 424w, https://substackcdn.com/image/fetch/$s_!SKZ8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ae39c37-1306-44b7-9f31-5e3c8256c514_737x847.png 848w, https://substackcdn.com/image/fetch/$s_!SKZ8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ae39c37-1306-44b7-9f31-5e3c8256c514_737x847.png 1272w, https://substackcdn.com/image/fetch/$s_!SKZ8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ae39c37-1306-44b7-9f31-5e3c8256c514_737x847.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SKZ8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ae39c37-1306-44b7-9f31-5e3c8256c514_737x847.png" width="462" height="530.955223880597" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5ae39c37-1306-44b7-9f31-5e3c8256c514_737x847.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:847,&quot;width&quot;:737,&quot;resizeWidth&quot;:462,&quot;bytes&quot;:49880,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!SKZ8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ae39c37-1306-44b7-9f31-5e3c8256c514_737x847.png 424w, https://substackcdn.com/image/fetch/$s_!SKZ8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ae39c37-1306-44b7-9f31-5e3c8256c514_737x847.png 848w, https://substackcdn.com/image/fetch/$s_!SKZ8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ae39c37-1306-44b7-9f31-5e3c8256c514_737x847.png 1272w, https://substackcdn.com/image/fetch/$s_!SKZ8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ae39c37-1306-44b7-9f31-5e3c8256c514_737x847.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></figure></div><p>Forward mode accumulation calculates derivatives from the input to the output, propagating through each node, so we start off with our input variables. We know that x and y are both independent variables, so from this, we know that &#8706;y/&#8706;x = 0 and that &#8706;x/&#8706;y = 0 (i.e. a change in x does not effect y and a change in y has no effect on x).</p><p>Now, let&#8217;s go through our intermediate calculations starting with variable z:</p><h4><strong>z = x + 2y</strong></h4><h4>&#8706;z/&#8706;x = 1</h4><h4>&#8706;z/&#8706;y = 2</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fYLS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08b2b377-8df0-4847-990e-8670fce4dd90_741x466.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fYLS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08b2b377-8df0-4847-990e-8670fce4dd90_741x466.png 424w, https://substackcdn.com/image/fetch/$s_!fYLS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08b2b377-8df0-4847-990e-8670fce4dd90_741x466.png 848w, https://substackcdn.com/image/fetch/$s_!fYLS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08b2b377-8df0-4847-990e-8670fce4dd90_741x466.png 1272w, https://substackcdn.com/image/fetch/$s_!fYLS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08b2b377-8df0-4847-990e-8670fce4dd90_741x466.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fYLS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08b2b377-8df0-4847-990e-8670fce4dd90_741x466.png" width="491" height="308.7800269905533" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/08b2b377-8df0-4847-990e-8670fce4dd90_741x466.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:466,&quot;width&quot;:741,&quot;resizeWidth&quot;:491,&quot;bytes&quot;:33499,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fYLS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08b2b377-8df0-4847-990e-8670fce4dd90_741x466.png 424w, https://substackcdn.com/image/fetch/$s_!fYLS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08b2b377-8df0-4847-990e-8670fce4dd90_741x466.png 848w, https://substackcdn.com/image/fetch/$s_!fYLS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08b2b377-8df0-4847-990e-8670fce4dd90_741x466.png 1272w, https://substackcdn.com/image/fetch/$s_!fYLS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08b2b377-8df0-4847-990e-8670fce4dd90_741x466.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></figure></div><p></p><p>Now, we have <strong>w = z<sup>2</sup></strong> and so:</p><h4>&#8706;w/&#8706;z = 2z</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tSfa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1235f3a3-48f7-49e9-8eec-c424946f96a1_770x631.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tSfa!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1235f3a3-48f7-49e9-8eec-c424946f96a1_770x631.png 424w, https://substackcdn.com/image/fetch/$s_!tSfa!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1235f3a3-48f7-49e9-8eec-c424946f96a1_770x631.png 848w, https://substackcdn.com/image/fetch/$s_!tSfa!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1235f3a3-48f7-49e9-8eec-c424946f96a1_770x631.png 1272w, https://substackcdn.com/image/fetch/$s_!tSfa!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1235f3a3-48f7-49e9-8eec-c424946f96a1_770x631.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tSfa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1235f3a3-48f7-49e9-8eec-c424946f96a1_770x631.png" width="489" height="400.72597402597404" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1235f3a3-48f7-49e9-8eec-c424946f96a1_770x631.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:631,&quot;width&quot;:770,&quot;resizeWidth&quot;:489,&quot;bytes&quot;:47285,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tSfa!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1235f3a3-48f7-49e9-8eec-c424946f96a1_770x631.png 424w, https://substackcdn.com/image/fetch/$s_!tSfa!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1235f3a3-48f7-49e9-8eec-c424946f96a1_770x631.png 848w, https://substackcdn.com/image/fetch/$s_!tSfa!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1235f3a3-48f7-49e9-8eec-c424946f96a1_770x631.png 1272w, https://substackcdn.com/image/fetch/$s_!tSfa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1235f3a3-48f7-49e9-8eec-c424946f96a1_770x631.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></figure></div><p></p><p>Using the chain rule, we can derive:</p><h4>&#8706;w/&#8706;x</h4><h4>= &#8706;w/&#8706;z * &#8706;z/&#8706;x</h4><h4>= 2z * 1</h4><h4>= 2z</h4><p></p><h4>&#8706;w/&#8706;y</h4><h4>= &#8706;w/&#8706;z * &#8706;z/&#8706;y</h4><h4>= 2z * 2</h4><h4>= 4z</h4><p></p><p>Next, we have variable <strong>v = sin(y)</strong> and so:</p><h4>&#8706;v/&#8706;y = cos(y)</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SreL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a479b8e-62df-4564-86f7-992500667046_295x495.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SreL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a479b8e-62df-4564-86f7-992500667046_295x495.png 424w, https://substackcdn.com/image/fetch/$s_!SreL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a479b8e-62df-4564-86f7-992500667046_295x495.png 848w, https://substackcdn.com/image/fetch/$s_!SreL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a479b8e-62df-4564-86f7-992500667046_295x495.png 1272w, https://substackcdn.com/image/fetch/$s_!SreL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a479b8e-62df-4564-86f7-992500667046_295x495.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SreL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a479b8e-62df-4564-86f7-992500667046_295x495.png" width="163" height="273.50847457627117" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1a479b8e-62df-4564-86f7-992500667046_295x495.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:495,&quot;width&quot;:295,&quot;resizeWidth&quot;:163,&quot;bytes&quot;:16159,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!SreL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a479b8e-62df-4564-86f7-992500667046_295x495.png 424w, https://substackcdn.com/image/fetch/$s_!SreL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a479b8e-62df-4564-86f7-992500667046_295x495.png 848w, https://substackcdn.com/image/fetch/$s_!SreL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a479b8e-62df-4564-86f7-992500667046_295x495.png 1272w, https://substackcdn.com/image/fetch/$s_!SreL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a479b8e-62df-4564-86f7-992500667046_295x495.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></figure></div><p>Finally, we get to our output which we denote as f, and we can compute our derivative using a series of chain rules and substitutions:</p><h4>f = w + v</h4><h4>&#8706;f/&#8706;w = 1</h4><h4>&#8706;f/&#8706;v = 1</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Ojx2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F020ac1ab-dd86-4e90-8210-5dfa0ad56900_381x353.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Ojx2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F020ac1ab-dd86-4e90-8210-5dfa0ad56900_381x353.png 424w, https://substackcdn.com/image/fetch/$s_!Ojx2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F020ac1ab-dd86-4e90-8210-5dfa0ad56900_381x353.png 848w, https://substackcdn.com/image/fetch/$s_!Ojx2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F020ac1ab-dd86-4e90-8210-5dfa0ad56900_381x353.png 1272w, https://substackcdn.com/image/fetch/$s_!Ojx2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F020ac1ab-dd86-4e90-8210-5dfa0ad56900_381x353.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Ojx2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F020ac1ab-dd86-4e90-8210-5dfa0ad56900_381x353.png" width="277" height="256.6430446194226" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/020ac1ab-dd86-4e90-8210-5dfa0ad56900_381x353.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:353,&quot;width&quot;:381,&quot;resizeWidth&quot;:277,&quot;bytes&quot;:15717,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Ojx2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F020ac1ab-dd86-4e90-8210-5dfa0ad56900_381x353.png 424w, https://substackcdn.com/image/fetch/$s_!Ojx2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F020ac1ab-dd86-4e90-8210-5dfa0ad56900_381x353.png 848w, https://substackcdn.com/image/fetch/$s_!Ojx2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F020ac1ab-dd86-4e90-8210-5dfa0ad56900_381x353.png 1272w, https://substackcdn.com/image/fetch/$s_!Ojx2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F020ac1ab-dd86-4e90-8210-5dfa0ad56900_381x353.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></figure></div><p>The chain rule applied to f gives with respect to x and y gives:</p><h4>&#8706;f/&#8706;x</h4><h4>= &#8706;f/&#8706;w * &#8706;w/&#8706;x + &#8706;f/&#8706;v * &#8706;v/&#8706;x</h4><h4>= 1 * 2z + 1 * 0</h4><h4>= 2z</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tHSO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb587072-d0b1-4487-9c50-cd190789290d_613x401.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tHSO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb587072-d0b1-4487-9c50-cd190789290d_613x401.png 424w, https://substackcdn.com/image/fetch/$s_!tHSO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb587072-d0b1-4487-9c50-cd190789290d_613x401.png 848w, https://substackcdn.com/image/fetch/$s_!tHSO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb587072-d0b1-4487-9c50-cd190789290d_613x401.png 1272w, https://substackcdn.com/image/fetch/$s_!tHSO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb587072-d0b1-4487-9c50-cd190789290d_613x401.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tHSO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb587072-d0b1-4487-9c50-cd190789290d_613x401.png" width="423" height="276.7096247960848" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/db587072-d0b1-4487-9c50-cd190789290d_613x401.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:401,&quot;width&quot;:613,&quot;resizeWidth&quot;:423,&quot;bytes&quot;:29359,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tHSO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb587072-d0b1-4487-9c50-cd190789290d_613x401.png 424w, https://substackcdn.com/image/fetch/$s_!tHSO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb587072-d0b1-4487-9c50-cd190789290d_613x401.png 848w, https://substackcdn.com/image/fetch/$s_!tHSO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb587072-d0b1-4487-9c50-cd190789290d_613x401.png 1272w, https://substackcdn.com/image/fetch/$s_!tHSO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb587072-d0b1-4487-9c50-cd190789290d_613x401.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></figure></div><p>Since z = x + 2y, we substituted it in to get:</p><h4>2(x + 2y)</h4><h4>= 2x + 4y</h4><p></p><p>And so:</p><h4>&#8706;<strong>f/&#8706;x = 2x + 4y</strong></h4><p></p><p>Now, we compute the partial derivative of f with respect to y:</p><h4>&#8706;f/&#8706;y</h4><h4>= &#8706;f/&#8706;w * &#8706;w/&#8706;y + &#8706;f/&#8706;v * &#8706;v/&#8706;y</h4><h4>= 1 * 4z + 1 * cos(y)</h4><h4>= 4z + cos(y)</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ZT-W!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14d57bf9-2014-4215-bbba-e3b27057c87d_598x395.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZT-W!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14d57bf9-2014-4215-bbba-e3b27057c87d_598x395.png 424w, https://substackcdn.com/image/fetch/$s_!ZT-W!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14d57bf9-2014-4215-bbba-e3b27057c87d_598x395.png 848w, https://substackcdn.com/image/fetch/$s_!ZT-W!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14d57bf9-2014-4215-bbba-e3b27057c87d_598x395.png 1272w, https://substackcdn.com/image/fetch/$s_!ZT-W!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14d57bf9-2014-4215-bbba-e3b27057c87d_598x395.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZT-W!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14d57bf9-2014-4215-bbba-e3b27057c87d_598x395.png" width="430" height="284.03010033444815" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/14d57bf9-2014-4215-bbba-e3b27057c87d_598x395.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:395,&quot;width&quot;:598,&quot;resizeWidth&quot;:430,&quot;bytes&quot;:30022,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ZT-W!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14d57bf9-2014-4215-bbba-e3b27057c87d_598x395.png 424w, https://substackcdn.com/image/fetch/$s_!ZT-W!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14d57bf9-2014-4215-bbba-e3b27057c87d_598x395.png 848w, https://substackcdn.com/image/fetch/$s_!ZT-W!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14d57bf9-2014-4215-bbba-e3b27057c87d_598x395.png 1272w, https://substackcdn.com/image/fetch/$s_!ZT-W!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14d57bf9-2014-4215-bbba-e3b27057c87d_598x395.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></figure></div><p>Once again, since z = x + 2y, we simply substitute it in and obtain:</p><h4>4(x + 2y) + cos(y)</h4><h4>= 4x + 8y + cos(y)</h4><p></p><p>And so:</p><h4>&#8706;<strong>f/&#8706;y = 4x + 8y + cos(y)</strong></h4><p></p><p>Our final computational graph with a few of the key partial derivatives included is provided 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_!H9tH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5942fc58-e06f-48fd-8dec-c9c5fbf4578a_830x857.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!H9tH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5942fc58-e06f-48fd-8dec-c9c5fbf4578a_830x857.png 424w, https://substackcdn.com/image/fetch/$s_!H9tH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5942fc58-e06f-48fd-8dec-c9c5fbf4578a_830x857.png 848w, https://substackcdn.com/image/fetch/$s_!H9tH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5942fc58-e06f-48fd-8dec-c9c5fbf4578a_830x857.png 1272w, https://substackcdn.com/image/fetch/$s_!H9tH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5942fc58-e06f-48fd-8dec-c9c5fbf4578a_830x857.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!H9tH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5942fc58-e06f-48fd-8dec-c9c5fbf4578a_830x857.png" width="540" height="557.566265060241" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5942fc58-e06f-48fd-8dec-c9c5fbf4578a_830x857.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:857,&quot;width&quot;:830,&quot;resizeWidth&quot;:540,&quot;bytes&quot;:63981,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!H9tH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5942fc58-e06f-48fd-8dec-c9c5fbf4578a_830x857.png 424w, https://substackcdn.com/image/fetch/$s_!H9tH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5942fc58-e06f-48fd-8dec-c9c5fbf4578a_830x857.png 848w, https://substackcdn.com/image/fetch/$s_!H9tH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5942fc58-e06f-48fd-8dec-c9c5fbf4578a_830x857.png 1272w, https://substackcdn.com/image/fetch/$s_!H9tH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5942fc58-e06f-48fd-8dec-c9c5fbf4578a_830x857.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></figure></div><p>We should be able to easily verify that the above products match the actual derivative calculations (which are provided below to ensure that our results are correct):</p><h4>f(x, y)</h4><h4>= (x+2y)<sup>2</sup> + sin(y)</h4><h4>= x<sup>2</sup> + 4xy + 4y<sup>2</sup> + sin(y)</h4><p></p><h4>&#8706;f/&#8706;x = 2x + 4y</h4><h4>&#8706;f/&#8706;y = 4x + 8y + cos(y)</h4><p></p><p>And indeed, our forward accumulation results match the results we obtain from manually calculating the derivatives!</p><h3><strong>Reverse Mode Accumulation</strong></h3><p>Reverse mode accumulation calculates derivatives from the output to the input, propagating gradients back through the nodes. This accumulation method is often preferred over forward accumulation when gradients are needed, although care must be taken on memory constrained systems when the computational graph is very large.</p><p>Let&#8217;s once again go through our example to illustrate how reverse mode accumulation could be used to compute the derivatives for our graph. The calculations for this method are very similar to our earlier example, although this time we compute the partial derivatives of our intermediate variables starting from the output node back to our inputs.</p><p>To start off, we know that f = w + v, so we compute the partial derivatives for these variables first:</p><h4>f = w + v</h4><h4>&#8706;f/&#8706;w = 1</h4><h4>&#8706;f/&#8706;v = 1</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rYtZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F590172ec-85de-4bb6-bd94-f5a30390da3c_579x389.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rYtZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F590172ec-85de-4bb6-bd94-f5a30390da3c_579x389.png 424w, https://substackcdn.com/image/fetch/$s_!rYtZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F590172ec-85de-4bb6-bd94-f5a30390da3c_579x389.png 848w, https://substackcdn.com/image/fetch/$s_!rYtZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F590172ec-85de-4bb6-bd94-f5a30390da3c_579x389.png 1272w, https://substackcdn.com/image/fetch/$s_!rYtZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F590172ec-85de-4bb6-bd94-f5a30390da3c_579x389.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rYtZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F590172ec-85de-4bb6-bd94-f5a30390da3c_579x389.png" width="395" height="265.37996545768567" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/590172ec-85de-4bb6-bd94-f5a30390da3c_579x389.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:389,&quot;width&quot;:579,&quot;resizeWidth&quot;:395,&quot;bytes&quot;:25586,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!rYtZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F590172ec-85de-4bb6-bd94-f5a30390da3c_579x389.png 424w, https://substackcdn.com/image/fetch/$s_!rYtZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F590172ec-85de-4bb6-bd94-f5a30390da3c_579x389.png 848w, https://substackcdn.com/image/fetch/$s_!rYtZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F590172ec-85de-4bb6-bd94-f5a30390da3c_579x389.png 1272w, https://substackcdn.com/image/fetch/$s_!rYtZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F590172ec-85de-4bb6-bd94-f5a30390da3c_579x389.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></figure></div><p>Next, we compute the partials for w and v (since these are the next input nodes flowing backward into our graph).</p><p>Let&#8217;s start off with w:</p><h4>w = z<sup>2</sup> and so:</h4><h4>&#8706;w/&#8706;z = 2z</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!X0yI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbc0d282-7d6e-4f3e-872a-89946ffa2d05_385x465.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!X0yI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbc0d282-7d6e-4f3e-872a-89946ffa2d05_385x465.png 424w, https://substackcdn.com/image/fetch/$s_!X0yI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbc0d282-7d6e-4f3e-872a-89946ffa2d05_385x465.png 848w, https://substackcdn.com/image/fetch/$s_!X0yI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbc0d282-7d6e-4f3e-872a-89946ffa2d05_385x465.png 1272w, https://substackcdn.com/image/fetch/$s_!X0yI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbc0d282-7d6e-4f3e-872a-89946ffa2d05_385x465.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!X0yI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbc0d282-7d6e-4f3e-872a-89946ffa2d05_385x465.png" width="261" height="315.23376623376623" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dbc0d282-7d6e-4f3e-872a-89946ffa2d05_385x465.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:465,&quot;width&quot;:385,&quot;resizeWidth&quot;:261,&quot;bytes&quot;:19237,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!X0yI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbc0d282-7d6e-4f3e-872a-89946ffa2d05_385x465.png 424w, https://substackcdn.com/image/fetch/$s_!X0yI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbc0d282-7d6e-4f3e-872a-89946ffa2d05_385x465.png 848w, https://substackcdn.com/image/fetch/$s_!X0yI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbc0d282-7d6e-4f3e-872a-89946ffa2d05_385x465.png 1272w, https://substackcdn.com/image/fetch/$s_!X0yI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbc0d282-7d6e-4f3e-872a-89946ffa2d05_385x465.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></figure></div><p>Using the chain rule:</p><h4>&#8706;f/&#8706;z</h4><h4>= &#8706;f/&#8706;w * &#8706;w/&#8706;z</h4><h4>= 1 * 2z</h4><h4>= 2z</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ArE0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee591ca4-a43b-48de-a136-65d23ee4d711_385x351.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ArE0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee591ca4-a43b-48de-a136-65d23ee4d711_385x351.png 424w, https://substackcdn.com/image/fetch/$s_!ArE0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee591ca4-a43b-48de-a136-65d23ee4d711_385x351.png 848w, https://substackcdn.com/image/fetch/$s_!ArE0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee591ca4-a43b-48de-a136-65d23ee4d711_385x351.png 1272w, https://substackcdn.com/image/fetch/$s_!ArE0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee591ca4-a43b-48de-a136-65d23ee4d711_385x351.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ArE0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee591ca4-a43b-48de-a136-65d23ee4d711_385x351.png" width="269" height="245.24415584415584" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ee591ca4-a43b-48de-a136-65d23ee4d711_385x351.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:351,&quot;width&quot;:385,&quot;resizeWidth&quot;:269,&quot;bytes&quot;:17805,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ArE0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee591ca4-a43b-48de-a136-65d23ee4d711_385x351.png 424w, https://substackcdn.com/image/fetch/$s_!ArE0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee591ca4-a43b-48de-a136-65d23ee4d711_385x351.png 848w, https://substackcdn.com/image/fetch/$s_!ArE0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee591ca4-a43b-48de-a136-65d23ee4d711_385x351.png 1272w, https://substackcdn.com/image/fetch/$s_!ArE0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee591ca4-a43b-48de-a136-65d23ee4d711_385x351.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></figure></div><p>Next, we compute the partials for variable v:</p><h4>v = sin(y)</h4><h4>&#8706;v/&#8706;y = cos(y)</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Vqko!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477344cd-5acf-4e5c-aea4-699955982b44_341x562.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Vqko!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477344cd-5acf-4e5c-aea4-699955982b44_341x562.png 424w, https://substackcdn.com/image/fetch/$s_!Vqko!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477344cd-5acf-4e5c-aea4-699955982b44_341x562.png 848w, https://substackcdn.com/image/fetch/$s_!Vqko!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477344cd-5acf-4e5c-aea4-699955982b44_341x562.png 1272w, https://substackcdn.com/image/fetch/$s_!Vqko!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477344cd-5acf-4e5c-aea4-699955982b44_341x562.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Vqko!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477344cd-5acf-4e5c-aea4-699955982b44_341x562.png" width="217" height="357.6363636363636" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/477344cd-5acf-4e5c-aea4-699955982b44_341x562.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:562,&quot;width&quot;:341,&quot;resizeWidth&quot;:217,&quot;bytes&quot;:19861,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Vqko!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477344cd-5acf-4e5c-aea4-699955982b44_341x562.png 424w, https://substackcdn.com/image/fetch/$s_!Vqko!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477344cd-5acf-4e5c-aea4-699955982b44_341x562.png 848w, https://substackcdn.com/image/fetch/$s_!Vqko!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477344cd-5acf-4e5c-aea4-699955982b44_341x562.png 1272w, https://substackcdn.com/image/fetch/$s_!Vqko!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477344cd-5acf-4e5c-aea4-699955982b44_341x562.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></figure></div><p>We once again apply the chain rule:</p><h4>&#8706;f/&#8706;y</h4><h4>= &#8706;f/&#8706;v * &#8706;v/&#8706;y</h4><h4>= 1 * cos(y)</h4><h4>= cos(y)</h4><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!cZ_L!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee7e6b0e-ae8f-431c-af6b-2f6d6fb5dd0e_315x353.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cZ_L!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee7e6b0e-ae8f-431c-af6b-2f6d6fb5dd0e_315x353.png 424w, https://substackcdn.com/image/fetch/$s_!cZ_L!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee7e6b0e-ae8f-431c-af6b-2f6d6fb5dd0e_315x353.png 848w, https://substackcdn.com/image/fetch/$s_!cZ_L!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee7e6b0e-ae8f-431c-af6b-2f6d6fb5dd0e_315x353.png 1272w, https://substackcdn.com/image/fetch/$s_!cZ_L!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee7e6b0e-ae8f-431c-af6b-2f6d6fb5dd0e_315x353.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cZ_L!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee7e6b0e-ae8f-431c-af6b-2f6d6fb5dd0e_315x353.png" width="207" height="231.97142857142856" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ee7e6b0e-ae8f-431c-af6b-2f6d6fb5dd0e_315x353.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:353,&quot;width&quot;:315,&quot;resizeWidth&quot;:207,&quot;bytes&quot;:17041,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!cZ_L!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee7e6b0e-ae8f-431c-af6b-2f6d6fb5dd0e_315x353.png 424w, https://substackcdn.com/image/fetch/$s_!cZ_L!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee7e6b0e-ae8f-431c-af6b-2f6d6fb5dd0e_315x353.png 848w, https://substackcdn.com/image/fetch/$s_!cZ_L!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee7e6b0e-ae8f-431c-af6b-2f6d6fb5dd0e_315x353.png 1272w, https://substackcdn.com/image/fetch/$s_!cZ_L!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee7e6b0e-ae8f-431c-af6b-2f6d6fb5dd0e_315x353.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Finally, we have z = x + 2y so:</p><h4>&#8706;z/&#8706;x = 1</h4><h4>&#8706;z/&#8706;y = 2</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!k5gX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff284599f-31e1-40dd-86df-79274b2f73df_732x466.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!k5gX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff284599f-31e1-40dd-86df-79274b2f73df_732x466.png 424w, https://substackcdn.com/image/fetch/$s_!k5gX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff284599f-31e1-40dd-86df-79274b2f73df_732x466.png 848w, https://substackcdn.com/image/fetch/$s_!k5gX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff284599f-31e1-40dd-86df-79274b2f73df_732x466.png 1272w, https://substackcdn.com/image/fetch/$s_!k5gX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff284599f-31e1-40dd-86df-79274b2f73df_732x466.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!k5gX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff284599f-31e1-40dd-86df-79274b2f73df_732x466.png" width="447" height="284.5655737704918" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f284599f-31e1-40dd-86df-79274b2f73df_732x466.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:466,&quot;width&quot;:732,&quot;resizeWidth&quot;:447,&quot;bytes&quot;:33143,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!k5gX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff284599f-31e1-40dd-86df-79274b2f73df_732x466.png 424w, https://substackcdn.com/image/fetch/$s_!k5gX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff284599f-31e1-40dd-86df-79274b2f73df_732x466.png 848w, https://substackcdn.com/image/fetch/$s_!k5gX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff284599f-31e1-40dd-86df-79274b2f73df_732x466.png 1272w, https://substackcdn.com/image/fetch/$s_!k5gX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff284599f-31e1-40dd-86df-79274b2f73df_732x466.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></figure></div><p></p><p>Using the chain rule:</p><h4>&#8706;f/&#8706;x</h4><h4>= &#8706;f/&#8706;z * &#8706;z/&#8706;x</h4><h4>= 2z * 1</h4><h4>= 2z</h4><h4>= 2(x + 2y) (since z = x + 2y)</h4><h4>= 2x + 4y</h4><p></p><h4>&#8706;f/&#8706;y</h4><h4>= &#8706;f/&#8706;z * &#8706;z/&#8706;y + &#8706;f/&#8706;y</h4><h4>= 2z * 2 + cos(y)</h4><h4>= 4z + cos(y)</h4><h4>= 4(x + 2y) + cos(y) (since z = x + 2y)</h4><h4>= 4x + 8y + cos(y)</h4><p></p><p>The reverse accumulation method looks very similar to our forward accumulation method &#8211; once again, the only difference is that instead of computing the partial derivatives starting from our input nodes, this time we start from our output and work backwards. As you can tell from the example, the results we obtain should obviously match our prior values (and they do).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!S1uX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42f6a795-c963-4e70-8da0-081ce9aac934_840x843.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!S1uX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42f6a795-c963-4e70-8da0-081ce9aac934_840x843.png 424w, https://substackcdn.com/image/fetch/$s_!S1uX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42f6a795-c963-4e70-8da0-081ce9aac934_840x843.png 848w, https://substackcdn.com/image/fetch/$s_!S1uX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42f6a795-c963-4e70-8da0-081ce9aac934_840x843.png 1272w, https://substackcdn.com/image/fetch/$s_!S1uX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42f6a795-c963-4e70-8da0-081ce9aac934_840x843.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!S1uX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42f6a795-c963-4e70-8da0-081ce9aac934_840x843.png" width="498" height="499.7785714285714" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/42f6a795-c963-4e70-8da0-081ce9aac934_840x843.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:843,&quot;width&quot;:840,&quot;resizeWidth&quot;:498,&quot;bytes&quot;:63887,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!S1uX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42f6a795-c963-4e70-8da0-081ce9aac934_840x843.png 424w, https://substackcdn.com/image/fetch/$s_!S1uX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42f6a795-c963-4e70-8da0-081ce9aac934_840x843.png 848w, https://substackcdn.com/image/fetch/$s_!S1uX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42f6a795-c963-4e70-8da0-081ce9aac934_840x843.png 1272w, https://substackcdn.com/image/fetch/$s_!S1uX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42f6a795-c963-4e70-8da0-081ce9aac934_840x843.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></figure></div><h3>Summary</h3><p>This post is already long, so I&#8217;ll continue my overview of optimization algorithms in part 2. A summary of the key points which we over-viewed in part 1 is provided below:</p><ul><li><p>The <strong>derivative </strong>of a function f(x) tells us how the output of the function varies with an infinitely small change in the input.</p></li><li><p>The <strong>gradient </strong>is the generalization of the derivative mapped onto multivariate functions. As with the derivative, it captures the local slope of the function, allowing us to predict the effect of taking a small step from a point in any direction.</p></li><li><p>The <strong>Hessian </strong>is a matrix of second derivatives that tells us how a multi-variable function bends or curves in different directions around a point. This helps us identify if we're at a minimum, maximum, or saddle point.</p></li><li><p>Derivatives play a vital role in optimization due to the fact that they give us information relating to how to change our input changes the output. We use this in order to get closer to our objective (or optimum) which plays a vital role in optimization.</p></li><li><p>Often, derivatives are not known analytically and cannot be directly derived, so we are forced to either estimate them numerically or via automatic differentiation techniques. </p></li><li><p><strong>Some methodologies of estimating the derivative:</strong></p></li><li><p><strong>Finite Difference Method</strong>: this is a numerical method of differentiation where the derivative is approximated by computing how the function value changes with small changes to its input.</p></li><li><p><strong>The Complex Step Method</strong>:<strong> </strong>To avoid numerical cancellation issues, instead of taking function steps close to an input and computing multiple outputs for the function in question &#8211; we simply use an imaginary number (a 2-dimensional number built out of a real and imaginary component) and use the real number component as our input while we use the imaginary component as our &#8216;step.&#8217;</p></li><li><p><strong>Automatic Differentiation</strong>:<strong> </strong>This is a method to compute derivatives automatically and accurately by using a special structure called a computational graph. There are 2 ways of performing automatic differentiation. The forward accumulation starts from the input variables and moves forward through the computational graph to the output, while the reverse accumulation method goes in the opposite direction (from output to input).</p></li></ul><p>Thank you for reading, and if you liked this post, don&#8217;t forget to like and subscribe.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Michel Talagrand: Advice to Young Mathematicians]]></title><description><![CDATA[Fantastic advice by an Abel prize winner to young mathematicians.]]></description><link>https://photonlines.substack.com/p/michel-talagrand-advice-to-young</link><guid isPermaLink="false">https://photonlines.substack.com/p/michel-talagrand-advice-to-young</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Tue, 09 Jul 2024 12:03:03 GMT</pubDate><enclosure url="https://substackcdn.com/image/youtube/w_728,c_limit/B8RkQq-1_ZU" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I recently watched a very inspiring video containing advice by a world-renowned mathematician Michel Talagrand which I decided to share and which I hope inspires others:</p><div id="youtube2-B8RkQq-1_ZU" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;B8RkQq-1_ZU&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/B8RkQq-1_ZU?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><p>Talagrand studied functional analysis, then probability and its applications until he retired in 2017. He received the prestigious Abel prize in 2024. The key to his success was his ability to connect geometric ideas to various abstract and probabilistic notions. I won&#8217;t waste too much time writing about his work &#8211; instead I&#8217;ll link an outstanding article which already provides an excellent overview of his life and work:</p><p><a href="https://www.quantamagazine.org/michel-talagrand-wins-abel-prize-for-work-wrangling-randomness-20240320/">Michel Talagrand Wins Abel Prize for Work Wrangling Randomness</a></p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Photon-Lines Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p><h3>Some Key Quotes on Talagrand:</h3><p></p><blockquote><p>Talagrand&#8217;s mathematical style is atypical. He does not mind studying small problems as stepping stones to further significant discoveries. He has himself written of his method that: &#8220;it helps to be humble and to start by understanding fully the simple situations. When working on a conjecture I also found it helpful to alternatively try to prove it and try to disprove it. The progress comes by jumps, much like matching two pieces of a puzzle. This is nearly instantaneous. Now you see it, and the moment before you did not. After such progress, you may have a much clearer vision of the problem.&#8221; - <em><a href="https://abelprize.no/biography/michel-talagrand-brief-biography">Michel Talagrand: A brief biography</a></em></p></blockquote><p></p><blockquote><p>&#8220;I&#8217;m not able to learn mathematics easily. I have to work. It takes a very long time and I have a terrible memory. I forget things. So I try to work, despite handicaps, and the way I worked was trying to understand really well the simple things. Really, really well, in complete detail. And that turned out to be a successful approach.&#8221; - <em><a href="https://www.newscientist.com/article/2423669-why-2024-abel-prize-winner-michel-talagrand-became-a-mathematician/">Why 2024 Abel prize winner Michel Talagrand became a mathematician</a></em></p></blockquote><p></p><blockquote><p>&#8220;I like to understand simple things very well, because my brain is very slow,&#8221; Talagrand said. &#8220;So I think about them for a very, very long time.&#8221; He&#8217;s driven, he said, by the desire to &#8220;understand something deeply, in a pure way, which makes the theory much easier. Then the next generation can start from there and make progress on their own terms.&#8221; - <em><a href="https://www.quantamagazine.org/michel-talagrand-wins-abel-prize-for-work-wrangling-randomness-20240320/">Michel Talagrand Wins Abel Prize for Work Wrangling Randomness</a></em></p></blockquote><p></p><p>And last but not least &#8211; a key highlight from his speech:</p><blockquote><p>&#8220;Of course, I would like to encourage you to keep doing mathematics. I think being a mathematician is the nicest job on Earth. That's why I did it &#8230; and&#8230;but the bad news is nothing comes for free ever and you have to really commit yourself entirely if you want to succeed unless you are somebody like Abel, happens every once every hundred years. But for one I understand, Abel &#8230; even Abel worked very hard at what he was doing. So there is no magic and if you are not Abel, you have to work even harder and also you have to be persistent. Things don't come so easily.</p><p>When I started doing mathematics, so I was a student, I didn't know anything at all and I arrived in a seminar where people have been doing this kind of stuff for years and I see there and I have no idea what they talk about and this lasted maybe something like a year. And there is no easy solution because I say, okay, give me papers that I can read. And then I look at the paper and the introduction, they mention ten other papers of which I have no idea. So it's sort of difficult to start. So you have to focus on something special and then you understand it and then you feel more comfortable and then you expand your knowledge. <strong>The important thing is don't get discouraged at the beginning.</strong> That's a part where you are the more fragile. Once you are started having achieved something somewhere, however small it gives you courage and energy.&#8221;</p></blockquote><p>A great message and story by a fantastic mathematician.</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Photon-Lines Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[An Intuitive Guide to Maxwell’s Equations]]></title><description><![CDATA[An Intuitive and Visual Guide to Maxwell's Equations]]></description><link>https://photonlines.substack.com/p/an-intuitive-guide-to-maxwells-equations</link><guid isPermaLink="false">https://photonlines.substack.com/p/an-intuitive-guide-to-maxwells-equations</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Sat, 01 Jun 2024 16:09:34 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!3Nut!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd115738-c63e-4190-890b-746375a6365c_2537x1374.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Introduction</h2><p>In 1865, James Clerk Maxwell published one of the most important papers ever produced. The paper was published in the Philosophical Transactions of the Royal Society and was called: &#8220;A dynamical theory of the electromagnetic field.&#8221; The paper might have been the most significant occurrence in the history of physical sciences, as it described the evolution of the electromagnetic field.</p><p>Why was such a description so important? Well, for one, we live in an electromagnetic world. Virtually every force we experience in everyday life (with the exception of gravity) is electromagnetic in origin. It was from Maxwell's equations that electromagnetic waves were predicted to exist. From this mathematical formulation, Maxwell determined that the speed of propagation of electromagnetic (EM) waves was the same as the speed of light, and thus showed that EM waves and visible light were really the same thing. Using the equations, we could mathematically construct and deduce the behavior of light and other electromagnetic radiation!</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Photon-Lines Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>The importance of Maxwell&#8217;s work wasn&#8217;t obvious immediately though. For more than 20 years, his work was largely ignored by the scientific community. Why?</p><p>Well &#8230; physicists and mathematicians had a hard time understanding it. The equations in their original format amounted to 20 equations, not the 4 elegant ones we have familiarity with today. Not only that, but they were incredibly complicated and difficult to grasp. Most physicists at the time were not equipped to deal with algebraic complexity of that extent. On the other hand, mathematicians also could not grasp what they meant; Maxwell used physical language to explain them, so it was not accessible to the mathematical community at large.</p><p>These weren&#8217;t the only reasons that the theory didn&#8217;t catch on. The predominant world view at the time relied on mechanics and the universe was seen as being moved by &#8216;wheels and gears&#8217; beneath the fields which Maxwell&#8217;s theory relied on.</p><p>What exactly are fields?</p><p>Well, fields can be thought of as a function acting throughout space and time. The predominant thinking at the time tried to account for such fields through mechanical structures composed of &#8216;wheels&#8217; and &#8216;vortices&#8217; which carried the mechanical stresses that the these fields propagated. Of course, such thinking made it difficult to grasp the beauty and meaning of the equations. Maxwell&#8217;s theory only becomes simple and elegant once we start to think of the fields (mathematical functions) as being primary and the electromagnetic stresses and mechanical forces as being a consequence of such fields, and not vice-versa.</p><p>The idea that such fields were the primary constituents of the universe did not come easily to Maxwell&#8217;s contemporaries. Fields were an abstract concept: mathematical objects which had no physical analogue. His equations were partial differential equations which weren&#8217;t accessible to simple interpretation. It wasn&#8217;t until the arrival of Oliver Heaviside, who reformulated and simplified the equations, as well as the next generation of physicists (Hertz, Lorentz, and Einstein) that the revelation came through: the universe was not built using the laws of mechanics. It was built through the laws of mathematics and the field equations.</p><p>The goal of this guide is to give an intuitive concept of what Maxwell&#8217;s equations represent, as well as capture the beauty of the physical concepts they embody.</p><blockquote><p>&#8220;<em>To see the beauty of the Maxwell theory it is necessary to move away from mechanical models and into the abstract world of fields. To see the beauty of quantum mechanics it is necessary to move away from verbal descriptions and into the abstract world of geometry. Mathematics is the language that nature speaks. The language of mathematics makes the world of Maxwell fields and the world of quantum processes equally transparent.&#8221; </em></p><p><em>- </em>Freeman Dyson</p></blockquote><h2>Fields</h2><h3><strong>What is a field?</strong></h3><p>A field can be thought of as a function working across space / time.</p><p>It&#8217;s important to note that the concept of a field cannot be broken down into something which has a material or mechanical analogy. Sometimes, physicists think of a field as the aggregate effect of exchange or virtual particles which are governed by a quantum field theory, or the effect of the curvature of space time, but it&#8217;s important to note that these exchange particles and geometries themselves can also be thought of as mathematical abstractions. We can try to think of a field as some sort of substance, but in reality, there is no substance and there&#8217;s no everyday intuition we can use to grasp them other than the basic intuition of having a mathematical function spread out throughout space and time. In other words: the mathematics are the interface, and they define exactly what we can expect from a field. How this interface is implemented is not defined and it&#8217;s not something that human beings have been able to figure out.</p><p>It&#8217;s easy to get hung up on the notion or question of asking &#8216;is a field real or not?&#8217; We humans grow up in a world with objects. Our brains are used to breaking down the world into divisible parts and constructing it based on the notion of having &#8216;things&#8217; which can be inspected by the senses and which are denoted by nouns. These &#8216;things&#8217; furthermore have mass and volume, and they have discrete boundaries.</p><p>The Greeks were the originators of this conception. They imagined that &#8216;things&#8217; were built out of smaller things, like atoms and molecules. When the atomic theory came about, they expected the atoms themselves to have some sort of mass, shape and size, and to be a microcosm of more things. Let&#8217;s take sand as an example. To the careless eye, sand seems like a fluid, since quantities of it appear to freely merge and split, but on closer inspection, it&#8217;s just a bunch of tiny objects which can be described as individual &#8216;things&#8217; interacting with each other.</p><p>The world of quantum mechanics and quantum field theory introduce a different conception of what things are though. It turns out that elementary particles can&#8217;t be thought of as individual &#8216;things&#8217; which have a volume. In fact, if particles did have a volume, physics wouldn&#8217;t work! We would end up with "surfaces" of electrons behaving in an impossible manner and spinning faster than the speed of light.</p><p>Well then, you say, what if particles aren&#8217;t objects with a volume, but points in space?</p><p>It turns out that this notion isn&#8217;t easily prone to interpretation either! No one actually knows or understands what a &#8216;point mass&#8217; is! It also has a bizarre implication: if indeed we did have volume-less point masses, we obtain something with an infinite density! In theory, the entire universe could be squeezed to a single point!</p><p>So how can we deal with this? Well, it turns out that all the properties that you associate with &#8216;stuff&#8217; are actually explainable in terms of electromagnetic fields and masses (which general relativity describes as a component of a tensor field). It turns out that the &#8216;object oriented&#8217; definition of the universe can be better understood in terms of continuous fields governed by mathematics rather than individual objects or atoms with individual properties.</p><h3><strong>Types of Fields</strong></h3><p>There are 2 primary types of fields which we&#8217;ll discuss: scalar fields and vector fields. The reality is that we could also encounter other types of fields (such as tensor or spinor fields), but we&#8217;ll leave these out of the discussion for now to focus on the ones we&#8217;ll need to understand in order to get familiar with Maxwell&#8217;s equations.</p><p>So, what is a scalar/vector field?</p><p>Well, a scalar field takes a point in space as input and outputs a single numeric value, while a vector field outputs a vector with a magnitude and direction.</p><p>Below, we&#8217;ll show a few examples of fields and illustrate what they mean.</p><h4><strong>Temperature</strong></h4><p>Let&#8217;s imagine that we&#8217;re climbing a mountain. As you climb, you notice that the higher you climb, the colder the air gets. We also notice the general heuristic property: the air gets colder at a typical rate of about 3 or 4 degrees Celsius for every kilometer that we climb.</p><p>Now, let&#8217;s pretend that we&#8217;re observing a large terrain map and we want to ask: what&#8217;s the temperature of air at point (x, y, z)?</p><p>We can do something very difficult and attempt to create a table which maps every point in space (over the terrain) to a definite temperature, or, we can do the simple thing: we define a function which transforms each point (input) to a definite scalar output which gives us a temperature according to our heuristic rules. We&#8217;ll denote this function as T(x,y,z), and we say that our function takes an input from a 3-dimensional real space R<sup>3</sup> (the x, y, and z coordinates) and outputs values in a 1-dimensional R space (the temperature).</p><p>That&#8217;s it! We described a very simple <strong>scalar field</strong>!</p><h4><strong>Temperature (and Heat)</strong></h4><p>To get a better grasp of scalar fields, or the functions which describe them, we now describe the heat equation which actually models heat flow (a vector field) using a partial differential equation, but we won&#8217;t focus on the actual flow of heat here. Instead, we&#8217;ll focus on the changing temperature field to keep things simple.</p><p>Now, going back to partial differential equations: what are they? Well, they play a vital role in physics, especially when attempting to model problems which have an extraordinary amount of complexity. In mathematical terms: we call changing entities variables, and the rate of change of one variable with respect to another is called a derivative. Equations which express relationships between variables and their derivatives are called differential equations. Solving them involves showing how the variables within the equation are related without needing the derivatives themselves. These equations can have many solutions, and the solution of interest may often be determined by its boundary conditions, which can usually be found through the data and conditions which describe our system.</p><p>We don&#8217;t have time to discuss how to obtain the solutions to differential equations at this moment. Lots of great books and resources are already available online! Here, we simply want to gain an intuitive picture of how to read them, so that we&#8217;re familiar with how they can be used to model fields.</p><p>Let&#8217;s assume that we have a metal plate, and that we know how the temperature is distributed along every point on this 2-D plate:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3Nut!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd115738-c63e-4190-890b-746375a6365c_2537x1374.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3Nut!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd115738-c63e-4190-890b-746375a6365c_2537x1374.png 424w, https://substackcdn.com/image/fetch/$s_!3Nut!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd115738-c63e-4190-890b-746375a6365c_2537x1374.png 848w, https://substackcdn.com/image/fetch/$s_!3Nut!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd115738-c63e-4190-890b-746375a6365c_2537x1374.png 1272w, https://substackcdn.com/image/fetch/$s_!3Nut!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd115738-c63e-4190-890b-746375a6365c_2537x1374.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3Nut!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd115738-c63e-4190-890b-746375a6365c_2537x1374.png" width="1456" height="789" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bd115738-c63e-4190-890b-746375a6365c_2537x1374.png&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;:726223,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3Nut!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd115738-c63e-4190-890b-746375a6365c_2537x1374.png 424w, https://substackcdn.com/image/fetch/$s_!3Nut!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd115738-c63e-4190-890b-746375a6365c_2537x1374.png 848w, https://substackcdn.com/image/fetch/$s_!3Nut!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd115738-c63e-4190-890b-746375a6365c_2537x1374.png 1272w, https://substackcdn.com/image/fetch/$s_!3Nut!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd115738-c63e-4190-890b-746375a6365c_2537x1374.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></figure></div><p>In the example above, we can see that for each positional coordinate (x, y) on our metal sheet, we have a simple mapping to a temperature. Now, let&#8217;s assume that instead of modeling the &#8216;snapshot&#8217; of the temperature at each point on our metal sheet, we want to model the <strong>evolution</strong> of the temperature (and thus, the heat flow) throughout time. To do this, we add an additional dimension (t for time) to try to model how our scalar temperature field changes throughout the metal sheet after time t. This is essentially what the heat equation does!</p><p>The heat equation is provided 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_!JKmj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa044a70-f3e0-4a60-a076-be2bc2827c16_2051x1379.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JKmj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa044a70-f3e0-4a60-a076-be2bc2827c16_2051x1379.png 424w, https://substackcdn.com/image/fetch/$s_!JKmj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa044a70-f3e0-4a60-a076-be2bc2827c16_2051x1379.png 848w, https://substackcdn.com/image/fetch/$s_!JKmj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa044a70-f3e0-4a60-a076-be2bc2827c16_2051x1379.png 1272w, https://substackcdn.com/image/fetch/$s_!JKmj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa044a70-f3e0-4a60-a076-be2bc2827c16_2051x1379.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JKmj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa044a70-f3e0-4a60-a076-be2bc2827c16_2051x1379.png" width="725" height="487.4828296703297" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fa044a70-f3e0-4a60-a076-be2bc2827c16_2051x1379.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:979,&quot;width&quot;:1456,&quot;resizeWidth&quot;:725,&quot;bytes&quot;:359358,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!JKmj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa044a70-f3e0-4a60-a076-be2bc2827c16_2051x1379.png 424w, https://substackcdn.com/image/fetch/$s_!JKmj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa044a70-f3e0-4a60-a076-be2bc2827c16_2051x1379.png 848w, https://substackcdn.com/image/fetch/$s_!JKmj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa044a70-f3e0-4a60-a076-be2bc2827c16_2051x1379.png 1272w, https://substackcdn.com/image/fetch/$s_!JKmj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa044a70-f3e0-4a60-a076-be2bc2827c16_2051x1379.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></figure></div><p>Once again: we note that instead of ascribing how our system evolves at each position (x, y) and at each point in time (t), we introduce a partial differential equation to model our system &#8216;heuristically.&#8217; Instead of using a table which provides the mapping for each point in space-time (x, y, t), we simplify this by introducing a field equation which models the system in terms of <strong>how it changes</strong> from one moment to the next. We then use this information to come up with a solution which allows us to accurately model our heat / temperature flow!</p><p>Now, let&#8217;s simplify our example even more. Let&#8217;s take a very small slice of our metal plate and pretend that we only have a simple x dimension which we want to model and which represents the temperature value at a position along our plate:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Jehw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87aafa6c-7598-4f3b-a288-6b4ae8821a1b_1424x585.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Jehw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87aafa6c-7598-4f3b-a288-6b4ae8821a1b_1424x585.png 424w, https://substackcdn.com/image/fetch/$s_!Jehw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87aafa6c-7598-4f3b-a288-6b4ae8821a1b_1424x585.png 848w, https://substackcdn.com/image/fetch/$s_!Jehw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87aafa6c-7598-4f3b-a288-6b4ae8821a1b_1424x585.png 1272w, https://substackcdn.com/image/fetch/$s_!Jehw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87aafa6c-7598-4f3b-a288-6b4ae8821a1b_1424x585.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Jehw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87aafa6c-7598-4f3b-a288-6b4ae8821a1b_1424x585.png" width="581" height="238.68328651685394" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/87aafa6c-7598-4f3b-a288-6b4ae8821a1b_1424x585.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:585,&quot;width&quot;:1424,&quot;resizeWidth&quot;:581,&quot;bytes&quot;:153091,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Jehw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87aafa6c-7598-4f3b-a288-6b4ae8821a1b_1424x585.png 424w, https://substackcdn.com/image/fetch/$s_!Jehw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87aafa6c-7598-4f3b-a288-6b4ae8821a1b_1424x585.png 848w, https://substackcdn.com/image/fetch/$s_!Jehw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87aafa6c-7598-4f3b-a288-6b4ae8821a1b_1424x585.png 1272w, https://substackcdn.com/image/fetch/$s_!Jehw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87aafa6c-7598-4f3b-a288-6b4ae8821a1b_1424x585.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Let&#8217;s also assume that we also have a function denoted by T(x) which maps the temperature at each point x to a temperature t, and the output of that function can be visualized below:</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!uCPu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F968edd96-c8da-45b0-92df-c6d1d7e5d3fb_2633x1432.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!uCPu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F968edd96-c8da-45b0-92df-c6d1d7e5d3fb_2633x1432.png 424w, https://substackcdn.com/image/fetch/$s_!uCPu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F968edd96-c8da-45b0-92df-c6d1d7e5d3fb_2633x1432.png 848w, https://substackcdn.com/image/fetch/$s_!uCPu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F968edd96-c8da-45b0-92df-c6d1d7e5d3fb_2633x1432.png 1272w, https://substackcdn.com/image/fetch/$s_!uCPu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F968edd96-c8da-45b0-92df-c6d1d7e5d3fb_2633x1432.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!uCPu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F968edd96-c8da-45b0-92df-c6d1d7e5d3fb_2633x1432.png" width="1456" height="792" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/968edd96-c8da-45b0-92df-c6d1d7e5d3fb_2633x1432.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:792,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:295515,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!uCPu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F968edd96-c8da-45b0-92df-c6d1d7e5d3fb_2633x1432.png 424w, https://substackcdn.com/image/fetch/$s_!uCPu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F968edd96-c8da-45b0-92df-c6d1d7e5d3fb_2633x1432.png 848w, https://substackcdn.com/image/fetch/$s_!uCPu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F968edd96-c8da-45b0-92df-c6d1d7e5d3fb_2633x1432.png 1272w, https://substackcdn.com/image/fetch/$s_!uCPu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F968edd96-c8da-45b0-92df-c6d1d7e5d3fb_2633x1432.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></figure></div><p>In the example above, we can see that the temperature along our cut out strip at point x = 6.283 is equal to around 55 degrees. We should be able to see that from this function, we can obtain a simple scalar field mapping each x point in space to a scalar field/value (the temperature).</p><p>Now, let&#8217;s add an additional component/dimension and attempt to model how the temperature in our metal slice is dispersed with time. What happens when we map the above function to our new system?</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!l1Jp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff6d600f-4a1d-4477-b355-45dfee2bb215_1629x923.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!l1Jp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff6d600f-4a1d-4477-b355-45dfee2bb215_1629x923.png 424w, https://substackcdn.com/image/fetch/$s_!l1Jp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff6d600f-4a1d-4477-b355-45dfee2bb215_1629x923.png 848w, https://substackcdn.com/image/fetch/$s_!l1Jp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff6d600f-4a1d-4477-b355-45dfee2bb215_1629x923.png 1272w, https://substackcdn.com/image/fetch/$s_!l1Jp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff6d600f-4a1d-4477-b355-45dfee2bb215_1629x923.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!l1Jp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff6d600f-4a1d-4477-b355-45dfee2bb215_1629x923.png" width="1456" height="825" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ff6d600f-4a1d-4477-b355-45dfee2bb215_1629x923.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:825,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:524952,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!l1Jp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff6d600f-4a1d-4477-b355-45dfee2bb215_1629x923.png 424w, https://substackcdn.com/image/fetch/$s_!l1Jp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff6d600f-4a1d-4477-b355-45dfee2bb215_1629x923.png 848w, https://substackcdn.com/image/fetch/$s_!l1Jp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff6d600f-4a1d-4477-b355-45dfee2bb215_1629x923.png 1272w, https://substackcdn.com/image/fetch/$s_!l1Jp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff6d600f-4a1d-4477-b355-45dfee2bb215_1629x923.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></figure></div><p></p><p>Indeed, looking at the above, we can see that we obtain a function which &#8216;evolves&#8217; in time! As we move across our time dimension, our function &#8216;smooths&#8217; out so that our temperature is distributed evenly across our x-space. This is what the heat equation describes! In simple terms, our graph above shows how the heat flows and how the temperature changes with time!</p><p>We also note that the nature of our new field equation makes things more difficult to model than what we saw in our earlier temperature example. The reason for this is due to the fact that we&#8217;re not only using the positional coordinates to model the field, but also a time coordinate as well! This is what makes our differential equation above a <strong>partial </strong>differential equation rather than an ordinary one!</p><p>That is, in addition to taking the differential of our temperature in regards to our positional (x) component, represented as dT/dx and shown below:</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!yBz7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd04bbcc-1a41-49bf-9724-fc6516e3c6dc_1652x910.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!yBz7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd04bbcc-1a41-49bf-9724-fc6516e3c6dc_1652x910.png 424w, https://substackcdn.com/image/fetch/$s_!yBz7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd04bbcc-1a41-49bf-9724-fc6516e3c6dc_1652x910.png 848w, https://substackcdn.com/image/fetch/$s_!yBz7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd04bbcc-1a41-49bf-9724-fc6516e3c6dc_1652x910.png 1272w, https://substackcdn.com/image/fetch/$s_!yBz7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd04bbcc-1a41-49bf-9724-fc6516e3c6dc_1652x910.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!yBz7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd04bbcc-1a41-49bf-9724-fc6516e3c6dc_1652x910.png" width="1456" height="802" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dd04bbcc-1a41-49bf-9724-fc6516e3c6dc_1652x910.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:802,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:407322,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!yBz7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd04bbcc-1a41-49bf-9724-fc6516e3c6dc_1652x910.png 424w, https://substackcdn.com/image/fetch/$s_!yBz7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd04bbcc-1a41-49bf-9724-fc6516e3c6dc_1652x910.png 848w, https://substackcdn.com/image/fetch/$s_!yBz7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd04bbcc-1a41-49bf-9724-fc6516e3c6dc_1652x910.png 1272w, https://substackcdn.com/image/fetch/$s_!yBz7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd04bbcc-1a41-49bf-9724-fc6516e3c6dc_1652x910.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></figure></div><p></p><p>we&#8217;re also modeling how our temperature evolves with <strong>time</strong> (represented as dT/dt):</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Uu9y!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81e72366-7660-4344-8cf6-e3ed68be5fed_1115x937.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Uu9y!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81e72366-7660-4344-8cf6-e3ed68be5fed_1115x937.png 424w, https://substackcdn.com/image/fetch/$s_!Uu9y!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81e72366-7660-4344-8cf6-e3ed68be5fed_1115x937.png 848w, https://substackcdn.com/image/fetch/$s_!Uu9y!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81e72366-7660-4344-8cf6-e3ed68be5fed_1115x937.png 1272w, https://substackcdn.com/image/fetch/$s_!Uu9y!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81e72366-7660-4344-8cf6-e3ed68be5fed_1115x937.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Uu9y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81e72366-7660-4344-8cf6-e3ed68be5fed_1115x937.png" width="1115" height="937" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/81e72366-7660-4344-8cf6-e3ed68be5fed_1115x937.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:937,&quot;width&quot;:1115,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:435815,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Uu9y!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81e72366-7660-4344-8cf6-e3ed68be5fed_1115x937.png 424w, https://substackcdn.com/image/fetch/$s_!Uu9y!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81e72366-7660-4344-8cf6-e3ed68be5fed_1115x937.png 848w, https://substackcdn.com/image/fetch/$s_!Uu9y!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81e72366-7660-4344-8cf6-e3ed68be5fed_1115x937.png 1272w, https://substackcdn.com/image/fetch/$s_!Uu9y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81e72366-7660-4344-8cf6-e3ed68be5fed_1115x937.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></figure></div><p></p><p>Because each one of our 2 above derivatives only tells us a <strong>partial</strong> story of how our function (or field) changes, we call them partial derivatives and we thus end up with a partial differential equation for our scalar temperature field!</p><p>Note also: we simplified our example to ignore the temperature field values present in our y dimension! Here, we&#8217;re showing a simplification of what would happen if we isolated our system and metal strip from the rest of our sheet. We did this so that we could get a good visual intuition of how to model a very simple field. If we wanted to get a more accurate real world picture, we would need to model the real heat equation which describes our scalar field evolution in terms 4-dimensional space defined as T (x, y, z, t)! In regards to our 2-dimensional metal sheet example, we would only need to define it in terms of T (x, y, t) &#8211; but you get the point! We simplified our case to show the principle in action. A real field equation may not be so simple!</p><h3><strong>Vector Fields</strong></h3><p>Not all fields are scalar. Let&#8217;s assume that we decide that we want to model a velocity field created by a fluid. We can&#8217;t model the motion of a fluid using single numerical values. Instead of outputting a scalar, we create a function which outputs a vector with a direction and magnitude!</p><p>That is, for each point coordinate point in 3-space (x, y, z), our function outputs the direction and magnitude of the fluid displacement at that point, and we thus get a simple vector field modeling the fluid flow:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MWtX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1af5490-9220-4319-9b1c-55a19a128b59_1299x981.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MWtX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1af5490-9220-4319-9b1c-55a19a128b59_1299x981.png 424w, https://substackcdn.com/image/fetch/$s_!MWtX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1af5490-9220-4319-9b1c-55a19a128b59_1299x981.png 848w, https://substackcdn.com/image/fetch/$s_!MWtX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1af5490-9220-4319-9b1c-55a19a128b59_1299x981.png 1272w, https://substackcdn.com/image/fetch/$s_!MWtX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1af5490-9220-4319-9b1c-55a19a128b59_1299x981.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MWtX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1af5490-9220-4319-9b1c-55a19a128b59_1299x981.png" width="543" height="410.0715935334873" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a1af5490-9220-4319-9b1c-55a19a128b59_1299x981.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:981,&quot;width&quot;:1299,&quot;resizeWidth&quot;:543,&quot;bytes&quot;:261631,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MWtX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1af5490-9220-4319-9b1c-55a19a128b59_1299x981.png 424w, https://substackcdn.com/image/fetch/$s_!MWtX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1af5490-9220-4319-9b1c-55a19a128b59_1299x981.png 848w, https://substackcdn.com/image/fetch/$s_!MWtX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1af5490-9220-4319-9b1c-55a19a128b59_1299x981.png 1272w, https://substackcdn.com/image/fetch/$s_!MWtX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1af5490-9220-4319-9b1c-55a19a128b59_1299x981.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></figure></div><p>A vector field doesn&#8217;t have to represent fluid flow though! We can use vector fields to model the force of gravity as well:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Grgo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e3ba84e-32b2-44e2-ade1-c9a1111840f0_1864x1029.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Grgo!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e3ba84e-32b2-44e2-ade1-c9a1111840f0_1864x1029.png 424w, https://substackcdn.com/image/fetch/$s_!Grgo!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e3ba84e-32b2-44e2-ade1-c9a1111840f0_1864x1029.png 848w, https://substackcdn.com/image/fetch/$s_!Grgo!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e3ba84e-32b2-44e2-ade1-c9a1111840f0_1864x1029.png 1272w, https://substackcdn.com/image/fetch/$s_!Grgo!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e3ba84e-32b2-44e2-ade1-c9a1111840f0_1864x1029.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Grgo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e3ba84e-32b2-44e2-ade1-c9a1111840f0_1864x1029.png" width="609" height="336.28846153846155" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5e3ba84e-32b2-44e2-ade1-c9a1111840f0_1864x1029.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:804,&quot;width&quot;:1456,&quot;resizeWidth&quot;:609,&quot;bytes&quot;:374936,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Grgo!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e3ba84e-32b2-44e2-ade1-c9a1111840f0_1864x1029.png 424w, https://substackcdn.com/image/fetch/$s_!Grgo!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e3ba84e-32b2-44e2-ade1-c9a1111840f0_1864x1029.png 848w, https://substackcdn.com/image/fetch/$s_!Grgo!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e3ba84e-32b2-44e2-ade1-c9a1111840f0_1864x1029.png 1272w, https://substackcdn.com/image/fetch/$s_!Grgo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e3ba84e-32b2-44e2-ade1-c9a1111840f0_1864x1029.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></figure></div><p>Below is another example showing a vector field for something which lies of central importance to us: the magnetic field!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GAVZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4030095a-85f8-4da1-ad31-3dc9bc737a10_685x432.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GAVZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4030095a-85f8-4da1-ad31-3dc9bc737a10_685x432.png 424w, https://substackcdn.com/image/fetch/$s_!GAVZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4030095a-85f8-4da1-ad31-3dc9bc737a10_685x432.png 848w, https://substackcdn.com/image/fetch/$s_!GAVZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4030095a-85f8-4da1-ad31-3dc9bc737a10_685x432.png 1272w, https://substackcdn.com/image/fetch/$s_!GAVZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4030095a-85f8-4da1-ad31-3dc9bc737a10_685x432.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GAVZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4030095a-85f8-4da1-ad31-3dc9bc737a10_685x432.png" width="579" height="365.15036496350365" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4030095a-85f8-4da1-ad31-3dc9bc737a10_685x432.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:432,&quot;width&quot;:685,&quot;resizeWidth&quot;:579,&quot;bytes&quot;:77229,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GAVZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4030095a-85f8-4da1-ad31-3dc9bc737a10_685x432.png 424w, https://substackcdn.com/image/fetch/$s_!GAVZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4030095a-85f8-4da1-ad31-3dc9bc737a10_685x432.png 848w, https://substackcdn.com/image/fetch/$s_!GAVZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4030095a-85f8-4da1-ad31-3dc9bc737a10_685x432.png 1272w, https://substackcdn.com/image/fetch/$s_!GAVZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4030095a-85f8-4da1-ad31-3dc9bc737a10_685x432.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></figure></div><p>We can obtain a lot of information about a vector field by looking at how the arrows are distributed over the plane. Going back to our fluid example: we can imagine that the 2-dimensional plane we&#8217;re looking at is covered in fluid, and that each arrow tells a particle passing through it what its velocity is.</p><p>As another note: this fluid doesn&#8217;t have regular flow like an everyday fluid may have. It may have &#8216;sources&#8217; or &#8216;sinks&#8217; where more fluid flows out than what flows in, and vice versa. Using the example of electric charges, we can imagine our electric charge &#8216;points&#8217; as being sources or sinks of an electromagnetic fluid, and the arrows representing how this field flows between them:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lxj5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10ec232-71a3-4071-97d0-a97d07fc222b_795x376.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lxj5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10ec232-71a3-4071-97d0-a97d07fc222b_795x376.png 424w, https://substackcdn.com/image/fetch/$s_!lxj5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10ec232-71a3-4071-97d0-a97d07fc222b_795x376.png 848w, https://substackcdn.com/image/fetch/$s_!lxj5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10ec232-71a3-4071-97d0-a97d07fc222b_795x376.png 1272w, https://substackcdn.com/image/fetch/$s_!lxj5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10ec232-71a3-4071-97d0-a97d07fc222b_795x376.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lxj5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10ec232-71a3-4071-97d0-a97d07fc222b_795x376.png" width="795" height="376" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b10ec232-71a3-4071-97d0-a97d07fc222b_795x376.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:376,&quot;width&quot;:795,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:59861,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lxj5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10ec232-71a3-4071-97d0-a97d07fc222b_795x376.png 424w, https://substackcdn.com/image/fetch/$s_!lxj5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10ec232-71a3-4071-97d0-a97d07fc222b_795x376.png 848w, https://substackcdn.com/image/fetch/$s_!lxj5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10ec232-71a3-4071-97d0-a97d07fc222b_795x376.png 1272w, https://substackcdn.com/image/fetch/$s_!lxj5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb10ec232-71a3-4071-97d0-a97d07fc222b_795x376.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></figure></div><p>To get an accurate conception of the source and sink idea though, we need to get familiar with the concept of divergence, which we illustrate in the next section.</p><h3><strong>Divergence</strong></h3><p>Specifying the divergence of the vector field at a point is equivalent to telling how much "denser" the fluid is getting near it. So, if we know that the arrows seem to be directed toward this point, the fluid particles tend to aggregate around it, and we say that the fluid converges there, or that it has negative divergence. Instead, if the arrows seem to be pointing away from the point, then the fluid is "thinning out", the fluid particles tend to escape from it and we say that the fluid diverges from there and has positive divergence. If the fluid seems to do neither, then we say that the divergence there is approximately zero or zero.</p><p>We can phrase this in simpler terms: let&#8217;s draw a small circle centered at the point whose divergence we want to measure. If there are more arrows going out of the circle, then we have a source point and a positive divergence. If there are more arrows pointing inwards and into the circle, then we have a sink point and a negative divergence.</p><p>In the below example, we can see one point which acts like a 'source' (fluid flows out) and thus we can see that it has a positive divergence:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sv_t!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3df9e1e4-827a-42f1-9a0f-baa6dd5c228b_811x425.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sv_t!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3df9e1e4-827a-42f1-9a0f-baa6dd5c228b_811x425.png 424w, https://substackcdn.com/image/fetch/$s_!sv_t!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3df9e1e4-827a-42f1-9a0f-baa6dd5c228b_811x425.png 848w, https://substackcdn.com/image/fetch/$s_!sv_t!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3df9e1e4-827a-42f1-9a0f-baa6dd5c228b_811x425.png 1272w, https://substackcdn.com/image/fetch/$s_!sv_t!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3df9e1e4-827a-42f1-9a0f-baa6dd5c228b_811x425.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sv_t!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3df9e1e4-827a-42f1-9a0f-baa6dd5c228b_811x425.png" width="811" height="425" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3df9e1e4-827a-42f1-9a0f-baa6dd5c228b_811x425.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:425,&quot;width&quot;:811,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:125715,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sv_t!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3df9e1e4-827a-42f1-9a0f-baa6dd5c228b_811x425.png 424w, https://substackcdn.com/image/fetch/$s_!sv_t!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3df9e1e4-827a-42f1-9a0f-baa6dd5c228b_811x425.png 848w, https://substackcdn.com/image/fetch/$s_!sv_t!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3df9e1e4-827a-42f1-9a0f-baa6dd5c228b_811x425.png 1272w, https://substackcdn.com/image/fetch/$s_!sv_t!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3df9e1e4-827a-42f1-9a0f-baa6dd5c228b_811x425.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></figure></div><p>On the flip side, if in a small region around a point there seems to be more fluid flowing into it than out of it, the divergence at that point would be a negative number:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!S7vJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced2a4d6-067b-4888-a8a4-d7110213d9e4_790x399.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!S7vJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced2a4d6-067b-4888-a8a4-d7110213d9e4_790x399.png 424w, https://substackcdn.com/image/fetch/$s_!S7vJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced2a4d6-067b-4888-a8a4-d7110213d9e4_790x399.png 848w, https://substackcdn.com/image/fetch/$s_!S7vJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced2a4d6-067b-4888-a8a4-d7110213d9e4_790x399.png 1272w, https://substackcdn.com/image/fetch/$s_!S7vJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced2a4d6-067b-4888-a8a4-d7110213d9e4_790x399.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!S7vJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced2a4d6-067b-4888-a8a4-d7110213d9e4_790x399.png" width="790" height="399" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ced2a4d6-067b-4888-a8a4-d7110213d9e4_790x399.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:399,&quot;width&quot;:790,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:137861,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!S7vJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced2a4d6-067b-4888-a8a4-d7110213d9e4_790x399.png 424w, https://substackcdn.com/image/fetch/$s_!S7vJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced2a4d6-067b-4888-a8a4-d7110213d9e4_790x399.png 848w, https://substackcdn.com/image/fetch/$s_!S7vJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced2a4d6-067b-4888-a8a4-d7110213d9e4_790x399.png 1272w, https://substackcdn.com/image/fetch/$s_!S7vJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced2a4d6-067b-4888-a8a4-d7110213d9e4_790x399.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></figure></div><p>Let&#8217;s show a more precise example, just so that we can make sure that there&#8217;s no confusion about what the divergence represents.</p><p>Remember that in 2 dimensions, the vector field is a function that takes in two-dimensional inputs and spits out two-dimensional outputs. In the example below, we can see a 2-dimensional field example which takes 2 coordinates and transforms them into a vector:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XdHx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97b679d6-f0d8-406d-8aa1-8abbe200ed27_661x408.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XdHx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97b679d6-f0d8-406d-8aa1-8abbe200ed27_661x408.png 424w, https://substackcdn.com/image/fetch/$s_!XdHx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97b679d6-f0d8-406d-8aa1-8abbe200ed27_661x408.png 848w, https://substackcdn.com/image/fetch/$s_!XdHx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97b679d6-f0d8-406d-8aa1-8abbe200ed27_661x408.png 1272w, https://substackcdn.com/image/fetch/$s_!XdHx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97b679d6-f0d8-406d-8aa1-8abbe200ed27_661x408.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XdHx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97b679d6-f0d8-406d-8aa1-8abbe200ed27_661x408.png" width="545" height="336.3993948562784" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/97b679d6-f0d8-406d-8aa1-8abbe200ed27_661x408.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:408,&quot;width&quot;:661,&quot;resizeWidth&quot;:545,&quot;bytes&quot;:117134,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!XdHx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97b679d6-f0d8-406d-8aa1-8abbe200ed27_661x408.png 424w, https://substackcdn.com/image/fetch/$s_!XdHx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97b679d6-f0d8-406d-8aa1-8abbe200ed27_661x408.png 848w, https://substackcdn.com/image/fetch/$s_!XdHx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97b679d6-f0d8-406d-8aa1-8abbe200ed27_661x408.png 1272w, https://substackcdn.com/image/fetch/$s_!XdHx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97b679d6-f0d8-406d-8aa1-8abbe200ed27_661x408.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></figure></div><p>In the case above, we can see that the input coordinates where x = -3.75 and y = +1.23 return a vector at the point which generates a vector which points -0.58 units in the x direction and -1.00 unites in the y direction.</p><p>The divergence of that vector field is a new function. This function takes only a single 2-dimensional point as its input, but its output depends on the behavior of the vector functions/fields in a small neighborhood around that point. As we already stated in our previous example, if the sum of the vectors going out at or around that point are larger than the vectors going in, we state that the divergence is positive. In the example below, we can see that the vectors at point x = 4.25 and y = 1.25 are &#8216;flowing out&#8217; of our point, so we quantify the divergence as being positive (+0.65):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GKxn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82a08b1d-1c4f-4226-8017-3f646e6638b9_876x406.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GKxn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82a08b1d-1c4f-4226-8017-3f646e6638b9_876x406.png 424w, https://substackcdn.com/image/fetch/$s_!GKxn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82a08b1d-1c4f-4226-8017-3f646e6638b9_876x406.png 848w, https://substackcdn.com/image/fetch/$s_!GKxn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82a08b1d-1c4f-4226-8017-3f646e6638b9_876x406.png 1272w, https://substackcdn.com/image/fetch/$s_!GKxn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82a08b1d-1c4f-4226-8017-3f646e6638b9_876x406.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GKxn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82a08b1d-1c4f-4226-8017-3f646e6638b9_876x406.png" width="876" height="406" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/82a08b1d-1c4f-4226-8017-3f646e6638b9_876x406.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:406,&quot;width&quot;:876,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:182069,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GKxn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82a08b1d-1c4f-4226-8017-3f646e6638b9_876x406.png 424w, https://substackcdn.com/image/fetch/$s_!GKxn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82a08b1d-1c4f-4226-8017-3f646e6638b9_876x406.png 848w, https://substackcdn.com/image/fetch/$s_!GKxn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82a08b1d-1c4f-4226-8017-3f646e6638b9_876x406.png 1272w, https://substackcdn.com/image/fetch/$s_!GKxn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82a08b1d-1c4f-4226-8017-3f646e6638b9_876x406.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></figure></div><p>You can think of the divergence as being similar to a derivative function. The output of the function is just a single number which measures how much that point acts as a source or a sink. If it is a source, then we have a point with a positive divergence. If it&#8217;s a sink, the divergence is negative.</p><h3><strong>Curl</strong></h3><p>You can think of the curl of a vector field being similar to the divergence, except that instead of measuring whether the point is a source or a sink, the curl tells us how much the fluid is &#8216;rotating&#8217; around it. To be exact: the curl measures the rotation of the field in the counterclockwise direction.</p><p>If you draw a small circle centered at a point, and the arrows around the circle are telling the &#8216;fluid&#8217; or field to rotate in a counterclockwise direction, then the vector field has a positive curl. On the other hand, if the arrows point in a clockwise direction, then the curl is negative. If the fluid or field has no rotation along our circle or point, we have a curl which is either zero or close to zero.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9Wba!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4d1a9ba-fa37-4556-8141-67cee6897b91_759x361.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9Wba!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4d1a9ba-fa37-4556-8141-67cee6897b91_759x361.png 424w, https://substackcdn.com/image/fetch/$s_!9Wba!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4d1a9ba-fa37-4556-8141-67cee6897b91_759x361.png 848w, https://substackcdn.com/image/fetch/$s_!9Wba!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4d1a9ba-fa37-4556-8141-67cee6897b91_759x361.png 1272w, https://substackcdn.com/image/fetch/$s_!9Wba!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4d1a9ba-fa37-4556-8141-67cee6897b91_759x361.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9Wba!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4d1a9ba-fa37-4556-8141-67cee6897b91_759x361.png" width="759" height="361" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4d1a9ba-fa37-4556-8141-67cee6897b91_759x361.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:361,&quot;width&quot;:759,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:134743,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!9Wba!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4d1a9ba-fa37-4556-8141-67cee6897b91_759x361.png 424w, https://substackcdn.com/image/fetch/$s_!9Wba!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4d1a9ba-fa37-4556-8141-67cee6897b91_759x361.png 848w, https://substackcdn.com/image/fetch/$s_!9Wba!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4d1a9ba-fa37-4556-8141-67cee6897b91_759x361.png 1272w, https://substackcdn.com/image/fetch/$s_!9Wba!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4d1a9ba-fa37-4556-8141-67cee6897b91_759x361.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></figure></div><p>As a note: a point in a region where the vectors are going in one direction could have a non-zero curl, as illustrated 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_!BdpT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7c8c615-ce1c-4fcf-8472-4068201c9239_471x287.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BdpT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7c8c615-ce1c-4fcf-8472-4068201c9239_471x287.png 424w, https://substackcdn.com/image/fetch/$s_!BdpT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7c8c615-ce1c-4fcf-8472-4068201c9239_471x287.png 848w, https://substackcdn.com/image/fetch/$s_!BdpT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7c8c615-ce1c-4fcf-8472-4068201c9239_471x287.png 1272w, https://substackcdn.com/image/fetch/$s_!BdpT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7c8c615-ce1c-4fcf-8472-4068201c9239_471x287.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BdpT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7c8c615-ce1c-4fcf-8472-4068201c9239_471x287.png" width="471" height="287" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d7c8c615-ce1c-4fcf-8472-4068201c9239_471x287.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:287,&quot;width&quot;:471,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:46186,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!BdpT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7c8c615-ce1c-4fcf-8472-4068201c9239_471x287.png 424w, https://substackcdn.com/image/fetch/$s_!BdpT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7c8c615-ce1c-4fcf-8472-4068201c9239_471x287.png 848w, https://substackcdn.com/image/fetch/$s_!BdpT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7c8c615-ce1c-4fcf-8472-4068201c9239_471x287.png 1272w, https://substackcdn.com/image/fetch/$s_!BdpT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7c8c615-ce1c-4fcf-8472-4068201c9239_471x287.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></figure></div><p>In the example above, we can see that the field shown will generate a larger force near the top of our circle than near the bottom. If we were to place an imaginary paddle wheel near it, the force generated would cause it to spin in the clockwise direction, so in the above instance, we say that the region has a negative curl.</p><p>Although it may seem that the curl function is scalar, the reality is that in 3-dimensional space, when we take the curl, we get an output vector which characterizes the rotation around that point according to a certain right hand rule. As we mentioned previously, a great analogy which we can use comes in terms of an imaginary paddle wheel. Imagine if we were to place this wheel at the point at which we want to measure the curl. If our field around this point causes the paddle wheel to turn in a clockwise or counterclockwise direction, then we obviously get our curl term: the faster the paddle wheel twists or moves at the point, then the stronger the magnitude of the curl.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ACKs!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5caeb86a-82b0-4ba2-9116-bb3168e1b7b1_508x410.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ACKs!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5caeb86a-82b0-4ba2-9116-bb3168e1b7b1_508x410.png 424w, https://substackcdn.com/image/fetch/$s_!ACKs!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5caeb86a-82b0-4ba2-9116-bb3168e1b7b1_508x410.png 848w, https://substackcdn.com/image/fetch/$s_!ACKs!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5caeb86a-82b0-4ba2-9116-bb3168e1b7b1_508x410.png 1272w, https://substackcdn.com/image/fetch/$s_!ACKs!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5caeb86a-82b0-4ba2-9116-bb3168e1b7b1_508x410.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ACKs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5caeb86a-82b0-4ba2-9116-bb3168e1b7b1_508x410.png" width="378" height="305.0787401574803" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5caeb86a-82b0-4ba2-9116-bb3168e1b7b1_508x410.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:410,&quot;width&quot;:508,&quot;resizeWidth&quot;:378,&quot;bytes&quot;:21715,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ACKs!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5caeb86a-82b0-4ba2-9116-bb3168e1b7b1_508x410.png 424w, https://substackcdn.com/image/fetch/$s_!ACKs!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5caeb86a-82b0-4ba2-9116-bb3168e1b7b1_508x410.png 848w, https://substackcdn.com/image/fetch/$s_!ACKs!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5caeb86a-82b0-4ba2-9116-bb3168e1b7b1_508x410.png 1272w, https://substackcdn.com/image/fetch/$s_!ACKs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5caeb86a-82b0-4ba2-9116-bb3168e1b7b1_508x410.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></figure></div><p>In the above example, we can see a demonstration of an imaginary paddle wheel at a point which has a positive curl and is surrounded by a field which pushes our wheel in a counterclockwise direction.</p><p>Now, if we were to extend this from 2-dimensions into 3, our curl function would simply output a vector which would show us in which direction to place our wheel such that we can maximize the work done by our field. We won&#8217;t go into too many details in illustrating the 3-dimensional concept though. For now, we&#8217;re going to focus on our simplified 2-dimensional case, which associates numbers and scalars rather than vectors. This is sufficient for what we need in order to finally get a clear conception on what we came here to understand: the meaning of Maxwell&#8217;s equations!</p><h2>Maxwell&#8217;s Equations</h2><p>As we already discussed, vector fields that represent fluid flow that have an immediate physical interpretation: the vector at every point in space represents a direction of motion of a fluid element, and we can construct snapshots of the motion of this fluid by drawing vector images over certain regions of space, just like we did in the previous section.</p><p>Now, for a more general vector field, such as the electromagnetic field discussed below, we do not have that immediate physical interpretation of a flow field. There is no &#8220;flow&#8221; or fluid that&#8217;s really present along the direction of those fields! However, even though the vectors in electromagnetism do not represent fluid flow, we carry over many of the terms we use to describe fluid flow. For example, we will speak of the flux of the electric field through a surface. If we were talking about fluid flow, &#8220;flux&#8221; would have a well-defined physical meaning, in that the flux would be the amount of fluid flowing across a given surface per unit time.</p><p>Noting this, let&#8217;s finally dive into the equations and try to interpret exactly what they mean. Below, we present the equations in <strong>differential form</strong> &#8211; that is, we present them in terms of the curl and the divergence of the vector field:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Dx86!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0191710b-41da-4525-940d-c10148071c4f_1220x821.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Dx86!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0191710b-41da-4525-940d-c10148071c4f_1220x821.png 424w, https://substackcdn.com/image/fetch/$s_!Dx86!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0191710b-41da-4525-940d-c10148071c4f_1220x821.png 848w, https://substackcdn.com/image/fetch/$s_!Dx86!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0191710b-41da-4525-940d-c10148071c4f_1220x821.png 1272w, https://substackcdn.com/image/fetch/$s_!Dx86!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0191710b-41da-4525-940d-c10148071c4f_1220x821.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Dx86!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0191710b-41da-4525-940d-c10148071c4f_1220x821.png" width="1220" height="821" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0191710b-41da-4525-940d-c10148071c4f_1220x821.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:821,&quot;width&quot;:1220,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:71257,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Dx86!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0191710b-41da-4525-940d-c10148071c4f_1220x821.png 424w, https://substackcdn.com/image/fetch/$s_!Dx86!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0191710b-41da-4525-940d-c10148071c4f_1220x821.png 848w, https://substackcdn.com/image/fetch/$s_!Dx86!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0191710b-41da-4525-940d-c10148071c4f_1220x821.png 1272w, https://substackcdn.com/image/fetch/$s_!Dx86!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0191710b-41da-4525-940d-c10148071c4f_1220x821.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></figure></div><p>After showing them in this form, we&#8217;ll then go on and present the same exact equations in <strong>integral </strong>form. The main difference between the two is in the perspective: the differential form focuses on presenting the electromagnetic field in terms of the curl and divergence of individual point charges, while the integral form focuses on presenting it in terms of a surface integral.</p><p>As already mentioned, the equations on the left are phrased in terms of the curl and divergence. The equations on the right are equivalent to the ones on the left, except that they phrase divergence and curl in terms of the dot and cross product, and we use arrows in our equations to denote that the fields we&#8217;re working with are vector fields rather than scalar fields.</p><p>Finally, let&#8217;s dive into what the 4 equations mean / represent!</p><h3><strong>Gauss&#8217;s Law for Electric Fields</strong></h3><p>The top equation is Gauss&#8217;s law for electric fields. It states that the divergence of an electric field at a given point is proportional to the charge density at that 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_!0PFT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5bd423c-3a9a-4224-881d-56debad51289_853x494.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0PFT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5bd423c-3a9a-4224-881d-56debad51289_853x494.png 424w, https://substackcdn.com/image/fetch/$s_!0PFT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5bd423c-3a9a-4224-881d-56debad51289_853x494.png 848w, https://substackcdn.com/image/fetch/$s_!0PFT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5bd423c-3a9a-4224-881d-56debad51289_853x494.png 1272w, https://substackcdn.com/image/fetch/$s_!0PFT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5bd423c-3a9a-4224-881d-56debad51289_853x494.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0PFT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5bd423c-3a9a-4224-881d-56debad51289_853x494.png" width="567" height="328.36811254396247" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a5bd423c-3a9a-4224-881d-56debad51289_853x494.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:494,&quot;width&quot;:853,&quot;resizeWidth&quot;:567,&quot;bytes&quot;:39833,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!0PFT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5bd423c-3a9a-4224-881d-56debad51289_853x494.png 424w, https://substackcdn.com/image/fetch/$s_!0PFT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5bd423c-3a9a-4224-881d-56debad51289_853x494.png 848w, https://substackcdn.com/image/fetch/$s_!0PFT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5bd423c-3a9a-4224-881d-56debad51289_853x494.png 1272w, https://substackcdn.com/image/fetch/$s_!0PFT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa5bd423c-3a9a-4224-881d-56debad51289_853x494.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></figure></div><p>Unpacking the intuition for this in terms of divergence, you can imagine positive charges as being sources of some imagined fluid, and negative charges as the sinks of that fluid:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xrVj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fca65bc-9edc-4ab7-91b5-100d8582fca6_647x277.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xrVj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fca65bc-9edc-4ab7-91b5-100d8582fca6_647x277.png 424w, https://substackcdn.com/image/fetch/$s_!xrVj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fca65bc-9edc-4ab7-91b5-100d8582fca6_647x277.png 848w, https://substackcdn.com/image/fetch/$s_!xrVj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fca65bc-9edc-4ab7-91b5-100d8582fca6_647x277.png 1272w, https://substackcdn.com/image/fetch/$s_!xrVj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fca65bc-9edc-4ab7-91b5-100d8582fca6_647x277.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xrVj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fca65bc-9edc-4ab7-91b5-100d8582fca6_647x277.png" width="505" height="216.20556414219473" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9fca65bc-9edc-4ab7-91b5-100d8582fca6_647x277.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:277,&quot;width&quot;:647,&quot;resizeWidth&quot;:505,&quot;bytes&quot;:77491,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!xrVj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fca65bc-9edc-4ab7-91b5-100d8582fca6_647x277.png 424w, https://substackcdn.com/image/fetch/$s_!xrVj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fca65bc-9edc-4ab7-91b5-100d8582fca6_647x277.png 848w, https://substackcdn.com/image/fetch/$s_!xrVj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fca65bc-9edc-4ab7-91b5-100d8582fca6_647x277.png 1272w, https://substackcdn.com/image/fetch/$s_!xrVj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fca65bc-9edc-4ab7-91b5-100d8582fca6_647x277.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Another example:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!I5YC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5464bd7a-e3d4-470d-995f-b7fd7082ca64_416x315.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!I5YC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5464bd7a-e3d4-470d-995f-b7fd7082ca64_416x315.png 424w, https://substackcdn.com/image/fetch/$s_!I5YC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5464bd7a-e3d4-470d-995f-b7fd7082ca64_416x315.png 848w, https://substackcdn.com/image/fetch/$s_!I5YC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5464bd7a-e3d4-470d-995f-b7fd7082ca64_416x315.png 1272w, https://substackcdn.com/image/fetch/$s_!I5YC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5464bd7a-e3d4-470d-995f-b7fd7082ca64_416x315.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!I5YC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5464bd7a-e3d4-470d-995f-b7fd7082ca64_416x315.png" width="352" height="266.53846153846155" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5464bd7a-e3d4-470d-995f-b7fd7082ca64_416x315.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:315,&quot;width&quot;:416,&quot;resizeWidth&quot;:352,&quot;bytes&quot;:82046,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!I5YC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5464bd7a-e3d4-470d-995f-b7fd7082ca64_416x315.png 424w, https://substackcdn.com/image/fetch/$s_!I5YC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5464bd7a-e3d4-470d-995f-b7fd7082ca64_416x315.png 848w, https://substackcdn.com/image/fetch/$s_!I5YC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5464bd7a-e3d4-470d-995f-b7fd7082ca64_416x315.png 1272w, https://substackcdn.com/image/fetch/$s_!I5YC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5464bd7a-e3d4-470d-995f-b7fd7082ca64_416x315.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></figure></div><p>We can also model the above picture in terms of flux, which is similar to the earlier concept of using vector fields to model our fluid flow. The idea is exactly the same, except that instead of using vectors and vector magnitudes spread through every point in space, we use flux lines flowing from a source to a destination.</p><p>Let&#8217;s show an example by drawing flux lines and showing how they relate to our earlier examples. Faraday called these field lines &#8220;lines of force&#8221; and believed that they had an existence of their own, describing them as stretching across a vacuum.</p><p>To draw a flux line, start out at any point in space and move your pen/pencil a very short distance in the direction of the local vector field. After that short distance, stop and find the new direction of the local vector field at that point. Now, begin moving again in that new direction (the direction of the arrow at the point that is). Continue this process indefinitely. By following this methodology, you can construct a line in space that is tangent to the local vector field. If we do this for different starting points, we can draw a set of field lines that give a great representation of the properties of the vector field, as illustrated 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_!Bo8Y!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d59678a-3d8b-4d1b-9da7-ff222ff8752f_483x498.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Bo8Y!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d59678a-3d8b-4d1b-9da7-ff222ff8752f_483x498.png 424w, https://substackcdn.com/image/fetch/$s_!Bo8Y!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d59678a-3d8b-4d1b-9da7-ff222ff8752f_483x498.png 848w, https://substackcdn.com/image/fetch/$s_!Bo8Y!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d59678a-3d8b-4d1b-9da7-ff222ff8752f_483x498.png 1272w, https://substackcdn.com/image/fetch/$s_!Bo8Y!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d59678a-3d8b-4d1b-9da7-ff222ff8752f_483x498.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Bo8Y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d59678a-3d8b-4d1b-9da7-ff222ff8752f_483x498.png" width="391" height="403.14285714285717" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0d59678a-3d8b-4d1b-9da7-ff222ff8752f_483x498.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:498,&quot;width&quot;:483,&quot;resizeWidth&quot;:391,&quot;bytes&quot;:48123,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Bo8Y!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d59678a-3d8b-4d1b-9da7-ff222ff8752f_483x498.png 424w, https://substackcdn.com/image/fetch/$s_!Bo8Y!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d59678a-3d8b-4d1b-9da7-ff222ff8752f_483x498.png 848w, https://substackcdn.com/image/fetch/$s_!Bo8Y!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d59678a-3d8b-4d1b-9da7-ff222ff8752f_483x498.png 1272w, https://substackcdn.com/image/fetch/$s_!Bo8Y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d59678a-3d8b-4d1b-9da7-ff222ff8752f_483x498.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></figure></div><p>So how do we use the flux lines to determine the strength of the field? When we used vectors, we could show the strength by going to a point and using the magnitude of our vector. In regards to flux lines, we no longer have this capability. To determine the strength of our field using flux lines, we simply use the<strong> density </strong>of field lines at some region of space. The total number of lines crossing the area / volume indicate the strength of the field at that region. This means that there is a direct proportionality between the electric field and the flux lines.</p><p>Once again, we can imagine that our flux lines have a direction. We draw the direction of our lines away from positive charges and towards the negative charges:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!62LL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44da0dae-0a9c-4cb1-abdc-2aa35fc38770_980x508.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!62LL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44da0dae-0a9c-4cb1-abdc-2aa35fc38770_980x508.png 424w, https://substackcdn.com/image/fetch/$s_!62LL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44da0dae-0a9c-4cb1-abdc-2aa35fc38770_980x508.png 848w, https://substackcdn.com/image/fetch/$s_!62LL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44da0dae-0a9c-4cb1-abdc-2aa35fc38770_980x508.png 1272w, https://substackcdn.com/image/fetch/$s_!62LL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44da0dae-0a9c-4cb1-abdc-2aa35fc38770_980x508.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!62LL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44da0dae-0a9c-4cb1-abdc-2aa35fc38770_980x508.png" width="581" height="301.1714285714286" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/44da0dae-0a9c-4cb1-abdc-2aa35fc38770_980x508.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:508,&quot;width&quot;:980,&quot;resizeWidth&quot;:581,&quot;bytes&quot;:32188,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!62LL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44da0dae-0a9c-4cb1-abdc-2aa35fc38770_980x508.png 424w, https://substackcdn.com/image/fetch/$s_!62LL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44da0dae-0a9c-4cb1-abdc-2aa35fc38770_980x508.png 848w, https://substackcdn.com/image/fetch/$s_!62LL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44da0dae-0a9c-4cb1-abdc-2aa35fc38770_980x508.png 1272w, https://substackcdn.com/image/fetch/$s_!62LL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44da0dae-0a9c-4cb1-abdc-2aa35fc38770_980x508.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></figure></div><p>We can demo the concept of flux between 2 opposite charges using the diagram 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_!rfQn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05869205-9ce5-4957-8da7-bc78ee5e7be3_566x307.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rfQn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05869205-9ce5-4957-8da7-bc78ee5e7be3_566x307.png 424w, https://substackcdn.com/image/fetch/$s_!rfQn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05869205-9ce5-4957-8da7-bc78ee5e7be3_566x307.png 848w, https://substackcdn.com/image/fetch/$s_!rfQn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05869205-9ce5-4957-8da7-bc78ee5e7be3_566x307.png 1272w, https://substackcdn.com/image/fetch/$s_!rfQn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05869205-9ce5-4957-8da7-bc78ee5e7be3_566x307.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rfQn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05869205-9ce5-4957-8da7-bc78ee5e7be3_566x307.png" width="566" height="307" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/05869205-9ce5-4957-8da7-bc78ee5e7be3_566x307.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:307,&quot;width&quot;:566,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:35153,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!rfQn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05869205-9ce5-4957-8da7-bc78ee5e7be3_566x307.png 424w, https://substackcdn.com/image/fetch/$s_!rfQn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05869205-9ce5-4957-8da7-bc78ee5e7be3_566x307.png 848w, https://substackcdn.com/image/fetch/$s_!rfQn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05869205-9ce5-4957-8da7-bc78ee5e7be3_566x307.png 1272w, https://substackcdn.com/image/fetch/$s_!rfQn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05869205-9ce5-4957-8da7-bc78ee5e7be3_566x307.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></figure></div><p>A diagram showing the flux lines flowing between 2 like charges:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!UMkJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9554a6f-62a7-48cb-bf73-70cb0666ebc5_574x343.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UMkJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9554a6f-62a7-48cb-bf73-70cb0666ebc5_574x343.png 424w, https://substackcdn.com/image/fetch/$s_!UMkJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9554a6f-62a7-48cb-bf73-70cb0666ebc5_574x343.png 848w, https://substackcdn.com/image/fetch/$s_!UMkJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9554a6f-62a7-48cb-bf73-70cb0666ebc5_574x343.png 1272w, https://substackcdn.com/image/fetch/$s_!UMkJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9554a6f-62a7-48cb-bf73-70cb0666ebc5_574x343.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!UMkJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9554a6f-62a7-48cb-bf73-70cb0666ebc5_574x343.png" width="574" height="343" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e9554a6f-62a7-48cb-bf73-70cb0666ebc5_574x343.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:343,&quot;width&quot;:574,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:46583,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!UMkJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9554a6f-62a7-48cb-bf73-70cb0666ebc5_574x343.png 424w, https://substackcdn.com/image/fetch/$s_!UMkJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9554a6f-62a7-48cb-bf73-70cb0666ebc5_574x343.png 848w, https://substackcdn.com/image/fetch/$s_!UMkJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9554a6f-62a7-48cb-bf73-70cb0666ebc5_574x343.png 1272w, https://substackcdn.com/image/fetch/$s_!UMkJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9554a6f-62a7-48cb-bf73-70cb0666ebc5_574x343.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></figure></div><p>As you can see from the figures above, the field line densities increase near our charges and drop off moving away from them. This shows that the electric field from a point charge decreases with the distance from it. We can thus see that the electric field strength, which is also sometimes referred to as the electric flux density, obeys the <strong>inverse square law:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_AuY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F344e2f5e-e522-4bbf-a2c3-03e71e9857b2_420x280.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_AuY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F344e2f5e-e522-4bbf-a2c3-03e71e9857b2_420x280.png 424w, https://substackcdn.com/image/fetch/$s_!_AuY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F344e2f5e-e522-4bbf-a2c3-03e71e9857b2_420x280.png 848w, https://substackcdn.com/image/fetch/$s_!_AuY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F344e2f5e-e522-4bbf-a2c3-03e71e9857b2_420x280.png 1272w, https://substackcdn.com/image/fetch/$s_!_AuY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F344e2f5e-e522-4bbf-a2c3-03e71e9857b2_420x280.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_AuY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F344e2f5e-e522-4bbf-a2c3-03e71e9857b2_420x280.png" width="420" height="280" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/344e2f5e-e522-4bbf-a2c3-03e71e9857b2_420x280.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:280,&quot;width&quot;:420,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:33974,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_AuY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F344e2f5e-e522-4bbf-a2c3-03e71e9857b2_420x280.png 424w, https://substackcdn.com/image/fetch/$s_!_AuY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F344e2f5e-e522-4bbf-a2c3-03e71e9857b2_420x280.png 848w, https://substackcdn.com/image/fetch/$s_!_AuY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F344e2f5e-e522-4bbf-a2c3-03e71e9857b2_420x280.png 1272w, https://substackcdn.com/image/fetch/$s_!_AuY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F344e2f5e-e522-4bbf-a2c3-03e71e9857b2_420x280.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></figure></div><p>The inverse square law not only applies to electric fields, but many different phenomena, such as gravity and sound as well. The law can easily be pictured through geometric intuition of visualizing an expanding sphere. As it expands, the force can be viewed as being distributed throughout the surface area. In other words, the force spreads out in an ever expanding spherical shell as the sphere moves radially and the surface area expands by r<sup>2</sup> (a spherical surface area is equal to 4&#960;r<sup>2</sup>):</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!t9C-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F194e43d4-7f91-43fd-b885-1b1910154119_748x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!t9C-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F194e43d4-7f91-43fd-b885-1b1910154119_748x500.png 424w, https://substackcdn.com/image/fetch/$s_!t9C-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F194e43d4-7f91-43fd-b885-1b1910154119_748x500.png 848w, https://substackcdn.com/image/fetch/$s_!t9C-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F194e43d4-7f91-43fd-b885-1b1910154119_748x500.png 1272w, https://substackcdn.com/image/fetch/$s_!t9C-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F194e43d4-7f91-43fd-b885-1b1910154119_748x500.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!t9C-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F194e43d4-7f91-43fd-b885-1b1910154119_748x500.png" width="541" height="361.63101604278074" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/194e43d4-7f91-43fd-b885-1b1910154119_748x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:748,&quot;resizeWidth&quot;:541,&quot;bytes&quot;:59145,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!t9C-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F194e43d4-7f91-43fd-b885-1b1910154119_748x500.png 424w, https://substackcdn.com/image/fetch/$s_!t9C-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F194e43d4-7f91-43fd-b885-1b1910154119_748x500.png 848w, https://substackcdn.com/image/fetch/$s_!t9C-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F194e43d4-7f91-43fd-b885-1b1910154119_748x500.png 1272w, https://substackcdn.com/image/fetch/$s_!t9C-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F194e43d4-7f91-43fd-b885-1b1910154119_748x500.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></figure></div><p></p><p>We can see that as we expand our spherical shell outwards, we get a decreasing concentration of the electromagnetic field as the flux density is spread out across our circular surface. Let&#8217;s take an arbitrary area located at an arbitrary distance d from our center. We can see that when our radius r = 3d, the area which our flux lines pass through is 9 times larger than the area that it passes through when r = d. When r = 4d, our flux density expands into an area which is 16 times larger (r<sup>2</sup> = 4<sup>2</sup> = 16), so our field strength is reduced by a factor of 16! We should be able to easily see what the field strength diminishes by a factor of 1 / r<sup>2</sup> (inverse square) as we travel away from an arbitrary point of charge.</p><p>Why are we spending this much time discussing Gauss&#8217;s law in terms of flux? We already have a good intuition of what it states when it comes to divergence: electric fields produced by electric charges diverge from those positive charges and converge to the negative charges. The reason we want to get a good intuition behind flux is so we can present this concept in terms of its <strong>integral </strong>form, which relates the same concept we just discussed in terms of integrating the surface area around a charge rather than expressing it through divergence!</p><p>What is an integral, and what do we mean by integration?</p><p>The motivation behind integration is to find the area under a curve. To do this, we break up a function interval (whose area we want to measure) into little regions of width &#916;x and add up the areas of the resulting rectangles.</p><p>Here's an illustration showing what happens as we make the width (&#916;x) of the rectangles smaller and smaller:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!AhYS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F631e7253-eed0-4f7d-b832-e78feea45957_300x300.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!AhYS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F631e7253-eed0-4f7d-b832-e78feea45957_300x300.png 424w, https://substackcdn.com/image/fetch/$s_!AhYS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F631e7253-eed0-4f7d-b832-e78feea45957_300x300.png 848w, https://substackcdn.com/image/fetch/$s_!AhYS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F631e7253-eed0-4f7d-b832-e78feea45957_300x300.png 1272w, https://substackcdn.com/image/fetch/$s_!AhYS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F631e7253-eed0-4f7d-b832-e78feea45957_300x300.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!AhYS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F631e7253-eed0-4f7d-b832-e78feea45957_300x300.png" width="300" height="300" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/631e7253-eed0-4f7d-b832-e78feea45957_300x300.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:300,&quot;width&quot;:300,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:24541,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!AhYS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F631e7253-eed0-4f7d-b832-e78feea45957_300x300.png 424w, https://substackcdn.com/image/fetch/$s_!AhYS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F631e7253-eed0-4f7d-b832-e78feea45957_300x300.png 848w, https://substackcdn.com/image/fetch/$s_!AhYS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F631e7253-eed0-4f7d-b832-e78feea45957_300x300.png 1272w, https://substackcdn.com/image/fetch/$s_!AhYS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F631e7253-eed0-4f7d-b832-e78feea45957_300x300.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></figure></div><p>Indeed, as &#916;x approaches 0, we obtain even more accurate values representing the area under the curve! When we take an integral of something, that&#8217;s all we&#8217;re doing! We can think of the integral as being a direct translation 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_!LA5N!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee5255f2-5454-4de4-a3c5-e789bdd99d39_1700x1649.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LA5N!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee5255f2-5454-4de4-a3c5-e789bdd99d39_1700x1649.png 424w, https://substackcdn.com/image/fetch/$s_!LA5N!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee5255f2-5454-4de4-a3c5-e789bdd99d39_1700x1649.png 848w, https://substackcdn.com/image/fetch/$s_!LA5N!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee5255f2-5454-4de4-a3c5-e789bdd99d39_1700x1649.png 1272w, https://substackcdn.com/image/fetch/$s_!LA5N!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee5255f2-5454-4de4-a3c5-e789bdd99d39_1700x1649.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LA5N!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee5255f2-5454-4de4-a3c5-e789bdd99d39_1700x1649.png" width="563" height="545.9862637362637" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ee5255f2-5454-4de4-a3c5-e789bdd99d39_1700x1649.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1412,&quot;width&quot;:1456,&quot;resizeWidth&quot;:563,&quot;bytes&quot;:112928,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!LA5N!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee5255f2-5454-4de4-a3c5-e789bdd99d39_1700x1649.png 424w, https://substackcdn.com/image/fetch/$s_!LA5N!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee5255f2-5454-4de4-a3c5-e789bdd99d39_1700x1649.png 848w, https://substackcdn.com/image/fetch/$s_!LA5N!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee5255f2-5454-4de4-a3c5-e789bdd99d39_1700x1649.png 1272w, https://substackcdn.com/image/fetch/$s_!LA5N!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee5255f2-5454-4de4-a3c5-e789bdd99d39_1700x1649.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></figure></div><p>Using the above methodology and finding the integral function (which we call the anti-derivative), we can find the area between point a and b!</p><p>This concept plays a central role in calculus, and a central role in modeling our integral equations, so let&#8217;s now express Gauss&#8217;s law in terms of our integral formulation:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BPer!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b1c4c6c-8b19-4df4-ae31-edaa60c63171_1039x877.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BPer!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b1c4c6c-8b19-4df4-ae31-edaa60c63171_1039x877.png 424w, https://substackcdn.com/image/fetch/$s_!BPer!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b1c4c6c-8b19-4df4-ae31-edaa60c63171_1039x877.png 848w, https://substackcdn.com/image/fetch/$s_!BPer!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b1c4c6c-8b19-4df4-ae31-edaa60c63171_1039x877.png 1272w, https://substackcdn.com/image/fetch/$s_!BPer!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b1c4c6c-8b19-4df4-ae31-edaa60c63171_1039x877.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BPer!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b1c4c6c-8b19-4df4-ae31-edaa60c63171_1039x877.png" width="1039" height="877" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4b1c4c6c-8b19-4df4-ae31-edaa60c63171_1039x877.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:877,&quot;width&quot;:1039,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:154065,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!BPer!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b1c4c6c-8b19-4df4-ae31-edaa60c63171_1039x877.png 424w, https://substackcdn.com/image/fetch/$s_!BPer!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b1c4c6c-8b19-4df4-ae31-edaa60c63171_1039x877.png 848w, https://substackcdn.com/image/fetch/$s_!BPer!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b1c4c6c-8b19-4df4-ae31-edaa60c63171_1039x877.png 1272w, https://substackcdn.com/image/fetch/$s_!BPer!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b1c4c6c-8b19-4df4-ae31-edaa60c63171_1039x877.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></figure></div><p>In integral form, Gauss&#8217;s law states that an electric charge produces an electric field, and that the flux / charge surrounding the field and passing through any closed surface is equal to the total charge contained within the surface. The total charge always equals to the number of point charge (or charges) which the surface envelops. We also notice the inverse square law in action once again: since our surface integral is always going to equal to the enclosed charge, as we travel away from our enveloping spherical shell, our charge / flux density will get weaker by a factor of 1 / r<sup>2</sup>. We can see that in the spherical example in the image above that the total charge passing through the surface area is going to equal to q<sub>enc</sub> / the electric permittivity of free space (&#949;<sub>0</sub>), which is equivalent to what we have in our equation in differential form.</p><p>But what is the electric permittivity of free space (&#949;<sub>0</sub>) though? We haven&#8217;t had a chance to discuss this term yet! To put things simply: the electric permittivity is a constant which allows us to describe how easily (or how difficult) it is for electric fields to pass through a medium (such as air, or water, or anything else for that matter). It&#8217;s called permittivity because of how much a given substance &#8220;permits&#8221; electric field lines to pass through them. So for certain substances, our electric field lines will pass through them easily, and for other ones, they won&#8217;t. This term encapsulates this permittivity. But what does this value for <strong>free space </strong>represent? The permittivity of free space has a special value and represents a the ability of a vacuum to let electric field lines to pass through. Its value is normally expressed as 1A<sup>2</sup>s<sup>4</sup>kg<sup>&#8722;1</sup>b<sup>&#8722;3</sup>.</p><p>Once again, we can say that our integral form is the same exact equivalent to our differential form. Whereas our differential form expresses the concept of having a charge modeled in terms of fluid flow and convergence and divergence (and that an electric field produces a charge which diverges from positive charges and converges towards negative charges), our integral form expresses the same idea, but in terms of capturing the field flow over an enclosed surface using integration. Here, we integrate the total surface area of a closed surface by summing small surface area elements (da) and adding them together to get the total charge / flux over that area, and we note that the total electric field encapsulated by this surface area will always equal to the total charges enclosed within that area.</p><p>And, that&#8217;s it! We&#8217;re now equipped and ready to tackle Gauss&#8217;s law for <strong>magnetic</strong> fields!</p><h3><strong>Gauss&#8217;s Law for Magnetic Fields</strong></h3><p>Gauss&#8217;s law for magnetic fields is very simple, and simply states that the divergence of a magnetic field is always 0:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wMy4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb909a4c5-699a-4ee5-981b-37c163d0a1db_449x357.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wMy4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb909a4c5-699a-4ee5-981b-37c163d0a1db_449x357.png 424w, https://substackcdn.com/image/fetch/$s_!wMy4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb909a4c5-699a-4ee5-981b-37c163d0a1db_449x357.png 848w, https://substackcdn.com/image/fetch/$s_!wMy4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb909a4c5-699a-4ee5-981b-37c163d0a1db_449x357.png 1272w, https://substackcdn.com/image/fetch/$s_!wMy4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb909a4c5-699a-4ee5-981b-37c163d0a1db_449x357.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wMy4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb909a4c5-699a-4ee5-981b-37c163d0a1db_449x357.png" width="353" height="280.67037861915367" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b909a4c5-699a-4ee5-981b-37c163d0a1db_449x357.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:357,&quot;width&quot;:449,&quot;resizeWidth&quot;:353,&quot;bytes&quot;:18660,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wMy4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb909a4c5-699a-4ee5-981b-37c163d0a1db_449x357.png 424w, https://substackcdn.com/image/fetch/$s_!wMy4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb909a4c5-699a-4ee5-981b-37c163d0a1db_449x357.png 848w, https://substackcdn.com/image/fetch/$s_!wMy4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb909a4c5-699a-4ee5-981b-37c163d0a1db_449x357.png 1272w, https://substackcdn.com/image/fetch/$s_!wMy4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb909a4c5-699a-4ee5-981b-37c163d0a1db_449x357.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></figure></div><p>If we once again go back to attempting to model this through fluid flow, we can say that the statement above indicates that the magnetic fluid is in-compressible, with no sources or sinks anywhere:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ReX_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3410de20-59d4-4160-9deb-1b29ec49597d_327x252.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ReX_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3410de20-59d4-4160-9deb-1b29ec49597d_327x252.png 424w, https://substackcdn.com/image/fetch/$s_!ReX_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3410de20-59d4-4160-9deb-1b29ec49597d_327x252.png 848w, https://substackcdn.com/image/fetch/$s_!ReX_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3410de20-59d4-4160-9deb-1b29ec49597d_327x252.png 1272w, https://substackcdn.com/image/fetch/$s_!ReX_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3410de20-59d4-4160-9deb-1b29ec49597d_327x252.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ReX_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3410de20-59d4-4160-9deb-1b29ec49597d_327x252.png" width="391" height="301.3211009174312" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3410de20-59d4-4160-9deb-1b29ec49597d_327x252.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:252,&quot;width&quot;:327,&quot;resizeWidth&quot;:391,&quot;bytes&quot;:64572,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ReX_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3410de20-59d4-4160-9deb-1b29ec49597d_327x252.png 424w, https://substackcdn.com/image/fetch/$s_!ReX_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3410de20-59d4-4160-9deb-1b29ec49597d_327x252.png 848w, https://substackcdn.com/image/fetch/$s_!ReX_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3410de20-59d4-4160-9deb-1b29ec49597d_327x252.png 1272w, https://substackcdn.com/image/fetch/$s_!ReX_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3410de20-59d4-4160-9deb-1b29ec49597d_327x252.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></figure></div><p>In terms of modeling this through flux, we could state that the flux of the magnetic field through any enclosed surface area will always be zero! This is often interpreted as &#8220;there are no magnetic analogues to charges&#8221; (called magnetic monopoles). You may then ask: so how do we get magnetic fields? How do we get permanent magnets for example, and what is their &#8216;source&#8217; if these fields never really have a &#8216;net&#8217; divergence?</p><p>Well, in order to produce the magnetic field, we don&#8217;t need sources or sinks! We can produce one through variation, or the concept we touched upon earlier: the <strong>curl.</strong> We can model our magnetic field functions in space such that when we sum all of our enclosed surface areas, we always get 0, but the net curl or &#8216;rotation&#8217; generated by the field results in an asymmetry in the distribution of the vectors and thus as having &#8216;circulating&#8217; field lines of force which are capable of doing work. This &#8216;circular&#8217; field throughout space is what produces magnets and the magnetic field, and we think of the magnetic field as being a by-product of a moving electric field or moving electric charges.</p><p>We can once again go back to our original question then and ask: so what are magnets? For the most part, in most materials, the electron &#8216;spins&#8217; (a term we use to describe a set of properties, one of them being its magnetic field orientation) are oriented relatively evenly / randomly, which results in a net magnetic charge which is close to 0. On the other hand, in magnets, the electrons are oriented in such a way that a large majority are aligned in one &#8216;direction.&#8217; Because of this asymmetry and alignment in the orientation, or as we mentioned earlier, the atomic spins within our material, we get a resulting net magnetic field and the equivalent of a circuit. This circuit in turn produces our magnetic field and results in a magnet!!</p><p>Let&#8217;s try to visualize the magnetic field, which is drawn and demoed 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_!ph8k!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21470981-fd65-4704-8078-31d9e72b891a_787x309.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ph8k!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21470981-fd65-4704-8078-31d9e72b891a_787x309.png 424w, https://substackcdn.com/image/fetch/$s_!ph8k!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21470981-fd65-4704-8078-31d9e72b891a_787x309.png 848w, https://substackcdn.com/image/fetch/$s_!ph8k!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21470981-fd65-4704-8078-31d9e72b891a_787x309.png 1272w, https://substackcdn.com/image/fetch/$s_!ph8k!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21470981-fd65-4704-8078-31d9e72b891a_787x309.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ph8k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21470981-fd65-4704-8078-31d9e72b891a_787x309.png" width="787" height="309" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/21470981-fd65-4704-8078-31d9e72b891a_787x309.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:309,&quot;width&quot;:787,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:111821,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ph8k!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21470981-fd65-4704-8078-31d9e72b891a_787x309.png 424w, https://substackcdn.com/image/fetch/$s_!ph8k!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21470981-fd65-4704-8078-31d9e72b891a_787x309.png 848w, https://substackcdn.com/image/fetch/$s_!ph8k!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21470981-fd65-4704-8078-31d9e72b891a_787x309.png 1272w, https://substackcdn.com/image/fetch/$s_!ph8k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21470981-fd65-4704-8078-31d9e72b891a_787x309.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></figure></div><p>Gauss&#8217;s law for magnetic fields essentially states that the magnetic field has a divergence of 0, and that the total resultant &#8216;magnetic charge&#8217; of any magnetic field will always equal to 0. In terms of flux, what this means is that unlike electric flux lines, magnetic flux lines do not originate and terminate on charges!! Instead, they always circulate back on themselves and form continuous loops.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!VbYp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23dec5e0-46f8-4326-8aae-aa883ec896ce_1920x1920.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VbYp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23dec5e0-46f8-4326-8aae-aa883ec896ce_1920x1920.png 424w, https://substackcdn.com/image/fetch/$s_!VbYp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23dec5e0-46f8-4326-8aae-aa883ec896ce_1920x1920.png 848w, https://substackcdn.com/image/fetch/$s_!VbYp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23dec5e0-46f8-4326-8aae-aa883ec896ce_1920x1920.png 1272w, https://substackcdn.com/image/fetch/$s_!VbYp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23dec5e0-46f8-4326-8aae-aa883ec896ce_1920x1920.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!VbYp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23dec5e0-46f8-4326-8aae-aa883ec896ce_1920x1920.png" width="351" height="351" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/23dec5e0-46f8-4326-8aae-aa883ec896ce_1920x1920.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;:351,&quot;bytes&quot;:188030,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!VbYp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23dec5e0-46f8-4326-8aae-aa883ec896ce_1920x1920.png 424w, https://substackcdn.com/image/fetch/$s_!VbYp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23dec5e0-46f8-4326-8aae-aa883ec896ce_1920x1920.png 848w, https://substackcdn.com/image/fetch/$s_!VbYp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23dec5e0-46f8-4326-8aae-aa883ec896ce_1920x1920.png 1272w, https://substackcdn.com/image/fetch/$s_!VbYp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23dec5e0-46f8-4326-8aae-aa883ec896ce_1920x1920.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></figure></div><p>We can once again express this using an integral form, which simply states the same thing as our differential form in terms of enclosed surface areas:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MZJF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fbab461-c7e2-42f5-a1be-4c299de5551b_1057x839.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MZJF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fbab461-c7e2-42f5-a1be-4c299de5551b_1057x839.png 424w, https://substackcdn.com/image/fetch/$s_!MZJF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fbab461-c7e2-42f5-a1be-4c299de5551b_1057x839.png 848w, https://substackcdn.com/image/fetch/$s_!MZJF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fbab461-c7e2-42f5-a1be-4c299de5551b_1057x839.png 1272w, https://substackcdn.com/image/fetch/$s_!MZJF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fbab461-c7e2-42f5-a1be-4c299de5551b_1057x839.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MZJF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fbab461-c7e2-42f5-a1be-4c299de5551b_1057x839.png" width="1057" height="839" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7fbab461-c7e2-42f5-a1be-4c299de5551b_1057x839.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:839,&quot;width&quot;:1057,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:138675,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MZJF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fbab461-c7e2-42f5-a1be-4c299de5551b_1057x839.png 424w, https://substackcdn.com/image/fetch/$s_!MZJF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fbab461-c7e2-42f5-a1be-4c299de5551b_1057x839.png 848w, https://substackcdn.com/image/fetch/$s_!MZJF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fbab461-c7e2-42f5-a1be-4c299de5551b_1057x839.png 1272w, https://substackcdn.com/image/fetch/$s_!MZJF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fbab461-c7e2-42f5-a1be-4c299de5551b_1057x839.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></figure></div><p>The above equation tells us that when we take the total net magnetic flux over a closed surface area, we&#8217;ll always get 0. We can think of magnetic flux going through a surface as always being a two-way street: any outward flux going out of the surface will always be balanced by an inward flux going into it! The equal amounts of outward (positive) flux and inward (negative) flux will always cancel, and we&#8217;ll always end up with a net amount of magnetic flux which equals zero.</p><p>As a note, although we always use the example of having an enclosed spherical surface, the above principle applies to any closed surface which we may place within a field! It could be a cube, sphere, torus: any surface which magnetic flux lines penetrate will always be balanced and will always equate to zero!! The same principle and concept applies to electric fields, except that whichever enclosed surface we choose to use, we&#8217;ll always get a net electric flux which equates to the net amount of charge present <strong>within</strong> the surface!</p><p>Noting the above, we&#8217;re now ready to show the meaning of our last 2 equations, which describe the complementary nature of our two fields! The equations tell us that a time-varying magnetic field produces a spatially varying electric field, and vice versa.</p><h3><strong>Faraday&#8217;s Law</strong></h3><p>Faraday&#8217;s law tells us that a changing magnetic field induces an electric field:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-x79!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37171b95-8e47-4a61-9cfa-28a7e9e193a1_823x529.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-x79!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37171b95-8e47-4a61-9cfa-28a7e9e193a1_823x529.png 424w, https://substackcdn.com/image/fetch/$s_!-x79!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37171b95-8e47-4a61-9cfa-28a7e9e193a1_823x529.png 848w, https://substackcdn.com/image/fetch/$s_!-x79!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37171b95-8e47-4a61-9cfa-28a7e9e193a1_823x529.png 1272w, https://substackcdn.com/image/fetch/$s_!-x79!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37171b95-8e47-4a61-9cfa-28a7e9e193a1_823x529.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-x79!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37171b95-8e47-4a61-9cfa-28a7e9e193a1_823x529.png" width="547" height="351.59538274605103" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/37171b95-8e47-4a61-9cfa-28a7e9e193a1_823x529.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:529,&quot;width&quot;:823,&quot;resizeWidth&quot;:547,&quot;bytes&quot;:48623,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-x79!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37171b95-8e47-4a61-9cfa-28a7e9e193a1_823x529.png 424w, https://substackcdn.com/image/fetch/$s_!-x79!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37171b95-8e47-4a61-9cfa-28a7e9e193a1_823x529.png 848w, https://substackcdn.com/image/fetch/$s_!-x79!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37171b95-8e47-4a61-9cfa-28a7e9e193a1_823x529.png 1272w, https://substackcdn.com/image/fetch/$s_!-x79!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37171b95-8e47-4a61-9cfa-28a7e9e193a1_823x529.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></figure></div><p>The above equation reads: "A circulating electric field is produced by a magnetic field<br>that changes with time. The direction of the circulating electric field which is generated opposes the magnetic flux.&#8221;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!oXO2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0677eb1f-cd97-4cc3-8021-56053b9d321b_257x270.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!oXO2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0677eb1f-cd97-4cc3-8021-56053b9d321b_257x270.png 424w, https://substackcdn.com/image/fetch/$s_!oXO2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0677eb1f-cd97-4cc3-8021-56053b9d321b_257x270.png 848w, https://substackcdn.com/image/fetch/$s_!oXO2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0677eb1f-cd97-4cc3-8021-56053b9d321b_257x270.png 1272w, https://substackcdn.com/image/fetch/$s_!oXO2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0677eb1f-cd97-4cc3-8021-56053b9d321b_257x270.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!oXO2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0677eb1f-cd97-4cc3-8021-56053b9d321b_257x270.png" width="259" height="272.1011673151751" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0677eb1f-cd97-4cc3-8021-56053b9d321b_257x270.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:270,&quot;width&quot;:257,&quot;resizeWidth&quot;:259,&quot;bytes&quot;:5821,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!oXO2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0677eb1f-cd97-4cc3-8021-56053b9d321b_257x270.png 424w, https://substackcdn.com/image/fetch/$s_!oXO2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0677eb1f-cd97-4cc3-8021-56053b9d321b_257x270.png 848w, https://substackcdn.com/image/fetch/$s_!oXO2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0677eb1f-cd97-4cc3-8021-56053b9d321b_257x270.png 1272w, https://substackcdn.com/image/fetch/$s_!oXO2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0677eb1f-cd97-4cc3-8021-56053b9d321b_257x270.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></figure></div><p>In terms of curl, this means that as the magnetic flux increases, it generates a circulating electric field in the clockwise direction. If it decreases, the generated electric field is in the counterclockwise direction.</p><p>We can get a good intuition of this by looking at our diagrams 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_!pP6W!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F899744e3-96ae-4075-9473-990addf5c410_1062x711.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pP6W!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F899744e3-96ae-4075-9473-990addf5c410_1062x711.png 424w, https://substackcdn.com/image/fetch/$s_!pP6W!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F899744e3-96ae-4075-9473-990addf5c410_1062x711.png 848w, https://substackcdn.com/image/fetch/$s_!pP6W!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F899744e3-96ae-4075-9473-990addf5c410_1062x711.png 1272w, https://substackcdn.com/image/fetch/$s_!pP6W!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F899744e3-96ae-4075-9473-990addf5c410_1062x711.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pP6W!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F899744e3-96ae-4075-9473-990addf5c410_1062x711.png" width="479" height="320.6864406779661" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/899744e3-96ae-4075-9473-990addf5c410_1062x711.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:711,&quot;width&quot;:1062,&quot;resizeWidth&quot;:479,&quot;bytes&quot;:155884,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!pP6W!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F899744e3-96ae-4075-9473-990addf5c410_1062x711.png 424w, https://substackcdn.com/image/fetch/$s_!pP6W!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F899744e3-96ae-4075-9473-990addf5c410_1062x711.png 848w, https://substackcdn.com/image/fetch/$s_!pP6W!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F899744e3-96ae-4075-9473-990addf5c410_1062x711.png 1272w, https://substackcdn.com/image/fetch/$s_!pP6W!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F899744e3-96ae-4075-9473-990addf5c410_1062x711.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></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!VTBB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7f60b-a119-4c37-bc0a-9a12b5fbacb2_1037x683.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VTBB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7f60b-a119-4c37-bc0a-9a12b5fbacb2_1037x683.png 424w, https://substackcdn.com/image/fetch/$s_!VTBB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7f60b-a119-4c37-bc0a-9a12b5fbacb2_1037x683.png 848w, https://substackcdn.com/image/fetch/$s_!VTBB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7f60b-a119-4c37-bc0a-9a12b5fbacb2_1037x683.png 1272w, https://substackcdn.com/image/fetch/$s_!VTBB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7f60b-a119-4c37-bc0a-9a12b5fbacb2_1037x683.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!VTBB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7f60b-a119-4c37-bc0a-9a12b5fbacb2_1037x683.png" width="475" height="312.84956605593055" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e0b7f60b-a119-4c37-bc0a-9a12b5fbacb2_1037x683.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:683,&quot;width&quot;:1037,&quot;resizeWidth&quot;:475,&quot;bytes&quot;:148474,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!VTBB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7f60b-a119-4c37-bc0a-9a12b5fbacb2_1037x683.png 424w, https://substackcdn.com/image/fetch/$s_!VTBB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7f60b-a119-4c37-bc0a-9a12b5fbacb2_1037x683.png 848w, https://substackcdn.com/image/fetch/$s_!VTBB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7f60b-a119-4c37-bc0a-9a12b5fbacb2_1037x683.png 1272w, https://substackcdn.com/image/fetch/$s_!VTBB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0b7f60b-a119-4c37-bc0a-9a12b5fbacb2_1037x683.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></figure></div><p>In essence, the above behavior encapsulates the basic relationship we already outlined. The more quickly the magnetic field increases in a certain direction, the more strongly the electric field will curl against it (the &#8220;against&#8221; bit of this statement also has its own name, and is called Lenz&#8217;s law).</p><p>Another diagram which illustrates how our changing field opposes the change in flux 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_!I8n7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca9d5d4-5b4e-48c4-9923-eef634f72a13_467x487.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!I8n7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca9d5d4-5b4e-48c4-9923-eef634f72a13_467x487.png 424w, https://substackcdn.com/image/fetch/$s_!I8n7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca9d5d4-5b4e-48c4-9923-eef634f72a13_467x487.png 848w, https://substackcdn.com/image/fetch/$s_!I8n7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca9d5d4-5b4e-48c4-9923-eef634f72a13_467x487.png 1272w, https://substackcdn.com/image/fetch/$s_!I8n7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca9d5d4-5b4e-48c4-9923-eef634f72a13_467x487.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!I8n7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca9d5d4-5b4e-48c4-9923-eef634f72a13_467x487.png" width="295" height="307.6338329764454" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bca9d5d4-5b4e-48c4-9923-eef634f72a13_467x487.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:487,&quot;width&quot;:467,&quot;resizeWidth&quot;:295,&quot;bytes&quot;:34996,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!I8n7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca9d5d4-5b4e-48c4-9923-eef634f72a13_467x487.png 424w, https://substackcdn.com/image/fetch/$s_!I8n7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca9d5d4-5b4e-48c4-9923-eef634f72a13_467x487.png 848w, https://substackcdn.com/image/fetch/$s_!I8n7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca9d5d4-5b4e-48c4-9923-eef634f72a13_467x487.png 1272w, https://substackcdn.com/image/fetch/$s_!I8n7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbca9d5d4-5b4e-48c4-9923-eef634f72a13_467x487.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></figure></div><p>In the above illustration, the circulating electric field which is induced and flows within the ring circulates in a direction such that the magnetic field it produces (represented by the dashed lines) opposes the increase in flux through the ring. We thus have a counter-balancing electric field which is generated any time we have a change in magnetic flux!</p><p>We must note once again that although the electric field induced through Faraday&#8217;s law has the same properties as our regular electric field, the resulting structure of this circulating field definitely differs from what we&#8217;re usually used to seeing when it comes to electric fields! We noted earlier that we could always think of the electric fields as originating from a source points (which we call positive charges) and as terminating at sink points (which we call negative charges). These charge-based fields always seem to have a source and sink (and thus, a non-zero divergence at those points)! In other words, in these instances, we could think of point charges as being the originators of the electric field. Now, with our new law, it seems that we have an induced field which doesn&#8217;t have an origin!</p><p>With Faraday&#8217;s law, we have induced electric fields which have field lines that loop back on themselves, with no points of origination or termination. Our induced field therefore has a divergence of zero! So, once again, we note that the resulting electric field is simply a circulating field which loops in around itself (thus, resulting in a net curl which opposes a magnetic field)! We can picture a simple 2-dimensional circulating electric field using the diagram 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_!evKN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd868742f-52f3-453f-b716-e70a7076750b_451x378.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!evKN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd868742f-52f3-453f-b716-e70a7076750b_451x378.png 424w, https://substackcdn.com/image/fetch/$s_!evKN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd868742f-52f3-453f-b716-e70a7076750b_451x378.png 848w, https://substackcdn.com/image/fetch/$s_!evKN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd868742f-52f3-453f-b716-e70a7076750b_451x378.png 1272w, https://substackcdn.com/image/fetch/$s_!evKN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd868742f-52f3-453f-b716-e70a7076750b_451x378.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!evKN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd868742f-52f3-453f-b716-e70a7076750b_451x378.png" width="363" height="304.2439024390244" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d868742f-52f3-453f-b716-e70a7076750b_451x378.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:378,&quot;width&quot;:451,&quot;resizeWidth&quot;:363,&quot;bytes&quot;:91631,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!evKN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd868742f-52f3-453f-b716-e70a7076750b_451x378.png 424w, https://substackcdn.com/image/fetch/$s_!evKN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd868742f-52f3-453f-b716-e70a7076750b_451x378.png 848w, https://substackcdn.com/image/fetch/$s_!evKN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd868742f-52f3-453f-b716-e70a7076750b_451x378.png 1272w, https://substackcdn.com/image/fetch/$s_!evKN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd868742f-52f3-453f-b716-e70a7076750b_451x378.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></figure></div><p>We note that since these changing magnetic fields are capable of inducing electric fields with closed loops, they&#8217;re also capable of driving charged particles around continuous circuits. We already demonstrated this in our diagrams, when we tried to show how the induced fields opposed the changing flux, but this also means that we can use Faraday&#8217;s law to create currents / generators and convert mechanical energy into electrical energy, so this law plays a central importance in our everyday lives! It&#8217;s what makes generators and conversion of mechanical energy into electrical energy possible!</p><p>Let&#8217;s present Faraday&#8217;s law in its integral form. Although it may look a lot more complex than our differential formulation, it essentially states the same thing!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!F_N5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a3851a7-4082-4463-9cc0-0caea2018a62_725x666.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!F_N5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a3851a7-4082-4463-9cc0-0caea2018a62_725x666.png 424w, https://substackcdn.com/image/fetch/$s_!F_N5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a3851a7-4082-4463-9cc0-0caea2018a62_725x666.png 848w, https://substackcdn.com/image/fetch/$s_!F_N5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a3851a7-4082-4463-9cc0-0caea2018a62_725x666.png 1272w, https://substackcdn.com/image/fetch/$s_!F_N5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a3851a7-4082-4463-9cc0-0caea2018a62_725x666.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!F_N5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a3851a7-4082-4463-9cc0-0caea2018a62_725x666.png" width="665" height="610.8827586206896" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1a3851a7-4082-4463-9cc0-0caea2018a62_725x666.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:666,&quot;width&quot;:725,&quot;resizeWidth&quot;:665,&quot;bytes&quot;:91452,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!F_N5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a3851a7-4082-4463-9cc0-0caea2018a62_725x666.png 424w, https://substackcdn.com/image/fetch/$s_!F_N5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a3851a7-4082-4463-9cc0-0caea2018a62_725x666.png 848w, https://substackcdn.com/image/fetch/$s_!F_N5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a3851a7-4082-4463-9cc0-0caea2018a62_725x666.png 1272w, https://substackcdn.com/image/fetch/$s_!F_N5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a3851a7-4082-4463-9cc0-0caea2018a62_725x666.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></figure></div><p>The left hand side of our equation represents the line integral of an enclosed electric field, which we also call the circulation of the field.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!O6b-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74ca4b56-3426-4c0c-93d8-5d1c2ed12ea9_408x282.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!O6b-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74ca4b56-3426-4c0c-93d8-5d1c2ed12ea9_408x282.png 424w, https://substackcdn.com/image/fetch/$s_!O6b-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74ca4b56-3426-4c0c-93d8-5d1c2ed12ea9_408x282.png 848w, https://substackcdn.com/image/fetch/$s_!O6b-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74ca4b56-3426-4c0c-93d8-5d1c2ed12ea9_408x282.png 1272w, https://substackcdn.com/image/fetch/$s_!O6b-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74ca4b56-3426-4c0c-93d8-5d1c2ed12ea9_408x282.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!O6b-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74ca4b56-3426-4c0c-93d8-5d1c2ed12ea9_408x282.png" width="356" height="246.05882352941177" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/74ca4b56-3426-4c0c-93d8-5d1c2ed12ea9_408x282.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:282,&quot;width&quot;:408,&quot;resizeWidth&quot;:356,&quot;bytes&quot;:15964,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!O6b-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74ca4b56-3426-4c0c-93d8-5d1c2ed12ea9_408x282.png 424w, https://substackcdn.com/image/fetch/$s_!O6b-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74ca4b56-3426-4c0c-93d8-5d1c2ed12ea9_408x282.png 848w, https://substackcdn.com/image/fetch/$s_!O6b-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74ca4b56-3426-4c0c-93d8-5d1c2ed12ea9_408x282.png 1272w, https://substackcdn.com/image/fetch/$s_!O6b-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F74ca4b56-3426-4c0c-93d8-5d1c2ed12ea9_408x282.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></figure></div><p>What exactly does the circulation represent? Well, since our induced electric field is capable of generating a current by moving a charge (or charges) around a loop, we can think of the circulation as representing the work done by the electric field in moving a unit charge around the closed path (C). We also call this the <strong>electromotive force</strong>.<strong> </strong>We can note that this term is is adjacent to what we term as the curl<strong> </strong>of the generated electric field in our differential form of Faraday&#8217;s law.</p><p>The right hand side of the equation represents the rate of change of magnetic flux. Here, we simply take a sum total of tiny surface area segments denoted by da:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!S5bJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685a246a-2b68-4b74-bb5c-5ec87260ee20_737x443.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!S5bJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685a246a-2b68-4b74-bb5c-5ec87260ee20_737x443.png 424w, https://substackcdn.com/image/fetch/$s_!S5bJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685a246a-2b68-4b74-bb5c-5ec87260ee20_737x443.png 848w, https://substackcdn.com/image/fetch/$s_!S5bJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685a246a-2b68-4b74-bb5c-5ec87260ee20_737x443.png 1272w, https://substackcdn.com/image/fetch/$s_!S5bJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685a246a-2b68-4b74-bb5c-5ec87260ee20_737x443.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!S5bJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685a246a-2b68-4b74-bb5c-5ec87260ee20_737x443.png" width="657" height="394.91316146540026" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/685a246a-2b68-4b74-bb5c-5ec87260ee20_737x443.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:443,&quot;width&quot;:737,&quot;resizeWidth&quot;:657,&quot;bytes&quot;:74885,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!S5bJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685a246a-2b68-4b74-bb5c-5ec87260ee20_737x443.png 424w, https://substackcdn.com/image/fetch/$s_!S5bJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685a246a-2b68-4b74-bb5c-5ec87260ee20_737x443.png 848w, https://substackcdn.com/image/fetch/$s_!S5bJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685a246a-2b68-4b74-bb5c-5ec87260ee20_737x443.png 1272w, https://substackcdn.com/image/fetch/$s_!S5bJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F685a246a-2b68-4b74-bb5c-5ec87260ee20_737x443.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></figure></div><p>We thus have the integral form for what we deemed as the total change in flux over the area, and the negative sign in our equation simply denotes the fact that our circulating electric field opposes the flux.</p><p>Our above equation thus has the same meaning as the equation in its differential form: a changing magnetic field / flux induces a circulating electric field which opposes the flux!</p><p>We thus end our presentation of Faraday&#8217;s law and move onto the last equation, which is the Ampere-Maxwell law!</p><h3><strong>Ampere-Maxwell Law</strong></h3><p>In a similar manner as to our first curl relation which expressed Faraday&#8217;s Law and stated that a changing magnetic field produced a circulating electric field, the last equation tells us that an electric current or a changing electric field (or both) induce a magnetic field!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TR6g!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2979a805-d98a-40ae-92c8-46a217c45957_769x629.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TR6g!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2979a805-d98a-40ae-92c8-46a217c45957_769x629.png 424w, https://substackcdn.com/image/fetch/$s_!TR6g!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2979a805-d98a-40ae-92c8-46a217c45957_769x629.png 848w, https://substackcdn.com/image/fetch/$s_!TR6g!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2979a805-d98a-40ae-92c8-46a217c45957_769x629.png 1272w, https://substackcdn.com/image/fetch/$s_!TR6g!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2979a805-d98a-40ae-92c8-46a217c45957_769x629.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TR6g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2979a805-d98a-40ae-92c8-46a217c45957_769x629.png" width="499" height="408.1547464239272" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2979a805-d98a-40ae-92c8-46a217c45957_769x629.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:629,&quot;width&quot;:769,&quot;resizeWidth&quot;:499,&quot;bytes&quot;:75141,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TR6g!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2979a805-d98a-40ae-92c8-46a217c45957_769x629.png 424w, https://substackcdn.com/image/fetch/$s_!TR6g!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2979a805-d98a-40ae-92c8-46a217c45957_769x629.png 848w, https://substackcdn.com/image/fetch/$s_!TR6g!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2979a805-d98a-40ae-92c8-46a217c45957_769x629.png 1272w, https://substackcdn.com/image/fetch/$s_!TR6g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2979a805-d98a-40ae-92c8-46a217c45957_769x629.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></figure></div><p>The left side of this equation is a mathematical description of the curl of the magnetic field while the two terms on the right side represent the electric current density and the time rate of change of the electric field. The equation essentially states that &#8220;An electric current or a changing electric field induce a circulating magnetic field.&#8221;</p><p>What does this mean exactly? And how can we picture the induced magnetic field?</p><p>We can capture this through a simple visual shown below, which show a circulating magnetic field produced by a moving electric current I:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Pf9a!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f07dc80-2ea2-455a-9d83-68f56a5c76f1_646x371.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Pf9a!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f07dc80-2ea2-455a-9d83-68f56a5c76f1_646x371.png 424w, https://substackcdn.com/image/fetch/$s_!Pf9a!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f07dc80-2ea2-455a-9d83-68f56a5c76f1_646x371.png 848w, https://substackcdn.com/image/fetch/$s_!Pf9a!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f07dc80-2ea2-455a-9d83-68f56a5c76f1_646x371.png 1272w, https://substackcdn.com/image/fetch/$s_!Pf9a!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f07dc80-2ea2-455a-9d83-68f56a5c76f1_646x371.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Pf9a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f07dc80-2ea2-455a-9d83-68f56a5c76f1_646x371.png" width="482" height="276.8142414860681" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3f07dc80-2ea2-455a-9d83-68f56a5c76f1_646x371.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:371,&quot;width&quot;:646,&quot;resizeWidth&quot;:482,&quot;bytes&quot;:44694,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Pf9a!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f07dc80-2ea2-455a-9d83-68f56a5c76f1_646x371.png 424w, https://substackcdn.com/image/fetch/$s_!Pf9a!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f07dc80-2ea2-455a-9d83-68f56a5c76f1_646x371.png 848w, https://substackcdn.com/image/fetch/$s_!Pf9a!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f07dc80-2ea2-455a-9d83-68f56a5c76f1_646x371.png 1272w, https://substackcdn.com/image/fetch/$s_!Pf9a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f07dc80-2ea2-455a-9d83-68f56a5c76f1_646x371.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></figure></div><p>The left hand sign of our equation simply expresses the curl of the magnetic field. The magnetic field, unlike the electric field, doesn&#8217;t have any &#8216;sources&#8217; or &#8216;sinks,&#8217; and there are no magnetic charges which can be used to produce them. All magnetic fields are therefore circulating fields: they always loop back upon themselves. We&#8217;ve already encountered circulating loops in our Faraday&#8217;s equation, which expressed a similar concept in relation to induced electric fields and which used a curl function to express this relationship. Here, we simply use the curl as an expression for the circulating magnetic field, and the equation states that this field is induced through one of <strong>two</strong> conditions:</p><p>1. <strong>An electric current</strong>: this is the first term expressed to the right of our equation, which we denoted as <strong>J</strong> and which denotes the electric current density<strong>.</strong></p><p>Prior to defining density though, we need to establish what an electric current is: an electric current is simply the rate of flow of electrical charge across some defined cross-sectional area. The &#8220;rate of flow&#8221; of charge represents the charge over time (charge/time). This calculation gives you the number of coulombs that go past a point in a second within an electrical circuit.</p><p>A lot of people like to associate currents with a flow of electrons present within a wire, but we must note that this view isn&#8217;t as simple as it seems: a current isn&#8217;t just a movement of charged particles, like electrons in a wire! "Electric charge" is not a "thing". It is a property of other things, like electrons and protons. In fact, we don&#8217;t need moving charges to produce an electrical current! We could have things which act like electric currents with no physical movement involved! We don&#8217;t have time to discuss the full extent of this. For now, we simply note that a current doesn&#8217;t necessarily equate to moving electrons!</p><p>Now, imagine that we have a current flowing into the page. The induced and circulating magnetic field produced by such a current is visualized 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_!iRk0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1078e01-e6f6-4515-bc0b-d2996d5977a2_619x359.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iRk0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1078e01-e6f6-4515-bc0b-d2996d5977a2_619x359.png 424w, https://substackcdn.com/image/fetch/$s_!iRk0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1078e01-e6f6-4515-bc0b-d2996d5977a2_619x359.png 848w, https://substackcdn.com/image/fetch/$s_!iRk0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1078e01-e6f6-4515-bc0b-d2996d5977a2_619x359.png 1272w, https://substackcdn.com/image/fetch/$s_!iRk0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1078e01-e6f6-4515-bc0b-d2996d5977a2_619x359.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iRk0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1078e01-e6f6-4515-bc0b-d2996d5977a2_619x359.png" width="493" height="285.924071082391" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f1078e01-e6f6-4515-bc0b-d2996d5977a2_619x359.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:359,&quot;width&quot;:619,&quot;resizeWidth&quot;:493,&quot;bytes&quot;:30594,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!iRk0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1078e01-e6f6-4515-bc0b-d2996d5977a2_619x359.png 424w, https://substackcdn.com/image/fetch/$s_!iRk0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1078e01-e6f6-4515-bc0b-d2996d5977a2_619x359.png 848w, https://substackcdn.com/image/fetch/$s_!iRk0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1078e01-e6f6-4515-bc0b-d2996d5977a2_619x359.png 1272w, https://substackcdn.com/image/fetch/$s_!iRk0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1078e01-e6f6-4515-bc0b-d2996d5977a2_619x359.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></figure></div><p>We can see that in the above diagram, our induced magnetic field curls in the direction of our current, and we can use the right-hand rule to get a clear conception of this. Imagine that the electric current is flowing out of the page, and place your hand on top of the paper / page. If you point your thumb upwards, you can now get a clear picture of the direction of the induced circulating magnetic field, which 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_!F5_u!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb6f453b-9aa8-4a67-abe2-c4a695d51f6f_946x417.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!F5_u!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb6f453b-9aa8-4a67-abe2-c4a695d51f6f_946x417.png 424w, https://substackcdn.com/image/fetch/$s_!F5_u!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb6f453b-9aa8-4a67-abe2-c4a695d51f6f_946x417.png 848w, https://substackcdn.com/image/fetch/$s_!F5_u!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb6f453b-9aa8-4a67-abe2-c4a695d51f6f_946x417.png 1272w, https://substackcdn.com/image/fetch/$s_!F5_u!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb6f453b-9aa8-4a67-abe2-c4a695d51f6f_946x417.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!F5_u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb6f453b-9aa8-4a67-abe2-c4a695d51f6f_946x417.png" width="946" height="417" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bb6f453b-9aa8-4a67-abe2-c4a695d51f6f_946x417.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:417,&quot;width&quot;:946,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:93280,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!F5_u!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb6f453b-9aa8-4a67-abe2-c4a695d51f6f_946x417.png 424w, https://substackcdn.com/image/fetch/$s_!F5_u!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb6f453b-9aa8-4a67-abe2-c4a695d51f6f_946x417.png 848w, https://substackcdn.com/image/fetch/$s_!F5_u!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb6f453b-9aa8-4a67-abe2-c4a695d51f6f_946x417.png 1272w, https://substackcdn.com/image/fetch/$s_!F5_u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb6f453b-9aa8-4a67-abe2-c4a695d51f6f_946x417.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></figure></div><p>Let&#8217;s also try to visualize the precise mathematical meaning behind the electric current density (J). The current density is defined as the current flowing through a unit cross-sectional area perpendicular to the direction of the current. In other words: it measures the amount of charge passing through the imaginary 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_!2Qv8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d60a97f-b8c0-47c5-ac0a-cca8f69871fd_1032x430.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2Qv8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d60a97f-b8c0-47c5-ac0a-cca8f69871fd_1032x430.png 424w, https://substackcdn.com/image/fetch/$s_!2Qv8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d60a97f-b8c0-47c5-ac0a-cca8f69871fd_1032x430.png 848w, https://substackcdn.com/image/fetch/$s_!2Qv8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d60a97f-b8c0-47c5-ac0a-cca8f69871fd_1032x430.png 1272w, https://substackcdn.com/image/fetch/$s_!2Qv8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d60a97f-b8c0-47c5-ac0a-cca8f69871fd_1032x430.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2Qv8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d60a97f-b8c0-47c5-ac0a-cca8f69871fd_1032x430.png" width="669" height="278.75" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1d60a97f-b8c0-47c5-ac0a-cca8f69871fd_1032x430.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:430,&quot;width&quot;:1032,&quot;resizeWidth&quot;:669,&quot;bytes&quot;:49950,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!2Qv8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d60a97f-b8c0-47c5-ac0a-cca8f69871fd_1032x430.png 424w, https://substackcdn.com/image/fetch/$s_!2Qv8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d60a97f-b8c0-47c5-ac0a-cca8f69871fd_1032x430.png 848w, https://substackcdn.com/image/fetch/$s_!2Qv8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d60a97f-b8c0-47c5-ac0a-cca8f69871fd_1032x430.png 1272w, https://substackcdn.com/image/fetch/$s_!2Qv8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d60a97f-b8c0-47c5-ac0a-cca8f69871fd_1032x430.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></figure></div><p>We thus have our first condition for inducing a magnetic field: an electric current / current density!</p><p>2. <strong>Changing electric field with respect to time</strong>: this is the second component (&#8706;E/&#8706;t) within the Ampere-Maxwell equation.</p><p>One question which you may ask is: well, if a changing electric field produces a circulating magnetic field, why do we need to separate terms to express this relationship? Couldn&#8217;t we tie our first component in with our second component and express the Ampere-Maxwell equation in terms of the electric currents only?</p><p>The answer to that questions is <strong>no.</strong> We don&#8217;t need a flowing current to produce a magnetic field! A changing electric field produces a changing magnetic field, even when no charges are present and where we might not have any physical current flow! The second expression in our equation expresses this fact!</p><p>Finally, let&#8217;s re-iterate our 2 conditions once again to summarize the equation: an electric current <strong>or </strong>a changing electric field are capable of generating a circulating magnetic field!</p><p>Let&#8217;s show one more visual illustrating this concept. To do so, we use a solenoid, which is a coil of wire wrapped in a cylindrical manner and which can be used to generate a magnetic field:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!B77D!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b3fdb13-76c0-43c0-9a6c-4d0d8f908cfc_237x135.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!B77D!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b3fdb13-76c0-43c0-9a6c-4d0d8f908cfc_237x135.png 424w, https://substackcdn.com/image/fetch/$s_!B77D!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b3fdb13-76c0-43c0-9a6c-4d0d8f908cfc_237x135.png 848w, https://substackcdn.com/image/fetch/$s_!B77D!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b3fdb13-76c0-43c0-9a6c-4d0d8f908cfc_237x135.png 1272w, https://substackcdn.com/image/fetch/$s_!B77D!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b3fdb13-76c0-43c0-9a6c-4d0d8f908cfc_237x135.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!B77D!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b3fdb13-76c0-43c0-9a6c-4d0d8f908cfc_237x135.png" width="237" height="135" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9b3fdb13-76c0-43c0-9a6c-4d0d8f908cfc_237x135.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:135,&quot;width&quot;:237,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:9495,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!B77D!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b3fdb13-76c0-43c0-9a6c-4d0d8f908cfc_237x135.png 424w, https://substackcdn.com/image/fetch/$s_!B77D!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b3fdb13-76c0-43c0-9a6c-4d0d8f908cfc_237x135.png 848w, https://substackcdn.com/image/fetch/$s_!B77D!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b3fdb13-76c0-43c0-9a6c-4d0d8f908cfc_237x135.png 1272w, https://substackcdn.com/image/fetch/$s_!B77D!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b3fdb13-76c0-43c0-9a6c-4d0d8f908cfc_237x135.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Because our wire is wrapped in such a manner, the resulting magnetic field generates a flux which passes through our coils and circulates around our solenoid, resulting in a magnet!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!EI7I!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2964364b-f31a-4917-b626-a63e26e908f5_768x519.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!EI7I!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2964364b-f31a-4917-b626-a63e26e908f5_768x519.png 424w, https://substackcdn.com/image/fetch/$s_!EI7I!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2964364b-f31a-4917-b626-a63e26e908f5_768x519.png 848w, https://substackcdn.com/image/fetch/$s_!EI7I!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2964364b-f31a-4917-b626-a63e26e908f5_768x519.png 1272w, https://substackcdn.com/image/fetch/$s_!EI7I!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2964364b-f31a-4917-b626-a63e26e908f5_768x519.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!EI7I!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2964364b-f31a-4917-b626-a63e26e908f5_768x519.png" width="513" height="346.67578125" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2964364b-f31a-4917-b626-a63e26e908f5_768x519.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:519,&quot;width&quot;:768,&quot;resizeWidth&quot;:513,&quot;bytes&quot;:93422,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!EI7I!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2964364b-f31a-4917-b626-a63e26e908f5_768x519.png 424w, https://substackcdn.com/image/fetch/$s_!EI7I!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2964364b-f31a-4917-b626-a63e26e908f5_768x519.png 848w, https://substackcdn.com/image/fetch/$s_!EI7I!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2964364b-f31a-4917-b626-a63e26e908f5_768x519.png 1272w, https://substackcdn.com/image/fetch/$s_!EI7I!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2964364b-f31a-4917-b626-a63e26e908f5_768x519.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></figure></div><p>We now express the Ampere-Maxwell law in integral notation:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GZ33!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b48aedd-cb18-49aa-a13a-7e002ef5661b_1023x693.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GZ33!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b48aedd-cb18-49aa-a13a-7e002ef5661b_1023x693.png 424w, https://substackcdn.com/image/fetch/$s_!GZ33!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b48aedd-cb18-49aa-a13a-7e002ef5661b_1023x693.png 848w, https://substackcdn.com/image/fetch/$s_!GZ33!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b48aedd-cb18-49aa-a13a-7e002ef5661b_1023x693.png 1272w, https://substackcdn.com/image/fetch/$s_!GZ33!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b48aedd-cb18-49aa-a13a-7e002ef5661b_1023x693.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GZ33!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b48aedd-cb18-49aa-a13a-7e002ef5661b_1023x693.png" width="1023" height="693" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0b48aedd-cb18-49aa-a13a-7e002ef5661b_1023x693.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:693,&quot;width&quot;:1023,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:119958,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GZ33!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b48aedd-cb18-49aa-a13a-7e002ef5661b_1023x693.png 424w, https://substackcdn.com/image/fetch/$s_!GZ33!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b48aedd-cb18-49aa-a13a-7e002ef5661b_1023x693.png 848w, https://substackcdn.com/image/fetch/$s_!GZ33!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b48aedd-cb18-49aa-a13a-7e002ef5661b_1023x693.png 1272w, https://substackcdn.com/image/fetch/$s_!GZ33!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b48aedd-cb18-49aa-a13a-7e002ef5661b_1023x693.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></figure></div><p>We can once again state that the equation in integral form has the same exact meaning as the equation in differential form. Essentially, we replace the curl with a line integral of an enclosed magnetic path, and instead of using the electric current density and the rate of change in the electric field with respect to time, we now use the enclosed electric current and the rate of change of electric flux!</p><p>We should already know what the first term in the equation relates to: we simply take line integral of the enclosed magnetic field to encapsulate its circulation / curl:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!evEf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895c3504-2872-4786-be05-b8a74e5250be_481x299.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!evEf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895c3504-2872-4786-be05-b8a74e5250be_481x299.png 424w, https://substackcdn.com/image/fetch/$s_!evEf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895c3504-2872-4786-be05-b8a74e5250be_481x299.png 848w, https://substackcdn.com/image/fetch/$s_!evEf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895c3504-2872-4786-be05-b8a74e5250be_481x299.png 1272w, https://substackcdn.com/image/fetch/$s_!evEf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895c3504-2872-4786-be05-b8a74e5250be_481x299.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!evEf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895c3504-2872-4786-be05-b8a74e5250be_481x299.png" width="375" height="233.1081081081081" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/895c3504-2872-4786-be05-b8a74e5250be_481x299.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:299,&quot;width&quot;:481,&quot;resizeWidth&quot;:375,&quot;bytes&quot;:13349,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!evEf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895c3504-2872-4786-be05-b8a74e5250be_481x299.png 424w, https://substackcdn.com/image/fetch/$s_!evEf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895c3504-2872-4786-be05-b8a74e5250be_481x299.png 848w, https://substackcdn.com/image/fetch/$s_!evEf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895c3504-2872-4786-be05-b8a74e5250be_481x299.png 1272w, https://substackcdn.com/image/fetch/$s_!evEf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895c3504-2872-4786-be05-b8a74e5250be_481x299.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We should also take note that the above relation implies that the inverse square law for magnetic fields! That is, if we were to take a current going through a wire and measure the magnetic field which it produced, we would notice that the strength of the magnetic field which circles around the wire gets weaker by a factor of around 1 / distance<sup>2</sup> as we move further from the current!</p><p>Let&#8217;s move on to the right side of the equation. The diagram below shows what the <strong>first</strong> term (<em>I</em><sub>enc</sub>) relates to:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!u7JA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c380812-3cac-4c2c-9545-314f2ec9a0e8_404x406.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!u7JA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c380812-3cac-4c2c-9545-314f2ec9a0e8_404x406.png 424w, https://substackcdn.com/image/fetch/$s_!u7JA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c380812-3cac-4c2c-9545-314f2ec9a0e8_404x406.png 848w, https://substackcdn.com/image/fetch/$s_!u7JA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c380812-3cac-4c2c-9545-314f2ec9a0e8_404x406.png 1272w, https://substackcdn.com/image/fetch/$s_!u7JA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c380812-3cac-4c2c-9545-314f2ec9a0e8_404x406.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!u7JA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c380812-3cac-4c2c-9545-314f2ec9a0e8_404x406.png" width="298" height="299.4752475247525" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5c380812-3cac-4c2c-9545-314f2ec9a0e8_404x406.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:406,&quot;width&quot;:404,&quot;resizeWidth&quot;:298,&quot;bytes&quot;:15412,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!u7JA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c380812-3cac-4c2c-9545-314f2ec9a0e8_404x406.png 424w, https://substackcdn.com/image/fetch/$s_!u7JA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c380812-3cac-4c2c-9545-314f2ec9a0e8_404x406.png 848w, https://substackcdn.com/image/fetch/$s_!u7JA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c380812-3cac-4c2c-9545-314f2ec9a0e8_404x406.png 1272w, https://substackcdn.com/image/fetch/$s_!u7JA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c380812-3cac-4c2c-9545-314f2ec9a0e8_404x406.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></figure></div><p>We can see that in our above example, we have an enclosed current with a net flow going through our surface. To be exact: we have a current I which penetrates the surface (S) at only one point, so in this instance, we have an enclosed current of +<em>I</em>.</p><p>What would happen if we were to create a loop such that the current flowed backwards through our enclosed 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_!hhO5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dde20de-9e52-4c21-adaa-bf500a5889c2_322x445.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hhO5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dde20de-9e52-4c21-adaa-bf500a5889c2_322x445.png 424w, https://substackcdn.com/image/fetch/$s_!hhO5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dde20de-9e52-4c21-adaa-bf500a5889c2_322x445.png 848w, https://substackcdn.com/image/fetch/$s_!hhO5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dde20de-9e52-4c21-adaa-bf500a5889c2_322x445.png 1272w, https://substackcdn.com/image/fetch/$s_!hhO5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dde20de-9e52-4c21-adaa-bf500a5889c2_322x445.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hhO5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dde20de-9e52-4c21-adaa-bf500a5889c2_322x445.png" width="198" height="273.6335403726708" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7dde20de-9e52-4c21-adaa-bf500a5889c2_322x445.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:445,&quot;width&quot;:322,&quot;resizeWidth&quot;:198,&quot;bytes&quot;:15560,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hhO5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dde20de-9e52-4c21-adaa-bf500a5889c2_322x445.png 424w, https://substackcdn.com/image/fetch/$s_!hhO5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dde20de-9e52-4c21-adaa-bf500a5889c2_322x445.png 848w, https://substackcdn.com/image/fetch/$s_!hhO5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dde20de-9e52-4c21-adaa-bf500a5889c2_322x445.png 1272w, https://substackcdn.com/image/fetch/$s_!hhO5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dde20de-9e52-4c21-adaa-bf500a5889c2_322x445.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></figure></div><p>In the instance above, our current penetrates the surface in both directions. In this instance, the net current penetrating the enclosed surface is 0!</p><p>We conclude that the <em>I</em><sub>enc</sub> enclosed term relates to the net current penetrating our enclosed surface. What really counts here is the net penetration, and not simply the total current which flows past the enclosure!</p><p>Noting this, we can move on and decipher the second term:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!P8HQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef2cbfe6-580f-4239-8107-5c98b342942e_813x540.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!P8HQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef2cbfe6-580f-4239-8107-5c98b342942e_813x540.png 424w, https://substackcdn.com/image/fetch/$s_!P8HQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef2cbfe6-580f-4239-8107-5c98b342942e_813x540.png 848w, https://substackcdn.com/image/fetch/$s_!P8HQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef2cbfe6-580f-4239-8107-5c98b342942e_813x540.png 1272w, https://substackcdn.com/image/fetch/$s_!P8HQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef2cbfe6-580f-4239-8107-5c98b342942e_813x540.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!P8HQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef2cbfe6-580f-4239-8107-5c98b342942e_813x540.png" width="601" height="399.18819188191884" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ef2cbfe6-580f-4239-8107-5c98b342942e_813x540.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:540,&quot;width&quot;:813,&quot;resizeWidth&quot;:601,&quot;bytes&quot;:88514,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!P8HQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef2cbfe6-580f-4239-8107-5c98b342942e_813x540.png 424w, https://substackcdn.com/image/fetch/$s_!P8HQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef2cbfe6-580f-4239-8107-5c98b342942e_813x540.png 848w, https://substackcdn.com/image/fetch/$s_!P8HQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef2cbfe6-580f-4239-8107-5c98b342942e_813x540.png 1272w, https://substackcdn.com/image/fetch/$s_!P8HQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef2cbfe6-580f-4239-8107-5c98b342942e_813x540.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></figure></div><p>In the above equation, we simply express the change of electric flux through a surface C. This relation was already explained when we discussed our equations in integral form, so we won&#8217;t spend much time explaining it here. Essentially, it represents the rate of change of electric flux.</p><p>We note that the electric permittivity and magnetic permeability terms both relate to the resistance of the medium to electric and magnetic fields. When it comes to permittivity / permeability of free space, we note that the 2 constants are related to one another, and equal &#949;<sub>0</sub>&#956;<sub>0 </sub>= 1/c<sup>2</sup>, where c represents the speed of light. Really, they&#8217;re dimensional constants which go away if we change our equations so that they&#8217;re expressed in Gaussian units. In other words, they&#8217;re essentially dimensional values that don&#8217;t have any physical significance!</p><p>Congratulations, you&#8217;ve survived through both the integral and differential forms of all four of Maxwell&#8217;s equations! Are we finally finished?</p><p>Not quite yet! We have one last section which we want to go through. This section deals with bringing a unified picture which combines our two fields into one!</p><h2><strong>Unification: The Electromagnetic Field</strong></h2><p>The magnetic and electric fields are really one unified concept which we call the <strong>electromagnetic</strong> field.</p><p>A better and easier way of visualizing the relationship between the two fields is provided below, where we show the vectors describing an electromagnetic wave (light) in 3 dimensions:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CiQV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6518a853-a155-4a63-a4bb-6ffdfdebf08b_1071x609.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CiQV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6518a853-a155-4a63-a4bb-6ffdfdebf08b_1071x609.png 424w, https://substackcdn.com/image/fetch/$s_!CiQV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6518a853-a155-4a63-a4bb-6ffdfdebf08b_1071x609.png 848w, https://substackcdn.com/image/fetch/$s_!CiQV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6518a853-a155-4a63-a4bb-6ffdfdebf08b_1071x609.png 1272w, https://substackcdn.com/image/fetch/$s_!CiQV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6518a853-a155-4a63-a4bb-6ffdfdebf08b_1071x609.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CiQV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6518a853-a155-4a63-a4bb-6ffdfdebf08b_1071x609.png" width="615" height="349.70588235294116" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6518a853-a155-4a63-a4bb-6ffdfdebf08b_1071x609.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:609,&quot;width&quot;:1071,&quot;resizeWidth&quot;:615,&quot;bytes&quot;:76378,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!CiQV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6518a853-a155-4a63-a4bb-6ffdfdebf08b_1071x609.png 424w, https://substackcdn.com/image/fetch/$s_!CiQV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6518a853-a155-4a63-a4bb-6ffdfdebf08b_1071x609.png 848w, https://substackcdn.com/image/fetch/$s_!CiQV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6518a853-a155-4a63-a4bb-6ffdfdebf08b_1071x609.png 1272w, https://substackcdn.com/image/fetch/$s_!CiQV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6518a853-a155-4a63-a4bb-6ffdfdebf08b_1071x609.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></figure></div><p>Here, we can see how the electric field vectors, the magnetic field vectors, and the direction of propagation are all aligned. We note that the electric field and magnetic field vectors are mutually perpendicular! We won&#8217;t worry too much about the Poynting vector, which relates to the propagation of the electromagnetic field - we mostly want to emphasize the fact that the electric and magnetic fields are <strong>always </strong>aligned in such a manner so that a change in one compliments the other!</p><p>Although the four equations may give us the notion that we have two separate fields which we must account for and which we call the electric and magnetic fields, here, we finally reveal a surprise: there&#8217;s only one field, and we call it the electromagnetic field!</p><p>So what happens to our 2 separate fields then? How is this possible? Well, we can actually model the magnetic field as being a product of relativity and relativistic effects produced from a changing electric field!</p><p>That&#8217;s right: with the proper choice of frames, a magnetic field can always be explained as a type of electrostatic attraction or repulsion made by relativistic effects of the electric field!</p><p>Let&#8217;s suppose that we have a current flowing through a wire. We place an electron next to the wire, and pretend that it&#8217;s moving in the same direction and velocity as the electrons within our wire. Using the right hand rule, we can find the direction of the wire&#8217;s magnetic field. That is, the rule will show us that the wire will attract our moving electron.</p><p>Let&#8217;s say that we were standing still and observing this. We could say that from our reference frame, this result was produced by the induced magnetic force! The wire, from our perspective, doesn&#8217;t have a charge density flowing through it! It should be neutral, as the net amount of positive and negative charges look equal!</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pwzy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb380c85c-b26d-4b55-a24e-c91dfe16ad3c_778x270.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pwzy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb380c85c-b26d-4b55-a24e-c91dfe16ad3c_778x270.png 424w, https://substackcdn.com/image/fetch/$s_!pwzy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb380c85c-b26d-4b55-a24e-c91dfe16ad3c_778x270.png 848w, https://substackcdn.com/image/fetch/$s_!pwzy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb380c85c-b26d-4b55-a24e-c91dfe16ad3c_778x270.png 1272w, https://substackcdn.com/image/fetch/$s_!pwzy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb380c85c-b26d-4b55-a24e-c91dfe16ad3c_778x270.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pwzy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb380c85c-b26d-4b55-a24e-c91dfe16ad3c_778x270.png" width="571" height="198.16195372750641" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b380c85c-b26d-4b55-a24e-c91dfe16ad3c_778x270.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:270,&quot;width&quot;:778,&quot;resizeWidth&quot;:571,&quot;bytes&quot;:12950,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!pwzy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb380c85c-b26d-4b55-a24e-c91dfe16ad3c_778x270.png 424w, https://substackcdn.com/image/fetch/$s_!pwzy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb380c85c-b26d-4b55-a24e-c91dfe16ad3c_778x270.png 848w, https://substackcdn.com/image/fetch/$s_!pwzy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb380c85c-b26d-4b55-a24e-c91dfe16ad3c_778x270.png 1272w, https://substackcdn.com/image/fetch/$s_!pwzy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb380c85c-b26d-4b55-a24e-c91dfe16ad3c_778x270.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>What if we were to decide to move next to the electron though, such that we were moving in the same direction and with the same velocity? Indeed, now we would be experiencing the world through a different reference frame! From this reference frame, our charge isn&#8217;t moving at all, and thus, there is no magnetic force! Only moving charges / fields produce a magnetic force after all. So, what happens now?</p><p>Well, in special relativity, when objects move uniformly, they undergo a contraction in length along the direction of motion. We call this the Lorenz contraction. This essentially means that the moving objects appear shorter to observers at rest. A simple example of relativistic length contraction using a baseball is provided below:</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!P4Qq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64f65f4-af3d-49f9-996f-d0507805f87c_440x141.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!P4Qq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64f65f4-af3d-49f9-996f-d0507805f87c_440x141.png 424w, https://substackcdn.com/image/fetch/$s_!P4Qq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64f65f4-af3d-49f9-996f-d0507805f87c_440x141.png 848w, https://substackcdn.com/image/fetch/$s_!P4Qq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64f65f4-af3d-49f9-996f-d0507805f87c_440x141.png 1272w, https://substackcdn.com/image/fetch/$s_!P4Qq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64f65f4-af3d-49f9-996f-d0507805f87c_440x141.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!P4Qq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64f65f4-af3d-49f9-996f-d0507805f87c_440x141.png" width="440" height="141" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c64f65f4-af3d-49f9-996f-d0507805f87c_440x141.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:141,&quot;width&quot;:440,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:20731,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!P4Qq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64f65f4-af3d-49f9-996f-d0507805f87c_440x141.png 424w, https://substackcdn.com/image/fetch/$s_!P4Qq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64f65f4-af3d-49f9-996f-d0507805f87c_440x141.png 848w, https://substackcdn.com/image/fetch/$s_!P4Qq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64f65f4-af3d-49f9-996f-d0507805f87c_440x141.png 1272w, https://substackcdn.com/image/fetch/$s_!P4Qq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc64f65f4-af3d-49f9-996f-d0507805f87c_440x141.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p><p>The image above shows what happens to the length of a baseball as it moves closer and closer to the speed of light: its length keeps contracting the faster we go!</p><p>Now, let&#8217;s get back to our original example and pretend that we&#8217;re moving along the same path as our electron. Once again, from this reference frame, the electron is standing still and the flowing electrons within our wire are also standing still as well! Here, the positive metal ions appear to be moving, and they&#8217;re moving backwards to our reference frame!</p><p>Now, let&#8217;s think about this: what happens when we have moving objects? Once again, we must remember that the faster we move, the more our length gets contracted. In the instance above, our positive ions will get &#8216;squished&#8217; along their direction of movement. What happens if you squash charged objects such that they occupy less space along their lengths? That&#8217;s right, the positive charges along the length of our wire will be compressed, resulting in a higher density of positive charges per centimeter of wire!</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!oWLD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf76d86-620b-4582-9faf-8a98b16040a7_773x254.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!oWLD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf76d86-620b-4582-9faf-8a98b16040a7_773x254.png 424w, https://substackcdn.com/image/fetch/$s_!oWLD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf76d86-620b-4582-9faf-8a98b16040a7_773x254.png 848w, https://substackcdn.com/image/fetch/$s_!oWLD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf76d86-620b-4582-9faf-8a98b16040a7_773x254.png 1272w, https://substackcdn.com/image/fetch/$s_!oWLD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf76d86-620b-4582-9faf-8a98b16040a7_773x254.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!oWLD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf76d86-620b-4582-9faf-8a98b16040a7_773x254.png" width="569" height="186.96765847347996" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3bf76d86-620b-4582-9faf-8a98b16040a7_773x254.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:254,&quot;width&quot;:773,&quot;resizeWidth&quot;:569,&quot;bytes&quot;:12300,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!oWLD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf76d86-620b-4582-9faf-8a98b16040a7_773x254.png 424w, https://substackcdn.com/image/fetch/$s_!oWLD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf76d86-620b-4582-9faf-8a98b16040a7_773x254.png 848w, https://substackcdn.com/image/fetch/$s_!oWLD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf76d86-620b-4582-9faf-8a98b16040a7_773x254.png 1272w, https://substackcdn.com/image/fetch/$s_!oWLD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf76d86-620b-4582-9faf-8a98b16040a7_773x254.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The diagram below does a better job of showing the exact effects of length contraction on a charged particle, as well as its effect on the particle&#8217;s electric field:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pPpK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6456fb91-159a-4172-9825-15a469f09261_681x331.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pPpK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6456fb91-159a-4172-9825-15a469f09261_681x331.png 424w, https://substackcdn.com/image/fetch/$s_!pPpK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6456fb91-159a-4172-9825-15a469f09261_681x331.png 848w, https://substackcdn.com/image/fetch/$s_!pPpK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6456fb91-159a-4172-9825-15a469f09261_681x331.png 1272w, https://substackcdn.com/image/fetch/$s_!pPpK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6456fb91-159a-4172-9825-15a469f09261_681x331.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pPpK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6456fb91-159a-4172-9825-15a469f09261_681x331.png" width="575" height="279.47870778267253" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6456fb91-159a-4172-9825-15a469f09261_681x331.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:331,&quot;width&quot;:681,&quot;resizeWidth&quot;:575,&quot;bytes&quot;:19800,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!pPpK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6456fb91-159a-4172-9825-15a469f09261_681x331.png 424w, https://substackcdn.com/image/fetch/$s_!pPpK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6456fb91-159a-4172-9825-15a469f09261_681x331.png 848w, https://substackcdn.com/image/fetch/$s_!pPpK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6456fb91-159a-4172-9825-15a469f09261_681x331.png 1272w, https://substackcdn.com/image/fetch/$s_!pPpK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6456fb91-159a-4172-9825-15a469f09261_681x331.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></figure></div><p>In the diagram on the left, we see a point charge which is symmetric along its length and thus at rest. We can picture the electromagnetic field as pointing directly away from the charge, with no effects of contractions taking place on our charge. On the other hand, if we take a look on the right, we imagine a moving particle. Here, our reference frame shows the particle moving to the right. The effect of this movement shows that its length is contracted in the direction of movement. The effect that this has on our moving field is such that the vertical component is stronger! Taking a look at our arrow (representing the electric field), we can easily see that this effect combines to make the field lines / arrows point directly away from the current location of our charge!</p><p>Let&#8217;s show another image which shows the relativistic transformation of our field as it moves to the right of our page:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WgQf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb87f927b-7480-4a18-8c2f-782667a8235b_253x363.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WgQf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb87f927b-7480-4a18-8c2f-782667a8235b_253x363.png 424w, https://substackcdn.com/image/fetch/$s_!WgQf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb87f927b-7480-4a18-8c2f-782667a8235b_253x363.png 848w, https://substackcdn.com/image/fetch/$s_!WgQf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb87f927b-7480-4a18-8c2f-782667a8235b_253x363.png 1272w, https://substackcdn.com/image/fetch/$s_!WgQf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb87f927b-7480-4a18-8c2f-782667a8235b_253x363.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WgQf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb87f927b-7480-4a18-8c2f-782667a8235b_253x363.png" width="217" height="311.3478260869565" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b87f927b-7480-4a18-8c2f-782667a8235b_253x363.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:363,&quot;width&quot;:253,&quot;resizeWidth&quot;:217,&quot;bytes&quot;:11813,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WgQf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb87f927b-7480-4a18-8c2f-782667a8235b_253x363.png 424w, https://substackcdn.com/image/fetch/$s_!WgQf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb87f927b-7480-4a18-8c2f-782667a8235b_253x363.png 848w, https://substackcdn.com/image/fetch/$s_!WgQf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb87f927b-7480-4a18-8c2f-782667a8235b_253x363.png 1272w, https://substackcdn.com/image/fetch/$s_!WgQf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb87f927b-7480-4a18-8c2f-782667a8235b_253x363.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></figure></div><p>Once again, we should be able to see that the vertical component of our field is compressed and thus stronger due to length contraction!</p><p>Let&#8217;s once again go back to our original example. From the electron&#8217;s reference frame, we can see that although we have no length contraction in terms of our negative charges, we do have length contraction in terms of our positive charges which are flowing to the left of our reference frame. Since this has an effect of compressing the length of our positive ions, the electrons within the wire can no longer fully cancel out the positive ion fields, leaving the wire with a net positive charge! This results in a net attractive force on our charged particle which is directed towards the wire:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_0iZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F905c68a7-aeae-4356-8d05-2bc23252e7a5_1192x845.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_0iZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F905c68a7-aeae-4356-8d05-2bc23252e7a5_1192x845.png 424w, https://substackcdn.com/image/fetch/$s_!_0iZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F905c68a7-aeae-4356-8d05-2bc23252e7a5_1192x845.png 848w, https://substackcdn.com/image/fetch/$s_!_0iZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F905c68a7-aeae-4356-8d05-2bc23252e7a5_1192x845.png 1272w, https://substackcdn.com/image/fetch/$s_!_0iZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F905c68a7-aeae-4356-8d05-2bc23252e7a5_1192x845.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_0iZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F905c68a7-aeae-4356-8d05-2bc23252e7a5_1192x845.png" width="1192" height="845" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/905c68a7-aeae-4356-8d05-2bc23252e7a5_1192x845.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:845,&quot;width&quot;:1192,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:95698,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_0iZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F905c68a7-aeae-4356-8d05-2bc23252e7a5_1192x845.png 424w, https://substackcdn.com/image/fetch/$s_!_0iZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F905c68a7-aeae-4356-8d05-2bc23252e7a5_1192x845.png 848w, https://substackcdn.com/image/fetch/$s_!_0iZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F905c68a7-aeae-4356-8d05-2bc23252e7a5_1192x845.png 1272w, https://substackcdn.com/image/fetch/$s_!_0iZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F905c68a7-aeae-4356-8d05-2bc23252e7a5_1192x845.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></figure></div><p>We can see in the above instance, from the electron&#8217;s reference frame, we no longer need a magnetic field to explain the force exerted on our charged particle! We can describe the resulting magnetic force as a product of relativistic length contraction of the electric field!</p><p>This is a simple example that shows that the electromagnetic field really is a single field whose overt manifestations can change dramatically depending on the frame from which they are viewed.</p><p>In fact, in Part VI of his 1864 paper titled &#8216;Electromagnetic Theory of Light,&#8217; Maxwell combined displacement current with some of the other equations of electromagnetism which resulted in a wave equation with a speed equal to the speed of light. He commented:</p><blockquote><p>&#8220;<em>The agreement of the results seems to show that light and magnetism are affections of the same substance, and that light is an electromagnetic disturbance propagated through the field according to electromagnetic laws.&#8221; </em></p></blockquote><p>In a vacuum and charge-free space, we can actually express Maxwell&#8217;s equations with the equations 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_!OLIH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bf81bd0-0eec-4774-97cd-904a04e67447_390x560.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OLIH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bf81bd0-0eec-4774-97cd-904a04e67447_390x560.png 424w, https://substackcdn.com/image/fetch/$s_!OLIH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bf81bd0-0eec-4774-97cd-904a04e67447_390x560.png 848w, https://substackcdn.com/image/fetch/$s_!OLIH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bf81bd0-0eec-4774-97cd-904a04e67447_390x560.png 1272w, https://substackcdn.com/image/fetch/$s_!OLIH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bf81bd0-0eec-4774-97cd-904a04e67447_390x560.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OLIH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bf81bd0-0eec-4774-97cd-904a04e67447_390x560.png" width="264" height="379.0769230769231" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2bf81bd0-0eec-4774-97cd-904a04e67447_390x560.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:560,&quot;width&quot;:390,&quot;resizeWidth&quot;:264,&quot;bytes&quot;:22495,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OLIH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bf81bd0-0eec-4774-97cd-904a04e67447_390x560.png 424w, https://substackcdn.com/image/fetch/$s_!OLIH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bf81bd0-0eec-4774-97cd-904a04e67447_390x560.png 848w, https://substackcdn.com/image/fetch/$s_!OLIH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bf81bd0-0eec-4774-97cd-904a04e67447_390x560.png 1272w, https://substackcdn.com/image/fetch/$s_!OLIH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bf81bd0-0eec-4774-97cd-904a04e67447_390x560.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></figure></div><p>We can use the vector identity:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!x7R0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F988261df-885c-4807-8743-664722e8f9be_843x147.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!x7R0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F988261df-885c-4807-8743-664722e8f9be_843x147.png 424w, https://substackcdn.com/image/fetch/$s_!x7R0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F988261df-885c-4807-8743-664722e8f9be_843x147.png 848w, https://substackcdn.com/image/fetch/$s_!x7R0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F988261df-885c-4807-8743-664722e8f9be_843x147.png 1272w, https://substackcdn.com/image/fetch/$s_!x7R0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F988261df-885c-4807-8743-664722e8f9be_843x147.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!x7R0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F988261df-885c-4807-8743-664722e8f9be_843x147.png" width="435" height="75.8540925266904" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/988261df-885c-4807-8743-664722e8f9be_843x147.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:147,&quot;width&quot;:843,&quot;resizeWidth&quot;:435,&quot;bytes&quot;:14842,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!x7R0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F988261df-885c-4807-8743-664722e8f9be_843x147.png 424w, https://substackcdn.com/image/fetch/$s_!x7R0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F988261df-885c-4807-8743-664722e8f9be_843x147.png 848w, https://substackcdn.com/image/fetch/$s_!x7R0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F988261df-885c-4807-8743-664722e8f9be_843x147.png 1272w, https://substackcdn.com/image/fetch/$s_!x7R0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F988261df-885c-4807-8743-664722e8f9be_843x147.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>and apply it to the third and fourth equations to 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_!wjcb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a00644-3d50-4814-aaf0-f55017d3be5b_466x498.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wjcb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a00644-3d50-4814-aaf0-f55017d3be5b_466x498.png 424w, https://substackcdn.com/image/fetch/$s_!wjcb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a00644-3d50-4814-aaf0-f55017d3be5b_466x498.png 848w, https://substackcdn.com/image/fetch/$s_!wjcb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a00644-3d50-4814-aaf0-f55017d3be5b_466x498.png 1272w, https://substackcdn.com/image/fetch/$s_!wjcb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a00644-3d50-4814-aaf0-f55017d3be5b_466x498.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wjcb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a00644-3d50-4814-aaf0-f55017d3be5b_466x498.png" width="234" height="250.068669527897" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/77a00644-3d50-4814-aaf0-f55017d3be5b_466x498.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:498,&quot;width&quot;:466,&quot;resizeWidth&quot;:234,&quot;bytes&quot;:26743,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wjcb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a00644-3d50-4814-aaf0-f55017d3be5b_466x498.png 424w, https://substackcdn.com/image/fetch/$s_!wjcb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a00644-3d50-4814-aaf0-f55017d3be5b_466x498.png 848w, https://substackcdn.com/image/fetch/$s_!wjcb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a00644-3d50-4814-aaf0-f55017d3be5b_466x498.png 1272w, https://substackcdn.com/image/fetch/$s_!wjcb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a00644-3d50-4814-aaf0-f55017d3be5b_466x498.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></figure></div><p>That shows that the electric and magnetic fields satisfy the wave equation! That is, electromagnetic waves exist! Furthermore, since 1 / &#956;<sub>0</sub>&#1013;<sub>0 </sub>= c<sup>2</sup>, we know that they travel at the speed of light!</p><div><hr></div><p><strong>Side Note</strong>: if you need a more in depth explanation on how to derive the above, this <a href="http://maxwells-equations.com/equations/wave.php">link does a good job of explaining how to derive the above equations</a>, and you can watch <a href="https://www.youtube.com/watch?v=ck-r_qmNNG0">this video to get a better intuition behind the equation itself</a>.</p><div><hr></div><p>Prior to ending our presentation of Maxwell&#8217;s equations, let&#8217;s quickly glance at another overview (with some additional details added in) to show how divine and powerful Maxwell&#8217;s equations really are:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SAZG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44ef0cab-7755-4c14-b174-7299239f6816_885x649.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SAZG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44ef0cab-7755-4c14-b174-7299239f6816_885x649.png 424w, https://substackcdn.com/image/fetch/$s_!SAZG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44ef0cab-7755-4c14-b174-7299239f6816_885x649.png 848w, https://substackcdn.com/image/fetch/$s_!SAZG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44ef0cab-7755-4c14-b174-7299239f6816_885x649.png 1272w, https://substackcdn.com/image/fetch/$s_!SAZG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44ef0cab-7755-4c14-b174-7299239f6816_885x649.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SAZG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44ef0cab-7755-4c14-b174-7299239f6816_885x649.png" width="885" height="649" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/44ef0cab-7755-4c14-b174-7299239f6816_885x649.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:649,&quot;width&quot;:885,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:56638,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!SAZG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44ef0cab-7755-4c14-b174-7299239f6816_885x649.png 424w, https://substackcdn.com/image/fetch/$s_!SAZG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44ef0cab-7755-4c14-b174-7299239f6816_885x649.png 848w, https://substackcdn.com/image/fetch/$s_!SAZG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44ef0cab-7755-4c14-b174-7299239f6816_885x649.png 1272w, https://substackcdn.com/image/fetch/$s_!SAZG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44ef0cab-7755-4c14-b174-7299239f6816_885x649.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></figure></div><p>What&#8217;s so special about the above table? In Feynman&#8217;s own words:</p><blockquote><p><em>In Table 18&#8211;1 we have all that was known of fundamental classical physics, that is, the physics that was known by 1905. Here it all is, in one table. With these equations we can understand the complete realm of classical physics.</em></p><p><em>First we have the Maxwell equations&#8212;written in both the expanded form and the short mathematical form. Then there is the conservation of charge, which is even written in parentheses, because the moment we have the complete Maxwell equations, we can deduce from them the conservation of charge. So the table is even a little redundant. Next, we have written the force law, because having all the electric and magnetic fields doesn&#8217;t tell us anything until we know what they do to charges. Knowing E and B, however, we can find the force on an object with the charge q moving with velocity v. Finally, having the force doesn&#8217;t tell us anything until we know what happens when a force pushes on something; we need the law of motion, which is that the force is equal to the rate of change of the momentum. (Remember? We had that in Volume I.) We even include relativity effects by writing the momentum as:</em></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rGTH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b94ae4-9d61-47d0-a3a0-cd5fe430e381_181x34.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rGTH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b94ae4-9d61-47d0-a3a0-cd5fe430e381_181x34.png 424w, https://substackcdn.com/image/fetch/$s_!rGTH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b94ae4-9d61-47d0-a3a0-cd5fe430e381_181x34.png 848w, https://substackcdn.com/image/fetch/$s_!rGTH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b94ae4-9d61-47d0-a3a0-cd5fe430e381_181x34.png 1272w, https://substackcdn.com/image/fetch/$s_!rGTH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b94ae4-9d61-47d0-a3a0-cd5fe430e381_181x34.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rGTH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b94ae4-9d61-47d0-a3a0-cd5fe430e381_181x34.png" width="181" height="34" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/02b94ae4-9d61-47d0-a3a0-cd5fe430e381_181x34.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:34,&quot;width&quot;:181,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2345,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!rGTH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b94ae4-9d61-47d0-a3a0-cd5fe430e381_181x34.png 424w, https://substackcdn.com/image/fetch/$s_!rGTH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b94ae4-9d61-47d0-a3a0-cd5fe430e381_181x34.png 848w, https://substackcdn.com/image/fetch/$s_!rGTH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b94ae4-9d61-47d0-a3a0-cd5fe430e381_181x34.png 1272w, https://substackcdn.com/image/fetch/$s_!rGTH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02b94ae4-9d61-47d0-a3a0-cd5fe430e381_181x34.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><em>If we really want to be complete, we should add one more law&#8212;Newton&#8217;s law of gravitation&#8212;so we put that at the end.</em></p><p><em>Therefore in one small table we have all the fundamental laws of classical physics&#8212;even with room to write them out in words and with some redundancy. This is a great moment. We have climbed a great peak. We are on the top of K2&#8212;we are nearly ready for Mount Everest, which is quantum mechanics. We have climbed the peak of a &#8220;Great Divide,&#8221; and now we can go down the other side.&#8221; </em></p></blockquote><p>Indeed, in a few simple lines and equations, we&#8217;ve summarized the classical world.</p><div><hr></div><h2>Resources / Credits</h2><p>The main inspiration for this guide was a video by 3Blue1Brown / Grant Sanderson titled &#8216;Divergence and Curl: The language of Maxwell's equations, fluid flow, and more&#8217; which can be found here:</p><div id="youtube2-rB83DpBJQsE" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;rB83DpBJQsE&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/rB83DpBJQsE?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><p>The images illustrating vector fields, as well as the concepts included in the curl and divergence sections were taken directly from the video.</p><p>The images shown when explaining the heat equation and partial differential equations were also taken from the video series by 3Blue1Brown / Grant Sanderson called &#8216;Solving the Heat Equation&#8217; which can be found using the link below:</p><div id="youtube2-ToIXSwZ1pJU" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;ToIXSwZ1pJU&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/ToIXSwZ1pJU?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><p>In addition to the above resources, the guide also references <a href="http://www.danfleisch.com/maxwell/">A Student&#8217;s Guide to Maxwell&#8217;s Equations</a> by Dan Fleisch which provides an excellent guide to understanding the exact meaning behind all of the equations (in both integral and differential form).</p><p>Other notable references and illustrations can be found using the resources listed below:</p><ul><li><p><a href="https://www.feynmanlectures.caltech.edu/II_toc.html">The Feynman Lectures on Physics (Vol 2) </a></p></li><li><p><a href="https://www.researchgate.net/publication/4317784_Why_is_Maxwell's_Theory_so_hard_to_understand">Why is Maxwell&#8217;s theory so hard to understand?</a></p></li><li><p><a href="http://web.mit.edu/8.02t/www/802TEAL3D/visualizations/guidedtour/Tour.htm">A Visual Tour of Classical Electromagnetism</a></p></li><li><p><a href="https://physics.info/em-waves/">The Physics Hypertexbook: Electromagnetic Waves</a></p></li></ul><p>You can also find the original write-up of this post directly in my GitHub repository:</p><ul><li><p><a href="https://github.com/photonlines/Intuitive-Guide-to-Maxwells-Equations">Intuitive Guide to Maxwell&#8217;s Equations.</a>  </p></li></ul><div><hr></div><p>Thank you for reading, and if you like these types of visual expositions, please like and subscribe. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Photon-Lines Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Intuitive and Visual Guide to Transformers and ChatGPT]]></title><description><![CDATA[An intuitive and visual exploration of how transformers and large language models like ChatGPT work.]]></description><link>https://photonlines.substack.com/p/intuitive-and-visual-guide-to-transformers</link><guid isPermaLink="false">https://photonlines.substack.com/p/intuitive-and-visual-guide-to-transformers</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Sat, 02 Mar 2024 14:14:02 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Jmcd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0048a628-176d-4553-920a-846028afa735_505x771.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I wasn&#8217;t too happy with many of the explanations of how ChatGPT and large language models worked which I found online. Many of the explanations focus in on ChatGPT being a simple next-word predictor, and after using ChatGPT for quite a few months now to help me with generating and automating all sorts of tasks, I found these explanations quite lacking.</p><p>For one, ChatGPT isn&#8217;t mediocre at attempting to generate text for the tasks which I told it to generate. In a lot of instances, it was able to generate incredibly elegant code <strong>and to fix the issues </strong>which came with it when I prompted it to do so &#8211; showing that it wasn&#8217;t just producing auto-correlated text. In other words, it&#8217;s not a simple next-word predictor and it&#8217;s in not strictly Bayesian in nature. Noting this, I decided to venture into the world of transformers and large language models and to try to grasp how exactly they performed their magic. To do this, I used the methodology I usually use when I&#8217;m confused about a particular topic: the Feynman method.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Photon-Lines Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>The Feynman method compromises of trying to pretend to teach a concept you want to learn to a young student who has no familiarity with it. To do this, I usually find source material online and take notes on it. If there&#8217;s anything I don&#8217;t understand, I find more material to read / watch and I keep taking notes until the concept is clarified. The general goal is to be able to understand the main components of a process from start to finish by 1) breaking them down into a step by step procedure composed of simple components and 2) providing explanations on how the simpler procedures / components work so that <strong>anyone</strong> reading it can have an intuitive understanding of how the whole thing functions.</p><p>Now, writing about ChatGPT isn&#8217;t an easy thing to do. To tell you the truth, I got lost quite a bit in my quest to simplify it. For one, Open-AI isn&#8217;t &#8230; well, &#8216;open,&#8217; so a lot of the information on how this GPT model works may not be accurate and is extremely hard to verify. Noting this, I still did my best to come up with something which could give others a big-picture view of how it all worked under the hood. After a long 6-month journey into transformers and generative pre-trained models, I decided to make the write-up available here.</p><p>If you have no knowledge of neural networks, I would recommend you start off by reading my own introduction available here: <a href="https://photonlines.substack.com/p/grokking-neural-networks">Visual Intro to Neural Networks</a>. There&#8217;s also lots of material on neural networks available on other sites, so I won&#8217;t go into too many details here. Noting this, let&#8217;s dive into the world of transformers.</p><h3>Transformers</h3><p>Transformers revolutionized the field of natural language processing when they were introduced in 2017. The "Attention is All You Need" paper by Vaswani et al. presented the transformer architecture. It addressed the challenges of modeling long-range dependencies in sequences and achieved breakthroughs in language translation tasks. Following its success in translation, the transformer architecture was further explored and applied to various other NLP tasks, including text summarization and generation. How exactly are transformers different from word-completion tasks performed by most modern software (i.e. like WhatsApp?). </p><p>In modern text completion tasks, after each word, you may get a few words suggested to you. For example, if you type &#8220;Hello, how&#8221; the phone may suggest words such as &#8220;are&#8221;, or &#8220;do.&#8221; Of course, if you continue selecting the suggested word in your phone, you&#8217;ll quickly find that the message formed by these words makes no sense. If you look at each set of 3 or 4 consecutive words, it may make sense, but these words don&#8217;t generate anything with a real meaning. This is because the model used in the app doesn&#8217;t carry the overall context of the message. It simply predicts which word is more likely to come up after the last few words are prompted.</p><p>Transformers are different. They keep track of a much larger context of what is being written, so the text they generate makes more sense. Although they still technically generate text by predicting one word at a time, there&#8217;s much more complexity hidden away within a seemingly simple transformer model. When &#8216;looking&#8217; at the past data, transformers capture the relationships between different elements in the sequence through something called &#8216;self-attention&#8217;. Self-attention allows the model to weigh the importance of different positions and elements in the input sequence and to capture the context which comes with each prior element.</p><p>And how are transformers trained? Well &#8211; with a ton of data!! ChatGPT was trained using a huge amount of online data-sets along with an agglomeration of books and articles, and this was just for a phase which we call &#8216;pre-training.&#8217; To perform fine-tuning, ChatGPT used real world human question and answer data sets and live chat results. This was done in order to tune the model to be able to converse with other human beings rather than simply being able to predict next words within text. Let&#8217;s not get ahead of ourselves though. First, we need to go over the general transformer architecture.</p><h3><strong>The Architecture</strong></h3><p>Before we dive into the details, let&#8217;s take a look at the full transformer architecture diagram outlined in the original paper &#8216;Attention is All You Need.&#8217;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Jmcd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0048a628-176d-4553-920a-846028afa735_505x771.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Jmcd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0048a628-176d-4553-920a-846028afa735_505x771.png 424w, https://substackcdn.com/image/fetch/$s_!Jmcd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0048a628-176d-4553-920a-846028afa735_505x771.png 848w, https://substackcdn.com/image/fetch/$s_!Jmcd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0048a628-176d-4553-920a-846028afa735_505x771.png 1272w, https://substackcdn.com/image/fetch/$s_!Jmcd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0048a628-176d-4553-920a-846028afa735_505x771.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Jmcd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0048a628-176d-4553-920a-846028afa735_505x771.png" width="505" height="771" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0048a628-176d-4553-920a-846028afa735_505x771.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:771,&quot;width&quot;:505,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:77531,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Jmcd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0048a628-176d-4553-920a-846028afa735_505x771.png 424w, https://substackcdn.com/image/fetch/$s_!Jmcd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0048a628-176d-4553-920a-846028afa735_505x771.png 848w, https://substackcdn.com/image/fetch/$s_!Jmcd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0048a628-176d-4553-920a-846028afa735_505x771.png 1272w, https://substackcdn.com/image/fetch/$s_!Jmcd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0048a628-176d-4553-920a-846028afa735_505x771.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></figure></div><p>To understand how transformers work, let's break things down and map out the key components and their interactions. We&#8217;ll then discuss how these elements relate in terms of the GPT architecture and what new elements have been added in order to make GPT as powerful as it is today.</p><h4><strong>Tokenization</strong></h4><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IaPX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F907b4811-4ccd-4423-b9fd-6891054de9b8_136x118.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IaPX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F907b4811-4ccd-4423-b9fd-6891054de9b8_136x118.png 424w, https://substackcdn.com/image/fetch/$s_!IaPX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F907b4811-4ccd-4423-b9fd-6891054de9b8_136x118.png 848w, https://substackcdn.com/image/fetch/$s_!IaPX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F907b4811-4ccd-4423-b9fd-6891054de9b8_136x118.png 1272w, https://substackcdn.com/image/fetch/$s_!IaPX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F907b4811-4ccd-4423-b9fd-6891054de9b8_136x118.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IaPX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F907b4811-4ccd-4423-b9fd-6891054de9b8_136x118.png" width="144" height="124.94117647058823" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/907b4811-4ccd-4423-b9fd-6891054de9b8_136x118.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:118,&quot;width&quot;:136,&quot;resizeWidth&quot;:144,&quot;bytes&quot;:4050,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!IaPX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F907b4811-4ccd-4423-b9fd-6891054de9b8_136x118.png 424w, https://substackcdn.com/image/fetch/$s_!IaPX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F907b4811-4ccd-4423-b9fd-6891054de9b8_136x118.png 848w, https://substackcdn.com/image/fetch/$s_!IaPX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F907b4811-4ccd-4423-b9fd-6891054de9b8_136x118.png 1272w, https://substackcdn.com/image/fetch/$s_!IaPX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F907b4811-4ccd-4423-b9fd-6891054de9b8_136x118.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The transformer takes a sequence of words and transforms them into tokens. For efficiency, GPT-3 actually uses byte-level Byte Pair Encoding (BPE) tokenization. What this means is that "words" in the vocabulary are not full words, but groups of characters (for byte-level BPE, bytes) which occur often in text.</p><p>As an example, the text &#8216;I love reading about transformers&#8217; would be broken up into:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!d3F1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84b1af9-aaf5-41ca-9476-bb46401a49ca_638x73.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!d3F1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84b1af9-aaf5-41ca-9476-bb46401a49ca_638x73.png 424w, https://substackcdn.com/image/fetch/$s_!d3F1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84b1af9-aaf5-41ca-9476-bb46401a49ca_638x73.png 848w, https://substackcdn.com/image/fetch/$s_!d3F1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84b1af9-aaf5-41ca-9476-bb46401a49ca_638x73.png 1272w, https://substackcdn.com/image/fetch/$s_!d3F1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84b1af9-aaf5-41ca-9476-bb46401a49ca_638x73.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!d3F1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84b1af9-aaf5-41ca-9476-bb46401a49ca_638x73.png" width="638" height="73" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b84b1af9-aaf5-41ca-9476-bb46401a49ca_638x73.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:73,&quot;width&quot;:638,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:7984,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!d3F1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84b1af9-aaf5-41ca-9476-bb46401a49ca_638x73.png 424w, https://substackcdn.com/image/fetch/$s_!d3F1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84b1af9-aaf5-41ca-9476-bb46401a49ca_638x73.png 848w, https://substackcdn.com/image/fetch/$s_!d3F1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84b1af9-aaf5-41ca-9476-bb46401a49ca_638x73.png 1272w, https://substackcdn.com/image/fetch/$s_!d3F1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb84b1af9-aaf5-41ca-9476-bb46401a49ca_638x73.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p><p>Afterwards, it&#8217;s converted into integers which represent unique ids for each token within the text. In the above instance, our 9 tokens would get converted to:</p><p>[40, 3021, 5403, 922, 87970, 13]</p><p>The above example was taken directly from the OpenAI tokenizer which is available to everyone to experiment with. You can experiment with it yourself using the link below:</p><p><a href="https://platform.openai.com/tokenizer">https://platform.openai.com/tokenizer</a></p><h4><strong>Embeddings</strong></h4><p>To make tokens more useful to the model, rather than just feeding in the raw numbers, each one is transformed into a numerical representation called an embedding. This representation helps the model understand the meaning and relationships between different elements in the sequence.</p><p>For example, the &#8220;I&#8221; token (represented by token 40) might get converted to the vector [0.2, 0.5, -0.1], the "love" (token 1842) may be mapped to [0.8, 0.3, 0.6], and "movie" (token 3807) might get converted to [0.4, -0.2, 0.9]. Although we use 3 numeric values to represent each word in our example above, the dimensionality (the number of numeric values) present in each word vector could be comprised of any number of values. In the instance of ChatGPT, the resulting vector has a length of 12,288 (with GPT3 having a length of 1,536). You can think of each value within our vector representing some sort of quantifiable property of each word. If two pieces of text are similar, then the numbers in their corresponding vectors are similar to each other. Otherwise, if two pieces of text are different, then the numbers in their corresponding vectors are different.</p><p>Even though embeddings are numerical, you can also imagine them geometrically. Imagine a 2-dimensional word-embedding (i.e. each word is converted to a vector of length 2). We can then use a regular graph representation to model. A snapshot of what some sample words in this word-embedding might get mapped to 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_!tZHl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe83c38e3-a075-41e2-88b8-ac407245f34d_1326x1351.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tZHl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe83c38e3-a075-41e2-88b8-ac407245f34d_1326x1351.png 424w, https://substackcdn.com/image/fetch/$s_!tZHl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe83c38e3-a075-41e2-88b8-ac407245f34d_1326x1351.png 848w, https://substackcdn.com/image/fetch/$s_!tZHl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe83c38e3-a075-41e2-88b8-ac407245f34d_1326x1351.png 1272w, https://substackcdn.com/image/fetch/$s_!tZHl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe83c38e3-a075-41e2-88b8-ac407245f34d_1326x1351.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tZHl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe83c38e3-a075-41e2-88b8-ac407245f34d_1326x1351.png" width="445" height="453.3898944193062" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e83c38e3-a075-41e2-88b8-ac407245f34d_1326x1351.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1351,&quot;width&quot;:1326,&quot;resizeWidth&quot;:445,&quot;bytes&quot;:213675,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tZHl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe83c38e3-a075-41e2-88b8-ac407245f34d_1326x1351.png 424w, https://substackcdn.com/image/fetch/$s_!tZHl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe83c38e3-a075-41e2-88b8-ac407245f34d_1326x1351.png 848w, https://substackcdn.com/image/fetch/$s_!tZHl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe83c38e3-a075-41e2-88b8-ac407245f34d_1326x1351.png 1272w, https://substackcdn.com/image/fetch/$s_!tZHl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe83c38e3-a075-41e2-88b8-ac407245f34d_1326x1351.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></figure></div><p>An embedding could also have more dimensional information than simple &#8216;semantic&#8217; or logical meaning of each individual word. In the case of a much larger embedding (where each word gets sent to a longer vector), the words no longer live in a 2-dimensional plane but in a larger multi-dimensional space. However, even in that large space, we can still keep the representation of words as being close or far away from each other through the measurement of vector similarity: similar words have similar vector values while non-similar ones don&#8217;t.</p><p>Think of it this way: our brains store many connections in regards to each word which we have in our vocabulary. As an example, the word &#8216;movie&#8217; could be connected to a whole range of other neurons. Together with a specific date, the word &#8216;movie&#8217; and the date itself could come up with a more specific movie reference (like &#8216;gone with the wind&#8217; which we happened to have watched or heard of on that date).</p><p>The word &#8216;movie&#8217; itself has many other connections in regards to what the term actually means and in which context it is used in. This is essentially what our embedding vector above holds. As an example, one numeric value in our vector might encode sentiment (how good we feel about watching movies vs. reading), and another one may hold the movie &#8216;romance&#8217; factor (is there a love story or stories and to which degree within the flick?). We could store every individual factor within a column in our vector. We could also extend our vector dimension to encode for as many &#8216;attributes&#8217; for each term within our dictionary as we want!</p><p>The embedding layer here essentially maps each term or token within the vocabulary to a more expressive numeric representation!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1sHk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3defb6f-7f8c-41e3-be8e-459212e2cfbf_2051x1413.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1sHk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3defb6f-7f8c-41e3-be8e-459212e2cfbf_2051x1413.png 424w, https://substackcdn.com/image/fetch/$s_!1sHk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3defb6f-7f8c-41e3-be8e-459212e2cfbf_2051x1413.png 848w, https://substackcdn.com/image/fetch/$s_!1sHk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3defb6f-7f8c-41e3-be8e-459212e2cfbf_2051x1413.png 1272w, https://substackcdn.com/image/fetch/$s_!1sHk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3defb6f-7f8c-41e3-be8e-459212e2cfbf_2051x1413.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1sHk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3defb6f-7f8c-41e3-be8e-459212e2cfbf_2051x1413.png" width="1456" height="1003" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d3defb6f-7f8c-41e3-be8e-459212e2cfbf_2051x1413.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1003,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:340284,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1sHk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3defb6f-7f8c-41e3-be8e-459212e2cfbf_2051x1413.png 424w, https://substackcdn.com/image/fetch/$s_!1sHk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3defb6f-7f8c-41e3-be8e-459212e2cfbf_2051x1413.png 848w, https://substackcdn.com/image/fetch/$s_!1sHk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3defb6f-7f8c-41e3-be8e-459212e2cfbf_2051x1413.png 1272w, https://substackcdn.com/image/fetch/$s_!1sHk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3defb6f-7f8c-41e3-be8e-459212e2cfbf_2051x1413.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></figure></div><p>The embedding represents the data we actually feed into our model. In other words &#8211; this is the data element which our encoding / transformer architecture will &#8216;train&#8217; on (after having the positional encoding added which we discuss below).</p><h4><strong>Positional Encoding</strong></h4><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7LUv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd51fe7b-79ea-4ee6-ad52-8e93ba844886_240x163.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7LUv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd51fe7b-79ea-4ee6-ad52-8e93ba844886_240x163.png 424w, https://substackcdn.com/image/fetch/$s_!7LUv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd51fe7b-79ea-4ee6-ad52-8e93ba844886_240x163.png 848w, https://substackcdn.com/image/fetch/$s_!7LUv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd51fe7b-79ea-4ee6-ad52-8e93ba844886_240x163.png 1272w, https://substackcdn.com/image/fetch/$s_!7LUv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd51fe7b-79ea-4ee6-ad52-8e93ba844886_240x163.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7LUv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd51fe7b-79ea-4ee6-ad52-8e93ba844886_240x163.png" width="246" height="167.075" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cd51fe7b-79ea-4ee6-ad52-8e93ba844886_240x163.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:163,&quot;width&quot;:240,&quot;resizeWidth&quot;:246,&quot;bytes&quot;:9528,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!7LUv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd51fe7b-79ea-4ee6-ad52-8e93ba844886_240x163.png 424w, https://substackcdn.com/image/fetch/$s_!7LUv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd51fe7b-79ea-4ee6-ad52-8e93ba844886_240x163.png 848w, https://substackcdn.com/image/fetch/$s_!7LUv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd51fe7b-79ea-4ee6-ad52-8e93ba844886_240x163.png 1272w, https://substackcdn.com/image/fetch/$s_!7LUv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd51fe7b-79ea-4ee6-ad52-8e93ba844886_240x163.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Since transformers don't inherently understand the order of words in a sequence, positional encodings are used.</p><p>For simplicity, let's assume we use a simple positional encoding scheme where each word is assigned a numerical value corresponding to its position in the sentence. In our example, "I" at position 1 might be encoded as [1, 0, 0], "love" at position 2 as [0, 1, 0], and "reading" at position 3 as [0, 0, 1]. The above is an example of one-hot encoding. In one-hot encoding, we use a value of 1 at the positional location where the word or token is located while we 0 out all of the other values. </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zJZV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6355a26-05a0-4078-b41d-9c2e9e8d4309_1518x874.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zJZV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6355a26-05a0-4078-b41d-9c2e9e8d4309_1518x874.png 424w, https://substackcdn.com/image/fetch/$s_!zJZV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6355a26-05a0-4078-b41d-9c2e9e8d4309_1518x874.png 848w, https://substackcdn.com/image/fetch/$s_!zJZV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6355a26-05a0-4078-b41d-9c2e9e8d4309_1518x874.png 1272w, https://substackcdn.com/image/fetch/$s_!zJZV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6355a26-05a0-4078-b41d-9c2e9e8d4309_1518x874.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zJZV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6355a26-05a0-4078-b41d-9c2e9e8d4309_1518x874.png" width="349" height="200.86675824175825" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c6355a26-05a0-4078-b41d-9c2e9e8d4309_1518x874.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:838,&quot;width&quot;:1456,&quot;resizeWidth&quot;:349,&quot;bytes&quot;:79142,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!zJZV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6355a26-05a0-4078-b41d-9c2e9e8d4309_1518x874.png 424w, https://substackcdn.com/image/fetch/$s_!zJZV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6355a26-05a0-4078-b41d-9c2e9e8d4309_1518x874.png 848w, https://substackcdn.com/image/fetch/$s_!zJZV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6355a26-05a0-4078-b41d-9c2e9e8d4309_1518x874.png 1272w, https://substackcdn.com/image/fetch/$s_!zJZV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6355a26-05a0-4078-b41d-9c2e9e8d4309_1518x874.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The actual encoding used in the original paper isn&#8217;t one-hot encoding though. The encoding used there uses the cosine and sine functions. By using this encoding, the model captures periodic patterns within our sentences along with the general global positioning information. In other words, not only do we encode the information about each word locally (to capture trends between words), but we also capture the longer acting connections between each word. </p><p>To add the positional encoding to a GPT3 model, we would simply add another vector of size 1536 to each one of our word embedding vectors (since the embedding vector size is 1536). The positional embedding is only computed once and re-used for every sentence during training and inference, so a lot is saved in terms of computing cost.</p><p>You don&#8217;t have to worry too much if you don&#8217;t understand the full detail on positional component I outlined above. The important points are that our first 2 steps:</p><ol><li><p>transform our natural language grammar into a vector of numeric values representing the meaning of the word and</p></li><li><p>encode the position of each word and pass this information along to the next step.</p></li></ol><h3><strong>Encoder-Decoder Structure</strong></h3><p>Transformers typically have two main parts: an encoder and a decoder. In tasks like machine translation, the encoder processes the input sequence, and the decoder generates the output sequence.</p><h3><strong>Encoder layers</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Y8Nw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4febb692-bea2-48f5-85b9-baea44905c14_993x728.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Y8Nw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4febb692-bea2-48f5-85b9-baea44905c14_993x728.png 424w, https://substackcdn.com/image/fetch/$s_!Y8Nw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4febb692-bea2-48f5-85b9-baea44905c14_993x728.png 848w, https://substackcdn.com/image/fetch/$s_!Y8Nw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4febb692-bea2-48f5-85b9-baea44905c14_993x728.png 1272w, https://substackcdn.com/image/fetch/$s_!Y8Nw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4febb692-bea2-48f5-85b9-baea44905c14_993x728.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Y8Nw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4febb692-bea2-48f5-85b9-baea44905c14_993x728.png" width="993" height="728" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4febb692-bea2-48f5-85b9-baea44905c14_993x728.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:728,&quot;width&quot;:993,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:103142,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Y8Nw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4febb692-bea2-48f5-85b9-baea44905c14_993x728.png 424w, https://substackcdn.com/image/fetch/$s_!Y8Nw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4febb692-bea2-48f5-85b9-baea44905c14_993x728.png 848w, https://substackcdn.com/image/fetch/$s_!Y8Nw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4febb692-bea2-48f5-85b9-baea44905c14_993x728.png 1272w, https://substackcdn.com/image/fetch/$s_!Y8Nw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4febb692-bea2-48f5-85b9-baea44905c14_993x728.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></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!D_Hn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f172581-eb56-4bba-b5b5-4b9ad220de81_444x628.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!D_Hn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f172581-eb56-4bba-b5b5-4b9ad220de81_444x628.png 424w, https://substackcdn.com/image/fetch/$s_!D_Hn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f172581-eb56-4bba-b5b5-4b9ad220de81_444x628.png 848w, https://substackcdn.com/image/fetch/$s_!D_Hn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f172581-eb56-4bba-b5b5-4b9ad220de81_444x628.png 1272w, https://substackcdn.com/image/fetch/$s_!D_Hn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f172581-eb56-4bba-b5b5-4b9ad220de81_444x628.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!D_Hn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f172581-eb56-4bba-b5b5-4b9ad220de81_444x628.png" width="288" height="407.35135135135135" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9f172581-eb56-4bba-b5b5-4b9ad220de81_444x628.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:628,&quot;width&quot;:444,&quot;resizeWidth&quot;:288,&quot;bytes&quot;:38437,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!D_Hn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f172581-eb56-4bba-b5b5-4b9ad220de81_444x628.png 424w, https://substackcdn.com/image/fetch/$s_!D_Hn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f172581-eb56-4bba-b5b5-4b9ad220de81_444x628.png 848w, https://substackcdn.com/image/fetch/$s_!D_Hn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f172581-eb56-4bba-b5b5-4b9ad220de81_444x628.png 1272w, https://substackcdn.com/image/fetch/$s_!D_Hn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f172581-eb56-4bba-b5b5-4b9ad220de81_444x628.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></figure></div><p>The <strong>encoder</strong> takes the encoded input sentence and processes it through multiple layers which consist of self-attention and feed-forward neural networks.</p><h4><strong>Self-attention</strong></h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OhtU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2308736d-bcc1-4698-9227-cb26941fde64_2003x1228.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OhtU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2308736d-bcc1-4698-9227-cb26941fde64_2003x1228.png 424w, https://substackcdn.com/image/fetch/$s_!OhtU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2308736d-bcc1-4698-9227-cb26941fde64_2003x1228.png 848w, https://substackcdn.com/image/fetch/$s_!OhtU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2308736d-bcc1-4698-9227-cb26941fde64_2003x1228.png 1272w, https://substackcdn.com/image/fetch/$s_!OhtU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2308736d-bcc1-4698-9227-cb26941fde64_2003x1228.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OhtU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2308736d-bcc1-4698-9227-cb26941fde64_2003x1228.png" width="643" height="394.36744505494505" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2308736d-bcc1-4698-9227-cb26941fde64_2003x1228.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:893,&quot;width&quot;:1456,&quot;resizeWidth&quot;:643,&quot;bytes&quot;:1689502,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OhtU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2308736d-bcc1-4698-9227-cb26941fde64_2003x1228.png 424w, https://substackcdn.com/image/fetch/$s_!OhtU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2308736d-bcc1-4698-9227-cb26941fde64_2003x1228.png 848w, https://substackcdn.com/image/fetch/$s_!OhtU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2308736d-bcc1-4698-9227-cb26941fde64_2003x1228.png 1272w, https://substackcdn.com/image/fetch/$s_!OhtU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2308736d-bcc1-4698-9227-cb26941fde64_2003x1228.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></figure></div><p>The self-attention mechanism in the encoder is extremely important. It helps the model understand the relationships between different words in the input sentence. In essence, it assigns weights to words based on their relevance to each other. For instance, in our example &#8216;I love reading&#8217;, "love" might have a higher weight with respect to "reading" since it strongly influences the overall meaning of the user's question.</p><p>Another great example illustrating this is provided in the example 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_!fmdG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8c1d7ab-dda9-44a2-a7b4-1d8c0c37ed39_1400x479.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fmdG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8c1d7ab-dda9-44a2-a7b4-1d8c0c37ed39_1400x479.png 424w, https://substackcdn.com/image/fetch/$s_!fmdG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8c1d7ab-dda9-44a2-a7b4-1d8c0c37ed39_1400x479.png 848w, https://substackcdn.com/image/fetch/$s_!fmdG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8c1d7ab-dda9-44a2-a7b4-1d8c0c37ed39_1400x479.png 1272w, https://substackcdn.com/image/fetch/$s_!fmdG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8c1d7ab-dda9-44a2-a7b4-1d8c0c37ed39_1400x479.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fmdG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8c1d7ab-dda9-44a2-a7b4-1d8c0c37ed39_1400x479.png" width="1400" height="479" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a8c1d7ab-dda9-44a2-a7b4-1d8c0c37ed39_1400x479.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:479,&quot;width&quot;:1400,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:114386,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fmdG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8c1d7ab-dda9-44a2-a7b4-1d8c0c37ed39_1400x479.png 424w, https://substackcdn.com/image/fetch/$s_!fmdG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8c1d7ab-dda9-44a2-a7b4-1d8c0c37ed39_1400x479.png 848w, https://substackcdn.com/image/fetch/$s_!fmdG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8c1d7ab-dda9-44a2-a7b4-1d8c0c37ed39_1400x479.png 1272w, https://substackcdn.com/image/fetch/$s_!fmdG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8c1d7ab-dda9-44a2-a7b4-1d8c0c37ed39_1400x479.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></figure></div><p>In the above example, your brain automatically infers what each word refers to based on the context given from the previous words which were encountered. As an example, we can immediately see that &#8216;entered&#8217; refers to &#8216;aliens&#8217; &#8211; as in the aliens entered our planet. When looking at &#8216;planet&#8217; &#8211; we know that this reference refers to &#8216;earth&#8217; and &#8216;colonize&#8217;. In the same manner, much of the contextual information in every piece of text can easily be figured out by a human being, but the task of figuring it out for a machine is not easy!! This is where self-attention comes to the rescue!</p><p>To really understand how this layer works, we need to pay attention to the multi-head attention step outlined within the architecture:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5BMm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9f98f5a-615a-4b7a-bcf6-ef6a62ba25bf_991x631.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5BMm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9f98f5a-615a-4b7a-bcf6-ef6a62ba25bf_991x631.png 424w, https://substackcdn.com/image/fetch/$s_!5BMm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9f98f5a-615a-4b7a-bcf6-ef6a62ba25bf_991x631.png 848w, https://substackcdn.com/image/fetch/$s_!5BMm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9f98f5a-615a-4b7a-bcf6-ef6a62ba25bf_991x631.png 1272w, https://substackcdn.com/image/fetch/$s_!5BMm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9f98f5a-615a-4b7a-bcf6-ef6a62ba25bf_991x631.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5BMm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9f98f5a-615a-4b7a-bcf6-ef6a62ba25bf_991x631.png" width="991" height="631" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f9f98f5a-615a-4b7a-bcf6-ef6a62ba25bf_991x631.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:631,&quot;width&quot;:991,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:81696,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5BMm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9f98f5a-615a-4b7a-bcf6-ef6a62ba25bf_991x631.png 424w, https://substackcdn.com/image/fetch/$s_!5BMm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9f98f5a-615a-4b7a-bcf6-ef6a62ba25bf_991x631.png 848w, https://substackcdn.com/image/fetch/$s_!5BMm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9f98f5a-615a-4b7a-bcf6-ef6a62ba25bf_991x631.png 1272w, https://substackcdn.com/image/fetch/$s_!5BMm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9f98f5a-615a-4b7a-bcf6-ef6a62ba25bf_991x631.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></figure></div><p></p><h4><strong>Query, Key and Value Projections</strong></h4><p></p><p>In transformer architectures, the concepts of query, key, and value are essential components of the self-attention mechanism. These vectors are derived from the input sequence, and each word from our input sequence is &#8216;projected&#8217; on to a separate lower dimensional query(Q), key(K), and value(V) vectors.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!w2LP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7ab5768-64a0-4b1a-883f-5a99efff529d_978x466.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!w2LP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7ab5768-64a0-4b1a-883f-5a99efff529d_978x466.png 424w, https://substackcdn.com/image/fetch/$s_!w2LP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7ab5768-64a0-4b1a-883f-5a99efff529d_978x466.png 848w, https://substackcdn.com/image/fetch/$s_!w2LP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7ab5768-64a0-4b1a-883f-5a99efff529d_978x466.png 1272w, https://substackcdn.com/image/fetch/$s_!w2LP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7ab5768-64a0-4b1a-883f-5a99efff529d_978x466.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!w2LP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7ab5768-64a0-4b1a-883f-5a99efff529d_978x466.png" width="978" height="466" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a7ab5768-64a0-4b1a-883f-5a99efff529d_978x466.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:466,&quot;width&quot;:978,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:29382,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!w2LP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7ab5768-64a0-4b1a-883f-5a99efff529d_978x466.png 424w, https://substackcdn.com/image/fetch/$s_!w2LP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7ab5768-64a0-4b1a-883f-5a99efff529d_978x466.png 848w, https://substackcdn.com/image/fetch/$s_!w2LP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7ab5768-64a0-4b1a-883f-5a99efff529d_978x466.png 1272w, https://substackcdn.com/image/fetch/$s_!w2LP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7ab5768-64a0-4b1a-883f-5a99efff529d_978x466.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></figure></div><p>The query, key and value vectors don&#8217;t have to be smaller than our word vector, but in our example instance above, the word vector is mapped from a 4-dimensional vector to 3 separate 3-dimensional Q, K, and V vectors. The reason this might be done is to save on computational costs. In the original &#8216;attention is all you need&#8217; paper, the word vector dimensionality was 512 while the query, key and value vectors had a dimension of 64.</p><p>After this step is performed, these 3 vectors are then fed into our scaled dot-product attention layer 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_!S31Z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb1fa27a-91eb-4503-9d53-930ff0c4eaa1_349x495.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!S31Z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb1fa27a-91eb-4503-9d53-930ff0c4eaa1_349x495.png 424w, https://substackcdn.com/image/fetch/$s_!S31Z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb1fa27a-91eb-4503-9d53-930ff0c4eaa1_349x495.png 848w, https://substackcdn.com/image/fetch/$s_!S31Z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb1fa27a-91eb-4503-9d53-930ff0c4eaa1_349x495.png 1272w, https://substackcdn.com/image/fetch/$s_!S31Z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb1fa27a-91eb-4503-9d53-930ff0c4eaa1_349x495.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!S31Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb1fa27a-91eb-4503-9d53-930ff0c4eaa1_349x495.png" width="237" height="336.1461318051576" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cb1fa27a-91eb-4503-9d53-930ff0c4eaa1_349x495.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:495,&quot;width&quot;:349,&quot;resizeWidth&quot;:237,&quot;bytes&quot;:39724,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!S31Z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb1fa27a-91eb-4503-9d53-930ff0c4eaa1_349x495.png 424w, https://substackcdn.com/image/fetch/$s_!S31Z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb1fa27a-91eb-4503-9d53-930ff0c4eaa1_349x495.png 848w, https://substackcdn.com/image/fetch/$s_!S31Z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb1fa27a-91eb-4503-9d53-930ff0c4eaa1_349x495.png 1272w, https://substackcdn.com/image/fetch/$s_!S31Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb1fa27a-91eb-4503-9d53-930ff0c4eaa1_349x495.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></figure></div><p>Let&#8217;s take an example sentence &#8216;Nick visits Europe&#8217; and see how it breaks down in regards to the query, key, value mapping.</p><p>When your eyes see &#8216;<strong>Nick</strong>&#8217;, your brain looks for the most related word in the rest of the sentence to understand what Nick is referring to (query). Your brain then focuses or attends to the word &#8216;<strong>visit</strong>&#8217; (key). This process happens for each word in the sentence as your eyes progress through the sentence. How does a transformer provide a mapping from a query to a key though? </p><p>To understand this, we need to focus on the scaled dot product step:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!uJUb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cfe89bc-ac41-4f4b-9d6f-1922e22033be_817x501.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!uJUb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cfe89bc-ac41-4f4b-9d6f-1922e22033be_817x501.png 424w, https://substackcdn.com/image/fetch/$s_!uJUb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cfe89bc-ac41-4f4b-9d6f-1922e22033be_817x501.png 848w, https://substackcdn.com/image/fetch/$s_!uJUb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cfe89bc-ac41-4f4b-9d6f-1922e22033be_817x501.png 1272w, https://substackcdn.com/image/fetch/$s_!uJUb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cfe89bc-ac41-4f4b-9d6f-1922e22033be_817x501.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!uJUb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cfe89bc-ac41-4f4b-9d6f-1922e22033be_817x501.png" width="561" height="344.01591187270503" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8cfe89bc-ac41-4f4b-9d6f-1922e22033be_817x501.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:501,&quot;width&quot;:817,&quot;resizeWidth&quot;:561,&quot;bytes&quot;:63600,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!uJUb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cfe89bc-ac41-4f4b-9d6f-1922e22033be_817x501.png 424w, https://substackcdn.com/image/fetch/$s_!uJUb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cfe89bc-ac41-4f4b-9d6f-1922e22033be_817x501.png 848w, https://substackcdn.com/image/fetch/$s_!uJUb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cfe89bc-ac41-4f4b-9d6f-1922e22033be_817x501.png 1272w, https://substackcdn.com/image/fetch/$s_!uJUb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8cfe89bc-ac41-4f4b-9d6f-1922e22033be_817x501.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></figure></div><p>To actually find the mapping of queries to values, a transformer performs the steps outlined 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_!r78o!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bb35de-e2dd-4f41-bf4a-edc9dc0c98bd_319x379.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!r78o!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bb35de-e2dd-4f41-bf4a-edc9dc0c98bd_319x379.png 424w, https://substackcdn.com/image/fetch/$s_!r78o!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bb35de-e2dd-4f41-bf4a-edc9dc0c98bd_319x379.png 848w, https://substackcdn.com/image/fetch/$s_!r78o!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bb35de-e2dd-4f41-bf4a-edc9dc0c98bd_319x379.png 1272w, https://substackcdn.com/image/fetch/$s_!r78o!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bb35de-e2dd-4f41-bf4a-edc9dc0c98bd_319x379.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!r78o!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bb35de-e2dd-4f41-bf4a-edc9dc0c98bd_319x379.png" width="243" height="288.705329153605" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/37bb35de-e2dd-4f41-bf4a-edc9dc0c98bd_319x379.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:379,&quot;width&quot;:319,&quot;resizeWidth&quot;:243,&quot;bytes&quot;:17793,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!r78o!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bb35de-e2dd-4f41-bf4a-edc9dc0c98bd_319x379.png 424w, https://substackcdn.com/image/fetch/$s_!r78o!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bb35de-e2dd-4f41-bf4a-edc9dc0c98bd_319x379.png 848w, https://substackcdn.com/image/fetch/$s_!r78o!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bb35de-e2dd-4f41-bf4a-edc9dc0c98bd_319x379.png 1272w, https://substackcdn.com/image/fetch/$s_!r78o!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37bb35de-e2dd-4f41-bf4a-edc9dc0c98bd_319x379.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></figure></div><p>The first matrix multiply implements an inquiry system or question-answer system that imitates this brain function using a vector similarity calculation. Think of the matrix multiply as an inquiry system that processes the inquiry: "For the word (query) that your eyes see in the given sentence, what is the most related word (key) in the sentence to understand what the word (query) is about?"</p><p>There are multiple ways to calculate the similarity between vectors, and the transformer attention uses a simple dot product.</p><h4><strong>What is a dot product?</strong></h4><p>If we take the dot product of two vectors v and w, we get a scalar value showing the result of multiplying each of the corresponding vector components of v and w and adding them together:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KTHq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e11ee98-82cd-4269-b11e-bcf544614ba8_629x286.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KTHq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e11ee98-82cd-4269-b11e-bcf544614ba8_629x286.png 424w, https://substackcdn.com/image/fetch/$s_!KTHq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e11ee98-82cd-4269-b11e-bcf544614ba8_629x286.png 848w, https://substackcdn.com/image/fetch/$s_!KTHq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e11ee98-82cd-4269-b11e-bcf544614ba8_629x286.png 1272w, https://substackcdn.com/image/fetch/$s_!KTHq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e11ee98-82cd-4269-b11e-bcf544614ba8_629x286.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KTHq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e11ee98-82cd-4269-b11e-bcf544614ba8_629x286.png" width="585" height="265.99364069952304" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0e11ee98-82cd-4269-b11e-bcf544614ba8_629x286.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:286,&quot;width&quot;:629,&quot;resizeWidth&quot;:585,&quot;bytes&quot;:18521,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!KTHq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e11ee98-82cd-4269-b11e-bcf544614ba8_629x286.png 424w, https://substackcdn.com/image/fetch/$s_!KTHq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e11ee98-82cd-4269-b11e-bcf544614ba8_629x286.png 848w, https://substackcdn.com/image/fetch/$s_!KTHq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e11ee98-82cd-4269-b11e-bcf544614ba8_629x286.png 1272w, https://substackcdn.com/image/fetch/$s_!KTHq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e11ee98-82cd-4269-b11e-bcf544614ba8_629x286.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></figure></div><p>The <strong>larger the dot product value we get between 2 vectors, the higher their similarity</strong>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!u2Dr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb40d80b6-95ed-4128-8419-34c499bbfd88_734x324.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!u2Dr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb40d80b6-95ed-4128-8419-34c499bbfd88_734x324.png 424w, https://substackcdn.com/image/fetch/$s_!u2Dr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb40d80b6-95ed-4128-8419-34c499bbfd88_734x324.png 848w, https://substackcdn.com/image/fetch/$s_!u2Dr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb40d80b6-95ed-4128-8419-34c499bbfd88_734x324.png 1272w, https://substackcdn.com/image/fetch/$s_!u2Dr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb40d80b6-95ed-4128-8419-34c499bbfd88_734x324.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!u2Dr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb40d80b6-95ed-4128-8419-34c499bbfd88_734x324.png" width="555" height="244.98637602179838" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b40d80b6-95ed-4128-8419-34c499bbfd88_734x324.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:324,&quot;width&quot;:734,&quot;resizeWidth&quot;:555,&quot;bytes&quot;:14667,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!u2Dr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb40d80b6-95ed-4128-8419-34c499bbfd88_734x324.png 424w, https://substackcdn.com/image/fetch/$s_!u2Dr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb40d80b6-95ed-4128-8419-34c499bbfd88_734x324.png 848w, https://substackcdn.com/image/fetch/$s_!u2Dr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb40d80b6-95ed-4128-8419-34c499bbfd88_734x324.png 1272w, https://substackcdn.com/image/fetch/$s_!u2Dr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb40d80b6-95ed-4128-8419-34c499bbfd88_734x324.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></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sTdE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2d6e10f-c45f-4ed8-8e63-7246afd39d23_656x386.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sTdE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2d6e10f-c45f-4ed8-8e63-7246afd39d23_656x386.png 424w, https://substackcdn.com/image/fetch/$s_!sTdE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2d6e10f-c45f-4ed8-8e63-7246afd39d23_656x386.png 848w, https://substackcdn.com/image/fetch/$s_!sTdE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2d6e10f-c45f-4ed8-8e63-7246afd39d23_656x386.png 1272w, https://substackcdn.com/image/fetch/$s_!sTdE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2d6e10f-c45f-4ed8-8e63-7246afd39d23_656x386.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sTdE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2d6e10f-c45f-4ed8-8e63-7246afd39d23_656x386.png" width="580" height="341.280487804878" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b2d6e10f-c45f-4ed8-8e63-7246afd39d23_656x386.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:386,&quot;width&quot;:656,&quot;resizeWidth&quot;:580,&quot;bytes&quot;:13010,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sTdE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2d6e10f-c45f-4ed8-8e63-7246afd39d23_656x386.png 424w, https://substackcdn.com/image/fetch/$s_!sTdE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2d6e10f-c45f-4ed8-8e63-7246afd39d23_656x386.png 848w, https://substackcdn.com/image/fetch/$s_!sTdE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2d6e10f-c45f-4ed8-8e63-7246afd39d23_656x386.png 1272w, https://substackcdn.com/image/fetch/$s_!sTdE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2d6e10f-c45f-4ed8-8e63-7246afd39d23_656x386.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></figure></div><p>For each word (query), we compare it to all the keys within our text and find which ones are most similar using the scaled<strong> </strong>dot product. The higher the value we get for each dot product, the higher the similarity between the query and key. This is the essence of what our attention mechanism is and what our first matrix multiply operation does.</p><p>Notice also that I used the term <strong>scaled</strong> dot product here to describe attention. All this means is that in addition to taking the dot product of the vectors, we also divide the result by the square root of the dimension of the key vectors. As an example, if we used 128 dimensions to describe out key / query / value vectors &#8211; here we would simply take the dot product of the key and query vectors and divide this by the square root of 128. This ensures that using a large number of dimensions doesn&#8217;t produce extremely large dot products!! Here &#8211; we simply want to get a &#8216;similarity&#8217; between each vector that scales with the number of dimensions we use!</p><p>Noting this &#8211; let&#8217;s get back to our earlier example. Let&#8217;s take a look at the probability values that our matrix multiplication might provide:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zDRL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37810d59-f161-4ee5-a40b-5e150457027c_2167x551.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zDRL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37810d59-f161-4ee5-a40b-5e150457027c_2167x551.png 424w, https://substackcdn.com/image/fetch/$s_!zDRL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37810d59-f161-4ee5-a40b-5e150457027c_2167x551.png 848w, https://substackcdn.com/image/fetch/$s_!zDRL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37810d59-f161-4ee5-a40b-5e150457027c_2167x551.png 1272w, https://substackcdn.com/image/fetch/$s_!zDRL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37810d59-f161-4ee5-a40b-5e150457027c_2167x551.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zDRL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37810d59-f161-4ee5-a40b-5e150457027c_2167x551.png" width="575" height="146.1195054945055" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/37810d59-f161-4ee5-a40b-5e150457027c_2167x551.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:370,&quot;width&quot;:1456,&quot;resizeWidth&quot;:575,&quot;bytes&quot;:78447,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!zDRL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37810d59-f161-4ee5-a40b-5e150457027c_2167x551.png 424w, https://substackcdn.com/image/fetch/$s_!zDRL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37810d59-f161-4ee5-a40b-5e150457027c_2167x551.png 848w, https://substackcdn.com/image/fetch/$s_!zDRL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37810d59-f161-4ee5-a40b-5e150457027c_2167x551.png 1272w, https://substackcdn.com/image/fetch/$s_!zDRL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37810d59-f161-4ee5-a40b-5e150457027c_2167x551.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>After obtaining these values, they are scaled and a soft-max layer within the network is then used to <strong>normalize</strong> the output (such that the probabilities sum to 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_!6nsz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6faf72f-d73d-479f-8902-252bea8fe9b4_763x656.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6nsz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6faf72f-d73d-479f-8902-252bea8fe9b4_763x656.png 424w, https://substackcdn.com/image/fetch/$s_!6nsz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6faf72f-d73d-479f-8902-252bea8fe9b4_763x656.png 848w, https://substackcdn.com/image/fetch/$s_!6nsz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6faf72f-d73d-479f-8902-252bea8fe9b4_763x656.png 1272w, https://substackcdn.com/image/fetch/$s_!6nsz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6faf72f-d73d-479f-8902-252bea8fe9b4_763x656.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6nsz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6faf72f-d73d-479f-8902-252bea8fe9b4_763x656.png" width="479" height="411.826998689384" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f6faf72f-d73d-479f-8902-252bea8fe9b4_763x656.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:656,&quot;width&quot;:763,&quot;resizeWidth&quot;:479,&quot;bytes&quot;:43245,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6nsz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6faf72f-d73d-479f-8902-252bea8fe9b4_763x656.png 424w, https://substackcdn.com/image/fetch/$s_!6nsz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6faf72f-d73d-479f-8902-252bea8fe9b4_763x656.png 848w, https://substackcdn.com/image/fetch/$s_!6nsz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6faf72f-d73d-479f-8902-252bea8fe9b4_763x656.png 1272w, https://substackcdn.com/image/fetch/$s_!6nsz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6faf72f-d73d-479f-8902-252bea8fe9b4_763x656.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></figure></div><p>Finally, we get to the last matrix multiply step. This is what results in our value.</p><h4><strong>Question: </strong>What exactly is the difference between each key and each value?</h4><p>Well, there doesn&#8217;t have to be a difference, but if one exists &#8211; usually, you can think of the key as a mechanism which captures the sort of information the word represents (i.e. an adjective / noun next to some sort of property within the sentence giving it a specific meaning), while the value maps to the information that the word actually contains. Under the hood, the query, key and value are all just vectors, and a query and a key match if their vectors are similar.</p><h4>The Matrix (The Data Structure Used to Represent Our Data)</h4><p>The above captures the essence of what happens in the self-attention step, but if we wanted an illustration of what happens in regards to the computational side, we would get a much better image by focusing in on the matrix mechanics and matrix computations which take place.</p><p>Although we started our introduction to attention in terms of vectors, whereby each word from our input was transformed into a multi-dimensional numeric vector, the actual data structure fed into our self-attention system isn&#8217;t performed in terms of vector operations. Instead, matrices are used.</p><p>A matrix is basically an array of vectors. It provides a convenient way to represent and perform operations on data and mathematical objects in linear algebra. This representation is widely used in machine learning in order to optimize computational steps and processes (along with tensors, which are just higher-dimensional matrices).</p><p>The below diagram gives a full view of what happens during self-attention step in a transformer (using matrix mechanics):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!80EF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26981d59-031e-406e-9f10-596f40692fd9_1190x548.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!80EF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26981d59-031e-406e-9f10-596f40692fd9_1190x548.png 424w, https://substackcdn.com/image/fetch/$s_!80EF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26981d59-031e-406e-9f10-596f40692fd9_1190x548.png 848w, https://substackcdn.com/image/fetch/$s_!80EF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26981d59-031e-406e-9f10-596f40692fd9_1190x548.png 1272w, https://substackcdn.com/image/fetch/$s_!80EF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26981d59-031e-406e-9f10-596f40692fd9_1190x548.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!80EF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26981d59-031e-406e-9f10-596f40692fd9_1190x548.png" width="727" height="334.7865546218487" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/26981d59-031e-406e-9f10-596f40692fd9_1190x548.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:548,&quot;width&quot;:1190,&quot;resizeWidth&quot;:727,&quot;bytes&quot;:137888,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!80EF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26981d59-031e-406e-9f10-596f40692fd9_1190x548.png 424w, https://substackcdn.com/image/fetch/$s_!80EF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26981d59-031e-406e-9f10-596f40692fd9_1190x548.png 848w, https://substackcdn.com/image/fetch/$s_!80EF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26981d59-031e-406e-9f10-596f40692fd9_1190x548.png 1272w, https://substackcdn.com/image/fetch/$s_!80EF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26981d59-031e-406e-9f10-596f40692fd9_1190x548.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></figure></div><p>I won&#8217;t go into the full details here on what exact steps are involved, but I&#8217;ve included the full details on the exact matrix mechanics which take place at the end of this post in the appendix section. In essence, we are &#8216;scaling&#8217; each value projection by a &#8216;growth&#8217; and &#8216;shrink&#8217; factor which we realize by computing our query to key attention score and multiplying each value within it to a mapping within our value matrix. The end result is a value matrix <strong>scaled</strong> by our attention scores!</p><h4><strong>Add and Norm</strong></h4><p>After calculating our attention matrix, the original input embedding matrices fed into each layer are added to our output and an additional normalization step is performed:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sNhE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ff311-d44f-4f63-8893-03d59861eaf9_397x398.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sNhE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ff311-d44f-4f63-8893-03d59861eaf9_397x398.png 424w, https://substackcdn.com/image/fetch/$s_!sNhE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ff311-d44f-4f63-8893-03d59861eaf9_397x398.png 848w, https://substackcdn.com/image/fetch/$s_!sNhE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ff311-d44f-4f63-8893-03d59861eaf9_397x398.png 1272w, https://substackcdn.com/image/fetch/$s_!sNhE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ff311-d44f-4f63-8893-03d59861eaf9_397x398.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sNhE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ff311-d44f-4f63-8893-03d59861eaf9_397x398.png" width="265" height="265.66750629722924" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/945ff311-d44f-4f63-8893-03d59861eaf9_397x398.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:398,&quot;width&quot;:397,&quot;resizeWidth&quot;:265,&quot;bytes&quot;:23774,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sNhE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ff311-d44f-4f63-8893-03d59861eaf9_397x398.png 424w, https://substackcdn.com/image/fetch/$s_!sNhE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ff311-d44f-4f63-8893-03d59861eaf9_397x398.png 848w, https://substackcdn.com/image/fetch/$s_!sNhE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ff311-d44f-4f63-8893-03d59861eaf9_397x398.png 1272w, https://substackcdn.com/image/fetch/$s_!sNhE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ff311-d44f-4f63-8893-03d59861eaf9_397x398.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></figure></div><h4><strong>Addition:</strong></h4><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OnjB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4d2c967-e799-44c0-8cb8-72a2678553f7_1030x272.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OnjB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4d2c967-e799-44c0-8cb8-72a2678553f7_1030x272.png 424w, https://substackcdn.com/image/fetch/$s_!OnjB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4d2c967-e799-44c0-8cb8-72a2678553f7_1030x272.png 848w, https://substackcdn.com/image/fetch/$s_!OnjB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4d2c967-e799-44c0-8cb8-72a2678553f7_1030x272.png 1272w, https://substackcdn.com/image/fetch/$s_!OnjB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4d2c967-e799-44c0-8cb8-72a2678553f7_1030x272.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OnjB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4d2c967-e799-44c0-8cb8-72a2678553f7_1030x272.png" width="585" height="154.48543689320388" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b4d2c967-e799-44c0-8cb8-72a2678553f7_1030x272.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:272,&quot;width&quot;:1030,&quot;resizeWidth&quot;:585,&quot;bytes&quot;:7653,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OnjB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4d2c967-e799-44c0-8cb8-72a2678553f7_1030x272.png 424w, https://substackcdn.com/image/fetch/$s_!OnjB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4d2c967-e799-44c0-8cb8-72a2678553f7_1030x272.png 848w, https://substackcdn.com/image/fetch/$s_!OnjB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4d2c967-e799-44c0-8cb8-72a2678553f7_1030x272.png 1272w, https://substackcdn.com/image/fetch/$s_!OnjB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4d2c967-e799-44c0-8cb8-72a2678553f7_1030x272.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The first step is simple matrix addition. We take our input matrix and add the output of our multi-head attention layer.</p><h4><strong>Layer Normalization:</strong></h4><p>This plays a crucial role in stabilizing the learning process, reducing sensitivity to initialization, improving generalization, and handling inputs with different scales. It ensures that the mean activation of each layer is centered around zero and that the variance is approximately one. This helps stabilize the learning process by reducing the impact of variations in input distributions and allows for more efficient gradient propagation during training.</p><p>Let&#8217;s go through a simplified example to illustrate what normalization does to our input vectors:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WaQQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfeda465-df07-4837-bee5-d89a2009ad12_488x549.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WaQQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfeda465-df07-4837-bee5-d89a2009ad12_488x549.png 424w, https://substackcdn.com/image/fetch/$s_!WaQQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfeda465-df07-4837-bee5-d89a2009ad12_488x549.png 848w, https://substackcdn.com/image/fetch/$s_!WaQQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfeda465-df07-4837-bee5-d89a2009ad12_488x549.png 1272w, https://substackcdn.com/image/fetch/$s_!WaQQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfeda465-df07-4837-bee5-d89a2009ad12_488x549.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WaQQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfeda465-df07-4837-bee5-d89a2009ad12_488x549.png" width="312" height="351" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bfeda465-df07-4837-bee5-d89a2009ad12_488x549.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:549,&quot;width&quot;:488,&quot;resizeWidth&quot;:312,&quot;bytes&quot;:17626,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WaQQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfeda465-df07-4837-bee5-d89a2009ad12_488x549.png 424w, https://substackcdn.com/image/fetch/$s_!WaQQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfeda465-df07-4837-bee5-d89a2009ad12_488x549.png 848w, https://substackcdn.com/image/fetch/$s_!WaQQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfeda465-df07-4837-bee5-d89a2009ad12_488x549.png 1272w, https://substackcdn.com/image/fetch/$s_!WaQQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbfeda465-df07-4837-bee5-d89a2009ad12_488x549.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></figure></div><p>In the above instance, we&#8217;re given 2 sets of matrices containing a 3-dimensional word embedding. First, we take the average and variance of each matrix:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6E_N!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956da5c9-83b6-41c6-bfb6-3fc26ed38256_767x544.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6E_N!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956da5c9-83b6-41c6-bfb6-3fc26ed38256_767x544.png 424w, https://substackcdn.com/image/fetch/$s_!6E_N!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956da5c9-83b6-41c6-bfb6-3fc26ed38256_767x544.png 848w, https://substackcdn.com/image/fetch/$s_!6E_N!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956da5c9-83b6-41c6-bfb6-3fc26ed38256_767x544.png 1272w, https://substackcdn.com/image/fetch/$s_!6E_N!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956da5c9-83b6-41c6-bfb6-3fc26ed38256_767x544.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6E_N!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956da5c9-83b6-41c6-bfb6-3fc26ed38256_767x544.png" width="473" height="335.47848761408085" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/956da5c9-83b6-41c6-bfb6-3fc26ed38256_767x544.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:544,&quot;width&quot;:767,&quot;resizeWidth&quot;:473,&quot;bytes&quot;:31465,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6E_N!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956da5c9-83b6-41c6-bfb6-3fc26ed38256_767x544.png 424w, https://substackcdn.com/image/fetch/$s_!6E_N!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956da5c9-83b6-41c6-bfb6-3fc26ed38256_767x544.png 848w, https://substackcdn.com/image/fetch/$s_!6E_N!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956da5c9-83b6-41c6-bfb6-3fc26ed38256_767x544.png 1272w, https://substackcdn.com/image/fetch/$s_!6E_N!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956da5c9-83b6-41c6-bfb6-3fc26ed38256_767x544.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></figure></div><p>We then shift and transform each matrix such that the average of each value is 0 while the variance is set to 1:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6qSM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29c7a357-8a0f-4005-956f-7d486e0369bb_810x590.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6qSM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29c7a357-8a0f-4005-956f-7d486e0369bb_810x590.png 424w, https://substackcdn.com/image/fetch/$s_!6qSM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29c7a357-8a0f-4005-956f-7d486e0369bb_810x590.png 848w, https://substackcdn.com/image/fetch/$s_!6qSM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29c7a357-8a0f-4005-956f-7d486e0369bb_810x590.png 1272w, https://substackcdn.com/image/fetch/$s_!6qSM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29c7a357-8a0f-4005-956f-7d486e0369bb_810x590.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6qSM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29c7a357-8a0f-4005-956f-7d486e0369bb_810x590.png" width="517" height="376.58024691358025" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/29c7a357-8a0f-4005-956f-7d486e0369bb_810x590.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:590,&quot;width&quot;:810,&quot;resizeWidth&quot;:517,&quot;bytes&quot;:36331,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6qSM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29c7a357-8a0f-4005-956f-7d486e0369bb_810x590.png 424w, https://substackcdn.com/image/fetch/$s_!6qSM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29c7a357-8a0f-4005-956f-7d486e0369bb_810x590.png 848w, https://substackcdn.com/image/fetch/$s_!6qSM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29c7a357-8a0f-4005-956f-7d486e0369bb_810x590.png 1272w, https://substackcdn.com/image/fetch/$s_!6qSM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29c7a357-8a0f-4005-956f-7d486e0369bb_810x590.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></figure></div><p>And that&#8217;s it - we&#8217;re done!!</p><p>Layer normalization was originally used in recurrent neural networks to fix issues regarding batch normalization (another popular normalization methodology) which didn&#8217;t work well in natural language processing tasks. We won&#8217;t go into too many details here, but wanted mainly to note what the "add and norm" step does. To put it simply, it helps facilitate better gradient propagation and aids in learning.</p><h4>How can we understand self-attention intuitively?</h4><p>Most language models prior to ChatGPT were simple statistical models, with one common type being n-gram models. These models focused on predicting the next word in a sequence based on the previous n-1 words.</p><p>In other words, these models calculate the probability of each word given its context (the preceding words) and by being trained on a large corpus of text. A simple example of an n-gram model which is given the task of predicting what comes next in the sentence &#8216;The train of thought&#8217; is shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hBCX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fabae7c78-eb53-4b88-89e9-1f5336a4d202_2112x358.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hBCX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fabae7c78-eb53-4b88-89e9-1f5336a4d202_2112x358.png 424w, https://substackcdn.com/image/fetch/$s_!hBCX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fabae7c78-eb53-4b88-89e9-1f5336a4d202_2112x358.png 848w, https://substackcdn.com/image/fetch/$s_!hBCX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fabae7c78-eb53-4b88-89e9-1f5336a4d202_2112x358.png 1272w, https://substackcdn.com/image/fetch/$s_!hBCX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fabae7c78-eb53-4b88-89e9-1f5336a4d202_2112x358.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hBCX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fabae7c78-eb53-4b88-89e9-1f5336a4d202_2112x358.png" width="1456" height="247" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/abae7c78-eb53-4b88-89e9-1f5336a4d202_2112x358.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:247,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:52370,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hBCX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fabae7c78-eb53-4b88-89e9-1f5336a4d202_2112x358.png 424w, https://substackcdn.com/image/fetch/$s_!hBCX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fabae7c78-eb53-4b88-89e9-1f5336a4d202_2112x358.png 848w, https://substackcdn.com/image/fetch/$s_!hBCX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fabae7c78-eb53-4b88-89e9-1f5336a4d202_2112x358.png 1272w, https://substackcdn.com/image/fetch/$s_!hBCX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fabae7c78-eb53-4b88-89e9-1f5336a4d202_2112x358.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>In our above example, we&#8217;re using a 4-gram model. Our training data may contain sentences such as:</p><p>"The train of thought <strong>is</strong> difficult to follow."</p><p>"The train of thought <strong>can</strong> quickly derail."</p><p>"The train of thought <strong>often</strong> leads to creative ideas."</p><p>In a real-world scenario, these probabilities would be based on the occurrences of these word sequences in a large and diverse training dataset. In the above instance, if we were to focus in on the most probable word sequence, the 4-gram model would use the word &#8216;is.&#8217; We would thus feed in &#8216;train of thought <strong>is</strong>&#8217; as our next sequence and use a similar approach in our next word prediction task.</p><p>You can probably see that n-gram models tend to be very simple and have issues in &#8216;generalizing&#8217; word prediction tasks. They consider only a limited number of preceding words and have no conception of the meaning and context behind each word that&#8217;s encountered.</p><h4><strong>How do transformers address this issue?</strong></h4><p>As we already outlined &#8211; transformers don&#8217;t simply take the statistical distribution of words which come after a sample block of text. Transformers &#8216;transform&#8217; each word into a very large unique <strong>embedding vector</strong> which may contain more than 1,000 numeric values for each word within our vocabulary. We can think of these representations as representing a &#8216;neuron bundle&#8217; which is supposed to encode various properties of each word. After performing this step &#8211; we reduce the dimensions of this vector and feed it into our self-attention layer which:</p><ol><li><p>Takes each word within our block of text and performs a dot-product similarity score between each neighboring word present within the context window.</p></li><li><p>Scales each of the neighboring words within our context and adds them together to come up with a new &#8216;encoding&#8217; for our vocabulary word which now contains the context information behind each word.</p></li></ol><p>As an example, in the &#8216;the train of thought&#8217; sentence, the word<strong> train </strong>would in essence be processed in the following way:</p><ol><li><p>The relationship between &#8216;train&#8217; and its neighbors (&#8216;the&#8217;, &#8216;of&#8217;, &#8216;thought&#8217;) would be computed using a dot-product similarity score.</p></li><li><p>The similarity scores would be used to &#8216;scale&#8217; each of the neighboring word value vectors.</p></li><li><p>The scaled value vectors are all added together.</p></li></ol><p>A very simple high-level diagram capturing this is provided 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_!CI7g!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52d566ec-2e32-4b6a-bcf7-1fed4d5ac5f5_1194x755.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CI7g!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52d566ec-2e32-4b6a-bcf7-1fed4d5ac5f5_1194x755.png 424w, https://substackcdn.com/image/fetch/$s_!CI7g!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52d566ec-2e32-4b6a-bcf7-1fed4d5ac5f5_1194x755.png 848w, https://substackcdn.com/image/fetch/$s_!CI7g!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52d566ec-2e32-4b6a-bcf7-1fed4d5ac5f5_1194x755.png 1272w, https://substackcdn.com/image/fetch/$s_!CI7g!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52d566ec-2e32-4b6a-bcf7-1fed4d5ac5f5_1194x755.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CI7g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52d566ec-2e32-4b6a-bcf7-1fed4d5ac5f5_1194x755.png" width="1194" height="755" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/52d566ec-2e32-4b6a-bcf7-1fed4d5ac5f5_1194x755.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:755,&quot;width&quot;:1194,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:70697,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!CI7g!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52d566ec-2e32-4b6a-bcf7-1fed4d5ac5f5_1194x755.png 424w, https://substackcdn.com/image/fetch/$s_!CI7g!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52d566ec-2e32-4b6a-bcf7-1fed4d5ac5f5_1194x755.png 848w, https://substackcdn.com/image/fetch/$s_!CI7g!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52d566ec-2e32-4b6a-bcf7-1fed4d5ac5f5_1194x755.png 1272w, https://substackcdn.com/image/fetch/$s_!CI7g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52d566ec-2e32-4b6a-bcf7-1fed4d5ac5f5_1194x755.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></figure></div><p>The above ensures that our transformer model takes <strong>context </strong>in the word encoding!! As an example, when we usually think of the word <strong>train, </strong>we tend to think of its noun representation (i.e. a connected series of railroad cars lead by a locomotive), but in our example context &#8211; the word train refers to a completely different meaning! In our above context, train is used as a metaphor. It&#8217;s used to describe a sequence or series of events or actions.</p><p>The complexity doesn&#8217;t end there though. Train has other meanings as well &#8211; like "to train" means to instruct, guide, or educate someone or something. In other instances, we might be referring to training in the context of physical exercise! In other words, we must take <strong>context </strong>into account!! The word in isolation in other words cannot reveal the <strong>meaning </strong>behind it, so we must ensure to encode all of the relevant information! Humans do this naturally, but to do it within a machine learning model, a transformer uses the sequence of steps which we outlined earlier. By scaling the relationships and taking the dot product relations, we are ensuring that the context within each word is included in our model. This step within a transformer model is in essence what we call <strong>self-attention!</strong></p><h4>Multi-Head Attention</h4><p>The complexity doesn&#8217;t end here. To encode each word and its context, we don&#8217;t simply apply one transformer layer. To fully perform our encoding, the above process is done <strong>96 times</strong> (or more) with different query, key &amp; values scores and the results are added together. This is what we refer to as <strong>multi-head attention</strong>! You can think of the different layers as being different &#8216;image filters&#8217; for each word. We&#8217;re applying different filters and paying attention to different facets of each block of text which we&#8217;re processing. This ensures that we have a very thorough representation of each word and its context prior to moving on to our next steps, which employ back-propagation to train our model.</p><h4>Feed-forward neural network</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qwtY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31b90492-dbf9-4c16-8270-8e65295e4b4b_329x371.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qwtY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31b90492-dbf9-4c16-8270-8e65295e4b4b_329x371.png 424w, https://substackcdn.com/image/fetch/$s_!qwtY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31b90492-dbf9-4c16-8270-8e65295e4b4b_329x371.png 848w, https://substackcdn.com/image/fetch/$s_!qwtY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31b90492-dbf9-4c16-8270-8e65295e4b4b_329x371.png 1272w, https://substackcdn.com/image/fetch/$s_!qwtY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31b90492-dbf9-4c16-8270-8e65295e4b4b_329x371.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qwtY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31b90492-dbf9-4c16-8270-8e65295e4b4b_329x371.png" width="229" height="258.2340425531915" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/31b90492-dbf9-4c16-8270-8e65295e4b4b_329x371.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:371,&quot;width&quot;:329,&quot;resizeWidth&quot;:229,&quot;bytes&quot;:22523,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qwtY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31b90492-dbf9-4c16-8270-8e65295e4b4b_329x371.png 424w, https://substackcdn.com/image/fetch/$s_!qwtY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31b90492-dbf9-4c16-8270-8e65295e4b4b_329x371.png 848w, https://substackcdn.com/image/fetch/$s_!qwtY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31b90492-dbf9-4c16-8270-8e65295e4b4b_329x371.png 1272w, https://substackcdn.com/image/fetch/$s_!qwtY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31b90492-dbf9-4c16-8270-8e65295e4b4b_329x371.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></figure></div><p>After self-attention, the encoded representations of the words pass through a feed-forward neural network. An example image showing a fully connected feed-forward neural network is provided below for reference:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XNLi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9935f157-ab4f-4fc1-b318-05ace8069cbb_692x329.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XNLi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9935f157-ab4f-4fc1-b318-05ace8069cbb_692x329.png 424w, https://substackcdn.com/image/fetch/$s_!XNLi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9935f157-ab4f-4fc1-b318-05ace8069cbb_692x329.png 848w, https://substackcdn.com/image/fetch/$s_!XNLi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9935f157-ab4f-4fc1-b318-05ace8069cbb_692x329.png 1272w, https://substackcdn.com/image/fetch/$s_!XNLi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9935f157-ab4f-4fc1-b318-05ace8069cbb_692x329.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XNLi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9935f157-ab4f-4fc1-b318-05ace8069cbb_692x329.png" width="692" height="329" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9935f157-ab4f-4fc1-b318-05ace8069cbb_692x329.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:329,&quot;width&quot;:692,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:82524,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!XNLi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9935f157-ab4f-4fc1-b318-05ace8069cbb_692x329.png 424w, https://substackcdn.com/image/fetch/$s_!XNLi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9935f157-ab4f-4fc1-b318-05ace8069cbb_692x329.png 848w, https://substackcdn.com/image/fetch/$s_!XNLi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9935f157-ab4f-4fc1-b318-05ace8069cbb_692x329.png 1272w, https://substackcdn.com/image/fetch/$s_!XNLi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9935f157-ab4f-4fc1-b318-05ace8069cbb_692x329.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></figure></div><p>The neural network here is responsible for learning how to perform the task which the transformer is training to perform. A large neural network takes the encoded language and context that&#8217;s fed in attempts to map it to the appropriate training data. If the output of the network matches the final result, the network stays the same. If it results in the wrong value - backpropagation is applied and the network weights are adjusted. The network then has a higher chance of producing the correct result the next time the same language data is applied.  </p><p>GPT does <strong>not </strong>contain an encoder, so we are going to skip over the encoder neural network details here. We&#8217;ll address what these feed-forward models do more thoroughly in our <strong>decoder </strong>section.</p><h3><strong>Decoder Layers</strong></h3><p>The <strong>decoder</strong>, similar to the encoder, has multiple steps to perform. . Think of it this way: you&#8217;re paying a card game and the job in this game is to translate a sentence in one language to a sentence in another one. Let&#8217;s assume that we&#8217;re looking to perform English to French translation. You pick a random card and attempt to perform the translation by writing down what you believe is the correct French equivalent. After writing down your guess &#8211; you then take a look and compare it to the correct answer and adjust the neural-network weights based on the result. This is the gist of what our decoder here does. In terms of how this translates to GPT though, the training process is a bit different. GPT isn&#8217;t attempting to perform translations from one language to the next. In a GPT pre-training step, we are attempting to guess the <strong>next</strong> word in our input based on what we were fed in from a <strong>prior</strong> context. We already went through some examples when we discussed our encoding layer, but let&#8217;s go through another one just to illustrate how our training would proceed.</p><p>Let&#8217;s assume we are given the input:</p><p><em>&#8220;The problem with quotes on the internet is that they are often &#8230;&#8221; </em></p><p>Here, our task would be to guess the next word. We guess the next word. Based on our answer, we do what we did in the instance for translation: if it is the correct guess, our weights stay the same. If we guess wrong, we take a look at the correct answer and we adjust based on what we see. In the instance above, the correct completion sequence might be &#8220;often&#8221; followed by &#8220;wrong.&#8221;</p><p>One primary difference between the encoder and decoder blocks is that while the encoder can attend to all of the elements in the sequence to calculate the attention scores, the decoder is limited to only being able to use the <strong>previous</strong> elements. Instead of being fed in the whole input to output mapping, a mask is applied to the input. The decoder &#8216;guesses&#8217; what the correct output is and the mask is then removed on a word-by-word basis. The output is compared to the unmasked input and our weights are adjusted to account for training the decoder to &#8216;guess&#8217; the correct and appropriate words.</p><p>Of course, the above just gives an outline of what happens in this layer. Let&#8217;s once again go through the architecture mapped out in the &#8216;Attention is All You Need&#8217; paper and discuss what happens during each training stage in the decoder block.</p><p>An entire image of a decoder is presented 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_!A9Y0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80b68619-e5c4-4867-a800-eb7acf32cd94_254x660.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!A9Y0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80b68619-e5c4-4867-a800-eb7acf32cd94_254x660.png 424w, https://substackcdn.com/image/fetch/$s_!A9Y0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80b68619-e5c4-4867-a800-eb7acf32cd94_254x660.png 848w, https://substackcdn.com/image/fetch/$s_!A9Y0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80b68619-e5c4-4867-a800-eb7acf32cd94_254x660.png 1272w, https://substackcdn.com/image/fetch/$s_!A9Y0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80b68619-e5c4-4867-a800-eb7acf32cd94_254x660.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!A9Y0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80b68619-e5c4-4867-a800-eb7acf32cd94_254x660.png" width="240" height="623.6220472440945" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/80b68619-e5c4-4867-a800-eb7acf32cd94_254x660.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:660,&quot;width&quot;:254,&quot;resizeWidth&quot;:240,&quot;bytes&quot;:42521,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!A9Y0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80b68619-e5c4-4867-a800-eb7acf32cd94_254x660.png 424w, https://substackcdn.com/image/fetch/$s_!A9Y0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80b68619-e5c4-4867-a800-eb7acf32cd94_254x660.png 848w, https://substackcdn.com/image/fetch/$s_!A9Y0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80b68619-e5c4-4867-a800-eb7acf32cd94_254x660.png 1272w, https://substackcdn.com/image/fetch/$s_!A9Y0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80b68619-e5c4-4867-a800-eb7acf32cd94_254x660.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></figure></div><p>Let&#8217;s go through and cover what each block does one by one.</p><h4><strong>Output Embedding and Positional Encoding</strong></h4><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pBpD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f918272-c65b-4fe3-a1e7-4bea7c840383_227x165.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pBpD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f918272-c65b-4fe3-a1e7-4bea7c840383_227x165.png 424w, https://substackcdn.com/image/fetch/$s_!pBpD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f918272-c65b-4fe3-a1e7-4bea7c840383_227x165.png 848w, https://substackcdn.com/image/fetch/$s_!pBpD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f918272-c65b-4fe3-a1e7-4bea7c840383_227x165.png 1272w, https://substackcdn.com/image/fetch/$s_!pBpD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f918272-c65b-4fe3-a1e7-4bea7c840383_227x165.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pBpD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f918272-c65b-4fe3-a1e7-4bea7c840383_227x165.png" width="241" height="175.1762114537445" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6f918272-c65b-4fe3-a1e7-4bea7c840383_227x165.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:165,&quot;width&quot;:227,&quot;resizeWidth&quot;:241,&quot;bytes&quot;:12287,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!pBpD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f918272-c65b-4fe3-a1e7-4bea7c840383_227x165.png 424w, https://substackcdn.com/image/fetch/$s_!pBpD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f918272-c65b-4fe3-a1e7-4bea7c840383_227x165.png 848w, https://substackcdn.com/image/fetch/$s_!pBpD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f918272-c65b-4fe3-a1e7-4bea7c840383_227x165.png 1272w, https://substackcdn.com/image/fetch/$s_!pBpD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f918272-c65b-4fe3-a1e7-4bea7c840383_227x165.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This step is similar to what we outlined in our encoder model, so we&#8217;ll once again summarize what happens here: in essence, our words are mapped to numeric vectors and the positions of each word is encoded using sine and cosine functions.</p><h4>Masked Multi-Head Attention</h4><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!yiJp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbfded08-0616-42b8-9a59-25627ef0bce8_189x129.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!yiJp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbfded08-0616-42b8-9a59-25627ef0bce8_189x129.png 424w, https://substackcdn.com/image/fetch/$s_!yiJp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbfded08-0616-42b8-9a59-25627ef0bce8_189x129.png 848w, https://substackcdn.com/image/fetch/$s_!yiJp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbfded08-0616-42b8-9a59-25627ef0bce8_189x129.png 1272w, https://substackcdn.com/image/fetch/$s_!yiJp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbfded08-0616-42b8-9a59-25627ef0bce8_189x129.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!yiJp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbfded08-0616-42b8-9a59-25627ef0bce8_189x129.png" width="201" height="137.1904761904762" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cbfded08-0616-42b8-9a59-25627ef0bce8_189x129.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:129,&quot;width&quot;:189,&quot;resizeWidth&quot;:201,&quot;bytes&quot;:10014,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!yiJp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbfded08-0616-42b8-9a59-25627ef0bce8_189x129.png 424w, https://substackcdn.com/image/fetch/$s_!yiJp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbfded08-0616-42b8-9a59-25627ef0bce8_189x129.png 848w, https://substackcdn.com/image/fetch/$s_!yiJp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbfded08-0616-42b8-9a59-25627ef0bce8_189x129.png 1272w, https://substackcdn.com/image/fetch/$s_!yiJp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbfded08-0616-42b8-9a59-25627ef0bce8_189x129.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This is similar to our self-attention layer which we over-viewed when we went through our encoder &#8211; with the exception of adding in <strong>masking.</strong></p><h4>Masking</h4><p>For this step, we go through the procedure of mapping each word or token to 3 vectors representing the query (Q), key (K) and value (V) for each term in our sequence. We then perform the attention steps similar to the ones we outlined in our encoder with the added masking layer:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LPkk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb342ddd-459a-41c2-b08e-dc6de6e72fae_1233x609.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LPkk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb342ddd-459a-41c2-b08e-dc6de6e72fae_1233x609.png 424w, https://substackcdn.com/image/fetch/$s_!LPkk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb342ddd-459a-41c2-b08e-dc6de6e72fae_1233x609.png 848w, https://substackcdn.com/image/fetch/$s_!LPkk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb342ddd-459a-41c2-b08e-dc6de6e72fae_1233x609.png 1272w, https://substackcdn.com/image/fetch/$s_!LPkk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb342ddd-459a-41c2-b08e-dc6de6e72fae_1233x609.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LPkk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb342ddd-459a-41c2-b08e-dc6de6e72fae_1233x609.png" width="1233" height="609" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eb342ddd-459a-41c2-b08e-dc6de6e72fae_1233x609.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:609,&quot;width&quot;:1233,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:45372,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!LPkk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb342ddd-459a-41c2-b08e-dc6de6e72fae_1233x609.png 424w, https://substackcdn.com/image/fetch/$s_!LPkk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb342ddd-459a-41c2-b08e-dc6de6e72fae_1233x609.png 848w, https://substackcdn.com/image/fetch/$s_!LPkk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb342ddd-459a-41c2-b08e-dc6de6e72fae_1233x609.png 1272w, https://substackcdn.com/image/fetch/$s_!LPkk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb342ddd-459a-41c2-b08e-dc6de6e72fae_1233x609.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></figure></div><p>To actually employ masking, a mask-matrix is used. A mask-matrix is an upper triangular matrix where all of the entries above its main diagonal are set to minus infinity:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sQR2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F282f11c7-c079-4003-b6ce-31b3732c02ff_446x447.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sQR2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F282f11c7-c079-4003-b6ce-31b3732c02ff_446x447.png 424w, https://substackcdn.com/image/fetch/$s_!sQR2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F282f11c7-c079-4003-b6ce-31b3732c02ff_446x447.png 848w, https://substackcdn.com/image/fetch/$s_!sQR2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F282f11c7-c079-4003-b6ce-31b3732c02ff_446x447.png 1272w, https://substackcdn.com/image/fetch/$s_!sQR2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F282f11c7-c079-4003-b6ce-31b3732c02ff_446x447.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sQR2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F282f11c7-c079-4003-b6ce-31b3732c02ff_446x447.png" width="252" height="252.56502242152467" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/282f11c7-c079-4003-b6ce-31b3732c02ff_446x447.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:447,&quot;width&quot;:446,&quot;resizeWidth&quot;:252,&quot;bytes&quot;:14157,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sQR2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F282f11c7-c079-4003-b6ce-31b3732c02ff_446x447.png 424w, https://substackcdn.com/image/fetch/$s_!sQR2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F282f11c7-c079-4003-b6ce-31b3732c02ff_446x447.png 848w, https://substackcdn.com/image/fetch/$s_!sQR2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F282f11c7-c079-4003-b6ce-31b3732c02ff_446x447.png 1272w, https://substackcdn.com/image/fetch/$s_!sQR2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F282f11c7-c079-4003-b6ce-31b3732c02ff_446x447.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></figure></div><p></p><p>This matrix is added to our query-key &#8216;score&#8217; matrix (which holds our computed &#8216;similarity&#8217; values between each query and key) and it performs the masking step by ensuring that all of the look-ahead values within our word sequence are ignored. It does this through the negative infinity addition: each term which could be used as a look-ahead within our sequence is added to negative infinity (which produces negative infinity) and all of these terms are fed into the soft-max layer to produce next-word probability values set to 0:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MtHK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05786491-eb60-4ace-9f3f-fe96d1802feb_1038x672.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MtHK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05786491-eb60-4ace-9f3f-fe96d1802feb_1038x672.png 424w, https://substackcdn.com/image/fetch/$s_!MtHK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05786491-eb60-4ace-9f3f-fe96d1802feb_1038x672.png 848w, https://substackcdn.com/image/fetch/$s_!MtHK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05786491-eb60-4ace-9f3f-fe96d1802feb_1038x672.png 1272w, https://substackcdn.com/image/fetch/$s_!MtHK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05786491-eb60-4ace-9f3f-fe96d1802feb_1038x672.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MtHK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05786491-eb60-4ace-9f3f-fe96d1802feb_1038x672.png" width="551" height="356.71676300578036" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/05786491-eb60-4ace-9f3f-fe96d1802feb_1038x672.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:672,&quot;width&quot;:1038,&quot;resizeWidth&quot;:551,&quot;bytes&quot;:18446,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MtHK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05786491-eb60-4ace-9f3f-fe96d1802feb_1038x672.png 424w, https://substackcdn.com/image/fetch/$s_!MtHK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05786491-eb60-4ace-9f3f-fe96d1802feb_1038x672.png 848w, https://substackcdn.com/image/fetch/$s_!MtHK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05786491-eb60-4ace-9f3f-fe96d1802feb_1038x672.png 1272w, https://substackcdn.com/image/fetch/$s_!MtHK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05786491-eb60-4ace-9f3f-fe96d1802feb_1038x672.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></figure></div><h4><strong>Multi-head attention</strong></h4><p>This was already covered in the encoder architecture, but we&#8217;ll once again cover it again to make sure we understand what&#8217;s going on. The &#8216;multi-head&#8217; term simply means that our input is mapped to different Query, Key and Value vectors. The masking and similarity scores are computed for each one and the results are added together and projected back to an appropriate dimensional representation to capture the output of each separate head.</p><h4>Second Multi-Head Attention Step</h4><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ziSk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39a9c268-801b-4fa3-9d59-6c90685a71fa_577x367.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ziSk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39a9c268-801b-4fa3-9d59-6c90685a71fa_577x367.png 424w, https://substackcdn.com/image/fetch/$s_!ziSk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39a9c268-801b-4fa3-9d59-6c90685a71fa_577x367.png 848w, https://substackcdn.com/image/fetch/$s_!ziSk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39a9c268-801b-4fa3-9d59-6c90685a71fa_577x367.png 1272w, https://substackcdn.com/image/fetch/$s_!ziSk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39a9c268-801b-4fa3-9d59-6c90685a71fa_577x367.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ziSk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39a9c268-801b-4fa3-9d59-6c90685a71fa_577x367.png" width="531" height="337.7417677642981" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/39a9c268-801b-4fa3-9d59-6c90685a71fa_577x367.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:367,&quot;width&quot;:577,&quot;resizeWidth&quot;:531,&quot;bytes&quot;:36165,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ziSk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39a9c268-801b-4fa3-9d59-6c90685a71fa_577x367.png 424w, https://substackcdn.com/image/fetch/$s_!ziSk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39a9c268-801b-4fa3-9d59-6c90685a71fa_577x367.png 848w, https://substackcdn.com/image/fetch/$s_!ziSk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39a9c268-801b-4fa3-9d59-6c90685a71fa_577x367.png 1272w, https://substackcdn.com/image/fetch/$s_!ziSk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39a9c268-801b-4fa3-9d59-6c90685a71fa_577x367.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></figure></div><p>Here, we once again apply self-attention, but instead of using input strictly from either our decoder or encoder, we mix things up. Our <strong>decoder</strong> feeds in a <strong>masked query</strong> while the <strong>encoder</strong> feeds in the <strong>key and value</strong> vectors:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2KIb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b0f0ec-ced0-4955-957e-678144dc8afd_1162x660.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2KIb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b0f0ec-ced0-4955-957e-678144dc8afd_1162x660.png 424w, https://substackcdn.com/image/fetch/$s_!2KIb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b0f0ec-ced0-4955-957e-678144dc8afd_1162x660.png 848w, https://substackcdn.com/image/fetch/$s_!2KIb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b0f0ec-ced0-4955-957e-678144dc8afd_1162x660.png 1272w, https://substackcdn.com/image/fetch/$s_!2KIb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b0f0ec-ced0-4955-957e-678144dc8afd_1162x660.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2KIb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b0f0ec-ced0-4955-957e-678144dc8afd_1162x660.png" width="521" height="295.92082616179" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b9b0f0ec-ced0-4955-957e-678144dc8afd_1162x660.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:660,&quot;width&quot;:1162,&quot;resizeWidth&quot;:521,&quot;bytes&quot;:108203,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!2KIb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b0f0ec-ced0-4955-957e-678144dc8afd_1162x660.png 424w, https://substackcdn.com/image/fetch/$s_!2KIb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b0f0ec-ced0-4955-957e-678144dc8afd_1162x660.png 848w, https://substackcdn.com/image/fetch/$s_!2KIb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b0f0ec-ced0-4955-957e-678144dc8afd_1162x660.png 1272w, https://substackcdn.com/image/fetch/$s_!2KIb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9b0f0ec-ced0-4955-957e-678144dc8afd_1162x660.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></figure></div><p>As we already know &#8211; the query and key vectors (or matrices to be exact) are used to compute our similarity scores. In this instance, the query matrix containing our masked sequence self-attention scores are used to find mappings and similarities to our non-masked key values which we computed in our encoder. An encoder-decoder transformer does this in order to properly map one representation to the next: the decoder query is used and it&#8217;s mapped to the encoder key / value which contains our translated mappings. As an example, in English to French translation, the decoder would contain the masked French translation data while the encoder would feed in the query and key English mappings. For <strong>decoder-only transformers like ChatGPT </strong>&#8211; this step isn&#8217;t needed at all, so using different mappings from 2 different data-sources isn&#8217;t necessary. In the instance of large language models, we can simply use the <strong>masked</strong> self-attention as the default to <strong>encode</strong> our context since we aren&#8217;t attempting to map one neural representation to another one. Here - we&#8217;re simply attempting to guess the next word. Masking enables this for us without needing a separate encoding step.  </p><h4><strong>Key Differences Between Encoder-Decoder and Decoder-Only Models</strong></h4><p>To avoid any confusion, let&#8217;s summarize the key differences between encoder-decoder models (used in translation tasks) versus decoder-only models (used for text-generation):</p><p><strong>Encoder-Decoder Models:</strong></p><ul><li><p>Two distinct phases: encoding and decoding.</p></li><li><p>The encoder compresses the input sequence into a context vector, which is then used by the decoder to generate the output sequence.</p></li><li><p>Separate mechanisms for understanding and generating sequences, allowing for better separation of concerns.</p></li><li><p>Often used for tasks like language translation, where the input and output sequences may have different lengths.</p></li></ul><p><strong>Decoder-Only Models:</strong></p><ul><li><p>No separate encoding phase; the decoder processes the input sequence directly.</p></li><li><p>The model handles both understanding the input and generating the output simultaneously.</p></li><li><p>Typically used in tasks where the input and output sequences are of similar lengths or where there's no clear separation between encoding and decoding phases, such as language modeling or text generation.</p></li></ul><p>While both models serve the purpose of sequence-to-sequence tasks, they differ in how they handle the processing of input sequences and the generation of output sequences. The encoder-decoder model splits these tasks into separate phases while the decoder-only model integrates them into a single step. </p><h4>Addition and Layer Normalization</h4><p>Once again, we add our results together and we use <strong>layer normalization </strong>after each stage in order to make gradient propagation easier and in order to prevent our model from over-fitting the data set:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!R-iH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c2540da-060a-49dd-8ae1-bf65c73dcfd5_998x808.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!R-iH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c2540da-060a-49dd-8ae1-bf65c73dcfd5_998x808.png 424w, https://substackcdn.com/image/fetch/$s_!R-iH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c2540da-060a-49dd-8ae1-bf65c73dcfd5_998x808.png 848w, https://substackcdn.com/image/fetch/$s_!R-iH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c2540da-060a-49dd-8ae1-bf65c73dcfd5_998x808.png 1272w, https://substackcdn.com/image/fetch/$s_!R-iH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c2540da-060a-49dd-8ae1-bf65c73dcfd5_998x808.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!R-iH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c2540da-060a-49dd-8ae1-bf65c73dcfd5_998x808.png" width="998" height="808" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3c2540da-060a-49dd-8ae1-bf65c73dcfd5_998x808.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:808,&quot;width&quot;:998,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:143046,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!R-iH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c2540da-060a-49dd-8ae1-bf65c73dcfd5_998x808.png 424w, https://substackcdn.com/image/fetch/$s_!R-iH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c2540da-060a-49dd-8ae1-bf65c73dcfd5_998x808.png 848w, https://substackcdn.com/image/fetch/$s_!R-iH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c2540da-060a-49dd-8ae1-bf65c73dcfd5_998x808.png 1272w, https://substackcdn.com/image/fetch/$s_!R-iH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c2540da-060a-49dd-8ae1-bf65c73dcfd5_998x808.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></figure></div><p>Noting this, let&#8217;s move on to explaining the next phase &#8211; the <strong>most important phase</strong> within out transformer model, which is the feed-forward neural network. This is the key ingredient in making the whole model work.</p><h4>Second Feed-Forward Neural Network</h4><p>This is where the transformer model adjusts its weights. The masked layers which we outlined in the previous steps attempts to predict the next word in the sequence, and this layer simply looks at the discrepancies between the prediction and the real output and uses this information to adjust the feed-forward weights in order to minimize the error.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5rtu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85b79b86-9a0d-4e86-9a15-945672e78c25_429x591.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5rtu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85b79b86-9a0d-4e86-9a15-945672e78c25_429x591.png 424w, https://substackcdn.com/image/fetch/$s_!5rtu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85b79b86-9a0d-4e86-9a15-945672e78c25_429x591.png 848w, https://substackcdn.com/image/fetch/$s_!5rtu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85b79b86-9a0d-4e86-9a15-945672e78c25_429x591.png 1272w, https://substackcdn.com/image/fetch/$s_!5rtu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85b79b86-9a0d-4e86-9a15-945672e78c25_429x591.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5rtu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85b79b86-9a0d-4e86-9a15-945672e78c25_429x591.png" width="395" height="544.1608391608391" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/85b79b86-9a0d-4e86-9a15-945672e78c25_429x591.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:591,&quot;width&quot;:429,&quot;resizeWidth&quot;:395,&quot;bytes&quot;:49269,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5rtu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85b79b86-9a0d-4e86-9a15-945672e78c25_429x591.png 424w, https://substackcdn.com/image/fetch/$s_!5rtu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85b79b86-9a0d-4e86-9a15-945672e78c25_429x591.png 848w, https://substackcdn.com/image/fetch/$s_!5rtu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85b79b86-9a0d-4e86-9a15-945672e78c25_429x591.png 1272w, https://substackcdn.com/image/fetch/$s_!5rtu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85b79b86-9a0d-4e86-9a15-945672e78c25_429x591.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></figure></div><p>This network is responsible for adjusting our neuron weights based on which next-word &#8216;guesses&#8217; are correct and which ones are wrong. Once again &#8211; we have both the input and output. In relation to GPT: we are given text and our job is to try to predict next-word sequences within our text based on the input &#8216;query&#8217; or &#8216;data&#8217; which we are given. All next word pairs within a sequence are masked to try to guess the output, and when a guess is made, the masked next word is revealed and compared to our guess. The feed-forward layer then adjusts our weights to account for any negative or positive feedback within our network.</p><h4>How the Feed-Forward Model Works</h4><p>Neural networks are layers of &#8216;functions&#8217; or &#8216;neurons&#8217; which serve as function approximators. In the instance of a very simple transformer network, the multi-layered perceptron only has one hidden layer, albeit this layer is extremely large and has many hidden neurons:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Fm1h!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3861d7-7b67-4d21-82dc-ebe4282b8148_833x481.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Fm1h!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3861d7-7b67-4d21-82dc-ebe4282b8148_833x481.png 424w, https://substackcdn.com/image/fetch/$s_!Fm1h!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3861d7-7b67-4d21-82dc-ebe4282b8148_833x481.png 848w, https://substackcdn.com/image/fetch/$s_!Fm1h!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3861d7-7b67-4d21-82dc-ebe4282b8148_833x481.png 1272w, https://substackcdn.com/image/fetch/$s_!Fm1h!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3861d7-7b67-4d21-82dc-ebe4282b8148_833x481.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Fm1h!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3861d7-7b67-4d21-82dc-ebe4282b8148_833x481.png" width="463" height="267.3505402160864" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3e3861d7-7b67-4d21-82dc-ebe4282b8148_833x481.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:481,&quot;width&quot;:833,&quot;resizeWidth&quot;:463,&quot;bytes&quot;:30506,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Fm1h!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3861d7-7b67-4d21-82dc-ebe4282b8148_833x481.png 424w, https://substackcdn.com/image/fetch/$s_!Fm1h!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3861d7-7b67-4d21-82dc-ebe4282b8148_833x481.png 848w, https://substackcdn.com/image/fetch/$s_!Fm1h!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3861d7-7b67-4d21-82dc-ebe4282b8148_833x481.png 1272w, https://substackcdn.com/image/fetch/$s_!Fm1h!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3861d7-7b67-4d21-82dc-ebe4282b8148_833x481.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></figure></div><p>With enough hidden neurons, shallow neural networks can approximate any continuous function to arbitrary precision. In the instance of the original transformer architecture, the hidden layer could be made up of around ~48,000 neurons and the ReLU activation function is used (which has the merit of being easily interpretable).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6WQJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1beb1650-4da3-46aa-ad30-de6ff8dd9b6a_609x679.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6WQJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1beb1650-4da3-46aa-ad30-de6ff8dd9b6a_609x679.png 424w, https://substackcdn.com/image/fetch/$s_!6WQJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1beb1650-4da3-46aa-ad30-de6ff8dd9b6a_609x679.png 848w, https://substackcdn.com/image/fetch/$s_!6WQJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1beb1650-4da3-46aa-ad30-de6ff8dd9b6a_609x679.png 1272w, https://substackcdn.com/image/fetch/$s_!6WQJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1beb1650-4da3-46aa-ad30-de6ff8dd9b6a_609x679.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6WQJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1beb1650-4da3-46aa-ad30-de6ff8dd9b6a_609x679.png" width="481" height="536.2873563218391" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1beb1650-4da3-46aa-ad30-de6ff8dd9b6a_609x679.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:679,&quot;width&quot;:609,&quot;resizeWidth&quot;:481,&quot;bytes&quot;:50746,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6WQJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1beb1650-4da3-46aa-ad30-de6ff8dd9b6a_609x679.png 424w, https://substackcdn.com/image/fetch/$s_!6WQJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1beb1650-4da3-46aa-ad30-de6ff8dd9b6a_609x679.png 848w, https://substackcdn.com/image/fetch/$s_!6WQJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1beb1650-4da3-46aa-ad30-de6ff8dd9b6a_609x679.png 1272w, https://substackcdn.com/image/fetch/$s_!6WQJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1beb1650-4da3-46aa-ad30-de6ff8dd9b6a_609x679.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></figure></div><p>When we use ReLU activations within a neural network, it divides the input space into different regions. These regions are simple, regular shapes called convex polygons. Each ReLU neuron in the hidden layer is a participant in defining these regions via the production of hyperplanes, and a hyperplane is like a decision boundary that helps the network separate different parts of the input space. Essentially, the ReLU activation function helps the network define boundaries in the input space that determine which neuron is activated for different input values.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mpIM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21d10f7d-1759-442f-b20d-9d134ddb479d_2030x1520.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mpIM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21d10f7d-1759-442f-b20d-9d134ddb479d_2030x1520.png 424w, https://substackcdn.com/image/fetch/$s_!mpIM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21d10f7d-1759-442f-b20d-9d134ddb479d_2030x1520.png 848w, https://substackcdn.com/image/fetch/$s_!mpIM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21d10f7d-1759-442f-b20d-9d134ddb479d_2030x1520.png 1272w, https://substackcdn.com/image/fetch/$s_!mpIM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21d10f7d-1759-442f-b20d-9d134ddb479d_2030x1520.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mpIM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21d10f7d-1759-442f-b20d-9d134ddb479d_2030x1520.png" width="1456" height="1090" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/21d10f7d-1759-442f-b20d-9d134ddb479d_2030x1520.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1090,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:901389,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mpIM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21d10f7d-1759-442f-b20d-9d134ddb479d_2030x1520.png 424w, https://substackcdn.com/image/fetch/$s_!mpIM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21d10f7d-1759-442f-b20d-9d134ddb479d_2030x1520.png 848w, https://substackcdn.com/image/fetch/$s_!mpIM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21d10f7d-1759-442f-b20d-9d134ddb479d_2030x1520.png 1272w, https://substackcdn.com/image/fetch/$s_!mpIM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21d10f7d-1759-442f-b20d-9d134ddb479d_2030x1520.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></figure></div><p>ReLU activations allows neural networks to capture non-linear relationships and complex decision boundaries in the data, which is essential for learning and representing intricate patterns and structures in tasks like natural language processing, image recognition, and many other complex processing tasks.</p><p>Now &#8211; the activation function for GPT isn&#8217;t ReLU but something <strong>very close to it</strong>. The actual activation function is GELU (Gaussian Error Linear Unit). The GELU function is a smooth approximation of the rectifier (ReLU) function. It's defined as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7w-Z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8df5e613-da05-4a36-9dff-09901f75f690_1327x172.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7w-Z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8df5e613-da05-4a36-9dff-09901f75f690_1327x172.png 424w, https://substackcdn.com/image/fetch/$s_!7w-Z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8df5e613-da05-4a36-9dff-09901f75f690_1327x172.png 848w, https://substackcdn.com/image/fetch/$s_!7w-Z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8df5e613-da05-4a36-9dff-09901f75f690_1327x172.png 1272w, https://substackcdn.com/image/fetch/$s_!7w-Z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8df5e613-da05-4a36-9dff-09901f75f690_1327x172.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7w-Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8df5e613-da05-4a36-9dff-09901f75f690_1327x172.png" width="567" height="73.4920874152223" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8df5e613-da05-4a36-9dff-09901f75f690_1327x172.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:172,&quot;width&quot;:1327,&quot;resizeWidth&quot;:567,&quot;bytes&quot;:29871,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!7w-Z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8df5e613-da05-4a36-9dff-09901f75f690_1327x172.png 424w, https://substackcdn.com/image/fetch/$s_!7w-Z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8df5e613-da05-4a36-9dff-09901f75f690_1327x172.png 848w, https://substackcdn.com/image/fetch/$s_!7w-Z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8df5e613-da05-4a36-9dff-09901f75f690_1327x172.png 1272w, https://substackcdn.com/image/fetch/$s_!7w-Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8df5e613-da05-4a36-9dff-09901f75f690_1327x172.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lJiI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803101c3-3442-45fb-b8c3-7d1339b32dda_1800x1399.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lJiI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803101c3-3442-45fb-b8c3-7d1339b32dda_1800x1399.png 424w, https://substackcdn.com/image/fetch/$s_!lJiI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803101c3-3442-45fb-b8c3-7d1339b32dda_1800x1399.png 848w, https://substackcdn.com/image/fetch/$s_!lJiI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803101c3-3442-45fb-b8c3-7d1339b32dda_1800x1399.png 1272w, https://substackcdn.com/image/fetch/$s_!lJiI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803101c3-3442-45fb-b8c3-7d1339b32dda_1800x1399.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lJiI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803101c3-3442-45fb-b8c3-7d1339b32dda_1800x1399.png" width="589" height="457.93131868131866" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/803101c3-3442-45fb-b8c3-7d1339b32dda_1800x1399.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1132,&quot;width&quot;:1456,&quot;resizeWidth&quot;:589,&quot;bytes&quot;:95760,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lJiI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803101c3-3442-45fb-b8c3-7d1339b32dda_1800x1399.png 424w, https://substackcdn.com/image/fetch/$s_!lJiI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803101c3-3442-45fb-b8c3-7d1339b32dda_1800x1399.png 848w, https://substackcdn.com/image/fetch/$s_!lJiI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803101c3-3442-45fb-b8c3-7d1339b32dda_1800x1399.png 1272w, https://substackcdn.com/image/fetch/$s_!lJiI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F803101c3-3442-45fb-b8c3-7d1339b32dda_1800x1399.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></figure></div><p></p><p><strong>Some advantages of using GELU over RELU are provided below:</strong></p><ul><li><p>Unlike ReLU, GELU is a smooth function. It means it has a well-defined derivative everywhere, including at the point where the input is zero. This smoothness can be advantageous during training, especially when dealing with optimization algorithms that rely on derivatives.</p></li><li><p>The GELU function has a non-zero mean, which can be beneficial in certain contexts. This helps to maintain non-zero activations in the network, potentially addressing the problem where neurons can become inactive during training.</p></li><li><p>GELU has been found to enhance the representation power of the model. The smoothness and non-linearity introduced by GELU can contribute to capturing more complex patterns in the data.</p></li><li><p>Empirical evidence suggests that using GELU as an activation function can lead to better performance in certain tasks compared to ReLU. This improvement is task-dependent, but it has been observed in practice.</p></li></ul><p>This step is in essence where our model &#8216;learns&#8217; how to excel at generating language. It enhances the representation of each word by introducing non-linearity and capturing higher-order interactions between the input features. It then uses these enhancements to &#8216;train&#8217; on the masked data which is fed into it.</p><h4>More Intuition Behind the Feed-Forward Network</h4><p>When I initially used ChatGPT, my thoughts were that OpenAI had a lot more going on &#8216;behind the scenes&#8217; in its decoder-only transformer model than just simple scaling up of the transformer model and throwing in a ton of data at it. After going through other large-language models and listening to a few interviews done by its founder(s) though &#8211; my perception completely changed. The general impression I have now is that ChatGPT doesn&#8217;t use any added &#8216;magic&#8217; or algorithmic complexity which differs from other language models out there. In other words, although OpenAI may have found a few <strong>optimization techniques</strong> which make their transformer models more efficient to pre-train and tune (as well as having access to a larger volume and high-quality tuning data) &#8211; OpenAI may not have a &#8216;secret ingredient&#8217; which makes its models flourish. In other words, there is no &#8216;secret sauce&#8217; which makes their large model generalize better than other models out there.</p><p>I&#8217;m now in the camp that a huge neural network with many parameters are a lot more capable of &#8216;generalizing&#8217; information and capturing higher-order textual relations than I ever thought possible. Through the simple magic of deep learning, GPT might be capable of capturing patterns and complicated relationships through 2 simple methodologies:</p><ol><li><p>Scale: Make the feed-forward network a <strong>huge </strong>fully connected neural net with many parameters (along with many layers &#8211; albeit transformer models may simply have one layer which is easy to tune).</p></li><li><p>Large Data Set(s): Feed in a lot of data into the network (we&#8217;re talking about all of the internet data along with text books and other word text). The data set which GPT-3 uses is provided below:</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!a9yZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F177125f3-2301-43ba-a586-6a5582e957e6_2051x1122.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!a9yZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F177125f3-2301-43ba-a586-6a5582e957e6_2051x1122.png 424w, https://substackcdn.com/image/fetch/$s_!a9yZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F177125f3-2301-43ba-a586-6a5582e957e6_2051x1122.png 848w, https://substackcdn.com/image/fetch/$s_!a9yZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F177125f3-2301-43ba-a586-6a5582e957e6_2051x1122.png 1272w, https://substackcdn.com/image/fetch/$s_!a9yZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F177125f3-2301-43ba-a586-6a5582e957e6_2051x1122.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!a9yZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F177125f3-2301-43ba-a586-6a5582e957e6_2051x1122.png" width="1456" height="797" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/177125f3-2301-43ba-a586-6a5582e957e6_2051x1122.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:797,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:512042,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!a9yZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F177125f3-2301-43ba-a586-6a5582e957e6_2051x1122.png 424w, https://substackcdn.com/image/fetch/$s_!a9yZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F177125f3-2301-43ba-a586-6a5582e957e6_2051x1122.png 848w, https://substackcdn.com/image/fetch/$s_!a9yZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F177125f3-2301-43ba-a586-6a5582e957e6_2051x1122.png 1272w, https://substackcdn.com/image/fetch/$s_!a9yZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F177125f3-2301-43ba-a586-6a5582e957e6_2051x1122.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></figure></div><p>You may have the impression that a simple architecture where you simply scale up a decoder-only model and add huge feed-forward layers would not result in something like ChatGPT, but you would be wrong. Other LLM models are currently being trained and are getting closer to generating the results that ChatGPT generates, albeit all of them are not quite there. Some huge models ranked by their &#8216;power&#8217; are provided 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_!ba_Z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865aa77f-da0c-447b-b8e0-f5291faec5a9_1582x1563.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ba_Z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865aa77f-da0c-447b-b8e0-f5291faec5a9_1582x1563.png 424w, https://substackcdn.com/image/fetch/$s_!ba_Z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865aa77f-da0c-447b-b8e0-f5291faec5a9_1582x1563.png 848w, https://substackcdn.com/image/fetch/$s_!ba_Z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865aa77f-da0c-447b-b8e0-f5291faec5a9_1582x1563.png 1272w, https://substackcdn.com/image/fetch/$s_!ba_Z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865aa77f-da0c-447b-b8e0-f5291faec5a9_1582x1563.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ba_Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865aa77f-da0c-447b-b8e0-f5291faec5a9_1582x1563.png" width="533" height="526.7767857142857" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/865aa77f-da0c-447b-b8e0-f5291faec5a9_1582x1563.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1439,&quot;width&quot;:1456,&quot;resizeWidth&quot;:533,&quot;bytes&quot;:650662,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ba_Z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865aa77f-da0c-447b-b8e0-f5291faec5a9_1582x1563.png 424w, https://substackcdn.com/image/fetch/$s_!ba_Z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865aa77f-da0c-447b-b8e0-f5291faec5a9_1582x1563.png 848w, https://substackcdn.com/image/fetch/$s_!ba_Z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865aa77f-da0c-447b-b8e0-f5291faec5a9_1582x1563.png 1272w, https://substackcdn.com/image/fetch/$s_!ba_Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865aa77f-da0c-447b-b8e0-f5291faec5a9_1582x1563.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></figure></div><p>A great image which also captures some of the capabilities achieved by different LLMs is also shown in the image 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_!2JwQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd2c2060-c692-4e2c-a1b4-a25396aa9690_1959x1230.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2JwQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd2c2060-c692-4e2c-a1b4-a25396aa9690_1959x1230.png 424w, https://substackcdn.com/image/fetch/$s_!2JwQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd2c2060-c692-4e2c-a1b4-a25396aa9690_1959x1230.png 848w, https://substackcdn.com/image/fetch/$s_!2JwQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd2c2060-c692-4e2c-a1b4-a25396aa9690_1959x1230.png 1272w, https://substackcdn.com/image/fetch/$s_!2JwQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd2c2060-c692-4e2c-a1b4-a25396aa9690_1959x1230.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2JwQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd2c2060-c692-4e2c-a1b4-a25396aa9690_1959x1230.png" width="1456" height="914" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cd2c2060-c692-4e2c-a1b4-a25396aa9690_1959x1230.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:914,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1592481,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!2JwQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd2c2060-c692-4e2c-a1b4-a25396aa9690_1959x1230.png 424w, https://substackcdn.com/image/fetch/$s_!2JwQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd2c2060-c692-4e2c-a1b4-a25396aa9690_1959x1230.png 848w, https://substackcdn.com/image/fetch/$s_!2JwQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd2c2060-c692-4e2c-a1b4-a25396aa9690_1959x1230.png 1272w, https://substackcdn.com/image/fetch/$s_!2JwQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd2c2060-c692-4e2c-a1b4-a25396aa9690_1959x1230.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></figure></div><p>Lex Friedman did a great interview with the co-founder and chief scientist at OpenAI Ilya Sutskever in 2020 which does a great job in highlighting some key insights in the magic of deep neural networks and their role in LLMs / ChatGPT which I decided to highlight and provide below.</p><div><hr></div><blockquote><p>Ilya Sutskever: &#8220;The most beautiful thing about deep learning is that it actually works. And I mean it; because you got these ideas, you've got a little neural network, you've got the back propagation algorithm. And then you've got <strong>some theories as to, you know, this is kind of like the brain, so maybe if you make it large &#8230; if you make the neural network large and you trained in a lot of data, then it will &#8230; do the same function of the brain does, and it turns out to be true, it&#8217;s crazy!</strong>&#8221;</p></blockquote><div><hr></div><blockquote><p>Ilya Sutskever: &#8220;Yeah, let's make a big neural network. Let's train is and it's going to work much better than anything before it. And it will, in fact, continue to get better and make it larger. And it turns out to be true. That's amazing. When a theory is validated with this, you know, it's not a mathematical theory. <strong>It's more of a biological theory almost.</strong>&#8221;</p></blockquote><div><hr></div><p><strong>Ilya</strong> <strong>on how LLMs / neural nets may capture higher-level information within text:</strong></p><blockquote><p>Ilya Sutskever: So the history is really, you know, fairly long at least and the thing that started, the thing that changed the trajectory of neural networks and language is the thing that changed the trajectory of all deep learning and that's <strong>data and compute</strong>. So suddenly you move from small language models, which learn a little bit, and with language models in particular, there's a very clear explanation for why they need to be large to be good, because they're trying to predict the next word. So when you don't know anything, you'll notice very, very broad strokes, surface level patterns, like sometimes there are characters and there is a space between those characters. You'll notice this pattern and you'll notice that sometimes there is a comma and then the next character is a capital letter. You'll notice that pattern. Eventually you may start to notice that there are certain words occur often. You may notice that spellings are a thing. You may notice syntax. And when you get really good at all these, you start to notice the semantics. You start to notice the facts. But for that to happen,<strong> the language model needs to be larger.</strong></p><p>Lex Friedman: So that's, let's linger on that, because that's where you and Noam Chomsky disagree. So you think we're actually taking incremental steps, a sort of larger network, larger compute will be able to get to the semantics, to be able to understand language without what Noam likes to sort of think of as a fundamental understandings of the structure of language, like imposing your theory of language onto the learning mechanism. So <strong>you're saying the learning, you can learn from raw data, the mechanism that underlies language.</strong></p><p>Ilya Sutskever: Well, I think it's pretty likely, but I also want to say that I don't really know precisely what Chomsky means when he talks about ... You said something about imposing your structural language. I'm not 100% sure what he means, but empirically it seems that when you inspect those larger language models, they <strong>exhibit signs of understanding the semantics </strong>whereas the smaller language models do not. We've seen that a few years ago when we did work on the sentiment neuron. We trained a small, you know, smallish LSTM to predict the next character in Amazon reviews. And we noticed that <strong>when you increase the size of the LSTM from 500 LSTM cells to 4,000 LSTM cells, then one of the neurons starts to represent the sentiment of the article</strong>, sorry, of the review. Now, why is that? Sentiment is a pretty semantic attribute. It's not a syntactic attribute.</p><p>Lex Friedman: And for people who might not know, I don't know if that's a standard term, but sentiment is whether it's a positive or a negative review.</p><p>Ilya Sutskever: That's right. Is the person happy with something or is the person unhappy with something? And so <strong>here we had very clear evidence that a small neural net does not capture sentiment while a large neural net does. And why is that? Well, our theory is that at some point you run out of syntax to model, you gotta start to focus on something else.</strong></p><p>Lex Friedman: And <strong>with size, you quickly run out of syntax to model and then you really start to focus on the semantics would be the idea.</strong></p><p>Ilya Sutskever: That's right. And so I don't wanna imply that our models have complete semantic understanding because that's not true, but they definitely <strong>are showing signs of semantic understanding, partial semantic understanding</strong>, but the smaller models do not show those signs.</p><p>Lex Friedman: Can you take a step back and say, what is GPT2, which is one of the big language models that was the conversation changer in the past couple of years?</p><p>Ilya Sutskever: Yeah, so <strong>GPT2 is a transformer with one and a half billion parameters that was trained on about 40 billion tokens of text</strong> which were obtained from web pages that were linked to from Reddit articles with more than three votes.</p><p>Lex Friedman: And what's a transformer?</p><p>Ilya Sutskever: The <strong>transformer, it's the most important advance in neural network architectures in recent history.</strong></p><p>Lex Friedman: What is attention maybe too? Cause I think that's an interesting idea, not necessarily sort of technically speaking, but the idea of attention versus maybe what recurrent neural networks represent.</p><p>Ilya Sutskever: Yeah, so the thing is the transformer is a combination of multiple ideas simultaneously of which attention is one.</p><p>Lex Friedman: Do you think attention is the key?</p><p>Ilya Sutskever: No, it's a key, but it's not the key. The <strong>transformer is successful because it is the simultaneous combination of multiple ideas. And if you were to remove either idea, it would be much less successful. So the transformer uses a lot of attention, but attention existed for a few years. So that can't be the main innovation. The transformer is designed in such a way that it runs really fast on the GPU. And that makes a huge amount of difference. This is one thing. The second thing is that transformer is not recurrent. And that is really important too, because it is more shallow and therefore much easier to optimize. So in other words, it uses attention, it is a really great fit to the GPU and it is not recurrent, so therefore less deep and easier to optimize. And the combination of those factors make it successful.</strong></p></blockquote><div><hr></div><p>In other words &#8211; Ilya tells us that the &#8216;secret&#8217; towards getting GPT to do what it does is through making it bigger, giving it more data and letting the large shallow neural network figure out the key contextual relationships which it needs to &#8216;figure&#8217; out in order to be great at generating text.</p><h4><strong>Yes, but can we get a better intuitive understanding of what each layer encodes?</strong></h4><p>To do this, we can reference the paper titled <a href="https://arxiv.org/pdf/2012.14913.pdf">Transformer Feed-Forward Layers Are Key-Value Memories</a></p><p>The paper goes on to explain that each key in a transformer corresponds to specific text patterns found in the training examples, while each value influences the distribution of the possible output words. They also found that lower layers (self-attention) of the model capture simple and shallow patterns while the higher layers (feed-forward) capture more semantic / complex ones. These feed-forward layers in other words seem to be responsible for much of the amazing performance in transformer models.</p><p>They attempt to also show that the output of a feed-forward layer is a combination of its memories, which are further refined across the model's layers using residual connections resulting in the final distribution of likely output words. A great summary image provided in the paper 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_!F90B!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16b52d92-7040-4c17-8953-186c8b225e90_479x704.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!F90B!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16b52d92-7040-4c17-8953-186c8b225e90_479x704.png 424w, https://substackcdn.com/image/fetch/$s_!F90B!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16b52d92-7040-4c17-8953-186c8b225e90_479x704.png 848w, https://substackcdn.com/image/fetch/$s_!F90B!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16b52d92-7040-4c17-8953-186c8b225e90_479x704.png 1272w, https://substackcdn.com/image/fetch/$s_!F90B!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16b52d92-7040-4c17-8953-186c8b225e90_479x704.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!F90B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16b52d92-7040-4c17-8953-186c8b225e90_479x704.png" width="429" height="630.5135699373695" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/16b52d92-7040-4c17-8953-186c8b225e90_479x704.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:704,&quot;width&quot;:479,&quot;resizeWidth&quot;:429,&quot;bytes&quot;:73290,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!F90B!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16b52d92-7040-4c17-8953-186c8b225e90_479x704.png 424w, https://substackcdn.com/image/fetch/$s_!F90B!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16b52d92-7040-4c17-8953-186c8b225e90_479x704.png 848w, https://substackcdn.com/image/fetch/$s_!F90B!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16b52d92-7040-4c17-8953-186c8b225e90_479x704.png 1272w, https://substackcdn.com/image/fetch/$s_!F90B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16b52d92-7040-4c17-8953-186c8b225e90_479x704.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></figure></div><p>Some great examples illustrating the difference between shallow and semantic patterns are also provided:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MbpW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c37397-4b22-44d7-8751-5b5b740f6482_618x477.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MbpW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c37397-4b22-44d7-8751-5b5b740f6482_618x477.png 424w, https://substackcdn.com/image/fetch/$s_!MbpW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c37397-4b22-44d7-8751-5b5b740f6482_618x477.png 848w, https://substackcdn.com/image/fetch/$s_!MbpW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c37397-4b22-44d7-8751-5b5b740f6482_618x477.png 1272w, https://substackcdn.com/image/fetch/$s_!MbpW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c37397-4b22-44d7-8751-5b5b740f6482_618x477.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MbpW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c37397-4b22-44d7-8751-5b5b740f6482_618x477.png" width="492" height="379.747572815534" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/87c37397-4b22-44d7-8751-5b5b740f6482_618x477.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:477,&quot;width&quot;:618,&quot;resizeWidth&quot;:492,&quot;bytes&quot;:48318,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MbpW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c37397-4b22-44d7-8751-5b5b740f6482_618x477.png 424w, https://substackcdn.com/image/fetch/$s_!MbpW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c37397-4b22-44d7-8751-5b5b740f6482_618x477.png 848w, https://substackcdn.com/image/fetch/$s_!MbpW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c37397-4b22-44d7-8751-5b5b740f6482_618x477.png 1272w, https://substackcdn.com/image/fetch/$s_!MbpW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c37397-4b22-44d7-8751-5b5b740f6482_618x477.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></figure></div><p>Image from the paper which demonstrates that neurons from lower layers capture shallow patterns while higher layers capture more semantic ones:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Kk1P!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fe073b7-67a7-404c-bbcf-4b0ab5b5d9b7_1021x483.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Kk1P!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fe073b7-67a7-404c-bbcf-4b0ab5b5d9b7_1021x483.png 424w, https://substackcdn.com/image/fetch/$s_!Kk1P!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fe073b7-67a7-404c-bbcf-4b0ab5b5d9b7_1021x483.png 848w, https://substackcdn.com/image/fetch/$s_!Kk1P!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fe073b7-67a7-404c-bbcf-4b0ab5b5d9b7_1021x483.png 1272w, https://substackcdn.com/image/fetch/$s_!Kk1P!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fe073b7-67a7-404c-bbcf-4b0ab5b5d9b7_1021x483.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Kk1P!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fe073b7-67a7-404c-bbcf-4b0ab5b5d9b7_1021x483.png" width="1021" height="483" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6fe073b7-67a7-404c-bbcf-4b0ab5b5d9b7_1021x483.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:483,&quot;width&quot;:1021,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:165797,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Kk1P!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fe073b7-67a7-404c-bbcf-4b0ab5b5d9b7_1021x483.png 424w, https://substackcdn.com/image/fetch/$s_!Kk1P!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fe073b7-67a7-404c-bbcf-4b0ab5b5d9b7_1021x483.png 848w, https://substackcdn.com/image/fetch/$s_!Kk1P!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fe073b7-67a7-404c-bbcf-4b0ab5b5d9b7_1021x483.png 1272w, https://substackcdn.com/image/fetch/$s_!Kk1P!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fe073b7-67a7-404c-bbcf-4b0ab5b5d9b7_1021x483.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></figure></div><p>A paper which hints that the feed-forward layers function more than just &#8216;key-value memories&#8217; is available here: <a href="https://arxiv.org/pdf/2309.04827.pdf">Neurons in Large Language Models: Dead, N-gram, Positional</a>. </p><p>Some key highlights:</p><ol><li><p>In the early part of the network, many neurons are inactive, meaning they don't activate on a wide range of data (more than 70% in some layers of the 66 billion parameter model).</p></li><li><p>The active neurons are mainly reserved for detecting specific features, like tokens and n-grams.</p></li><li><p>Interestingly, these active neurons not only suggest the next token but also focus on removing information about the current input, which is a novel finding.</p></li><li><p>As the model size increases, it becomes more sparse, meaning it has more inactive neurons and token detectors.</p></li><li><p>Some neurons are position-dependent, meaning they activate or deactivate based on position rather than textual data (mostly in smaller large language models).</p></li><li><p>Smaller models have neurons indicating position ranges more explicitly, while larger models do this in a less clear manner.</p></li></ol><p>Similarly to the key-value paper, they show that early layers encode largely shallow lexical patterns while later layers encode high-level semantics.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!N36L!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F959f4b51-67fc-452c-b76f-3a9e5cc2b39d_1055x473.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!N36L!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F959f4b51-67fc-452c-b76f-3a9e5cc2b39d_1055x473.png 424w, https://substackcdn.com/image/fetch/$s_!N36L!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F959f4b51-67fc-452c-b76f-3a9e5cc2b39d_1055x473.png 848w, https://substackcdn.com/image/fetch/$s_!N36L!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F959f4b51-67fc-452c-b76f-3a9e5cc2b39d_1055x473.png 1272w, https://substackcdn.com/image/fetch/$s_!N36L!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F959f4b51-67fc-452c-b76f-3a9e5cc2b39d_1055x473.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!N36L!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F959f4b51-67fc-452c-b76f-3a9e5cc2b39d_1055x473.png" width="1055" height="473" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/959f4b51-67fc-452c-b76f-3a9e5cc2b39d_1055x473.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:473,&quot;width&quot;:1055,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:104575,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!N36L!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F959f4b51-67fc-452c-b76f-3a9e5cc2b39d_1055x473.png 424w, https://substackcdn.com/image/fetch/$s_!N36L!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F959f4b51-67fc-452c-b76f-3a9e5cc2b39d_1055x473.png 848w, https://substackcdn.com/image/fetch/$s_!N36L!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F959f4b51-67fc-452c-b76f-3a9e5cc2b39d_1055x473.png 1272w, https://substackcdn.com/image/fetch/$s_!N36L!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F959f4b51-67fc-452c-b76f-3a9e5cc2b39d_1055x473.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></figure></div><p>Since the number of possible shallow patterns is not large and potentially, enumerable, in the early layers, the model can assign dedicated neurons to some features. The more neurons that are available to the model the easier this is to do and so larger models tend to be more sparse. In addition to this, smaller models rely substantially on oscillatory neurons: this is the most frequent type of positional neurons for models smaller than 6.7b of parameters. In combination with many less than/greater than neurons, the model is able to derive token's absolute position rather accurately. Interestingly, larger models do not have oscillatory neurons and rely on more generic patterns shown with red- and green-colored circles:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_Xuv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e842dbb-849f-4a92-bea1-ed687e087b27_2063x1377.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_Xuv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e842dbb-849f-4a92-bea1-ed687e087b27_2063x1377.png 424w, https://substackcdn.com/image/fetch/$s_!_Xuv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e842dbb-849f-4a92-bea1-ed687e087b27_2063x1377.png 848w, https://substackcdn.com/image/fetch/$s_!_Xuv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e842dbb-849f-4a92-bea1-ed687e087b27_2063x1377.png 1272w, https://substackcdn.com/image/fetch/$s_!_Xuv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e842dbb-849f-4a92-bea1-ed687e087b27_2063x1377.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_Xuv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e842dbb-849f-4a92-bea1-ed687e087b27_2063x1377.png" width="1456" height="972" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4e842dbb-849f-4a92-bea1-ed687e087b27_2063x1377.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:972,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1214012,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_Xuv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e842dbb-849f-4a92-bea1-ed687e087b27_2063x1377.png 424w, https://substackcdn.com/image/fetch/$s_!_Xuv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e842dbb-849f-4a92-bea1-ed687e087b27_2063x1377.png 848w, https://substackcdn.com/image/fetch/$s_!_Xuv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e842dbb-849f-4a92-bea1-ed687e087b27_2063x1377.png 1272w, https://substackcdn.com/image/fetch/$s_!_Xuv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e842dbb-849f-4a92-bea1-ed687e087b27_2063x1377.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></figure></div><p>I won&#8217;t dive into all the details here, but you can find a great overview and summary of these results here:</p><p><a href="https://lena-voita.github.io/posts/neurons_in_llms_dead_ngram_positional.html">https://lena-voita.github.io/posts/neurons_in_llms_dead_ngram_positional.html</a></p><p>You can think of these layers of key-value associative memories which we brought up in some of our earlier examples. They not only capture simple patterns within sentences, but also capture more complex relationships and serve to predict contextual information within certain bounded context that allow prediction to be more accurate.</p><p>Let&#8217;s take an example of the following sentence:</p><p>&#8216;Mike and I were at the dock, and after a few beers, we got tipsy and we almost &#8230;&#8217;</p><p>Now, as a human being &#8211; you might say that there are a lot of possibilities here in our word completion task. The context is that 2 individuals were at the dock and had a bit too much to drink, so some of the possibilities here may involve 1) knocking over the boat or 2) slipping and falling or 3) falling into the water or etc...Now, the details here aren&#8217;t important. What&#8217;s important here is the exact context: we have certain things which we know and which we humans associate with certain outcomes. We use our memories in order to come to these associations. To try to predict what comes next, we take the most probable outcomes which come to our mind and we might try to guess that &#8216;Mike&#8217; and his friend were involved in some sort of incident.</p><p>In this same manner, the feed-forward layer takes many training examples and develops a context that comes with each input. These contexts are captured and the patterns within them are also mapped and captured by these layers. In essence, they serve similarly to auto-associative memories which aid us in word-completion tasks and which make transformer models so powerful!</p><h4>Temperature</h4><p>As you may already know, the output from a human-being is not deterministic. We may for example provide different answers to the same question based on 1) the context of our conversation 2) the context and tone of our previous conversations and 3) simple randomness introduced though the complexity of the human brain and the non-deterministic and chaotic manner in which it sometimes processes information in.</p><p>To introduce this &#8216;randomness&#8217; into our model, a parameter called the <strong>temperature</strong> is used, and it allows us to tune the randomness within our LLM or GPT model. In other words &#8211; the higher the temperature setting, the more randomness we introduce in our next word prediction task. Our model doesn&#8217;t simply pick the word with the top probability value which our feed-forward network points to. Instead, our model randomly samples from the top-K values generated by our next-word prediction output. K may be an integer parameter which is either hard-coded into our network or may be generated based on our temperature value. Either way - this ensures that we have some randomness and variation in our output &#8212; and important component in making the output more interesting.</p><h3>GPT-3</h3><p>In our discussion above, we mainly focused on outlining the transformer architecture and outlining the components in <strong>decoder-only transformer pre-training</strong>. We need to go further in order to understand more-advanced and human-centric models like ChatGPT. </p><p>Let&#8217;s summarize what we&#8217;ve outlined so far. A decoder-only transformer optimized for next-word prediction:</p><ol><li><p>Converts the sequence of text into input tokens.</p></li><li><p>Maps the input tokens to much larger multi-dimensional embedding vectors which capture the 1) meaning and 2) positional encoding information for each token.</p></li><li><p>Uses multi-head attention to capture meaning and relationship information between the embedding information along with the specific word context.</p></li><li><p>Uses masked attention in order to produce a set of probabilities for the next word to generate. </p></li><li><p>Checks the accuracy of its guess once it&#8217;s produced: a shallow but large feed-forward neural network is used to compare the next-word guess to the actual output. After comparing the results, the network weights are adjusted to capture  the information it needs in order for it to do better next time.</p></li><li><p>It continues on with attempting to generate the next word, incorporating context from the preceding words and continuing on with the above training process.</p></li></ol><p><strong>That&#8217;s it!! That&#8217;s all there is to it!!</strong></p><p>Ha! Well &#8230; not really! Sorry for the bad news, but that only refers to the training needed in order to make the <strong>base</strong> model work! Further refinements need to be made in order to generate an agent which can have conversations with humans. To do this, we need to go through more steps of fine-tuning our base model, but the large majority of our <strong>hardware utilization is spent on this</strong> <strong>base</strong> model. It takes a lot of energy to train it!</p><p>The main key is that 1) GPT has a lot of data and compute to work with and 2) the sequence length (and thus the context) it has to work with is 2048 tokens long. The total batch size is 3.2 million tokens. There are 96 heads in the self-attention layers, and the value, query, and key dimension is 128. It is trained with 300 billion tokens and contains 175 billion parameters. We&#8217;re talking about a massive amount of data to train with here.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!by_u!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb48138d3-08cf-445f-9200-1444069e09a8_1850x783.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!by_u!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb48138d3-08cf-445f-9200-1444069e09a8_1850x783.png 424w, https://substackcdn.com/image/fetch/$s_!by_u!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb48138d3-08cf-445f-9200-1444069e09a8_1850x783.png 848w, https://substackcdn.com/image/fetch/$s_!by_u!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb48138d3-08cf-445f-9200-1444069e09a8_1850x783.png 1272w, https://substackcdn.com/image/fetch/$s_!by_u!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb48138d3-08cf-445f-9200-1444069e09a8_1850x783.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!by_u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb48138d3-08cf-445f-9200-1444069e09a8_1850x783.png" width="1456" height="616" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b48138d3-08cf-445f-9200-1444069e09a8_1850x783.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:616,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:504235,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!by_u!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb48138d3-08cf-445f-9200-1444069e09a8_1850x783.png 424w, https://substackcdn.com/image/fetch/$s_!by_u!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb48138d3-08cf-445f-9200-1444069e09a8_1850x783.png 848w, https://substackcdn.com/image/fetch/$s_!by_u!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb48138d3-08cf-445f-9200-1444069e09a8_1850x783.png 1272w, https://substackcdn.com/image/fetch/$s_!by_u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb48138d3-08cf-445f-9200-1444069e09a8_1850x783.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></figure></div><p>You would think that throwing in a large amount of hardware and data would produce the results we want &#8211; but we are not done. The job of a GPT model <strong>isn&#8217;t to simply predict the next token in a sample of text input</strong>. Its job is to simulate and provide a live human-centered assistant which is able to answer and generate text based on a wide range of inquiries!</p><p>To put it simply: everything we went over in the above transformer discussion only involved the transformer model pre-training and next-word prediction. If we were to use our current next-word prediction model, it wouldn&#8217;t do a very good job conversing with a human being. To adjust our model to respond to human input and feedback, we need to go to the next step which is called fine-tuning.</p><h3>Fine-Tuning</h3><p>During this step, our large language model (or ChatGPT) generates multiple responses for numerous prompts and human reviewers rank them based on their quality. The model which is generated from this feedback is called the <strong>assistant model.</strong></p><p>The training data used for this model is completely different than the unranked data our in the base model. Here, we have real human centered and labeled question and answer data sets. In other words, instead of using our raw internet or book data, real humans are asked to read questions and provide their own &#8216;ideal&#8217; answers. This data-set is then fed into our assistant model and used to produce the next stage of training, which once again asks human participants to provide a &#8216;rank&#8217; for each set of answers produced by the GPT model. These rankings are used to furthermore train another model called the <strong>reward model.</strong></p><p>The main reason for the reward model is to avoid the cost of needing real-time human feedback for every response. Instead of asking humans to rank the responses individually, this reward model is trained to <strong>predict</strong> how humans would rank it. To do this, a small fraction of the output generated from the training process is shared with human reviewers. This data is utilized to further train the reward model using heuristics (such as reward model uncertainty) to guesstimate the quality of the model output.</p><p>If you want the full details, you can find them in the following paper: <a href="https://arxiv.org/pdf/2203.02155.pdf">Training language models to follow instructions with human feedback</a>.</p><p>A great diagram which provides a summary of fine tuning is provided 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_!Jf_m!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5696aada-b119-48af-ac93-b45f9e7ccd33_1302x788.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Jf_m!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5696aada-b119-48af-ac93-b45f9e7ccd33_1302x788.png 424w, https://substackcdn.com/image/fetch/$s_!Jf_m!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5696aada-b119-48af-ac93-b45f9e7ccd33_1302x788.png 848w, https://substackcdn.com/image/fetch/$s_!Jf_m!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5696aada-b119-48af-ac93-b45f9e7ccd33_1302x788.png 1272w, https://substackcdn.com/image/fetch/$s_!Jf_m!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5696aada-b119-48af-ac93-b45f9e7ccd33_1302x788.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Jf_m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5696aada-b119-48af-ac93-b45f9e7ccd33_1302x788.png" width="1302" height="788" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5696aada-b119-48af-ac93-b45f9e7ccd33_1302x788.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:788,&quot;width&quot;:1302,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:191999,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Jf_m!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5696aada-b119-48af-ac93-b45f9e7ccd33_1302x788.png 424w, https://substackcdn.com/image/fetch/$s_!Jf_m!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5696aada-b119-48af-ac93-b45f9e7ccd33_1302x788.png 848w, https://substackcdn.com/image/fetch/$s_!Jf_m!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5696aada-b119-48af-ac93-b45f9e7ccd33_1302x788.png 1272w, https://substackcdn.com/image/fetch/$s_!Jf_m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5696aada-b119-48af-ac93-b45f9e7ccd33_1302x788.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></figure></div><p>Once again, although GPT-3 already demonstrated the ability to follow natural language instructions / prompts just after pre-training, these instructions typically needed to be carefully worded in order for it to perform well. In order for us to achieve the next breakthrough in getting our model to perform well on human data, we needed to do fine-tuning which got our model to 1) work with higher quality data to judge and asses how high the quality of its output was and 2) develop further models which were involved in ranking different answers to the training data. These let our model develop and &#8216;instinct&#8217; on how good each result was.</p><p>You can think of this as intuitively conversing with different humans and using their response to judge the appropriateness of your feedback. Of course &#8211; generative pre-trained models don&#8217;t have access to this type of data, so we simply &#8216;simulate&#8217; this process through fine-tuning and by having a separate <strong>reward</strong> model to perform the task!! This reward model can be thought of as representing the natural &#8216;human instinct&#8217; which the model can use, and it uses it to rank and judge the quality of its own responses.</p><h3><strong>Few-Shot Learning</strong></h3><p>Fine-tuning a large-language model doesn&#8217;t need to involve any human feedback in order for it to achieve outstanding results. Instead, feeding in a few examples into each prompt can give an LLM the contextual information it needs in order to &#8216;generalize&#8217; and solve a task.</p><p>You can find more details in a paper called: <a href="https://arxiv.org/pdf/2005.14165.pdf">Language Models are Few-Shot Learners</a>.</p><p>Some key highlights from the paper are provided below:</p><blockquote><p>Recent work has demonstrated substantial gains on many NLP tasks and benchmarks by pre-training on a large corpus of text followed by fine-tuning on a specific task. While typically task-agnostic in architecture, this method still requires task-specific fine-tuning datasets of thousands or tens of thousands of examples. By contrast, humans can generally perform a new language task from only a few examples or from simple instructions &#8211; something which current NLP systems still largely struggle to do. Here we show that scaling up language models greatly improves task-agnostic, few-shot performance, sometimes even reaching competitiveness with prior state-of-the-art finetuning approaches. Specifically, we train GPT-3, an autoregressive language model with 175 billion parameters, 10x more than any previous non-sparse language model, and test its performance in the few-shot setting. For all tasks, <strong>GPT-3 is applied without any gradient updates or fine-tuning, with tasks and few-shot demonstrations specified purely via text interaction with the model</strong>. GPT-3 achieves strong performance on many NLP datasets, including translation, question-answering, and cloze tasks, as well as several tasks that require on-the-fly reasoning or domain adaptation, such as unscrambling words, using a novel word in a sentence, or performing 3-digit arithmetic.</p></blockquote><p>In other words &#8211; the authors of the paper found that large language models develop a broad set of skills and pattern recognition abilities from n-shot learning &#8211; where n represents an integer and where the task performance increases as n increases (i.e. more examples are provided). It then uses these abilities at inference time to adapt to or recognize tasks and can use this info in making its prompt responses more accurate without having to do any fine-tuning and without having to update its feed-forward model weights.</p><p>This ability to extract patterns from examples is called &#8216;in-context&#8217; learning and some examples of sequences fed into the input are provided 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_!UqSo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fad9e12-7fe4-472d-b527-8cab440ec988_920x326.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UqSo!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fad9e12-7fe4-472d-b527-8cab440ec988_920x326.png 424w, https://substackcdn.com/image/fetch/$s_!UqSo!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fad9e12-7fe4-472d-b527-8cab440ec988_920x326.png 848w, https://substackcdn.com/image/fetch/$s_!UqSo!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fad9e12-7fe4-472d-b527-8cab440ec988_920x326.png 1272w, https://substackcdn.com/image/fetch/$s_!UqSo!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fad9e12-7fe4-472d-b527-8cab440ec988_920x326.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!UqSo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fad9e12-7fe4-472d-b527-8cab440ec988_920x326.png" width="920" height="326" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6fad9e12-7fe4-472d-b527-8cab440ec988_920x326.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:326,&quot;width&quot;:920,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:45449,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!UqSo!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fad9e12-7fe4-472d-b527-8cab440ec988_920x326.png 424w, https://substackcdn.com/image/fetch/$s_!UqSo!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fad9e12-7fe4-472d-b527-8cab440ec988_920x326.png 848w, https://substackcdn.com/image/fetch/$s_!UqSo!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fad9e12-7fe4-472d-b527-8cab440ec988_920x326.png 1272w, https://substackcdn.com/image/fetch/$s_!UqSo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6fad9e12-7fe4-472d-b527-8cab440ec988_920x326.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></figure></div><p>In the above example, we can see that when prompted to do arithmetic / addition, the model learns how to output the correct results; when prompted with misspelled words followed by their correct spelling, the model learns to correctly output spelling corrections &#8211; and when prompted to provide translations (from English to French) &#8211; the model recognizes this pattern as well and correctly outputs the French translation when prompted with an English word.</p><p>A diagram which shows that the more examples we use &#8211; the better the model can generalize is provided 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_!uZ64!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc26e26ad-125e-4192-ba4d-6eb1d2b731d9_1053x595.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!uZ64!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc26e26ad-125e-4192-ba4d-6eb1d2b731d9_1053x595.png 424w, https://substackcdn.com/image/fetch/$s_!uZ64!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc26e26ad-125e-4192-ba4d-6eb1d2b731d9_1053x595.png 848w, https://substackcdn.com/image/fetch/$s_!uZ64!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc26e26ad-125e-4192-ba4d-6eb1d2b731d9_1053x595.png 1272w, https://substackcdn.com/image/fetch/$s_!uZ64!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc26e26ad-125e-4192-ba4d-6eb1d2b731d9_1053x595.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!uZ64!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc26e26ad-125e-4192-ba4d-6eb1d2b731d9_1053x595.png" width="1053" height="595" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c26e26ad-125e-4192-ba4d-6eb1d2b731d9_1053x595.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:595,&quot;width&quot;:1053,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:89599,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!uZ64!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc26e26ad-125e-4192-ba4d-6eb1d2b731d9_1053x595.png 424w, https://substackcdn.com/image/fetch/$s_!uZ64!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc26e26ad-125e-4192-ba4d-6eb1d2b731d9_1053x595.png 848w, https://substackcdn.com/image/fetch/$s_!uZ64!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc26e26ad-125e-4192-ba4d-6eb1d2b731d9_1053x595.png 1272w, https://substackcdn.com/image/fetch/$s_!uZ64!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc26e26ad-125e-4192-ba4d-6eb1d2b731d9_1053x595.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></figure></div><p>And a simple diagram showing an example of zero-shot, one-shot and few-shot learning vs. traditional fine-tuning:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!V6mW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d96b20e-2fa2-4778-970b-3af67a16d1fd_789x686.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!V6mW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d96b20e-2fa2-4778-970b-3af67a16d1fd_789x686.png 424w, https://substackcdn.com/image/fetch/$s_!V6mW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d96b20e-2fa2-4778-970b-3af67a16d1fd_789x686.png 848w, https://substackcdn.com/image/fetch/$s_!V6mW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d96b20e-2fa2-4778-970b-3af67a16d1fd_789x686.png 1272w, https://substackcdn.com/image/fetch/$s_!V6mW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d96b20e-2fa2-4778-970b-3af67a16d1fd_789x686.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!V6mW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d96b20e-2fa2-4778-970b-3af67a16d1fd_789x686.png" width="789" height="686" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6d96b20e-2fa2-4778-970b-3af67a16d1fd_789x686.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:686,&quot;width&quot;:789,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:107553,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!V6mW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d96b20e-2fa2-4778-970b-3af67a16d1fd_789x686.png 424w, https://substackcdn.com/image/fetch/$s_!V6mW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d96b20e-2fa2-4778-970b-3af67a16d1fd_789x686.png 848w, https://substackcdn.com/image/fetch/$s_!V6mW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d96b20e-2fa2-4778-970b-3af67a16d1fd_789x686.png 1272w, https://substackcdn.com/image/fetch/$s_!V6mW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d96b20e-2fa2-4778-970b-3af67a16d1fd_789x686.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></figure></div><p>Key quote:</p><blockquote><p>GPT-3 also displays one-shot and few-shot proficiency at tasks designed to test rapid adaption or on-the-fly reasoning, which include unscrambling words, performing arithmetic, and using novel words in a sentence after seeing them defined only once. We also show that in the few-shot setting, <strong>GPT-3 can generate synthetic news articles which human evaluators have difficulty distinguishing from human-generated articles.</strong></p></blockquote><p>In other words &#8211; GPT3 can extract the &#8216;meta&#8217; information from sequences and apply them to improving its set of outputs without having to do any backpropagation!</p><p>How exactly the authors of the paper got GPT to recognize &#8216;meta-patterns&#8217; isn&#8217;t really revealed, and we&#8217;re left with the notion that simply scaling up the models leads to them being able to extract &#8216;higher order&#8217; meta information from text which is fed in. From the input text, the model is able to recognize patterns and use these patterns to accurately produce the desired output!</p><p>The LLMs trained by the authors also use <strong>sparse attention </strong>and sparse transformers. These are different from the regular attention / transformer mechanism we outlined earlier. These models introduce a mechanism which focuses in on specific parts of the input sequence rather than using the whole context window / sequence. The authors of the paper <a href="https://arxiv.org/pdf/1904.10509.pdf">here</a> note that sparse transformers can &#8216;<em> achieve state-of-the-art compression and generation of natural language, raw audio, and natural images. The simplicity of the architecture leads us to believe it may be useful for many problems of interest.&#8217;</em> In other words &#8211; this sparse architecture may be useful in helping the model perform information compression<strong> </strong>as well as meta-learning, although this is more-of my interpretation of the paper rather than something that&#8217;s outlined by the authors.</p><p>A great diagram which also illustrates the key difference between normal transformers and ones which implement sparse attention is also provided below:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2QSa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9870333-f951-4dbb-b93c-2672ed587320_1027x370.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2QSa!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9870333-f951-4dbb-b93c-2672ed587320_1027x370.png 424w, https://substackcdn.com/image/fetch/$s_!2QSa!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9870333-f951-4dbb-b93c-2672ed587320_1027x370.png 848w, https://substackcdn.com/image/fetch/$s_!2QSa!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9870333-f951-4dbb-b93c-2672ed587320_1027x370.png 1272w, https://substackcdn.com/image/fetch/$s_!2QSa!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9870333-f951-4dbb-b93c-2672ed587320_1027x370.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2QSa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9870333-f951-4dbb-b93c-2672ed587320_1027x370.png" width="659" height="237.4196689386563" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a9870333-f951-4dbb-b93c-2672ed587320_1027x370.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:370,&quot;width&quot;:1027,&quot;resizeWidth&quot;:659,&quot;bytes&quot;:21146,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!2QSa!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9870333-f951-4dbb-b93c-2672ed587320_1027x370.png 424w, https://substackcdn.com/image/fetch/$s_!2QSa!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9870333-f951-4dbb-b93c-2672ed587320_1027x370.png 848w, https://substackcdn.com/image/fetch/$s_!2QSa!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9870333-f951-4dbb-b93c-2672ed587320_1027x370.png 1272w, https://substackcdn.com/image/fetch/$s_!2QSa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9870333-f951-4dbb-b93c-2672ed587320_1027x370.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Once again &#8211; I don&#8217;t have enough information on how sparse modeling and few-shot learning impact ChatGPT &#8211; but the key take-away for me here is that sparse GPT and LLM models are capable of capturing trends and patterns within sequences of data which can be thought of as meta-learning!! This type of meta-learning also occurs within humans and comes naturally to us &#8212; most human beings are also able to capture &#8216;higher order&#8217; knowledge by simply being given a few simple examples of input-output pairs.</p><p>Finally, another note by the authors which is captured in the paper is also provided below:</p><blockquote><p>The main advantages of few-shot are a major reduction in the need for task-specific data and reduced potential to learn an overly narrow distribution from a large but narrow fine-tuning dataset. The main disadvantage is that results from this method have so far been much worse than state-of-the-art fine-tuned models.</p></blockquote><p>In other words, although the results are extremely interesting, fine-tuning still seems to be needed in order to make the model perform and generalize the results needed in order to perform well when it comes to human prompts.</p><p>Noting this &#8211; let&#8217;s move on to the next ingredient which I believe also plays a huge role in making ChatGPT as great as it is, which involves training the model to have chain of reasoning capabilities.</p><h3>Chain of Reason Training</h3><p>Humans don&#8217;t simply produce outputs based on the raw inputs which they receive. Underneath the vast amount of neurons which power us &#8211; we use many subconscious processes and algorithms which produce a <strong>chain of reasoning</strong> which we build up from observing and learning about the world around us.</p><p>In the paper <a href="https://arxiv.org/pdf/2201.11903.pdf">Chain-of-Thought Prompting Elicits Reasoning in Large Language Models</a>, the authors show how a chain of thought (a series of intermediate reasoning steps) significantly improve the ability of large language models to perform complex reasoning:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dL53!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F288f93b1-0485-407a-bc3b-3055123a3e58_1314x631.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dL53!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F288f93b1-0485-407a-bc3b-3055123a3e58_1314x631.png 424w, https://substackcdn.com/image/fetch/$s_!dL53!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F288f93b1-0485-407a-bc3b-3055123a3e58_1314x631.png 848w, https://substackcdn.com/image/fetch/$s_!dL53!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F288f93b1-0485-407a-bc3b-3055123a3e58_1314x631.png 1272w, https://substackcdn.com/image/fetch/$s_!dL53!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F288f93b1-0485-407a-bc3b-3055123a3e58_1314x631.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dL53!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F288f93b1-0485-407a-bc3b-3055123a3e58_1314x631.png" width="1314" height="631" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/288f93b1-0485-407a-bc3b-3055123a3e58_1314x631.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:631,&quot;width&quot;:1314,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:163490,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!dL53!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F288f93b1-0485-407a-bc3b-3055123a3e58_1314x631.png 424w, https://substackcdn.com/image/fetch/$s_!dL53!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F288f93b1-0485-407a-bc3b-3055123a3e58_1314x631.png 848w, https://substackcdn.com/image/fetch/$s_!dL53!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F288f93b1-0485-407a-bc3b-3055123a3e58_1314x631.png 1272w, https://substackcdn.com/image/fetch/$s_!dL53!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F288f93b1-0485-407a-bc3b-3055123a3e58_1314x631.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></figure></div><p>In the above example &#8211; you can probably notice that the model doesn&#8217;t infer the correct amount of apples from the first prompt. By adding an example where the text demonstrates a &#8216;chain of reason&#8217; in which the &#8216;reasoning&#8217; behind the output is given, the model follows a similar path and attempts to produce a &#8216;chain of reason&#8217; for our apple example. After doing so, it&#8217;s able to infer the correct output through this &#8216;reasoning&#8217; ability. The authors of the paper note that when chain-of-thought prompting is fed into the model, it outperforms standard prompting by quite a large factor in arithmetic, commonsense, and symbolic reasoning benchmarks.</p><p>The reasoning behind this is simple: once again, humans don&#8217;t simply map inputs to outputs. There&#8217;s usually a chain of reasoning which we follow in order to solve complex problems. Let&#8217;s go through an example outlined in the paper to show why chain-of-reason prompting may be important in regards to allowing LLMs to &#8216;infer&#8217; correct answers to these types of problems:</p><blockquote><p>Consider one&#8217;s own thought process when solving a complicated reasoning task such as a multi-step math word problem. It is typical to decompose the problem into intermediate steps and solve each before giving the final answer: &#8220;After Jane gives 2 flowers to her mom she has 10 . . . then after she gives 3 to her dad she will have 7 . . . so the answer is 7.&#8221; The goal of this paper is to endow language models with the ability to generate a similar chain of thought&#8212;a coherent series of intermediate reasoning steps that lead to the final answer for a problem. We will show that sufficiently large language models can generate chains of thought if demonstrations of chain-of-thought reasoning are provided in the exemplars for few-shot prompting.</p></blockquote><p>The authors also note that chain-of-thought prompting only works on <strong>extremely large </strong>LLM models (like GPT-3) and that smaller models tend to produce jumbled chain-of-thought results which don&#8217;t necessarily generalize into accurate abstractions which can allow the model to solve real world problems. Once again &#8211; we&#8217;re shown that extremely large parameter models are capable of capturing &#8216;meta-learning&#8217; type behavior by being given examples. Through these chain-of-thought examples, they&#8217;re able to abstract away concepts which they can use to solve complex tasks. </p><p>The paper authors also show the incredible effect which chain-of-thought prompting can have when being applied to a few data-sets which contain challenging math problems (GSM8K, SVAMP, and MAWPS):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xGWu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56485f30-eee6-4091-9e7d-631177c469f6_519x790.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xGWu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56485f30-eee6-4091-9e7d-631177c469f6_519x790.png 424w, https://substackcdn.com/image/fetch/$s_!xGWu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56485f30-eee6-4091-9e7d-631177c469f6_519x790.png 848w, https://substackcdn.com/image/fetch/$s_!xGWu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56485f30-eee6-4091-9e7d-631177c469f6_519x790.png 1272w, https://substackcdn.com/image/fetch/$s_!xGWu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56485f30-eee6-4091-9e7d-631177c469f6_519x790.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xGWu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56485f30-eee6-4091-9e7d-631177c469f6_519x790.png" width="413" height="628.6512524084778" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/56485f30-eee6-4091-9e7d-631177c469f6_519x790.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:790,&quot;width&quot;:519,&quot;resizeWidth&quot;:413,&quot;bytes&quot;:87627,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!xGWu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56485f30-eee6-4091-9e7d-631177c469f6_519x790.png 424w, https://substackcdn.com/image/fetch/$s_!xGWu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56485f30-eee6-4091-9e7d-631177c469f6_519x790.png 848w, https://substackcdn.com/image/fetch/$s_!xGWu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56485f30-eee6-4091-9e7d-631177c469f6_519x790.png 1272w, https://substackcdn.com/image/fetch/$s_!xGWu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56485f30-eee6-4091-9e7d-631177c469f6_519x790.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></figure></div><p>The authors note:</p><blockquote><p>Another potential benefit of chain-of-thought prompting could simply be that such prompts allow the model to better access relevant knowledge acquired during pre-training. Therefore, we test an alternative configuration where <strong>the chain of thought prompt is only given after the answer</strong>, isolating whether the model actually depends on the produced chain of thought to give the final answer. This <strong>variant performs about the same as the baseline</strong>, which <strong>suggests that the sequential reasoning embodied in the chain of thought is useful for reasons beyond just activating knowledge</strong>.</p></blockquote><p>We can once again see that these large language models can capture and activate abstractions which allow them to <strong>reason </strong>about specific tasks through a simple example based approach. They&#8217;re capable of capturing patterns within the sequences which are fed in!! Human beings are also capable of generalizing in this manner as well, albeit human beings have a lot more data to work with and are capable of performing more complex tasks!</p><h3>Mixture of Experts (MoE) Models</h3><p>ChatGPT 4 most likely isn&#8217;t one giant model, but a mixture of various ones which are labeled as &#8216;experts.&#8217; In other words, instead of creating one <strong>huge</strong> model which serves all prompts, the model uses a &#8216;mixture of experts&#8217; or &#8216;MoE&#8217; which are composed of 8 to 16 different models. There isn&#8217;t much info to confirm whether GTP-4 really is a MoE model, but the recently released Mixtral 8x7B model was shown to outperform ChatGPT 3.5 on most standard benchmarks. It consists of 8 separate &#8216;experts&#8217; which have been optimized through supervised fine-tuning and direct preference optimization (DPO). (Side note: The core insight of <strong>direct preference optimization</strong> is to derive a loss function that directly solves the policy optimization and reward modeling steps simultaneously rather than having to have a separate &#8216;reward&#8217; model which evaluates an LLMs response from a set of different possibilities.) To route each prompt to an appropriate model, there&#8217;s a router (another neural-network / model) which picks the best two 7 billion parameter models to use and those two models generate the next token to use. The results from these models are then combined and this turns out to be much more efficient than routing each prompt to one giant model, so there are tremendous cost savings in using this approach!</p><p>The full diagram showing how this model works is provided 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_!vzjO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26b6d673-b3cf-4aa5-ace6-07ee6f73780f_1851x1517.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vzjO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26b6d673-b3cf-4aa5-ace6-07ee6f73780f_1851x1517.png 424w, https://substackcdn.com/image/fetch/$s_!vzjO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26b6d673-b3cf-4aa5-ace6-07ee6f73780f_1851x1517.png 848w, https://substackcdn.com/image/fetch/$s_!vzjO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26b6d673-b3cf-4aa5-ace6-07ee6f73780f_1851x1517.png 1272w, https://substackcdn.com/image/fetch/$s_!vzjO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26b6d673-b3cf-4aa5-ace6-07ee6f73780f_1851x1517.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vzjO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26b6d673-b3cf-4aa5-ace6-07ee6f73780f_1851x1517.png" width="1456" height="1193" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/26b6d673-b3cf-4aa5-ace6-07ee6f73780f_1851x1517.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1193,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:691934,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!vzjO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26b6d673-b3cf-4aa5-ace6-07ee6f73780f_1851x1517.png 424w, https://substackcdn.com/image/fetch/$s_!vzjO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26b6d673-b3cf-4aa5-ace6-07ee6f73780f_1851x1517.png 848w, https://substackcdn.com/image/fetch/$s_!vzjO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26b6d673-b3cf-4aa5-ace6-07ee6f73780f_1851x1517.png 1272w, https://substackcdn.com/image/fetch/$s_!vzjO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26b6d673-b3cf-4aa5-ace6-07ee6f73780f_1851x1517.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></figure></div><p>You can find a much more thorough write-up of how mixture of experts models work here: <a href="https://huggingface.co/blog/moe">Mixture of Experts Explained</a>. No one outside of OpenAI knows for sure the size/architecture of GPT-4, but it's rumored to be a mixture of experts model composed of 16 experts, each of which has over 100 billion parameters. In the case of Mixtral 8x7B, this approach has been shown to be superior to using one large model due to the cost of training 8 smaller ones (which contains only 7 billion parameters) being far lower. </p><p>In regards to the actual performance, there are no easy analogies which I can use to understand why the mixture of experts models perform so well. The best one that I can come up with is that ensemble models tend to outperform single or simple models within many machine learning data-sets and real-world scenarios, and this might also be an attempt to use an ensemble albeit this one is composed of many similar LLMs which &#8216;specialize&#8217; in a more randomized fashion. Of course &#8211; OpenAI may have chosen to feed different data-sets into each &#8216;expert&#8217; model (i.e. such as choosing one expert which specializes in coding tasks, another which may handle a more mathematical domain, and another for creativity, and so on). This was my initial hypothesis, although there isn&#8217;t a lot of data which I can use to back this up. Either way, the developments within mixture of experts models are incredibly interesting and there&#8217;s a lot of unexplored territory here which I hope to eventually untangle and understand. The best take-away is that these models have a huge advantage in terms of cost since they require a lot less energy to train. </p><h3>The Mental Model for Understanding LLMs</h3><p>Andrej Karpathy did a great job of summarizing how LLMs like ChatGPT do what they do in his <a href="https://www.youtube.com/watch?v=zjkBMFhNj_g">Intro to Large Language Models</a>. In his talk, he uses a diagram of an OS to show that and LLM can be thought of as a &#8216;kernel process of an emerging operating system&#8217; which is coordinating a lot of resources and memory to solving various problems:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!E96z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc11f553-8b67-42e4-a8ba-d202d7bddad4_880x472.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!E96z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc11f553-8b67-42e4-a8ba-d202d7bddad4_880x472.png 424w, https://substackcdn.com/image/fetch/$s_!E96z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc11f553-8b67-42e4-a8ba-d202d7bddad4_880x472.png 848w, https://substackcdn.com/image/fetch/$s_!E96z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc11f553-8b67-42e4-a8ba-d202d7bddad4_880x472.png 1272w, https://substackcdn.com/image/fetch/$s_!E96z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc11f553-8b67-42e4-a8ba-d202d7bddad4_880x472.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!E96z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc11f553-8b67-42e4-a8ba-d202d7bddad4_880x472.png" width="880" height="472" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dc11f553-8b67-42e4-a8ba-d202d7bddad4_880x472.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:472,&quot;width&quot;:880,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:100325,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!E96z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc11f553-8b67-42e4-a8ba-d202d7bddad4_880x472.png 424w, https://substackcdn.com/image/fetch/$s_!E96z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc11f553-8b67-42e4-a8ba-d202d7bddad4_880x472.png 848w, https://substackcdn.com/image/fetch/$s_!E96z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc11f553-8b67-42e4-a8ba-d202d7bddad4_880x472.png 1272w, https://substackcdn.com/image/fetch/$s_!E96z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc11f553-8b67-42e4-a8ba-d202d7bddad4_880x472.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></figure></div><p></p><p>I&#8217;m not an expert, but I tend to view LLMs like ChatGPT as being more like an artificial brain rather than an operating system. Of course, the brain isn&#8217;t &#8216;conscious.&#8217; It doesn&#8217;t have any survival instincts which we humans do. It&#8217;s simply a huge network which can excel in language tasks by using the properties below:</p><ul><li><p><strong>The context window: </strong>you can think of the context window as <strong>working memory</strong>. Normally, humans have a working memory of only 6-8 items, although unconscious processes which are working underneath our awareness actually make this window much broader. Although the human capacity for keeping things in memory are much more limited that that of ChatGPT, I don&#8217;t believe that they are really that far off from representing what a human &#8216;context window&#8217; is composed of. As an example, although my working memory may not be able to hold much more than a few items that I&#8217;m conscious of, when I&#8217;m performing a reading task, the words which I encounter from a previous page or previous pages aren&#8217;t necessarily &#8216;unavailable&#8217; to me while I&#8217;m reading. As an example &#8211; although a novel might introduce a character called &#8216;Mark&#8217; 10 pages prior to the current one, this doesn&#8217;t necessarily mean that I have to expand a lot of effort in retrieving the memories which were associated with the Mark character. My unconscious &#8216;neural network&#8217; automatically retrieves this information and brings it to my awareness as I&#8217;m reading it. You can think of the context window as both the conscious and unconscious &#8216;cache&#8217; which we humans are equipped with.</p></li><li><p><strong>Attention</strong> is <strong>association</strong>: you can think of attention as being an auto-associative type of word encoding. It assigns different meanings to words based on the context which they&#8217;re presented in. As an example, &#8216;apple&#8217; may refer to a fruit, or the company (Apple Inc.) &#8211; and the word &#8216;Jobs&#8217; (aka for Steve Jobs) will be associated with the company in a much more entangled manner than with the fruit. This type of associative chaining is accomplished through the self-attention layer. The transformer architecture thus allows for the model to come up with auto-associative relations between a huge amount of textual relations and blocks which it encounters. Humans in a lot of ways function based on associations. A lot of our learning can be encapsulated by the term: 'Neurons that fire together wire together.' In a similar manner &#8211; self-attention brings this type of <strong>auto-association</strong> to transformer networks.</p></li><li><p><strong>Prediction / backpropagation: </strong>The 'unconscious' is composed of many neuronal bundles / cascades which are formed over years of experience. These cascades are automatically triggered and evolved through our past experiences. As an example, when we open a door, we don't have to 'think' about how to open it. This comes from the unconscious mechanism which makes our lives easy: we automatically figure it out based on old patterns. If the unconscious cannot figure it out automatically, the conscious mind is engaged and starts becoming aware of the action. Once aware, the conscious mind's perceptual filer engages in 'retraining' the network. You can think of this process as &#8216;backpropagation,&#8217; but the brain does it in a different way than a transformer does. The conscious mind is able to view the output and compare it to an expected one and tune the individual module weights by re-trying the action and letting unconscious processes automatically adjust the neuronal weights. A good action is followed by a good emotion (controlled by the amygdala) while a bad one is followed by a bad one &#8211; and so we signal to the unconscious that weights must be adjusted. The transformer on the other hand tunes the feed-forward weights in a much more direct manner: it simply looks at the difference between the input and output and can use calculus to figure out which weights within its network to adjust. In this manner, <strong>we can think of our feed-forward networks as being neural cascades or &#8216;predictions&#8217; which get executed based on the text input</strong>. Whenever the cascades result in the wrong output, they are adjusted such that the feed-forward network is closer to generating the correct outputs the next time we encounter the same block of text, and so this also very much resembles a process which humans go through.</p><p>The cascade which is triggered in a human being depends on many different signals which are sent to the neural module(s). These are never quite 'equal' but are similar for similar inputs. As an example, a great tennis player can hit the ball and has a consistent set of neuronal cascades which are triggered based on the height and speed of the ball which the tennis player encounters. No tennis ball or input is quite the same, but the unconscious is able to 'adjust' based on the feedback it has and its output adapts to make the ball function according to what it views as a 'success.' Initially, the player may not have the optimal output &#8211; but over years of training, the player tunes the underlying unconscious network to perform according to a set of expectations. In a similar manner &#8211; a transformer or GPT model substitutes huge volumes of text as its &#8216;years of training.&#8217; By feeding in huge amounts of textual information into our network, it&#8217;s able to generate all sorts of associations and cascades which are suitable for generating the appropriate responses to many human prompts / inputs.</p><p>The brain itself is a <strong>predictive machine</strong>. It tries to send actions to be performed unconsciously while trying to predict the next sequence - as well as what it needs to do in order to get through the next sequence of events. A great and funny overview of this can be shown <a href="https://fluxus.org/FluxusMidwest/doorknobs/">here </a>(where a man goes through an episode of consciously interrupting opening doors on purpose in order to document the experience: &#8220;<em>Paying attention to my hands opening and closing doors and drawers 1. increased my awareness of that activity, which 2. interrupted my "looking ahead to the next action in the sequence" mentality, which 3. increased my "being" in the "here and now"--at least for the door knob/drawer knob action.&#8221; </em>In other words - being 'here and now' is not the default action of the frontal lobes. The default action is preparing for the next set of steps and 'looking ahead' to prepare for the next set of steps which need to be executed. In a similar manner, transformers and GPT models are auto-associative prediction networks which are constantly looking for feedback in whether their predictions meet expectations and adjusting their &#8216;internal model&#8217; to match the real world. </p><p>We can associate our transformer feed-forward networks as automatically programmed neural &#8216;cascades&#8217; which are generated from a huge amount of training data, while the backpropagation mechanism can be associated with &#8216;consciousness&#8217; &#8211; although the consciousness in this context simply refers to the model being able to &#8216;adjust&#8217; and &#8216;think&#8217; about the discrepancies between its own representations and the ones which are presented to it through real-world feedback.</p></li><li><p><strong>Capturing patterns:</strong> human beings aren&#8217;t simple auto-associative cascade networks. Humans are capable of compression information and capturing trends within data. In a similar manner, ChatGPT and large LLMs have been shown to be able to also model these patterns and to capture trends within textual input. As an example, few-shot learning shows that GPT has meta-learning components which can take examples and automatically figure out pattern and word-completion tasks, so the models themselves aren&#8217;t simple statistical predictors and function approximators. These networks are capable of capturing relationships and patterns in a much more generalizable manner in the same way that people can. This is accomplished by having a deep neural network in combination with sparse self-attention layers which are able to find associations and deep level structures within text and through having a huge volume of training data. The human brain itself also does this as well, albeit using different training data and different algorithms to do so.</p></li><li><p><strong>Fine-tuning is intuition and feedback:</strong> human beings perform fine-tuning naturally, as we seek feedback from our environment and constantly use emotional triggers in order to aid us in understanding whether our &#8216;output&#8217; is received in a good way or not. Transformer models don&#8217;t have this, so manual fine-tuning is performed and a reward model is trained to distinguish between appropriate language-task responses and inappropriate ones. The reward-model is then furthermore used in choosing a response to generate. This can be thought of as augmenting the base language layer with the intuition as to what types of responses to generate which are appropriate to each context. You can also think of this reward-model as being the &#8216;amygdala&#8217; (emotional processing layer within the human brain).</p><p>The ingenious approach employed in transitioning from GPT2 to GPT3 and ChatGPT involves training and refining models based on human feedback while utilizing user feedback to continuously improve the system. In a sense, this feedback mechanism is similar to what humans already use. Whenever we generate a response, we produce various &#8216;simulations&#8217; within our own mental landscape to try to asses what our options are. Based on what we think the response will be to our response, we then produce the output which we believe is the most appropriate to the situation at hand. In order to evaluate which output is best, we use a plethora of mental models which we&#8217;ve already built up throughout our lifetimes.</p><p>The feedback might come in various forms; at a party with guests, the feedback would be in the form of guests responding to your comments; in school, we might receive delayed responses to our test answers in the form of grades. In every setting, we receive feedback to the actions which we choose to enact on the world. </p><p>Of course, each individual will perceive the feedback itself differently since our mental models and beliefs differ. ChatGPT receives feedback in a more uniform way since the feedback mechanism is more direct. Although the individual humans giving it feedback may have different views on what constitutes a &#8216;great&#8217; answer, the ChatGPT system still processes feedback using a similar methodology that humans do: it outputs responses and asks the participants to rate them. Using these ratings, the system itself then knows what constitutes as a &#8216;good&#8217; response vs a &#8216;bad&#8217; response and it continues on in evaluating and generating new answers. In trying to capture the data which it needs to pay attention to in order to excel at generating text, it&#8217;s deep feed-forward model is able to capture all sorts of information about language and automatically and use this data to build semantically meaningful representations which it&#8217;s able to furthermore utilize in continuing to improve its own models of the world.</p></li><li><p><strong>Chain of thought prompting is logic and reasoning: </strong>This teaches the model to develop more of an  <strong>intuition behind causality</strong> and figure out more complex relationships between textual encodings. Humans too go through this process when going through school: we&#8217;re given many problems with examples and solutions to work through and/or which we attempt to solve. Though this process, we learn how to model the world more accurately and it allows us to develop a perceived &#8216;chain of reasoning&#8217; behind each action. In a similar manner &#8211; you can think of the chain of thought prompting as allowing our model to infer or try to infer &#8216;causality&#8217; by providing it with examples. By introducing this causal chain &#8211; the model can generalize in a much better manner and can produce more meaningful and correct representations of the world.</p></li><li><p><strong>The mixture of experts model(s):</strong> they are used are mostly there to save computational costs and for efficiency reasons, but you can also think of these as modeling the 2 hemispheres within human brain. Each brain has a left and right side, and each side has to coordinate or &#8216;vote&#8217; on which action to take (along with having different specializations). You can think of mixture of experts as modeling this hemispheric specialization &#8211; at least in the Mixtral models which I&#8217;ve explored thus far (i.e. there is a &#8216;routing&#8217; network which routes to 2 separate areas which vote on what &#8216;neuronal bundles&#8217; to engage based on the task or phrase on hand). This analogy may not be the best since some models have way more than 2 experts / models, but it&#8217;s the best one I can come up with for now.</p></li></ul><p>In sum, ChatGPT is a miracle of engineering and in many ways has revolutionized the field of AI. I continue to be astounded by the capabilities which are being added to the current model and by the amazing landscape of new large-language models being developed.</p><p>Noting this, I also wanted to make something clear: <strong>although I may have drawn some analogies behind ChatGPT and some ideas behind human thinking, in no way do I believe that GPT nor any LLM models out there represent a conscious being. </strong>The human brain is far more complex and has many more components that what I outlined in some of my analogies above. If we were to truly embark to develop a human level AGI agent, we would need 1) far more compute than what&#8217;s available 2) more models being able to simulate &#8216;emotion&#8217; or the amygdala region and 3) evolutionary and evolution based reinforcement learning algorithms which breed survival and competition.</p><p>I&#8217;m going to end this write-up by providing one of my favorite articles on the human brain. It&#8217;s a write up called &#8216;<a href="https://www.edge.org/response-detail/11663">Overlapping Solutions</a>&#8217; by David Eagleman and it does a great job of highlighting some of the major complexities and intricate details needed in order to really fathom the magic behind human thinking.</p><h3>Overlapping Solutions</h3><blockquote><p>For centuries, neuroscience attempted to neatly assign labels to the various parts of the brain: this is the area for language, this one for morality, this for tool use, color detection, face recognition, and so on. This search for an orderly brain map started off as a viable endeavor, but turned out to be misguided.</p><p>The deep and beautiful trick of the brain is more interesting: it possesses multiple, overlapping ways of dealing with the world. It is a machine built of conflicting parts. It is a representative democracy that functions by competition among parties who all believe they know the right way to solve the problem.</p><p>As a result, we can get mad at ourselves, argue with ourselves, curse at ourselves and contract with ourselves. We can feel conflicted. These sorts of neural battles lie behind marital infidelity, relapses into addiction, cheating on diets, breaking of New Year&#8217;s resolutions &#8211; all situations in which some parts of a person want one thing and other parts another.</p><p>These are things which modern machines simply do not do. Your car cannot be conflicted about which way to turn: it has one steering wheel commanded by only one driver, and it follows directions without complaint.</p><p>Brains, on the other hand, can be of two minds, and often many more. We don&#8217;t know whether to turn toward the cake or away from it, because there are several sets of hands on the steering wheel of behavior.</p><p>Take memory. Under normal circumstances, memories of daily events are consolidated by an area of the brain called the hippocampus. But in frightening situations &#8211; such as a car accident or a robbery &#8211; another area, the amygdala, also lays down memories along an independent, secondary memory track. Amygdala memories have a different quality to them: they are difficult to erase and they can return in &#8220;flash-bulb&#8221; fashion &#8211; a common description of rape victims and war veterans. In other words, there is more than one way to lay down memory. We&#8217;re not talking about memories of different events, but different memories of the same event. There may be even more than two factions involved, all writing down information and later competing to tell the story. The unity of memory is an illusion.</p><p>And consider the different systems involved in decision making: some are fast, automatic and below the surface of conscious awareness; others are slow, cognitive, and conscious. And there&#8217;s no reason to assume there are only two systems; there may well be a spectrum. Some networks in the brain are implicated in long-term decisions, others in short-term impulses (and there may be a fleet of medium-term biases as well).</p><p>Attention, also, has also recently come to be understood as the end result of multiple, competing networks, some for focused, dedicated attention to a specific task, and others for monitoring broadly (vigilance). They are always locked in competition to steer the actions of the organism.</p><p>On a larger anatomical scale, the two hemispheres of the brain, left and right, can be understood as overlapping systems that compete. We know this from patients whose hemispheres are disconnected: they essentially function with two independent brains. For example, put a pencil in each hand, and they can simultaneously draw incompatible figures such as a circle and a triangle. The two hemispheres function differently in the domains of language, abstract thinking, story construction, inference, memory, gambling strategies, and so on. The two halves constitute a team of rivals: agents with the same goals but slightly different ways of going about it.</p><p>The neural democracy model may be just the thing to dislodge artificial intelligence. We human programmers still approach a problem by assuming there&#8217;s a best way to solve it, or that there&#8217;s a way it should be solved. But evolution does not solve a problem and then check it off the list. Instead, it ceaselessly reinvents programs, each with overlapping and competing approaches. The lesson is to abandon the question &#8220;what&#8217;s the most clever way to solve that problem?&#8221; in favor of &#8220;are there multiple, overlapping ways to solve that problem?&#8221; This will be the starting point in ushering in a fruitful new age of elegantly inelegant computational devices.</p><p><em><strong>Source</strong>: https://www.edge.org/response-detail/11663 </em></p></blockquote><h3>Finally</h3><p>This write-up has been a very long journey for me and I hope that you find it useful in helping explain how large-language models like ChatGPT work. I went into very long detail on showing the architectural principles behind transformers (including encoder-decoder models). If you like this write-up, please like and share or if you have any feedback for me, let me know in the comments.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WlcQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F811bb3b0-c0a4-43b4-9c0d-e81aad14da21_803x788.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WlcQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F811bb3b0-c0a4-43b4-9c0d-e81aad14da21_803x788.png 424w, https://substackcdn.com/image/fetch/$s_!WlcQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F811bb3b0-c0a4-43b4-9c0d-e81aad14da21_803x788.png 848w, https://substackcdn.com/image/fetch/$s_!WlcQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F811bb3b0-c0a4-43b4-9c0d-e81aad14da21_803x788.png 1272w, https://substackcdn.com/image/fetch/$s_!WlcQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F811bb3b0-c0a4-43b4-9c0d-e81aad14da21_803x788.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WlcQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F811bb3b0-c0a4-43b4-9c0d-e81aad14da21_803x788.png" width="521" height="511.26774595267744" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/811bb3b0-c0a4-43b4-9c0d-e81aad14da21_803x788.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:788,&quot;width&quot;:803,&quot;resizeWidth&quot;:521,&quot;bytes&quot;:381259,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WlcQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F811bb3b0-c0a4-43b4-9c0d-e81aad14da21_803x788.png 424w, https://substackcdn.com/image/fetch/$s_!WlcQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F811bb3b0-c0a4-43b4-9c0d-e81aad14da21_803x788.png 848w, https://substackcdn.com/image/fetch/$s_!WlcQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F811bb3b0-c0a4-43b4-9c0d-e81aad14da21_803x788.png 1272w, https://substackcdn.com/image/fetch/$s_!WlcQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F811bb3b0-c0a4-43b4-9c0d-e81aad14da21_803x788.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></figure></div><p></p><h2><strong>Appendix</strong></h2><h3><strong>Deciphering Encoder Architecture and Matrix Mechanics</strong></h3><h4><strong>Matrix multiplication</strong></h4><p>Although the definition of matrix multiplication can be a little confusing, an explicit multiplication might clarify this simple task. We&#8217;ll multiply the two following matrices to quickly show an example of matrix multiplication for anyone needing a refresher:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6Zj9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8029355-dc9b-4521-84a3-111201e6f55e_248x75.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6Zj9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8029355-dc9b-4521-84a3-111201e6f55e_248x75.png 424w, https://substackcdn.com/image/fetch/$s_!6Zj9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8029355-dc9b-4521-84a3-111201e6f55e_248x75.png 848w, https://substackcdn.com/image/fetch/$s_!6Zj9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8029355-dc9b-4521-84a3-111201e6f55e_248x75.png 1272w, https://substackcdn.com/image/fetch/$s_!6Zj9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8029355-dc9b-4521-84a3-111201e6f55e_248x75.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6Zj9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8029355-dc9b-4521-84a3-111201e6f55e_248x75.png" width="248" height="75" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d8029355-dc9b-4521-84a3-111201e6f55e_248x75.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:75,&quot;width&quot;:248,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:3420,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6Zj9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8029355-dc9b-4521-84a3-111201e6f55e_248x75.png 424w, https://substackcdn.com/image/fetch/$s_!6Zj9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8029355-dc9b-4521-84a3-111201e6f55e_248x75.png 848w, https://substackcdn.com/image/fetch/$s_!6Zj9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8029355-dc9b-4521-84a3-111201e6f55e_248x75.png 1272w, https://substackcdn.com/image/fetch/$s_!6Zj9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8029355-dc9b-4521-84a3-111201e6f55e_248x75.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Since A is a 2x3 matrix and B is a 3x2 matrix, we know that the result of the multiplication is a 2x2 matrix:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!e4BD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd8f1cb8-937f-4456-acbc-c34a14662bee_405x91.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!e4BD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd8f1cb8-937f-4456-acbc-c34a14662bee_405x91.png 424w, https://substackcdn.com/image/fetch/$s_!e4BD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd8f1cb8-937f-4456-acbc-c34a14662bee_405x91.png 848w, https://substackcdn.com/image/fetch/$s_!e4BD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd8f1cb8-937f-4456-acbc-c34a14662bee_405x91.png 1272w, https://substackcdn.com/image/fetch/$s_!e4BD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd8f1cb8-937f-4456-acbc-c34a14662bee_405x91.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!e4BD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd8f1cb8-937f-4456-acbc-c34a14662bee_405x91.png" width="405" height="91" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cd8f1cb8-937f-4456-acbc-c34a14662bee_405x91.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:91,&quot;width&quot;:405,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:3293,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!e4BD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd8f1cb8-937f-4456-acbc-c34a14662bee_405x91.png 424w, https://substackcdn.com/image/fetch/$s_!e4BD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd8f1cb8-937f-4456-acbc-c34a14662bee_405x91.png 848w, https://substackcdn.com/image/fetch/$s_!e4BD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd8f1cb8-937f-4456-acbc-c34a14662bee_405x91.png 1272w, https://substackcdn.com/image/fetch/$s_!e4BD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd8f1cb8-937f-4456-acbc-c34a14662bee_405x91.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Let&#8217;s go through the steps below:</p><p>Step 1: We multiply the 1<sup>st</sup> column of M by the 1<sup>st</sup> row of N to get our entry at [1, 1]:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Dscz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89c3afb-7127-4cfc-89ab-a3858381dd53_390x86.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Dscz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89c3afb-7127-4cfc-89ab-a3858381dd53_390x86.png 424w, https://substackcdn.com/image/fetch/$s_!Dscz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89c3afb-7127-4cfc-89ab-a3858381dd53_390x86.png 848w, https://substackcdn.com/image/fetch/$s_!Dscz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89c3afb-7127-4cfc-89ab-a3858381dd53_390x86.png 1272w, https://substackcdn.com/image/fetch/$s_!Dscz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89c3afb-7127-4cfc-89ab-a3858381dd53_390x86.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Dscz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89c3afb-7127-4cfc-89ab-a3858381dd53_390x86.png" width="390" height="86" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f89c3afb-7127-4cfc-89ab-a3858381dd53_390x86.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:86,&quot;width&quot;:390,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:5521,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Dscz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89c3afb-7127-4cfc-89ab-a3858381dd53_390x86.png 424w, https://substackcdn.com/image/fetch/$s_!Dscz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89c3afb-7127-4cfc-89ab-a3858381dd53_390x86.png 848w, https://substackcdn.com/image/fetch/$s_!Dscz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89c3afb-7127-4cfc-89ab-a3858381dd53_390x86.png 1272w, https://substackcdn.com/image/fetch/$s_!Dscz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff89c3afb-7127-4cfc-89ab-a3858381dd53_390x86.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Step 2: We multiply the 1<sup>st</sup> column of M by the 2<sup>nd</sup> row of N to get our entry at [1, 2]:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!uaxZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9728757d-7910-478f-9b82-3d65a3546969_398x80.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!uaxZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9728757d-7910-478f-9b82-3d65a3546969_398x80.png 424w, https://substackcdn.com/image/fetch/$s_!uaxZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9728757d-7910-478f-9b82-3d65a3546969_398x80.png 848w, https://substackcdn.com/image/fetch/$s_!uaxZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9728757d-7910-478f-9b82-3d65a3546969_398x80.png 1272w, https://substackcdn.com/image/fetch/$s_!uaxZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9728757d-7910-478f-9b82-3d65a3546969_398x80.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!uaxZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9728757d-7910-478f-9b82-3d65a3546969_398x80.png" width="398" height="80" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9728757d-7910-478f-9b82-3d65a3546969_398x80.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:80,&quot;width&quot;:398,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:6477,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!uaxZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9728757d-7910-478f-9b82-3d65a3546969_398x80.png 424w, https://substackcdn.com/image/fetch/$s_!uaxZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9728757d-7910-478f-9b82-3d65a3546969_398x80.png 848w, https://substackcdn.com/image/fetch/$s_!uaxZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9728757d-7910-478f-9b82-3d65a3546969_398x80.png 1272w, https://substackcdn.com/image/fetch/$s_!uaxZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9728757d-7910-478f-9b82-3d65a3546969_398x80.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Step 3: We multiply the 2<sup>nd</sup> column of M by the 1<sup>st</sup> row of N to get our entry at [2, 1]:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Xhu-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee01426-e323-431f-b3a7-c553c0eca5a0_397x82.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Xhu-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee01426-e323-431f-b3a7-c553c0eca5a0_397x82.png 424w, https://substackcdn.com/image/fetch/$s_!Xhu-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee01426-e323-431f-b3a7-c553c0eca5a0_397x82.png 848w, https://substackcdn.com/image/fetch/$s_!Xhu-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee01426-e323-431f-b3a7-c553c0eca5a0_397x82.png 1272w, https://substackcdn.com/image/fetch/$s_!Xhu-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee01426-e323-431f-b3a7-c553c0eca5a0_397x82.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Xhu-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee01426-e323-431f-b3a7-c553c0eca5a0_397x82.png" width="397" height="82" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7ee01426-e323-431f-b3a7-c553c0eca5a0_397x82.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:82,&quot;width&quot;:397,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:7230,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Xhu-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee01426-e323-431f-b3a7-c553c0eca5a0_397x82.png 424w, https://substackcdn.com/image/fetch/$s_!Xhu-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee01426-e323-431f-b3a7-c553c0eca5a0_397x82.png 848w, https://substackcdn.com/image/fetch/$s_!Xhu-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee01426-e323-431f-b3a7-c553c0eca5a0_397x82.png 1272w, https://substackcdn.com/image/fetch/$s_!Xhu-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ee01426-e323-431f-b3a7-c553c0eca5a0_397x82.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Step 4: We multiply the 2<sup>nd</sup> column of M by the 2<sup>nd</sup> row of N to get our entry at [2, 2]:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!oe29!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2446758-b214-427f-99cb-f9320dbed8d9_393x82.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!oe29!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2446758-b214-427f-99cb-f9320dbed8d9_393x82.png 424w, https://substackcdn.com/image/fetch/$s_!oe29!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2446758-b214-427f-99cb-f9320dbed8d9_393x82.png 848w, https://substackcdn.com/image/fetch/$s_!oe29!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2446758-b214-427f-99cb-f9320dbed8d9_393x82.png 1272w, https://substackcdn.com/image/fetch/$s_!oe29!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2446758-b214-427f-99cb-f9320dbed8d9_393x82.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!oe29!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2446758-b214-427f-99cb-f9320dbed8d9_393x82.png" width="393" height="82" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d2446758-b214-427f-99cb-f9320dbed8d9_393x82.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:82,&quot;width&quot;:393,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:7912,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!oe29!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2446758-b214-427f-99cb-f9320dbed8d9_393x82.png 424w, https://substackcdn.com/image/fetch/$s_!oe29!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2446758-b214-427f-99cb-f9320dbed8d9_393x82.png 848w, https://substackcdn.com/image/fetch/$s_!oe29!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2446758-b214-427f-99cb-f9320dbed8d9_393x82.png 1272w, https://substackcdn.com/image/fetch/$s_!oe29!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2446758-b214-427f-99cb-f9320dbed8d9_393x82.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>In a nutshell, matrix multiplication can also be interpreted as a linear transformation on a set of vectors. To perform this linear transformation, we use dot products. The dot product is taken between every row in our first matrix by every column in our 2<sup>nd</sup> matrix. To put it more formally, if we have matrix A and B and we multiply the 2 matrices to get AB, the elements located at index (i, j) in our product matrix is the dot product between the i<sup>th</sup> row of A and j<sup>th</sup> column of B:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nV1d!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66bcdef6-3065-460f-92a3-a69134335b78_681x554.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nV1d!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66bcdef6-3065-460f-92a3-a69134335b78_681x554.png 424w, https://substackcdn.com/image/fetch/$s_!nV1d!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66bcdef6-3065-460f-92a3-a69134335b78_681x554.png 848w, https://substackcdn.com/image/fetch/$s_!nV1d!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66bcdef6-3065-460f-92a3-a69134335b78_681x554.png 1272w, https://substackcdn.com/image/fetch/$s_!nV1d!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66bcdef6-3065-460f-92a3-a69134335b78_681x554.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nV1d!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66bcdef6-3065-460f-92a3-a69134335b78_681x554.png" width="389" height="316.4552129221733" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/66bcdef6-3065-460f-92a3-a69134335b78_681x554.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:554,&quot;width&quot;:681,&quot;resizeWidth&quot;:389,&quot;bytes&quot;:13684,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!nV1d!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66bcdef6-3065-460f-92a3-a69134335b78_681x554.png 424w, https://substackcdn.com/image/fetch/$s_!nV1d!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66bcdef6-3065-460f-92a3-a69134335b78_681x554.png 848w, https://substackcdn.com/image/fetch/$s_!nV1d!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66bcdef6-3065-460f-92a3-a69134335b78_681x554.png 1272w, https://substackcdn.com/image/fetch/$s_!nV1d!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66bcdef6-3065-460f-92a3-a69134335b78_681x554.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></figure></div><p>Let&#8217;s take our word encodings (which contain the semantic and positional information in vector format and transform them into a matrix):</p><p>Sentence: I like to read.</p><p>Example vector representation (with a dimensionality of 3):</p><p>I - &gt; [0.4, 0.0, 0.0]</p><p>like - &gt; [-0.2, 0.3, -0.1]</p><p>to - &gt; [0.5, -0.1, 0.8]</p><p>read - &gt; [-0.2, 0.1, -0.1]</p><p>Instead of feeding in each individual vector/word into our self-attention step, we actually feed in a matrix containing each word (inserted as a separate) row and we perform out calculations and the needed steps needed in order perform our attention steps on the matrix itself:</p><p>[ 0.4, 0.0, 0.0 ]</p><p>[-0.2, 0.3, -0.1 ]</p><p>[ 0.5, -0.1, 0.8 ]</p><p>[-0.2, 0.1, -0.1 ]</p><p>We&#8217;ll summarize what happens in a visual manner and then go through each step. The image used in the paper to show how the attention is computed along with helpful annotations is provided 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_!hWDg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba8ae98b-d934-49ab-b62b-5278ebffe1ae_1262x591.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hWDg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba8ae98b-d934-49ab-b62b-5278ebffe1ae_1262x591.png 424w, https://substackcdn.com/image/fetch/$s_!hWDg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba8ae98b-d934-49ab-b62b-5278ebffe1ae_1262x591.png 848w, https://substackcdn.com/image/fetch/$s_!hWDg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba8ae98b-d934-49ab-b62b-5278ebffe1ae_1262x591.png 1272w, https://substackcdn.com/image/fetch/$s_!hWDg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba8ae98b-d934-49ab-b62b-5278ebffe1ae_1262x591.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hWDg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba8ae98b-d934-49ab-b62b-5278ebffe1ae_1262x591.png" width="1262" height="591" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ba8ae98b-d934-49ab-b62b-5278ebffe1ae_1262x591.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:591,&quot;width&quot;:1262,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:86465,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hWDg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba8ae98b-d934-49ab-b62b-5278ebffe1ae_1262x591.png 424w, https://substackcdn.com/image/fetch/$s_!hWDg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba8ae98b-d934-49ab-b62b-5278ebffe1ae_1262x591.png 848w, https://substackcdn.com/image/fetch/$s_!hWDg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba8ae98b-d934-49ab-b62b-5278ebffe1ae_1262x591.png 1272w, https://substackcdn.com/image/fetch/$s_!hWDg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba8ae98b-d934-49ab-b62b-5278ebffe1ae_1262x591.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></figure></div><h4><strong>1) Computing query / key similarity:</strong></h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YjI9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6dc8db8-80ed-4d17-a8b8-de441fe83453_707x321.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YjI9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6dc8db8-80ed-4d17-a8b8-de441fe83453_707x321.png 424w, https://substackcdn.com/image/fetch/$s_!YjI9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6dc8db8-80ed-4d17-a8b8-de441fe83453_707x321.png 848w, https://substackcdn.com/image/fetch/$s_!YjI9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6dc8db8-80ed-4d17-a8b8-de441fe83453_707x321.png 1272w, https://substackcdn.com/image/fetch/$s_!YjI9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6dc8db8-80ed-4d17-a8b8-de441fe83453_707x321.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YjI9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6dc8db8-80ed-4d17-a8b8-de441fe83453_707x321.png" width="589" height="267.4243281471004" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b6dc8db8-80ed-4d17-a8b8-de441fe83453_707x321.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:321,&quot;width&quot;:707,&quot;resizeWidth&quot;:589,&quot;bytes&quot;:26150,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!YjI9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6dc8db8-80ed-4d17-a8b8-de441fe83453_707x321.png 424w, https://substackcdn.com/image/fetch/$s_!YjI9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6dc8db8-80ed-4d17-a8b8-de441fe83453_707x321.png 848w, https://substackcdn.com/image/fetch/$s_!YjI9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6dc8db8-80ed-4d17-a8b8-de441fe83453_707x321.png 1272w, https://substackcdn.com/image/fetch/$s_!YjI9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6dc8db8-80ed-4d17-a8b8-de441fe83453_707x321.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></figure></div><p></p><p>Here, the dot product of each row containing the query word vector in in our query matrix is multiplied by each column in our transposed key matrix (which represents the corresponding key word vector) to obtain the <strong>similarity score </strong>between each query-key vector pair that we have within our Q and K matrix elements.</p><p>Let&#8217;s suppose that we have a matrix of 4 words which we are feeding into our input. This would result in 4 separate rows in our query, key, and value matrices. The multiplication step would result in a 4 by 4 matrix containing a similarity score (dot product) with high scores given to words which have a high similarity mapping while low scores (negative value or 0 valued) to words which aren&#8217;t mapped similarly.</p><p>In our example-illustration above, we would get a 2x2 matrix since we are only feeding int 2 words (each matrix has 2 rows).</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!usAd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff630477e-fce8-4935-9687-0fd41fd4f167_320x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!usAd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff630477e-fce8-4935-9687-0fd41fd4f167_320x200.png 424w, https://substackcdn.com/image/fetch/$s_!usAd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff630477e-fce8-4935-9687-0fd41fd4f167_320x200.png 848w, https://substackcdn.com/image/fetch/$s_!usAd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff630477e-fce8-4935-9687-0fd41fd4f167_320x200.png 1272w, https://substackcdn.com/image/fetch/$s_!usAd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff630477e-fce8-4935-9687-0fd41fd4f167_320x200.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!usAd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff630477e-fce8-4935-9687-0fd41fd4f167_320x200.png" width="300" height="187.5" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f630477e-fce8-4935-9687-0fd41fd4f167_320x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:320,&quot;resizeWidth&quot;:300,&quot;bytes&quot;:3440,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!usAd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff630477e-fce8-4935-9687-0fd41fd4f167_320x200.png 424w, https://substackcdn.com/image/fetch/$s_!usAd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff630477e-fce8-4935-9687-0fd41fd4f167_320x200.png 848w, https://substackcdn.com/image/fetch/$s_!usAd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff630477e-fce8-4935-9687-0fd41fd4f167_320x200.png 1272w, https://substackcdn.com/image/fetch/$s_!usAd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff630477e-fce8-4935-9687-0fd41fd4f167_320x200.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p><h4><strong>2) Scaling:</strong></h4><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!92me!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd87c8e29-2971-4940-b8a9-1fc15fb2ba87_396x504.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!92me!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd87c8e29-2971-4940-b8a9-1fc15fb2ba87_396x504.png 424w, https://substackcdn.com/image/fetch/$s_!92me!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd87c8e29-2971-4940-b8a9-1fc15fb2ba87_396x504.png 848w, https://substackcdn.com/image/fetch/$s_!92me!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd87c8e29-2971-4940-b8a9-1fc15fb2ba87_396x504.png 1272w, https://substackcdn.com/image/fetch/$s_!92me!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd87c8e29-2971-4940-b8a9-1fc15fb2ba87_396x504.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!92me!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd87c8e29-2971-4940-b8a9-1fc15fb2ba87_396x504.png" width="326" height="414.90909090909093" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d87c8e29-2971-4940-b8a9-1fc15fb2ba87_396x504.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:504,&quot;width&quot;:396,&quot;resizeWidth&quot;:326,&quot;bytes&quot;:22302,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!92me!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd87c8e29-2971-4940-b8a9-1fc15fb2ba87_396x504.png 424w, https://substackcdn.com/image/fetch/$s_!92me!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd87c8e29-2971-4940-b8a9-1fc15fb2ba87_396x504.png 848w, https://substackcdn.com/image/fetch/$s_!92me!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd87c8e29-2971-4940-b8a9-1fc15fb2ba87_396x504.png 1272w, https://substackcdn.com/image/fetch/$s_!92me!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd87c8e29-2971-4940-b8a9-1fc15fb2ba87_396x504.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></figure></div><p>The dot products in the attention computation can have large magnitudes and can move the arguments of the softmax function into a region where the largest value completely dominates. This makes the model difficult to train. To avoid this behavior, the resulting query / key similarity matrix is scaled by the square root of the query / key / value vector dimension(s).</p><p>If our query and key vectors are of length 64 as an example, the matrix values are all divided by 8 (square root of 64) to perform this scaling.</p><h4><strong>3) Soft-max computation (normalizing each similarity value to a valid probability mapping):</strong></h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gU3X!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd08df2-15ff-4054-8114-bb668646aeb0_861x342.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gU3X!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd08df2-15ff-4054-8114-bb668646aeb0_861x342.png 424w, https://substackcdn.com/image/fetch/$s_!gU3X!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd08df2-15ff-4054-8114-bb668646aeb0_861x342.png 848w, https://substackcdn.com/image/fetch/$s_!gU3X!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd08df2-15ff-4054-8114-bb668646aeb0_861x342.png 1272w, https://substackcdn.com/image/fetch/$s_!gU3X!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd08df2-15ff-4054-8114-bb668646aeb0_861x342.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gU3X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd08df2-15ff-4054-8114-bb668646aeb0_861x342.png" width="703" height="279.2404181184669" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ecd08df2-15ff-4054-8114-bb668646aeb0_861x342.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:342,&quot;width&quot;:861,&quot;resizeWidth&quot;:703,&quot;bytes&quot;:29997,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!gU3X!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd08df2-15ff-4054-8114-bb668646aeb0_861x342.png 424w, https://substackcdn.com/image/fetch/$s_!gU3X!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd08df2-15ff-4054-8114-bb668646aeb0_861x342.png 848w, https://substackcdn.com/image/fetch/$s_!gU3X!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd08df2-15ff-4054-8114-bb668646aeb0_861x342.png 1272w, https://substackcdn.com/image/fetch/$s_!gU3X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fecd08df2-15ff-4054-8114-bb668646aeb0_861x342.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></figure></div><p>This step takes each resulting key value for each query word / vector and turns the resulting scaled dot product value into a probability. All of the probabilities across the query to key mapping end up summing to 1 (100%) so an example mapping of I love to read scaled dot product matrix provided below:</p><p>Attention score for "I" attending to "I": 0.16</p><p>Attention score for "I" attending to "like": 0.42</p><p>Attention score for "I" attending to "to": 0.2</p><p>Attention score for "I" attending to "read": 0.22</p><p>To calculate the probability values, we need to normalize these scores using the softmax function. The softmax function transforms the scores into a probability distribution where the values sum up to 1.</p><p>First, let's exponentiate the scores:</p><p>exp(0.16) &#8776; 1.174</p><p>exp(0.42) &#8776; 1.523</p><p>exp(0.2) &#8776; 1.221</p><p>exp(0.22) &#8776; 1.245</p><p>Next, we calculate the sum of these exponentiated scores:</p><p>1.174 + 1.523 + 1.221 + 1.245 &#8776; 5.163</p><p>Finally, we divide each exponentiated score by the sum to obtain the normalized probability values:</p><p>Probability for "I" attending to "I": 1.174 / 5.163 &#8776; 0.23</p><p>Probability for "I" attending to "like": 1.523 / 5.163 &#8776; 0.29</p><p>Probability for "I" attending to "to": 1.221 / 5.163 &#8776; 0.24</p><p>Probability for "I" attending to "read": 1.245 / 5.163 &#8776; 0.24</p><p>These are the approximate probability values for each mapping after passing through the softmax calculation, and as you can note that when we sum up all of the resulting values, we get 1:</p><p>0.23 + 0.29 + 0.24 + 0.24 = 1</p><p>Although the above takes us through an example calculation &#8211; the end product after the softmax would result once again in a 4x4 matrix mapping each query vector to the scaled and normalized key:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FSPt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc45a33ae-b50f-4731-9e09-282f7bcae534_735x413.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FSPt!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc45a33ae-b50f-4731-9e09-282f7bcae534_735x413.png 424w, https://substackcdn.com/image/fetch/$s_!FSPt!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc45a33ae-b50f-4731-9e09-282f7bcae534_735x413.png 848w, https://substackcdn.com/image/fetch/$s_!FSPt!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc45a33ae-b50f-4731-9e09-282f7bcae534_735x413.png 1272w, https://substackcdn.com/image/fetch/$s_!FSPt!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc45a33ae-b50f-4731-9e09-282f7bcae534_735x413.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FSPt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc45a33ae-b50f-4731-9e09-282f7bcae534_735x413.png" width="587" height="329.83809523809526" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c45a33ae-b50f-4731-9e09-282f7bcae534_735x413.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:413,&quot;width&quot;:735,&quot;resizeWidth&quot;:587,&quot;bytes&quot;:17759,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FSPt!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc45a33ae-b50f-4731-9e09-282f7bcae534_735x413.png 424w, https://substackcdn.com/image/fetch/$s_!FSPt!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc45a33ae-b50f-4731-9e09-282f7bcae534_735x413.png 848w, https://substackcdn.com/image/fetch/$s_!FSPt!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc45a33ae-b50f-4731-9e09-282f7bcae534_735x413.png 1272w, https://substackcdn.com/image/fetch/$s_!FSPt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc45a33ae-b50f-4731-9e09-282f7bcae534_735x413.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></figure></div><h4><strong>4) Multiplication by value matrix:</strong></h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0Vjz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F659af423-7b28-4161-8199-2a621eb06a12_1261x564.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0Vjz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F659af423-7b28-4161-8199-2a621eb06a12_1261x564.png 424w, https://substackcdn.com/image/fetch/$s_!0Vjz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F659af423-7b28-4161-8199-2a621eb06a12_1261x564.png 848w, https://substackcdn.com/image/fetch/$s_!0Vjz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F659af423-7b28-4161-8199-2a621eb06a12_1261x564.png 1272w, https://substackcdn.com/image/fetch/$s_!0Vjz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F659af423-7b28-4161-8199-2a621eb06a12_1261x564.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0Vjz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F659af423-7b28-4161-8199-2a621eb06a12_1261x564.png" width="1261" height="564" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/659af423-7b28-4161-8199-2a621eb06a12_1261x564.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:564,&quot;width&quot;:1261,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:91055,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!0Vjz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F659af423-7b28-4161-8199-2a621eb06a12_1261x564.png 424w, https://substackcdn.com/image/fetch/$s_!0Vjz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F659af423-7b28-4161-8199-2a621eb06a12_1261x564.png 848w, https://substackcdn.com/image/fetch/$s_!0Vjz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F659af423-7b28-4161-8199-2a621eb06a12_1261x564.png 1272w, https://substackcdn.com/image/fetch/$s_!0Vjz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F659af423-7b28-4161-8199-2a621eb06a12_1261x564.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></figure></div><p>Finally, we multiply our normalized query to key value probability matrix (containing the query to key mapping score) by our value matrix values (containing our value vector on each row) to get a resulting summed product of each query to value mapping.</p><p>The primary intuition here is to take the values of the words we want to focus on and to drown-out irrelevant words by using our scaled and normalized dot-product similarity mapping for each input value.</p><p>As an example, if we were to use our original example &#8216;I love to read&#8217; and isolate the matrix multiplications which take place, we would get something like the image 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_!toVB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a2f620-527d-4b5c-92c2-6ac414b2c841_1009x707.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!toVB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a2f620-527d-4b5c-92c2-6ac414b2c841_1009x707.png 424w, https://substackcdn.com/image/fetch/$s_!toVB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a2f620-527d-4b5c-92c2-6ac414b2c841_1009x707.png 848w, https://substackcdn.com/image/fetch/$s_!toVB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a2f620-527d-4b5c-92c2-6ac414b2c841_1009x707.png 1272w, https://substackcdn.com/image/fetch/$s_!toVB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a2f620-527d-4b5c-92c2-6ac414b2c841_1009x707.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!toVB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a2f620-527d-4b5c-92c2-6ac414b2c841_1009x707.png" width="1009" height="707" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f0a2f620-527d-4b5c-92c2-6ac414b2c841_1009x707.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:707,&quot;width&quot;:1009,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:59566,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!toVB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a2f620-527d-4b5c-92c2-6ac414b2c841_1009x707.png 424w, https://substackcdn.com/image/fetch/$s_!toVB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a2f620-527d-4b5c-92c2-6ac414b2c841_1009x707.png 848w, https://substackcdn.com/image/fetch/$s_!toVB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a2f620-527d-4b5c-92c2-6ac414b2c841_1009x707.png 1272w, https://substackcdn.com/image/fetch/$s_!toVB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a2f620-527d-4b5c-92c2-6ac414b2c841_1009x707.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></figure></div><p>Multiplying the 2 matrices above would essentially result in a &#8216;scaled&#8217; value vector encoding with each one of our value dimensions (2<sup>nd</sup> matrix column-vector) being multiplied by each normalized attention score (1<sup>st</sup> matrix row-vector).</p><p>Once again, every entry at index (i, j) in our first matrix contains our normalized and scaled dot-product &#8216;similarity&#8217; computations containing the similarity values between the query word present in our input at position i compared against the key-word present in column j. Our first row vector as an example for the input &#8216;I love to read&#8217; would contain the &#8216;similarity&#8217; score mapping between the query word &#8216;I&#8217; to each key word - &gt; &#8216;I&#8217;, &#8216;love&#8217;, &#8216;to&#8217;, &#8216;read&#8217;.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CaX-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627602a2-b18d-472b-a7ed-91586a283ec6_497x433.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CaX-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627602a2-b18d-472b-a7ed-91586a283ec6_497x433.png 424w, https://substackcdn.com/image/fetch/$s_!CaX-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627602a2-b18d-472b-a7ed-91586a283ec6_497x433.png 848w, https://substackcdn.com/image/fetch/$s_!CaX-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627602a2-b18d-472b-a7ed-91586a283ec6_497x433.png 1272w, https://substackcdn.com/image/fetch/$s_!CaX-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627602a2-b18d-472b-a7ed-91586a283ec6_497x433.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CaX-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627602a2-b18d-472b-a7ed-91586a283ec6_497x433.png" width="471" height="410.3480885311871" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/627602a2-b18d-472b-a7ed-91586a283ec6_497x433.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:433,&quot;width&quot;:497,&quot;resizeWidth&quot;:471,&quot;bytes&quot;:21952,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!CaX-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627602a2-b18d-472b-a7ed-91586a283ec6_497x433.png 424w, https://substackcdn.com/image/fetch/$s_!CaX-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627602a2-b18d-472b-a7ed-91586a283ec6_497x433.png 848w, https://substackcdn.com/image/fetch/$s_!CaX-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627602a2-b18d-472b-a7ed-91586a283ec6_497x433.png 1272w, https://substackcdn.com/image/fetch/$s_!CaX-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627602a2-b18d-472b-a7ed-91586a283ec6_497x433.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></figure></div><p>In the same manner, the column vectors in our 2<sup>nd</sup> value matrix hold the j<sup>th</sup> dimensional mapping for each value present for each word present in our input:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9pl1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d0ea3ca-bf78-41cd-b7aa-e38a04d3146a_632x632.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9pl1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d0ea3ca-bf78-41cd-b7aa-e38a04d3146a_632x632.png 424w, https://substackcdn.com/image/fetch/$s_!9pl1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d0ea3ca-bf78-41cd-b7aa-e38a04d3146a_632x632.png 848w, https://substackcdn.com/image/fetch/$s_!9pl1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d0ea3ca-bf78-41cd-b7aa-e38a04d3146a_632x632.png 1272w, https://substackcdn.com/image/fetch/$s_!9pl1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d0ea3ca-bf78-41cd-b7aa-e38a04d3146a_632x632.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9pl1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d0ea3ca-bf78-41cd-b7aa-e38a04d3146a_632x632.png" width="486" height="486" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0d0ea3ca-bf78-41cd-b7aa-e38a04d3146a_632x632.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:632,&quot;width&quot;:632,&quot;resizeWidth&quot;:486,&quot;bytes&quot;:44531,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!9pl1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d0ea3ca-bf78-41cd-b7aa-e38a04d3146a_632x632.png 424w, https://substackcdn.com/image/fetch/$s_!9pl1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d0ea3ca-bf78-41cd-b7aa-e38a04d3146a_632x632.png 848w, https://substackcdn.com/image/fetch/$s_!9pl1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d0ea3ca-bf78-41cd-b7aa-e38a04d3146a_632x632.png 1272w, https://substackcdn.com/image/fetch/$s_!9pl1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d0ea3ca-bf78-41cd-b7aa-e38a04d3146a_632x632.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></figure></div><p>Multiplying the 2 matrices above would result in a matrix containing the dot product between the i<sup>th </sup>row of our attention score matrix (which represents the normalized attention score vector for word i from our input) and the j<sup>th</sup> column of our value matrix representing the j<sup>th</sup> embedding dimension for each input word.</p><p>In other words, we are &#8216;scaling&#8217; each value projection by a &#8216;growth&#8217; and &#8216;shrink&#8217; factor which we realize by computing our query to key attention score and multiplying each value within it to a mapping within our value matrix.</p><p>The end result would be a value matrix <strong>scaled</strong> by our attention scores!</p><h2>References and Links</h2><p>Much of the above work and many of the illustrations are not my own, so a full list of referenced articles / books / papers is provided below:</p><ol><li><p><a href="https://arxiv.org/abs/1706.03762">Attention is All You Need</a> (Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, Illia Polosukhin)</p></li><li><p><a href="https://txt.cohere.com/what-are-transformer-models/">What Are Transformer Models and How Do They Work?</a> (Luis Serrano)</p></li><li><p><a href="https://www.youtube.com/watch?v=XSSTuhyAmnI">What are Transformer Neural Networks?</a> (Ari Seff)</p></li><li><p><a href="https://towardsdatascience.com/illustrated-guide-to-transformers-step-by-step-explanation-f74876522bc0">Illustrated Guide to Transformers- Step by Step Explanation</a>. (Michael Phi)</p></li><li><p><a href="https://www.youtube.com/watch?v=XowwKOAWYoQ">Attention Is All You Need - Paper Explained</a>. (Matt Namvarpour)</p></li><li><p><a href="https://udlbook.github.io/udlbook/">Understanding Deep Learning</a>. (Simon J.D. Prince)</p></li><li><p><a href="https://lifearchitect.ai/models/">Inside language models (from GPT to Olympus)</a>. (Alan D. Thompson)</p></li><li><p><a href="https://www.youtube.com/watch?v=4Bdc55j80l8">Illustrated Guide to Transformers Neural Network: A step by step explanation</a>. (Michael Nguyen)</p></li><li><p><a href="https://www.youtube.com/watch?v=13CZPWmke6A">Ilya Sutskever: Deep Learning | Lex Fridman Podcast #94</a>.</p></li><li><p><a href="https://arxiv.org/abs/2012.14913">Transformer Feed-Forward Layers Are Key-Value Memories</a>. (Mor Geva, Roei Schuster, Jonathan Berant, Omer Levy)</p></li><li><p><a href="https://arxiv.org/abs/2309.04827">Neurons in Large Language Models: Dead, N-gram, Positional</a>. (Elena Voita, Javier Ferrando, Christoforos Nalmpantis)</p></li><li><p><a href="https://lena-voita.github.io/posts/neurons_in_llms_dead_ngram_positional.html">Neurons in LLMs - Dead, N-gram, Positional</a>. (Lena Voita)</p></li><li><p><a href="https://arxiv.org/abs/2005.14165">Language Models are Few-Shot Learners</a>. (Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, Dario Amodei)</p></li><li><p><a href="https://arxiv.org/abs/2203.02155">Training language models to follow instructions with human feedback</a>. (Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L. Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, John Schulman, Jacob Hilton, Fraser Kelton, Luke Miller, Maddie Simens, Amanda Askell, Peter Welinder, Paul Christiano, Jan Leike, Ryan Lowe)</p></li><li><p><a href="https://arxiv.org/abs/1904.10509">Generating Long Sequences with Sparse Transformers</a>. (Rewon Child, Scott Gray, Alec Radford, Ilya Sutskever)</p></li><li><p><a href="https://arxiv.org/abs/2201.11903">Chain-of-Thought Prompting Elicits Reasoning in Large Language Models</a>. (Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Brian Ichter, Fei Xia, Ed Chi, Quoc Le, Denny Zhou)</p></li><li><p><a href="https://arxiv.org/abs/2101.03961">Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity</a>. (William Fedus, Barret Zoph, Noam Shazeer)</p></li><li><p><a href="https://huggingface.co/blog/moe">Mixture of Experts Explained</a>. (Sanseviero, et al.)</p></li><li><p><a href="https://www.youtube.com/watch?v=zjkBMFhNj_g">Intro to Large Language Models</a>. (Andrej Karpathy)</p></li><li><p><a href="https://fluxus.org/FluxusMidwest/doorknobs/">Fluxus Research: Opening and Closing Doors and Drawers</a>. (Allen Bukoff)</p></li><li><p><a href="https://www.edge.org/response-detail/11663">Ceaseless Reinvention Leads To Overlapping Solutions</a>. (David M. Eagleman)</p></li></ol><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Photon-Lines Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Sam Altman's Startup Advice (Part 2)]]></title><description><![CDATA[Part 2 of my own personal notes / summaries of the readings available on Sam Altman's 'How to Start a Startup' lectures.]]></description><link>https://photonlines.substack.com/p/sam-altmans-startup-advice-part-2</link><guid isPermaLink="false">https://photonlines.substack.com/p/sam-altmans-startup-advice-part-2</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Fri, 02 Feb 2024 16:32:13 GMT</pubDate><enclosure url="https://substackcdn.com/image/vimeo/w_728,c_limit,d_video_placeholder.png/34081566" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let&#8217;s continue on with exploring the recommended readings / material available in Sam Altman&#8217;s how to start a startup notes <a href="https://startupclass.samaltman.com/lists/readings/">available here</a>.</p><p>You can find part 1 of this series below.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Photon-Lines Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div><hr></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;a32f48e2-5f67-47e0-8eb6-9a47d2684180&quot;,&quot;caption&quot;:&quot;I decided to venture into the world of Sam Altman this week. If you&#8217;ve been living on Mars and you don&#8217;t happen to know who he is, I&#8217;ll summarize it for you briefly: Sam Altman is the current CEO of OpenAI. The organization's mission is to ensure that artificial general intelligence (AGI) benefits all of humanity, and they&#8217;re the master-minds behind Chat&#8230;&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;lg&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Sam Altman's Startup Advice (Part 1)&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:120792961,&quot;name&quot;:&quot;Nick M&quot;,&quot;bio&quot;:&quot;I'm a software engineer who loves explaining complex topics in an intuitive and simple manner. Some of my favorite subjects are software, applied mathematics, and particle physics. &quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/83a4601e-abc1-4dae-9417-4b0461a758cc_600x408.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2024-01-20T20:25:50.887Z&quot;,&quot;cover_image&quot;:null,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://photonlines.substack.com/p/sam-altmans-startup-advice-part-1&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:140864977,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:1,&quot;comment_count&quot;:0,&quot;publication_id&quot;:null,&quot;publication_name&quot;:&quot;Photon-Lines Substack&quot;,&quot;publication_logo_url&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%2Fd23c96bd-e136-4004-96c4-318b52a9538f_408x408.png&quot;,&quot;belowTheFold&quot;:false,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div><hr></div><h4><a href="https://www.fastcompany.com/1657030/happiness-culture-zappos-isnt-company-its-mission">#28: </a><strong><a href="https://www.fastcompany.com/1657030/happiness-culture-zappos-isnt-company-its-mission">The Happiness Culture: Zappos isn&#8217;t a Company -- it&#8217;s a Mission (by Fast Company)</a>:</strong></h4><ul><li><p>Article focuses of Tony Hsieh &#8211; the founder of Zappos.</p></li><li><p>Hsieh noticed that a lot of other entrepreneurs usually do all sorts of crazy things. They also tend to try a lot of different things at a pretty young age.</p></li><li><p>He thought of failure as being part of the path to success: &#8220;I think entrepreneurs view the failures as getting one step closer to the success. As opposed to oh, like I&#8217;m a failure.&#8221;</p></li><li><p>A key part of Zappos success lies in their culture and their obsession with making customers happy.</p></li><li><p>When hiring, they pay special attention to their 10 core values:</p><ul><li><p>Deliver Wow Through Service</p></li><li><p>Embrace and Drive Change</p></li><li><p>Create Fun and a Little Weirdness</p></li><li><p>Be Adventurous, Creative and Open-Minded</p></li><li><p>Pursue Growth and Learning</p></li><li><p>Build Open and Honest Relationships with Communication</p></li><li><p>Build a Positive Team and Family Spirit</p></li><li><p>Do More with Less</p></li><li><p>Be Passionate and Determined</p></li><li><p>Be Humble</p></li></ul></li></ul><ul><li><p>Zappos has a 4-week training program for everyone. No matter what the role, all employees were asked to spend 2 weeks on the phone with customers.</p></li><li><p>They don&#8217;t (or didn&#8217;t) tolerate employees who strayed from their culture: any employees that didn&#8217;t fit in were paid to leave.</p></li><li><p>Zappos really struggled during the dot-com bust: had trouble with getting enough cash-flow and almost went bankrupt, but persevered.</p></li><li><p>Wanted employees to be who they are and to not be scared of sharing who they really were. The idea is that people who are themselves at work aren&#8217;t scared of sharing new ideas and being creative.</p></li><li><p>Research shows that best companies over the long-term are ones that can combine profits, passion and purpose. Hsieh&#8217;s focus was on delivering happiness, not just to Zappos employees but to investors and customers as well.</p></li></ul><h4><strong><a href="https://medium.com/@bchesky/dont-fuck-up-the-culture-597cde9ee9d4">#29: Don&#8217;t Fuck Up the Culture (by Brian Chesky)</a>:</strong></h4><ul><li><p>Brian Chesky (the founder of AirBnb) asked Peter Thiel in 2012 what the single most important piece of advice was for him and has answer was: &#8220;Don&#8217;t fuck up the culture.&#8221;</p></li><li><p>Culture is simply a shared way of doing something with passion.</p></li><li><p>The culture is the foundation of a company. </p></li><li><p>If you break the culture, you break the machine that makes your product.</p></li><li><p><strong>How do you build a culture? </strong>By upholding your core values in everything you do. When you hire, when you write an email, when you&#8217;re working on something &#8211; it must all be rooted in your culture.</p></li><li><p>Why this is important: when you have a strong culture, you don&#8217;t have to rely on process. You can trust your team to do the right thing.</p></li><li><p>Problems come and go but culture is forever and something that you&#8217;ll be remembered for.</p></li></ul><h4><strong><a href="https://blog.alexmaccaw.com/what-its-like-to-work-for-stripe/">#30: What&#8217;s It Like to Work for Stripe (by Alex Maccaw)</a>:</strong></h4><ul><li><p>Stripe has a culture based on transparency and communication.</p></li><li><p>E-mails are sent to either the whole company or a team: this fosters inclusion and communication. Everyone knows what&#8217;s going on and everyone is attached and encouraged to give input. Other companies preach fearless communication. Stripe practices it.</p></li><li><p>Once a week they have an all-hands meeting where each team explains what happened during the week prior and at the end of the meeting. They discuss FUD (fear, uncertainty and doubt). This prevents problems from being hidden and encourages everyone to think about them and try to solve them.</p></li><li><p>Meetings are expensive, so they try to limit them (weekly meeting is the only mandatory meeting they have).</p></li><li><p>They all have lunch together once a day. They also have social events together (like going to the theater) and they have company hackathons twice a year where they all go away on a trip and work on new Stripe-related projects.</p></li><li><p>Every single engineer does support on a bi-weekly rotation. Even the founders take part in it. This is one of the best ways to learn about the company and customers.</p></li><li><p>They use chat often and communicate asynchronously to prevent interruptions. Also employees are prompted to post what they&#8217;re working on every few hours in the chat (keeps communication channels open).</p></li><li><p>Once a week &#8211; one team takes a technical paper and discusses it over lunch.</p></li><li><p>Employees are asked to describe their &#8216;dream machine&#8217; and find that it&#8217;s waiting for them on their first day of work (i.e. give your employees the right tools to do their jobs).</p></li><li><p>During the first few days, new employees are asked to work with different engineering groups (great way to get familiar with everyone in the company and what they do).</p></li><li><p>Organization is very flat: they don&#8217;t have managers / hierarchy and focus on hiring great people. People are also encouraged to be generalists and to not be afraid of exploring different domains.</p></li></ul><h4><strong><a href="https://blog.samaltman.com/how-to-hire">#31: How to Hire (by Sam Altman)</a>:</strong></h4><ul><li><p>After raising money, the next biggest problems startups face is hiring. Hiring is really hard and really important. In fact, it&#8217;s most likely the most important thing a founder does. </p></li><li><p>If you don&#8217;t hire very well, you will not be successful. Companies are a product of the team and founders who build them.</p></li><li><p>Some advice on hiring:</p><ul><li><p>Spend more time doing it: most founders should spend between one third to one half their time hiring. Greatest companies always have great people. You can&#8217;t outsource this either.</p></li><li><p>Get your hands dirty: hiring for a sales role? Spend some time doing it / understanding it and then hire.</p></li><li><p>Look for smart, effective people. Ask them what they&#8217;ve done during the last month or what their average day looks like &#8211; as well as check their references. You want smart people that get things done.</p></li><li><p>Have people do a &#8216;work sample test.&#8217; Instead of hiring them right away, pay them to do the work you&#8217;re hiring them to do for 1-2 days to see how they perform.</p></li><li><p>Sourcing candidates: focus on using your personal networks more. Look for friends and friends of friends. Often to get great people, you have to poach. Also, use your investors and their network to find candidates.</p></li><li><p>You need a mission in order to hire good people. The candidates you hire need to believe in the mission.</p></li><li><p>Hire people that you like (would you be willing to spend a Sunday working with them all day if you had to do so)?</p></li><li><p>Have a set of cultural values you hire for. Make sure everyone in your company knows what they are and believes in them. &#8220;Values are a decision making framework that empower individuals to make the decision that you, the founder, would make, in situations where there are conflicting interests (e.g. growth vs. customer satisfaction)&#8221;. - Andrew Mason</p></li><li><p>Don&#8217;t compromise. Only hire great people that fit your culture. A bad hire can ruin a company. Great people attract other great people. Getting someone mediocre can kill this phenomenon.</p></li><li><p>Be generous with compensation &#8211; especially when it comes to giving equity. You should give out below or fair market salaries with equity (ownership) of the company to great people and they should be happy to take it.</p></li><li><p>Trust your gut and always be on the lookout for new hires.</p></li><li><p>Fire fast: many founders don&#8217;t fire fast enough. If the person doesn&#8217;t fit, it&#8217;s better to let go of them sooner than waiting.</p></li></ul></li><li><p>After you hire people, you need to keep them. Remember to check in with people, be a good manager, have regular all hands meetings, make sure people are happy and challenged, etc. Always keep a sense of momentum at your company. Give people new roles every six months or so.</p></li><li><p>Always be identifying and promoting new talent.</p></li></ul><h4><strong>#33: Robert Cialdini&#8217;s six principles of influence:</strong></h4><ul><li><p>Get familiar with these 6 principles which are:</p><ul><li><p>Reciprocity (the practice of exchanging things with others for mutual benefit).</p></li><li><p>Commitment and consistency (feeling the need to be consistent in our beliefs).</p></li><li><p>Social proof (when people are uncertain, they'll look to others for behavioral guidance).</p></li><li><p>Authority (people follow the lead of credible, knowledgeable experts).</p></li><li><p>Liking (people prefer to work with and support those that they like).</p></li><li><p>Scarcity (the rarer or more difficult the products are perceived to be, the more valuable they are).</p></li></ul></li></ul><h4><strong><a href="https://techcrunch.com/2013/01/27/marc-andreessen-on-the-future-of-the-enterprise/">#34: Marc Andreessen on the Future of Enterprise (Interview from 2013)</a>:</strong></h4><ul><li><p>This is a really good interview with Marc Andreessen that discusses a few topics primarily dealing with the adoption of technology / software and how it&#8217;s going to change the world.</p></li><li><p>Talks about how the world goes in cycles: 2001 internet bust brought about extreme pessimism for technology / online businesses, but many turned out to be wrong in their assessment. Businesses are never easy to run, but investors seem to be attracted in finding &#8216;easy&#8217; businesses; but then they find out that running them isn&#8217;t so easy and they flock to different industries / segments at different times. The only &#8216;easy&#8217; business might be Google and that&#8217;s a very rare exception - most businesses are hard to establish and run. </p></li><li><p>Some predictions for the future?</p><ul><li><p>A lot of industries prior to the internet boom had a lot of gate-keeping: unless you were a large company, you had limited resources and you couldn&#8217;t compete. Today, this is different, and being small is almost an advantage to being large. Predicts that small companies will become more predominant.</p></li><li><p>CAPEX to OPEX: before, you had to buy equipment and servers etc.. to run a business, but these days everyone can just rent (i.e. use Amazon / cloud computing). This enables lower barriers to entry for companies and the need to budget less (in the short term anyways).</p></li><li><p>A lot more enterprise companies are going to use SaaS going forward.</p></li><li><p>Next companies he believes will bring a great return? Companies which offer outsourced work (like TaskRabbit and Zaarly). He&#8217;s also big on enterprise education (many companies can&#8217;t find qualified employees so he thinks online education is the solution).</p></li></ul></li><li><p>Big technology markets actually tend to be winner take all. Winners in technology tend to have 90 percent market share. In normal markets though (like Pepsi and Coke) it works very differently (Coke had only ~10% of the total market at the time).</p></li><li><p>Since this is the case, many competitors or companies in tech space tend to be over-founded and go bust after a period of time. The same will happen in VC space: it will have a few winners which take the whole market while many other competitors will lose. </p></li><li><p>Market is cyclical and investors tend to act in waves: Once capital starts flowing in a rotation, all capital leaves one sector and goes into another one (raising stock prices) and everyone follows due to rising prices and wanting to make money.  Down cycle is similar. A smart investor ignores these waves and simply invests in good entrepreneurs.</p></li><li><p>Like entrepreneurs with vision, knowledge and persistence and who say: &#8220;I have this really good idea and I know it&#8217;s a good idea for the following eight reasons, and I have thought about it and I have worked in the field, and I know what I am doing, and I have talked to the customers and I have figured it out, and I am going to do it. I am just going to flat-out do it. And I am going to do it whether you fund me or whether you don&#8217;t fund me or I don&#8217;t get funded. I am still going to do it.&#8221;</p></li></ul><h4><strong>#35 - #38: Mostly Generic Articles and Slides from Reid Hoffman</strong></h4><ul><li><p>A lot of these were either generic advice / book pitches by Reid Hoffman (one of which being that employee / employer relationship dynamics are changing in the modern marketplace and there is no loyalty unless a mutual relationship between each is established) along with some semi-useful advice about pitching to VCs and the importance of hiring a &#8220;professional&#8221; CEO.</p></li></ul><h4><strong><a href="https://paulgraham.com/startupmistakes.html">#39: The 18 Mistakes the Kill Startups (by Paul Graham)</a>:</strong></h4><ul><li><p>There&#8217;s only one mistake that kills startups: not making something users want. If you make something users want, you'll most likely be fine.</p></li><li><p>This is a list of 18 things that cause startups not to make something users want:</p><ul><li><p><strong>Single founder</strong>: few companies are started by one person. There&#8217;s a reason for this &#8211; most people can&#8217;t handle running a company by themselves, but also: if you have co-founders and people that depend on you, you won&#8217;t want to let them down.</p></li><li><p><strong>Bad location</strong>: Startups prosper in some areas but not in others. Main locations where startups thrive? Silicon Valley, Boston, Seattle, Austin, Denver and New York. There&#8217;s a huge drop off as we go down.</p></li><li><p><strong>Marginal Niche</strong>: choosing a small, obscure niche market in the hope of avoiding competition.</p></li><li><p><strong>Imitating Other Companies</strong>: most successful companies / startups aren&#8217;t started through imitation. Solve problems that affect you personally &#8211; don&#8217;t imitate others. &#8220;Instead of starting from companies and working back to the problems they solved, look for problems and imagine the company that might solve them.&#8221;</p></li><li><p><strong>Not Being Open to New Ideas</strong>: Most successful startups end up doing something different than what they originally intended. Many pivot into new areas so you have to be adaptable and open to new ideas / avenues.</p></li><li><p><strong>Hiring Bad Programmers</strong>: what killed most of the startups in the e-commerce space in the 90s was bad programmers / business guys. Most successful companies he founded were run by programmers. Programmers know how to hire good programmers &#8211; business guys don&#8217;t.</p></li><li><p><strong>Choosing the Wrong Platform</strong>: PayPal dodged a bullet when they merged with X.com. Their new CEO (Musk) wanted to use the Windows platform but the PayPal team showed that the software scaled only 1% as well as it did on Unix. Switching CEOs took them on a new path and were keys in their success. How do you choose the right platform? Hire good programmers and let them choose (or talk to other programmers in comp sci departments).</p></li><li><p><strong>Slowness in Launching</strong>: force yourself to launch things quickly. The best form of feedback you can get is directly from your users.</p></li><li><p><strong>Launching Too Early</strong>: launching slowly kills more startups than launching early, but launching early can also be detrimental. If you scare away your early adopters, many may not come back. Think about the overall goal, then start by writing the smallest subset of it that does anything useful and launch it. Early adapters don&#8217;t expect a new launch to do everything; it just has to do something.</p></li><li><p><strong>Having No Specific User in Mind</strong>: you can&#8217;t make great things unless you understand its users. This is why most successful start ups start off as something the founders are trying to solve themselves. If the problem you&#8217;re solving doesn&#8217;t involve you, you need empirical / measurable feedback from your users.</p></li><li><p><strong>Raising Too Little Money</strong>: startup funding is measured in time. How much run-way do you have to be profitable? If you don&#8217;t have enough, there is a high chance your start-up will fail. That&#8217;s why the general advice is to keep costs low initially and to spend all your time in building a solid prototype.</p></li><li><p><strong>Spending Too Much</strong>: the number one issue that tends to happen is hiring too many people. This slows you down and increases your costs. Avoid hiring people unless it&#8217;s necessary. Also, pay people with equity rather than salary and only hire people who are either going to code or go out and get users.</p></li><li><p><strong>Raising Too Much Money</strong>: there is pressure with taking on money, and it limits you in pivoting if you do need to pivot. Raising capital also usually takes a long time. Advice to founders is to take the first reasonable deal they can get from VCs.</p></li><li><p><strong>Poor Investor Management: you have to manage your investors</strong>: You as the founder have to dictate where the company goes, not them. If you raise too much money, they will be your boss. If things go well and your company grows rapidly, usually they&#8217;ll leave you alone but if this isn&#8217;t the case be ready to deal with trouble.</p></li><li><p><strong>Sacrificing Users to (Supposed) Profit</strong>: &#8220;In version 1, solve the core problem. And the core problem in a startup is how to create wealth (= how much people want something x the number who want it), not how to convert that wealth into money.&#8221; Advises company to worry about building the product or something people want first and worry about the business model later (side note: this is something which I largely disagree with).</p></li><li><p><strong>Not Wanting to Get Your Hands Dirty</strong>: as a founder, you can&#8217;t spend all your time programming. You have to get into the business and find users / make sales.</p></li><li><p><strong>Fights Between Founders</strong>: fights between founders are very common (20% of their startups had a founder leave). This doesn&#8217;t kill a startup though (Blogger recovered from having one founder to being successful). If you have a bad feeling about a founder, let it be known and don&#8217;t hide it. People are the most important ingredient in a startup.</p></li><li><p><strong>A Half-Hearted Effort</strong>: Most startups fail because they don't make something people want, and the reason most don't is that they don't try hard enough. Most successful start-ups are also led by founders who quit their day-jobs to dedicate their time fully to the startup &#8211; they are fully committed to the startup and idea and are willing to dedicate enough energy to making things happen.</p></li></ul></li></ul><h4><strong>#40: Bill Walsh, The Score Takes Care of Itself, pp. 2-31, 137-146, 202-203</strong></h4><ul><li><p>&#8220;His mind for technical football was extraordinary, but beyond that was his ability to organize and manage his staff, players, everybody&#8212;to get the whole organization on exactly the same page. On that page he set the standard for how he wanted things done, and his standard was simple: <strong>perfection</strong>. That&#8217;s what he taught us individually and as a group&#8212;to believe it could be achieved and then achieve it (or come close). He had in his mind this ideal&#8212;an image of perfect football&#8212;coupled with the nuts-and-bolts details of how to accomplish it, which he then taught.&#8221;</p></li><li><p>His primary leadership asset: his ability to teach people how to think and play at a different and much higher, and, at times, perfect level.</p></li><li><p>Three main ways he did it in 1) he had tremendous knowledge of all aspects of football 2) he brought in great staff and coaches who knew how to coach and 3) he taught players to hate mistakes.</p></li><li><p>Got all players to strive to be perfect in games and in practice. If you aim for perfection and miss, you&#8217;re still pretty good. If you aim for mediocrity&#8230;</p></li><li><p>Bill didn&#8217;t jump on anyone for making mistakes. Instead he found out what was wrong and taught others how to correct it. He taught the smallest details in perfecting performance.</p></li><li><p>He didn&#8217;t view the organization as a group of separate individuals. He viewed people as being the heart of the organization.</p></li><li><p>Was an amazing problem solver: knew how to look at things differently and break down complex things into individual parts to make them simpler. He loved lists.</p></li><li><p>Was an educator and teacher. He studied other great coaches and also learned from them.</p></li><li><p>Almost always, your road to victory goes through a place called &#8216;failure.&#8217; However, a good leader intelligently and relentlessly seeks solutions that will increase his chances of succeeding and prevailing in a competitive environment. When you do that, the score will take care of itself.</p></li><li><p>&#8220;Pursuing your ambitions, especially those of any magnitude, can be grueling and hazardous, and produce agonizing failure along the way, but achieving those goals is among life&#8217;s most gratifying and thrilling experiences. The ability to survive and overcome the former to attain the latter is a fundamental difference between winners and losers. I&#8217;ve observed that if individuals who prevail in a highly competitive environment have any one thing in common besides success, it is failure&#8212;and their ability to overcome it.&#8221;</p></li><li><p>Being the best has a price: &#8220;If you&#8217;re up at 3 A.M. every night talking into a tape recorder and writing notes on scraps of paper, have a knot in your stomach and a rash on your skin, are losing sleep and losing touch with your wife and kids, have no appetite or sense of humor, and feel that everything might turn out wrong, then you&#8217;re probably doing the job.&#8221;</p></li><li><p>Talks about his times as a coach where he was devastated by defeat and failure and was very close to resigning (but didn&#8217;t): &#8220;When the inevitable setback, loss, failure, or defeat comes crashing down on you&#8212;losing a big sale, being passed over for a career-making promotion, even getting fired&#8212;allow yourself the &#8220;grieving time,&#8221; but then recognize that the road to recovery and victory lies in having the strength to get up off the mat and start planning your next move. This is how you must think if you want to win. Otherwise you have lost.&#8221; </p></li><li><p>During the ensuing fourteen years after his &#8216;big&#8217; failure, the 49ers won five championships. The worst had been over. This happened because at the moment of his deepest despair, he had the strength to stand up and keep fighting.</p></li><li><p>How did he turn 49ers around? He implemented a Standard of Performance: &#8216;regardless of your specific job, it is vital to our team that you do that job at the highest possible level in all its various aspects, both mental and physical.&#8217;</p></li><li><p>If you were lucky enough to receive a 49er paycheck, it meant you were part of an organization that had high expectations of itself and of you, whether you were a superstar or a secretary, manager or maintenance man, athlete, executive, or head coach. Those expectations, of course, went beyond ethics and attitude to specific performance standards and actions.</p></li><li><p>In regards to linesmen, the coaching staff identified 30 specific skills they needed to master in order to the job at the highest level and created multiple drills for each one of those skills which were practiced relentlessly until their execution as automatic.</p></li><li><p>Passing routes were designed down to the inch and then practiced until receivers learned how to be at that exact inch at the exact moment the ball arrived.</p></li><li><p>Treated all people the same: it doesn&#8217;t matter if you were the start quarterback or secretary, everyone was part of the organization and needed to embrace his principles.</p></li><li><p>Instead of making winning the primary goal, he focused in on getting people to focus on improving their actions and attitude and obsessing about the quality of their execution and the content of their thinking through following his standard of performance.</p></li><li><p>Hired people based on the characteristics he valued most: talent, character, functional intelligence, and an eagerness to adopt to his way of doing things.</p></li><li><p>&#8220;The leader&#8217;s job is to facilitate a battlefield-like sense of camaraderie among his or her personnel, an environment for people to find a way to bond together, to care about one another and the work they do, to feel the connection and extension so necessary for great results. Ultimately, it&#8217;s the strongest bond of all, even stronger than money.&#8221;</p></li><li><p>Don&#8217;t seek &#8216;conventional&#8217; approaches or wisdom (it produces average results). Jerry Rice coming out of school wasn&#8217;t considered a top-flight prospect due to his limited forty-yard time according to scouts, but Walsh recognized that there was more to simple running speed when it comes down to receiving (he knew how to get open, catch the ball, and gain yardage with ease) and Walsh ended up drafting him 1<sup>st</sup>. Rice ended up being one of the greatest football players of all time.</p></li><li><p>Use mentors and learn from them. A good leader is always learning. The great leaders start learning young and continue until their last breath.</p></li><li><p>&#8220;Bill Walsh had the ability to change the way people thought&#8212;not just how we performed a task, but how we thought and felt about who we were. In the beginning, when we were as bad as we were, nobody was thinking about a Super Bowl. Our goal in life was just to be pretty good. Bill&#8217;s goal in life was to convince us that we could be great. And he did; and we were. That&#8217;s why he was such a great leader.&#8221;</p></li><li><p>The path to mastery: practice, continual improvement, and mastering the fundamentals. Joe Montana and Jerry Rice were constantly practicing and trying to improve. Even at the last stages of their careers were still working very hard on the fundamental things that high-school kids won&#8217;t do because it&#8217;s too damn dull.</p></li><li><p>Hard work is the key to success. You as a leader need to lead by example, but it&#8217;s not up to you alone. Bring in people that put the work in.</p></li><li><p>&#8220;I sought perfection, and 99 percent isn&#8217;t perfection. Why &#8216;almost perfect&#8217; wasn&#8217;t enough for me is something I can&#8217;t explain.&#8221;</p></li><li><p>Superb, reliable results take time. The little improvements that lead to impressive achievements come from a series of months and years until your organization knows what you are teaching inside and out and everyone is able to execute their responsibilities in all ways at the highest level.</p></li></ul><h4><strong><a href="https://danlebrero.com/2023/04/12/high-output-management-summary/">#41: High Output Management (by Andy Grove) (Chapters 3 (optional), 4, 9, 11, 13, 14)</a></strong></h4><ul><li><p>I didn&#8217;t have time to summarize this book / recommended chapters, but if you&#8217;re curious you can find a great summary and notes on it in the provided link (available in the heading title). </p></li></ul><h4><strong><a href="https://a16z.com/making-yourself-a-ceo/">#42: Making Yourself a CEO (by Ben Horowitz)</a>:</strong></h4><ul><li><p>Being a CEO doesn&#8217;t come very naturally to most people. Developing the skill set to be a good CEO usually takes years of experience / practice.</p></li><li><p>Most people have a natural instinct to do things that make people like them (enhancing their chance of survival), but a good CEO must do many things that upset people in the short run in order to be liked in the long run, which is in many ways unnatural.</p></li><li><p>An important part of being a good CEO is giving feedback. Earlier in his career, he believed in the shit sandwich approach to feedback (wrap the bad feedback / news (shit) with a layer of good feedback (bread)) but it came off badly.</p></li><li><p>Here are the keys to be an effective CEO:</p><ul><li><p>Be authentic: believe in the information / feedback which you hand out.</p></li><li><p>Come from the right place: give people feedback because you want the to succeed &#8211; not fail.</p></li><li><p>Don&#8217;t get personal: if you decide to fire someone, fire them.</p></li><li><p>Don&#8217;t embarrass / clown other people in front of others.</p></li><li><p>Tailor your feedback to the employee: not everyone is the same when it comes to feedback.</p></li><li><p>Be direct, but not mean.</p></li><li><p>Keep an open door: feedback isn&#8217;t one way. Listen to what your employees have to say.</p></li><li><p>Say what you think and always express yourself. Get used to giving your company constant feedback: it gets people to get used to it (so it&#8217;s not personal) and people get comfortable with discussing bad news.</p></li></ul></li><li><p>Being a CEO isn&#8217;t easy and doesn&#8217;t come naturally and there are many more unnatural things which you must do in order to be a good one. The key to becoming a good one basically is mastering the unnatural.</p></li></ul><h4><strong><a href="https://a16z.com/a-good-place-to-work/">#43: A Good Place to Work (by Ben Horowitz)</a>:</strong></h4><ul><li><p>Mostly bullshit article. Talks about how one of his employees / managers didn&#8217;t meet with his/her subordinates for over 6 months, so he called in their manager and threatened to fire both of them if they didn&#8217;t meet in 24 hours.</p></li><li><p>Apparently, meetings are very important but doesn&#8217;t go into why in much detail and gives a few analogies / stories that don&#8217;t really connect with the message.</p></li></ul><h4><strong><a href="https://a16z.com/how-to-minimize-politics-in-your-company/">#44: How to Minimize Politics in Your Company (by Ben Horowitz)</a>:</strong></h4><ul><li><p>The CEO at a company creates politics. What is politics? &#8216;People advancing their careers or agendas by means other than merit and contribution.<em>&#8217;</em></p></li><li><p>Apparently, giving a raise to an employee counts as political behavior (even if the said employee has a higher offer to go work else-where). Why? Because it may get other employees to ask for a raise. This encourages &#8216;political behavior.&#8217; (<strong>Personal take:</strong> bullshit. Apparently companies are allowed to operate according to the principles of the free market but employees aren&#8217;t??)</p></li><li><p>Advice on minimizing politics is:</p><ul><li><p>Hire people with the right kind of ambition (should value the company&#8217;s success as first and foremost priority ahead of anything else).</p></li><li><p>Avoid activities which encourage political behavior, including: performance evaluation and compensation, organizational design and territory, promotions.</p></li><li><p>Be careful with &#8220;he said, she said.&#8221; Apparently even listening to another employee complaining about another one will get others to notice and may encourage further bad behavior. If an employee has a problem with an executive &#8211; get them in the room together and get them to talk it out. If you hear another executive complaining about another executive? Try to ignore it and assess it yourself. Doesn&#8217;t address what to do if non-executives complain (apparently to him they might not matter?).</p></li></ul></li><li><p><strong>Personal take</strong>: Sorry, but most of these write-ups by Mr. Horowitz come off as complete bullshit and in my opinion are extremely bad advice. Read at your own discretion. </p></li></ul><h4><strong><a href="https://www.youtube.com/watch?v=ZpINPjfSlZc">#45: [video] Hosain Rahman (at Startup School 2014)</a>:</strong></h4><ul><li><p>Talks about the early days prior to having success: silicon valley was struggling at the time and mobile didn&#8217;t take off, but their idea was to bring &#8216;Siri&#8217; and a better way to interact with voice technology.</p></li><li><p>Pivoted from that idea to noise-canceling: discovered this by accident as a product of attempting to develop voice-technology.</p></li><li><p>Convincing people to invest with them was really hard at the time.</p></li><li><p>Raising first 500,000 was harder than raising the first 100 million.</p></li><li><p>Focused on little details and product: how do they deliver a great experience to customers?</p></li><li><p>First head-set they released wasn&#8217;t a hit. In order to hit deadlines, they compromised the end-product.</p></li><li><p>They ended up running out of money and investors lost faith. They still believed in their product though. They paid off 600,000 in debt and took on another DARPA contract.</p></li><li><p>Failure is the best thing to learn from: they ruminated over all of the things they did wrong with their first effort and started again. Realized that the product had to be packaged correctly in order to make it a success.</p></li><li><p>Worked for next 2 years with no salaries.</p></li><li><p>Their next launch: had issues with manufacturer releasing product from customs. Had only 2K in the bank and they wouldn&#8217;t release, so they had to raise money to get it released. They had a huge amount of success with this product (revenue was 70 million in the first year).</p></li><li><p>Key lesson: you have to focus on solving problems ruthlessly to make product work and to package it correctly.</p></li><li><p>Hit another huge bump on the read in 2008 (lots of orders were canceled). Hit another issue in regards to product quality when launching another head set after. Focused on putting customer first and solving the problem. Learned to persevere from earlier experiences.</p></li><li><p>To solve issues, he focused on &#8216;doing what&#8217;s right&#8217; and putting customers first.</p></li><li><p>Talks about difference between hardware and software. Hardware: have to focus on selling something for a higher price than what it cost them to make it (had to have discipline in choosing parts / making decisions). Had to infuse that same discipline in their software division.</p></li><li><p>Talks about the importance of great design in both hardware and software and how important it is to get it right.</p></li></ul><h4><strong>#46 &amp; #47: Some Great Advice on Hiring a Lawyer and the <a href="https://www.startupcompanylawyer.com/">Following Link</a>: </strong></h4><ul><li><p>Mostly quality advice on hiring a lawyer that I won&#8217;t include here. </p></li></ul><h4><strong>#49: How I Raised Myself From Failure to Success In Selling (by Frank Bettger):</strong></h4><ul><li><p>This is one of the best books on selling that I&#8217;ve ever read and I highly recommend it. It mostly talks about Frank Bettger and what he did to overcome his failure in sales to become masterful at it. The key points from the book and summarized below:</p></li><li><p><strong>The importance of enthusiasm: </strong>talks about how he was demoted for being &#8216;too lazy&#8217; to being promoted and having his salary go up more than 700% simply by forcing himself to be enthusiastic. The enthusiasm went over and impacted his team-mates by quite a lot.</p></li><li><p>Enthusiasm is the most important part of selling. It doesn&#8217;t matter how much you know. Showing enthusiasm is vital and carries over to your client. The best salesmen all have great enthusiasm.</p></li><li><p><strong>Force yourself to tell your story / see at least 4 or 5 people every day</strong>. He forced himself to make at least 4-5 calls every single day. Kept records of each one and calculated that it made a huge difference. Calculated that each call was worth 2.30 (which amounted to quite a bit) over the year.</p></li><li><p><strong>Keep records of what you do (be data driven)</strong>: he saw that his success rate was 70 percent for his first interview, 23 percent for his second, and 7 percent for third. This made him realize what to focus his energy on and improved his per call metrics from 2.80 dollars per call to 4.27. Keeping records is vital to improvement.</p></li><li><p>You must make calls in order to be successful in selling.</p></li><li><p><strong>The importance of hard work</strong>: sales is the easiest job in the world if you work hard, but the hardest one in the world if you aren&#8217;t trying.</p></li><li><p><strong>The importance of public speaking:</strong> talks about how he went from being terrified to speaking to crowds to taking a course in public speaking which got him to get rid of the fear. &#8216;Join only a course where you make a talk at every meeting because that&#8217;s what you want &#8211; experience is speaking.&#8217;</p></li><li><p>When you lose your fear of speaking to an audience, you lose your fear of talking to individuals, no matter how big and important they are.</p></li><li><p>The best way he every found to help him overcome fear and rapidly develop courage and self-confidence is through public speaking and speaking in front of groups. Almost all leaders have courage and self-confidence, so this is important.</p></li><li><p><strong>The importance of planning: </strong>realized that he wasn&#8217;t meeting his call goals and started dedicating each Saturday to planning. Studied his records and made notes in preparation for each week to the extent of what he would say / do and making a schedule to make each call which lead to outstanding results.</p></li><li><p><strong>Become an early riser</strong>: Benjamin Franklin advised many others to raise early and he used the same approach. He gave the same advice to his peers and it worked great for them as well.</p></li><li><p>Take more time to think and do things in the order of their importance (and to also plan them).</p></li><li><p><strong>Set aside one day as a &#8216;self-organization&#8217; day and plan your hours</strong>: many successful people are strict with planning and utilizing their time in the correct manner each day.</p></li><li><p>Talks about how he made an outstanding sale to someone who didn&#8217;t seem like he wanted it, but he was persistent enough to stick around and get them interested and to eventually buy in. &#8216;<strong>The most important secret of salesmanship is to find out what the other fellow wants, then help him find the best way to get it.</strong>&#8217; If you remember this one rule, selling will be easy.</p></li><li><p>Talks about a sale he made to a businessman: he convinced him to focus on the future of his business (where he highlighted an issue of what will happen to him once he passed away). The businessman accepted this and he made more money that day than he had in the previous year.</p></li><li><p>Resolved right then and there to dedicate the rest of his selling career to this principle: <strong>Finding out what people want and helping them get it.</strong></p></li><li><p><strong>The importance of framing things the right way:</strong> talks about how he got 2 calls pitching him to speak in public at an event. The first call framed things in terms of the speaker. The second framed things in terms of his own frame of reference (i.e. caller go him to envision himself when he was young and realize how important the talk would have been to him). The second call got him to say yes.</p></li><li><p>Talks about an unsuccessful salesman who sold magazines: usually the objection is that they didn&#8217;t have the time to read what he sold. He took this and re-framed his sales pitch as &#8216;reading this means that you get a summary of all news in one short evening of reading&#8217; thus turning the problem on its head: he was actually selling the most precious thing in life, more time. That approach turned his failure into a success.</p></li><li><p>&#8216;<strong>When you show a man what he wants, he&#8217;ll move heaven and earth to get it.</strong>&#8217; Talks about the importance of phrasing things in terms of what his prospects wanted &#8211; not what he wanted.</p></li><li><p>Three important lessons:</p><ul><li><p>The most important secret of salesmanship is to find out what the others want and help them find the best way to get it.</p></li><li><p>There is only one way to get someone to do something: by making the other person want to do it. There is no other way.</p></li><li><p>When you show a man what he wants, he will move heaven and earth to get it.</p></li></ul></li><li><p><strong>Elliot Hall&#8217;s lesson:</strong> Elliot had been unsuccessful as a salesman and one of the reasons was because he was &#8216;too positive.&#8217; Realized that instead of trying to be positive and facing objections &#8211; whenever a prospect had an objection, he would come up with a question. He would keep asking questions (that got the prospect to say &#8216;yes&#8217;) until coming to just one conclusion &#8211; a sound conclusion which was based on facts.</p></li><li><p>Elliot Hall&#8217;s questions had just one purpose: &#8216;<strong>to help the other fellow recognize what he wants, and then help him decide how to get it.</strong>&#8217; Whenever Elliot would have an objection he would follow up with . &#8216;Let me help you ____ (resolve the objection) ____.&#8217; He never objected or disagreed with anyone. Learned from Elliot that mastering the art of asking questions was a key to becoming a successful salesman.</p></li><li><p>The author goes through a sale he made by asking follow up questions and noting down some take-aways on making such sales:</p><ul><li><p><strong>Make appointments:</strong> be expected. You gain a big advantage in doing so. It tells the person that you appreciate the value of his/her time.</p></li><li><p><strong>Be prepared:</strong> ask the question &#8216;what is the key issue?&#8217; in helping you prepare.</p></li><li><p><strong>Questions to ask?</strong> What is the key issue? Or, what is the major point of interest? Or, what is the most vulnerable point?</p></li><li><p><strong>Make key-word notes.</strong> Unless you make notes, you&#8217;re bound to forget what you plan to present. Prior to the interview, rehearse and review the notes over and over again (you should know exactly what you will say and how to say it.)</p></li><li><p><strong>Ask questions</strong>: this is vital to getting a sale.</p></li><li><p><strong>Explode dynamite: do something startling / surprising.</strong> (During his earlier example, he insisted that he and his client go to a doctors appointment immediately). It&#8217;s necessary to arouse and stir people to take action for their own benefit.</p></li><li><p><strong>Arouse fear</strong>: there are 2 main factors that move men into action: <strong>desire for gain and a fear of loss.</strong></p></li><li><p><strong>Create confidence:</strong> </p><ul><li><p>Imagine yourself to be a salaried employee at your prospect&#8217;s company. You can imagine yourself as being an &#8216;assistant-buyer&#8217; for the prospect in question which should inspire you to be more confident. </p></li><li><p>Also: &#8216;If you were my own brother, I&#8217;d say to you what I&#8217;m going to say to you now&#8230;&#8217; is another confidence gainer. </p></li><li><p>Praise your competitors. </p></li><li><p>Create a powerful selling phrase &#8216;I am in position to do something for you this morning that no other living person can do.&#8217;</p></li></ul></li><li><p><strong>Express honest appreciation of your listener&#8217;s ability</strong> (people like feeling important and are hungry for praise) but don&#8217;t go overboard.</p></li><li><p><strong>Assume a close: have a winning attitude.</strong></p></li><li><p><strong>Put YOU in the interview</strong>: it&#8217;s a superb way for you to make sure you&#8217;re practicing the most important rule of all: seeing things from the other person&#8217;s point of view and talking in terms of his/her needs, wants, and desires. Strike out &#8216;I&#8217; or &#8216;we&#8217; and change it to &#8216;you&#8217; or &#8216;your.&#8217;</p></li></ul></li><li><p>Talks about the importance of asking your prospect questions and <strong>getting to know them. </strong>Talks about a case where one man wouldn&#8217;t talk with him but he showed up and asked him the question &#8216;how did you get into this business?&#8217; and the prospect opened up to him (and discussed things that even his wife didn&#8217;t know). His follow up and plan after this won him a sale.</p></li><li><p>Six things you gain through the question method:</p><ul><li><p>Helps avoid arguments.</p></li><li><p>Helps avoid talking too much.</p></li><li><p>Enables you to help the other person recognize what he/she wants.</p></li><li><p>Helps crystallize the other person&#8217;s thinking (the idea becomes his idea).</p></li><li><p>Helps you find the most vulnerable point with which to close the sale...the key issue.</p></li><li><p>Gives the other person a feeling of importance (when you respect his/her opinion, they&#8217;ll respect yours).</p></li></ul></li><li><p><strong>Key question to ask when going into a sale: what is the key issue?</strong></p></li><li><p>How do you identify the key issue?</p><ul><li><p>What is the basic need?</p></li><li><p>What is the main point of interest; the most vulnerable point?</p></li></ul></li><li><p>If you try to argue each of your opponent&#8217;s issues one-by-one, you&#8217;ll never win. Identify the key one. How do you do so? Get your opponent to talk. He or she will most likely list a few but he&#8217;ll keep coming back to the key issue.</p></li><li><p>The main problem of the sale is to:</p><ul><li><p>Find the basic need, or</p></li><li><p>The main point of interest.</p></li><li><p>Then stick to it!</p></li></ul></li><li><p><strong>What&#8217;s the most important word in the English language? Why.</strong></p></li><li><p>If someone objects to you, ask why? Keep asking it and your prospect will may eventually find the answer to his objection.</p></li><li><p>Milton Hershey had 3 failures before he was 40. He asked the question: why? He realized that the reason was that he didn&#8217;t have all the facts. Ever since then, he kept asking the why question.</p></li><li><p><strong>The real reason for not buying:</strong> many prospects won&#8217;t give you the real reason they won&#8217;t buy right away (he collected data from his sales, and realized that 62% of the time the first thing his prospects listed was not the real reason they didn&#8217;t want to buy).</p></li><li><p>Always ask: &#8216;In addition to that, isn&#8217;t there something else in the back of your mind?&#8217; after a prospect objects to get them to possibly open up and to find the real reason behind their objection.</p></li><li><p>A man has two reasons for doing a thing: one that sounds good, and the real one.</p></li><li><p>The best formula he ever found to draw out the real one is built around these 2 little questions: </p><ul><li><p><strong>&#8216;Why?&#8217; </strong></p></li><li><p><strong>&#8216;In addition to that&#8230;&#8217;</strong></p></li></ul></li><li><p><strong>The importance of being a good listener: </strong>talks about one sale which he had where he simply asked the prospect about his family. After talking for about 3 hours, he was about to say good-bye (without saying anything about himself) &#8211; when the prospect turned into a sale. Sometimes, simply listening gets the job done. Always show the other person that you&#8217;re sincerely interested in what they&#8217;re saying. Listening has become a rare art. Good listeners are rare.</p></li><li><p>Whenever you&#8217;re talking and you find someone disengaged or not responding (they&#8217;re not really listening to you): stop talking. Nine out of ten times they&#8217;ll start talking and say what&#8217;s on their mind. Even if there&#8217;s an uncomfortable silence, usually the prospect will break it.</p></li><li><p>When listening: don&#8217;t focus in on what you&#8217;re going to say next. Really listen.</p></li><li><p><strong>Be honest:</strong> The best talker doesn&#8217;t win the sale &#8211; the most honest one does. To win confidence, you must deserve confidence &#8211; and this is done through honesty.</p></li><li><p><strong>Be the best informed: knowledge is power. </strong>Knew 2 salesman early in his career that brought in 70 percent of the profits out of an office with 16. Those 2 men were continually being consulted by other salesmen &#8211; they were the best informed. When asked where they got their info from: &#8216;I subscribe to services that give all the legal answers, sales ideas, etc&#8230; and I read the best journals and magazines.&#8217;</p></li><li><p>Always make time to read and learn new things. One of the best doctors he knew was still learning and staying engaged at the age of 66.</p></li><li><p>In other words: <strong>know your business and keep on knowing your business.</strong></p></li><li><p><strong>Praise your competitors: </strong>talks about how he made an important sale where he asked the prospect what companies he was insured with. After answering, he praised the companies and gave good info on all 3 companies and called them world class. After doing so &#8211; he made his sales pitch and won the prospect over.</p></li><li><p><strong>The power of witnesses: </strong>talks about the power of getting other customers to give testimony on the product. He would sometimes make calls in the middle of the sales pitch to existing customers and ask them what they thought about x and y, and the testimony would do a great deal in winning the prospect over.</p></li><li><p><strong>The importance of grooming and being well dressed: </strong>Unless the man looks the part, people won&#8217;t believe what he says is important. Be well dressed and have a professional appearance (also advises to wear suits / shoes / etc.. on alternate days to preserve their life). Ask experts for help in helping you &#8216;look professional&#8217; and giving you advice on what to wear / buy.</p></li><li><p>Main reminders:</p><ul><li><p><strong>Deserve confidence:</strong> the real test is: do you believe it, not will the other person believe it.</p></li><li><p><strong>To win the confidence of others, you have to know your business</strong> &#8230; and keep knowing your business. Always study and look to learn new things.</p></li><li><p>Benjamin Franklin&#8217;s key motto: &#8220;I will speak ill of no man &#8211; and speak all the good I know of everybody.&#8221; (Praise your competitors).</p></li><li><p>Cultivate the habit of making understatements; never exaggerate!</p></li><li><p><strong>An infallible way to gain a man&#8217;s confidence: bring on your own witness</strong> (use a telephone).</p></li><li><p><strong>Look your best.</strong></p></li></ul></li><li><p>One of the greatest questions to ask your prospects is &#8216;<strong>How did you ever get started in this business?</strong>&#8217; Many times it opens doors.</p></li><li><p><strong>Praise is another way to get through the door</strong>: many businesses and people don&#8217;t get enough praise / compliments.</p></li><li><p>He kept cards on the people he met throughout the years and information they told him: many people are amazed that he remembered so much. Careful notes / cards made things easier for him. Advises everyone to do the same.</p></li><li><p>&#8220;If you would win man to your cause, first convince him that you are his sincere friend.&#8221; - Lincoln. </p></li><li><p><strong>Encourage young men and help them see how they could be successes in life.</strong> Tells a story how he told a young man that he would become president of the company one day &#8211; and the prediction came to be true. Try to get men to tell you their highest ambitions in life and help them raise to it.</p></li><li><p>If anyone has inspired you or helped you in any way in life, don&#8217;t keep it a secret. Tell other people about it.</p></li><li><p><strong>The importance of smiling</strong>: action seems to follow feeling, but really action and feeling go together. Give every living soul you meet the best smile you ever smiled in your life and see how much better you feel and look.</p></li><li><p><strong>The importance of remembering names: </strong>When you meet someone, your entire focus should be on them (and remembering his/her face and name). If you didn&#8217;t get the name, simply ask them to repeat it &#8211; then, take a mental snapshot of the face/name so that you&#8217;ll remember it.</p></li><li><p>In sum, to remember names:</p><ul><li><p><strong>Impression</strong>: get a clear impression of his/her name and face.</p></li><li><p><strong>Repetition</strong>: Repeat his/her name at short intervals.</p></li><li><p><strong>Association</strong>: Associate it with an action picture, if possible, include the person&#8217;s business.</p></li></ul></li><li><p><strong>Brevity: don&#8217;t over-talk. Be succinct and get to the point</strong> (long talks bore people).</p></li><li><p>&#8216;At a recent meeting of purchasing agents, we took a vote to find out the biggest reason why salesmen lose business.&#8217; &#8594; &#8216;The vote was three to one that salesmen <strong>talk too much</strong>.&#8217;</p></li><li><p>Before he makes a phone-call, he makes a list of things he wants to talk about and gets to each point: &#8216;I know you are busy, there are just four things I want to take up with you&#8230;&#8217;</p></li><li><p><strong>If you&#8217;re scared, admit it!!</strong> Many big men and huge public figures have been in the same situation &#8211; there&#8217;s no reason to feel ashamed of it or to hide it, so if you&#8217;re speaking to someone big or high-up, you pay him/her a compliment by admitting that you&#8217;re scared!</p></li><li><p><strong>The approach: </strong>the approach which you plan is very important. &#8216;In my twenty-five years of selling, the best approach I ever found was to first find out about a prospect&#8217;s hobby, and then talk about that hobby.&#8217; Also gives a story about winning a prospect over by playing with his young daughter (and getting invited to her birthday party).</p></li><li><p>The first and most important step of selling: &#8216;<strong>Sell yourself first.</strong>&#8217; Talks about another salesman that was very successful simply by having a very welcoming and embracing approach and making each customer entering his store feel fantastic.</p></li><li><p><strong>The Questionnaire</strong>: he had a questionnaire that he would use which would take each prospect 5 to 10 minutes to answer:</p><ul><li><p>What minimum monthly income would your wife need in the event of your death?</p></li><li><p>Minimum monthly income for yourself at age 65?</p></li><li><p>What is the present value of your estate?</p></li><li><p>Stocks bonds, other securities?</p></li><li><p>Real estate (mortgages)?</p></li><li><p>Cash on hand?</p></li><li><p>Earned annual income?</p></li><li><p>Your life insurance?</p></li><li><p>How much do you pay out each year for insurance?</p></li></ul></li><li><p>The above would give him ample information which he could use to win the prospect over whenever he got back to them.</p></li><li><p>An <strong>approach must have only one objective: selling the sales interview -- not the product, your interview.</strong> It is the sale before the sale.</p></li><li><p><strong>Making appointments</strong>: talks about how a barber was able to revive his business simply by asking his customers to make appointments instead of doing first-come first-serve. Many people prefer appointments. They save time &#8211; they give appreciation to the customers&#8217; time and it makes each call an event.</p></li><li><p>Making appointments is like getting on-base in baseball: the foundations in sales relies on getting interviews.</p></li><li><p><strong>Persistence</strong>: some of the hardest prospects he took on wouldn&#8217;t make appointments with him, but he persisted and won the sale over simply by persevering and getting a chance to talk with them / approaching them.</p></li><li><p><strong>The importance of practice and rehearsal</strong>: takes us through a few stories where he makes it clear that practice makes perfect &#8211; many people who made it made it through hard-work and practice. Rehearsing his sales calls with another work-mate made his pitches better.</p></li><li><p><strong>The best time to prepare a sales talk is right after you made one</strong>: all the things you should have said and should not have said are fresh in your mind. Write them down immediately!</p></li><li><p><strong>Write your talk out word for word. Keep on improving it.</strong> Read it and reread it until you know it (but don&#8217;t memorize it). Try it out on your wife. If it&#8217;s bad, she&#8217;ll tell you. Deliver it to your manager and another salesman. Give it until you love it.</p></li><li><p><strong>One demonstration is worth more than a thousand words:</strong> If possible, let the customer / prospect perform the demonstration and let them help you make the sale. Gives a few examples where demos played an important role in landing the sale (including one where he placed a quarter and dime next to a pen to demo how much of the estate goes to a customer&#8217;s family &#8211; he would say the quarter is what the prospect has, and the dime is how much is left to the family after the executors are done after he passes).</p></li><li><p><strong>Never forget a customer; never let a customer forget you:</strong> out of the 33 cars he bought, he dealt with 33 different salesmen. Not one of the salesmen he dealt with thought of picking up the phone and following up with him. Chevrolet Motor adopted the motto of never forgetting a customer and were first in sales for 13 / 15 years.</p></li><li><p>Gives another example where a business would follow up with customers on how they were doing soon after making a sale. If the customers need any help &#8211; they helped them out and this in turn lead to other possible prospects. &#8216;If you take care of your customers, they take care of you.&#8217;</p></li><li><p>When is the best time to follow a referred lead? Six days or six weeks? The real answer: <strong>six minutes!!</strong></p></li><li><p>Never fail to show appreciation for a lead. Report results whether good or bad.</p></li><li><p>Play position for the next shot (just as in pool &#8211; look for the next opportunity / lead whenever possible). &#8216;Prospecting is like shaving...if you don&#8217;t do something about it every day, first thing you know, you&#8217;ll be a bum.&#8217;</p></li><li><p>Earlier in his career &#8211; he had issues closing a sale. Most of his sales were being done on the first interview and only 23 percent we successful on follow up second interview (with 7 percent being successful on the third). Learned something important about closing: appeal to action!! Some rules which he used to close a sale:</p><ul><li><p><strong>Save closing points for the close</strong> (he used to use them too early). Average successful sale goes through 4 steps: 1) Attention, 2) Interest, 3) Desire, 4) Close. Save the enthusiasm / excitement in the closing points for the end of the sale.</p></li><li><p><strong>Summarize</strong>: a summary should be brief and only take you a few seconds to voice.</p></li><li><p><strong>The magic phrase: &#8216;How do you like it?&#8217;</strong> After summarizing the pitch for the prospects, he asks this question and if the answer is yes, he asks the prospect a few more questions (and tries to get them to say &#8216;yes&#8217; a few more times) and usually he already has the sale and is in the process of filling out their application form.</p></li><li><p><strong>Welcome objections and have persistence</strong>: some of his best sales prospects have been ones who objected. &#8216;I can&#8217;t afford it.&#8217; or &#8216;come back in January&#8217; were all great news to him: it told him the prospect wanted the product. An objection is not a turn-down.</p></li><li><p><strong>Why? &#8230; in addition to that &#8230; ?</strong> If a prospect isn&#8217;t willing to commit yet, usually asks the why questions and follows up with more questions (&#8216;if you were my own brother, I&#8217;d say to you what I&#8217;m going to say to you now&#8217;) and the persistence does pay off. &#8216;Why&#8217; gets the customer talking and brings out his objections. &#8216;In addition to that&#8217; finds the real reason, or the key issue.</p></li><li><p>Always have an &#8216;X&#8217; penciled in where the prospect signs.</p></li><li><p>Get the prospect to commit / pay as soon as you can. Once someone commits money to the sale, they rarely pull out.</p></li></ul></li><li><p>Check yourself every day on these closing rules. Apply them until they become habits.</p></li><li><p>Approach each interview like it will be the best interview you ever had.</p></li><li><p>If you&#8217;re unsuccessful after the prospect interview, make notes and review them.</p></li><li><p><strong>Remove barriers to entry</strong>: make it easy for the prospect to buy / sign. Tells a story on how he followed up with a prospect on a second interview by filling out his insurance application form and asking him to sign. The prospect wanted no part of this initially but did end up signing and paying up when he showed up and presented the filled out paper-work:</p><ul><li><p>Write up the order or application or contract in advance, even though you may only have the prospect&#8217;s name and address on it.</p></li><li><p>Mark a heavy &#8216;X&#8217; in each place where he/she is to sign.</p></li><li><p>Your first words: &#8216;Is that right, Mr. Blank?&#8217; laying the paper on his desk directly in front of him. If it is a stand-up interview, place the unfolded paper in his hands.</p></li><li><p>The ball is now down on his/her one-yard line and the momentum is with you.</p></li></ul></li><li><p><strong>Don&#8217;t fear failure: embrace it.</strong> Babe Ruth struck out over 1000 times, but he isn&#8217;t remembered for that. If you fail, keep going: each week and each month you&#8217;re improving. Once day soon, you will find a way to do the thing that looks impossible today. <strong>Courage is not the absence of fear; it is the conquest of it.</strong></p></li><li><p><strong>Benjamin Franklin&#8217;s secret of success:</strong> Franklin chose 13 subjects which he felt were necessary or desirable for him to acquire and try to master, and he gave a week&#8217;s strict attention to each subject successfully (and repeated this process 4X per year).</p></li><li><p>Frank Bettinger made his own list of 13 subjects, and they were: 1) Enthusiasm 2) Order: self-organization 3) Think in terms of the others&#8217; interests. 4) Questions 5) Key issue 6) Silence: listen 7) Sincerity: deserve confidence 8) Knowledge of my business 9) Appreciation and praise 10) Smile: happiness 11) Remember names and faces 12) Service and prospecting. 13) Closing the sale: action.</p></li><li><p>Each week, he carried a card in his pocket and focused on emphasizing that one principle during the week.</p></li><li><p>&#8216;Whether you are a printer, salesman, banking, or candy pushcart peddler, let&#8217;s assume that you select thirteen subjects best suited to you. By concentrating on one thing at a time, you will get farther with it in one week than you otherwise would in a year. A new confidence will take hold of you. At the end of 13 weeks, I know you will be surprised with your progress.&#8217;</p></li></ul><h4><strong><a href="https://medium.com/point-nine-news/five-ways-to-build-a-100-million-business-82ac6ea8ffd9">#50: Five ways to build a $100 million business (by Cristoph Janz)</a>:</strong></h4><ul><li><p>To build a company generating $100 million you need:</p><ul><li><p>1,000 enterprise customers paying you $100k+ per year each or</p></li><li><p>10,000 medium-sized companies paying you $10k+ per year each; or</p></li><li><p>100,000 small businesses paying you $1k+ per year each; or</p></li><li><p>1 million consumers paying you $100+ per year each or</p></li><li><p>10 million active consumers who you monetize at $10+ per year each by selling ads</p></li></ul></li><li><p>Salespeople sometimes refer to &#8220;elephants&#8221;, &#8220;deers&#8221; and &#8220;rabbits&#8221; when they talk about the first three categories of customers. To extend the metaphor to the 4th and 5th type of customer, let&#8217;s call them &#8220;mice&#8221; and &#8220;flies.&#8221;</p></li><li><p>Hunting flies: to get over 10 million users, you need 100+ million downloads AND either 1) have a product that is social and has a high viral coefficient (i.e. Facebook, WhatsApp) or 2) have a ton of user-generated content which leads to large amounts of SEO traffic (i.e. Yelp).</p></li><li><p>Hunting mice: to acquire 1 million customers paying 100 dollars a year you need 10 to 20 million downloads and a level of virality. Examples of this type of business are Evernote and MailChimp.</p></li><li><p>Hunting rabbits: to acquire 100,000 customers paying 1K per year, you need 0.5 to 2 million trial sign-ups along with inbound marketing, a focus on promoting your NPS score and sales funnel optimization although there is no silver bullet here.</p></li><li><p>Hunting deer: to acquire 10,000 customers paying 10K a year, most of the rabbit hunting techniques still apply along with maybe needing an inside sales force to generate or close leads along with an experienced VP of sales.</p></li><li><p>Hunting elephants: most of the big SaaS companies are elephants (i.e. have a few large enterprises paying for expensive subscriptions) and they include Workday and SalesForce. Remember, here you only need 1,000 customers paying 100K a year which is less than one executive per company (so it&#8217;s not that much money).</p></li><li><p>If you have 100 million in revenue, you&#8217;re looking at an exit of anywhere from 500 million to a billion and over.</p></li></ul><div><hr></div><p>Overall, going through most of the material was very useful, although the perception I had was that it was mostly centered on founders who wanted to go in the &#8216;move fast and break things&#8217; category. It&#8217;s my firm belief that there are more sustainable approaches to building companies &#8211; albeit most of the advice here focuses on start-ups. Approaches that focus on generating income rather than continually growing revenue which YC seems to be obsessed with tend to be more promising approaches when capital / lending is expensive (i.e. when interest rates are high), and we&#8217;re currently in a high-interest rate environment. Either way, I did agree with most of the general advice so it&#8217;s still extremely great advice for a lot of founders. Some key ideas which really stuck with me are outlined below:</p><ul><li><p>Start ups are hard and not for everyone. If you do start a start up, you are in for a very painful road, albeit one that also has a ton of rewards.</p></li><li><p>To be successful at starting a startup, you need to be passionate about the idea. Entrepreneurship is hard.</p></li><li><p>Focus on a small market and aim to make something insanely great. Choose to build something a small amount of users <strong>really want</strong> rather than a large group of users somewhat want.</p></li><li><p>Keep your expenses low and minimize your commitments.</p></li><li><p>The key factor which will determine whether a start-up and company will be successful is <strong>hard work and determination. </strong>This is the number one factor which determines whether you&#8217;ll succeed.</p></li><li><p>Ignore the haters and work on whatever you find interesting.</p></li><li><p>Build something that solves your own problem(s). You have to have passion for the idea that you&#8217;re bringing about.</p></li><li><p>Do things that don&#8217;t scale: pay attention to the early users and take extra measures to not only acquire them, but to make them incredibly happy (you can focus on scaling later).</p></li><li><p><strong>Live in the future, then build what's missing. </strong>That describes the way many if not most of the biggest startups got started. Try to notice and find things that seem to be missing. Turn off the normal perceptual filters which you use in everyday life and open up.</p></li><li><p>Talk to other people about their unmet needs. Find the gaps that they believe exist in the world. What's missing? What would they like to do that they can't? What's tedious or annoying, particularly in their work?</p></li><li><p>If you want to create and capture lasting value, don&#8217;t build an undifferentiated commodity business and <strong>avoid markets which have destructive competition </strong>(like the airline or restaurant industries). Look to build differentiated products and a monopoly (like Google).</p></li><li><p>If you have a competitor that&#8217;s growing faster than you - you may need to assess how fast the growth is and make sure that you don&#8217;t let them capture the entire market (i.e. think Oracle vs. Ingres: Oracle sucked but the obsession on growth allowed it to capture the market).</p></li><li><p>Keep on adding new product innovations and new features to the core business: what do the users want and how can you make your core product better?</p></li><li><p>Take Zuckerberg&#8217;s advice:<strong> listen to your users, stay simple, be reliable.</strong></p></li><li><p>Willpower and cognitive processing draw from the same pool of resources: don&#8217;t make your users think. Make the product simple and less cognitively demanding.</p></li><li><p>Do field studies and usability testing and use them to make it easy for your target users to do what they want.</p></li><li><p>The press is only a tool and can kill young companies. Things you should focus on: What problem am I solving for customers? Does my startup have a reason to exist? How can I make my service even better? Am I improving things for the economy or society at large? Who is your closest competitor and what do you do differently?</p></li><li><p>Software is eating the world: many new business are now migrating to being on-line, and it&#8217;s now easier to build a software based business than during any other point in history. This is a tremendous opportunity for many entrepreneurs. </p></li><li><p>How to pitch successfully: make something worth investing in, understand why it&#8217;s worth investing it and explain it clearly. </p></li><li><p>Don&#8217;t get addicted to fundraising: you should be listening to your users, not focusing on raising money. Also, don&#8217;t raise too much money.</p></li><li><p>Encourage your employees to be open and to share as much as possible at work. Your job is to deliver happiness to customers, employees and investors.</p></li><li><p>Build a strong culture by doing things the right way and have trust in your employees to do the right thing. Embrace employee openness and foster communication through sharing. Try to get everyone together (lunch / events) and have fun. Hire only the best.</p></li><li><p>Hiring is really hard and really important. In fact, it&#8217;s most likely the most important thing a founder does. Hire people that aren&#8217;t a**holes and that you like. Look for smart and effective people that get things done. </p></li><li><p>Be generous with compensation &#8211; especially when it comes to giving equity. Give your employees a share in the company and shared goals and values that align with your own.</p></li><li><p>Market is cyclical and investors tend to act in waves: understand that this happens and that many people follow each other, so the waves will come and go. A smart investor ignores them and invests in people who want to build great things and have perseverance. </p></li><li><p>There&#8217;s only one mistake that kills startups: not making something users want. If you make something users want, you'll most likely be fine.</p></li><li><p>Follow Bill Walsh&#8217;s advice: Focus on improving yourself and your team - as well as perfecting the fine details that matter and the score will take care of itself. </p></li><li><p>Don&#8217;t ever compromise the end-product: focus on building and packaging something great for your customers / end-users. If you package something that looks like garbage, it&#8217;ll result in garbage. Also, embrace failure and don&#8217;t give up: perseverance is the most important factor in determining whether you&#8217;ll be successful. </p></li><li><p>Follow the advice in and read the book '<a href="https://www.amazon.com/Raised-Myself-Failure-Success-Selling/dp/B01MSHJDRS">How I Raised Myself From Failure to Success In Selling</a>&#8217; if you want to find some great tips on being a great salesman. I included detailed notes and a summary above, but reading the book was invaluable and I highly highly recommend it to everyone. </p></li></ul><p>Hopefully you find these notes useful and hopefully they help other people in starting their own company. I&#8217;m also extremely sorry for not being able to include more material. My overall favorite talk is creative mornings with Ben Chestnut: </p><div id="vimeo-34081566" class="vimeo-wrap" data-attrs="{&quot;videoId&quot;:&quot;34081566&quot;,&quot;videoKey&quot;:&quot;&quot;,&quot;belowTheFold&quot;:true}" data-component-name="VimeoToDOM"><div class="vimeo-inner"><iframe src="https://player.vimeo.com/video/34081566?autoplay=0" frameborder="0" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" loading="lazy"></iframe></div></div><p>There&#8217;s also other great material there which I either may have missed or which I didn&#8217;t have time to include. I highly urge any founders to actually go through and read all of the material rather than just skimming my notes. Either way, if you have any improvement suggestions or want me to include anything, please let me know and I&#8217;ll be more than happy to do so. If you found these summaries helpful, please make sure to like and share :)</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Photon-Lines Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Sam Altman's Startup Advice (Part 1)]]></title><description><![CDATA[My personal notes / summaries of the readings available on Sam Altman's 'How to Start a Startup' lectures.]]></description><link>https://photonlines.substack.com/p/sam-altmans-startup-advice-part-1</link><guid isPermaLink="false">https://photonlines.substack.com/p/sam-altmans-startup-advice-part-1</guid><dc:creator><![CDATA[Nick M]]></dc:creator><pubDate>Sat, 20 Jan 2024 20:25:50 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!b3hP!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd23c96bd-e136-4004-96c4-318b52a9538f_408x408.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I decided to venture into the world of Sam Altman this week. If you&#8217;ve been living on Mars and you don&#8217;t happen to know who he is, I&#8217;ll summarize it for you briefly:</p><p>Sam Altman is the current CEO of OpenAI. The organization's mission is to ensure that artificial general intelligence (AGI) benefits all of humanity, and they&#8217;re the master-minds behind ChatGPT. Prior to OpenAI, Mr. Altman was the president of Y-Combinator (YC) -- one of the most prestigious startup accelerators in Silicon Valley. Y-Combinator has played a significant role in the growth and success of numerous tech startups (including Airbnb, Dropbox, Reddit, Stripe, Docker, etc&#8230; ) and it was originally founded by the one and only <a href="http://www.paulgraham.com/">Paul Graham</a>. Prior to that, he founded Loopt &#8211; a mobile location-based social networking app. The company aimed to connect users with their friends and discover local events. Loopt was eventually acquired by Green Dot Corporation for $43.4 million.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Photon-Lines Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>In other words, Altman is a man beaming with success, so I decided to go through his notes on starting a start up and to do my best to summarize some of the advice given throughout his recommended reading list. For anyone who wants to slog through each one manually, you can find them all here:</p><p><a href="https://startupclass.samaltman.com/lists/readings/">https://startupclass.samaltman.com/lists/readings/</a></p><p>My own notes and highlights are provided below.</p><h4><strong><a href="https://blog.samaltman.com/advice-for-ambitious-19-year-olds">#1 Advice for Ambitious 19 year olds (by Sam Altman):</a></strong></h4><ul><li><p>No matter what you choose, build stuff and be around smart people.</p></li><li><p>&#8220;Stuff&#8221; can be a lot of different things&#8212;open source projects outside of class, a startup, a new sales process at a company you work at. The key: don&#8217;t talk about it. Build it.</p></li><li><p>Don&#8217;t be scared of taking risk (most people are too risk averse).</p></li><li><p>Try to join a company on a breakout trajectory.</p></li><li><p>Don&#8217;t choose a job for salary (like joining Microsoft. Mentions a friend who chose Microsoft and judged him to make a terrible decision since his mental model of Microsoft was most likely a bunch of non-intelligent bureaucrats working on non-interesting things. Ohh Sam, how times change?).</p></li><li><p>If you start a company, only do so if you have an idea you&#8217;re in love with. Startups are a 6-10 year commitment, so you need to be in love with the idea you&#8217;re pushing forward.</p></li><li><p>Keep your expenses low and minimize your commitments (in other words, commit yourself to making the idea happen no matter what circumstances may be in store).</p></li></ul><h4><strong><a href="https://medium.com/i-m-h-o/good-and-bad-reasons-to-become-an-entrepreneur-decf0766de8d">#2: Good and Bad Reasons to Become an Entrepreneur (by Dustin Moskovitz</a>):</strong></h4><ul><li><p><strong> </strong>To be successful at starting a startup, you need to be passionate about the idea. Entrepreneurship is hard.</p></li><li><p>Bad reasons for trying to start a company:</p><ul><li><p>You want to be your own boss. The reality is that starting a startup makes everyone else (the customer, employees, partners, etc&#8230;) your boss.</p></li><li><p>Glamour. Usually any glamour is clouded with a mountain of hard work.</p></li><li><p>Financial return (for your talent). There are much easier ways to receive a good piece of the financial pie than starting a start up (the 100<sup>th</sup> engineer at Facebook made much more money than 95% of Silicon Valley entrepreneurs).</p></li></ul></li></ul><h4><strong><a href="https://blog.samaltman.com/stupid-apps-and-changing-the-world">#3: Stupid Apps and Changing the World (by Sam Altman</a>):</strong></h4><ul><li><p>Many people often accuse Silicon Valley of working on stuff that doesn&#8217;t matter, but a ton of important things usually start out looking as if they don&#8217;t matter.</p></li><li><p>If some users really love what you&#8217;re building and engage with it often in their daily lives, keep working on it!!</p></li><li><p>Pay no attention to market predictions (they tend to be terrible).</p></li><li><p>There are 2 primary ways of change the world with tech:</p><ul><li><p>Build something that some people love but most others think is a toy.</p></li><li><p>Be hyper-ambitious.</p></li></ul></li><li><p>Ignore the haters and work on whatever you find interesting. Most critics tend to be ignorant f*cks that aren&#8217;t building anything themselves.</p></li></ul><h4><strong><a href="https://paulgraham.com/ds.html">#4: Do things that Don&#8217;t Scale (by Paul Graham</a>):</strong></h4><ul><li><p>Do things that don&#8217;t scale (i.e. do things manually and really get involved &#8211; at least in the beginning). The most common thing founders have to do at the start is recruit users manually. Airbnb and Stripe are great examples of this (founders went WAY out of their way to recruit new users).</p></li><li><p>Many founders under-estimate the power of compound growth. If you have 100 users, you need to get 10 more next week to grow 10% a week. If you keep growing at 10% a week, after a year you'll have 14,000 users, and after 2 years you'll have 2 million.</p></li><li><p>The right question to ask a start up: how fast is the company growing? Forget about changing the world and everything else. Focus on growth.</p></li><li><p>Build something that solves your own problem(s) &#8211; which also opens up the door to finding new users as well (since they&#8217;ll be your peers).</p></li><li><p>Take extraordinary measures to not only acquire users, but to make them incredibly happy (send out thank you notes / do a lot of schmoozing / do whatever it takes to make your initial users happy).</p></li><li><p>Focus on making your user experience &#8216;insanely great&#8217; (as coined by Steve Jobs). The product is just one component of that. (As a note, he also mentions that you can make the experience great even with an early, incomplete, buggy product which &#8230; well, I tend to disagree with but hey, he&#8217;s the pro).</p></li><li><p>Over-engaging with early users is not just permissible, but necessary. You need them as a feed-back loop in order to make the product better.</p></li><li><p>Perfectionism is often an excuse for procrastination. Don&#8217;t try to make things perfect &#8211; focus on shipping.</p></li><li><p>Sometimes the best early trick is to focus on a <strong>narrow </strong>market (like Facebook, which start off as a platform for Harvard / university students and focused on building a great experience <strong>for them</strong> initially and expanded afterwards).</p></li><li><p>Most great start-ups focus on a narrow market: the founders build something great for themselves or their friends, and then later realize that it could be expanded to a broader market.</p></li><li><p>If you can find someone with a problem that needs solving and you can solve it manually, go ahead and do that for as long as you can, and then gradually automate the bottlenecks.</p></li><li><p>Launches: forget big launches. Most founders believe that a &#8216;big event&#8217; is necessary to get off to a good start. Most great things don&#8217;t start off with a big launch event. They start off quietly and attract a few users.</p></li></ul><h4><strong><a href="https://www.paulgraham.com/startupideas.html">#5: How to Get Startup Ideas (by Paul Graham</a>):</strong></h4><ul><li><p>Don&#8217;t try to think of start up ideas. Look for problems &#8211; preferably problems that you have yourself.</p></li><li><p>The very best startup ideas tend to have three things in common: they're something the founders themselves want, that they themselves can build, and that few others realize are worth doing. Microsoft, Apple, Yahoo, Google, and Facebook all began this way.</p></li><li><p>There have to be users who really need what you&#8217;re making (or trying to make). Not just people who see themselves as using it one day &#8211; they need to have the urge to use it IMMEDIATELY. The initial user group needing it is usually small, but it doesn&#8217;t hinder the idea (if the need was broad &#8211; an existing company would have tried to solve it already).</p></li><li><p>Choose to build something a small amount of users <strong>really want</strong> rather than a large group of users somewhat want.</p></li><li><p><strong>Live in the future, then build what's missing. </strong>That describes the way many if not most of the biggest startups got started. As an example, Zuckerberg pretty much lived online prior to starting Facebook. If you asked most people on whether they would like to post their personal info online prior to Facebook, most of them would have been terrified.</p></li><li><p>Be open to new opportunities. Bill Gates and Paul Allen hear about the Altair and think "I bet we could write a Basic interpreter for it." Drew Houston realizes he's forgotten his USB stick and thinks "I really need to make my files live online." The verb you want to be using with respect to startup ideas is not "think up" but "notice." Observe the opportunities that stand unnoticed before you.</p></li><li><p>Try to be at the leading edge of a rapidly changing field. This is where the real opportunities come from.</p></li><li><p>Try to notice and find things that seem to be missing. Turn off the normal perceptual filters which you use in everyday life and open up. Try to think of things that make life more efficient or tolerable. You're trying to see things that are obvious, and yet that you hadn't seen.</p></li><li><p>Try to work on cool projects and build things &#8211; even if they seem like toys at first. Live in the future and build what seems interesting.</p></li><li><p>If you&#8217;re going to college, don&#8217;t take a class on entrepreneurship. Build things and look for ideas to build and people to build it with.</p></li><li><p>Don&#8217;t worry about being late: good ideas seem like they&#8217;re obvious, which means that someone might have already tried to solve it. Don&#8217;t let that deter you.</p></li><li><p>It&#8217;s better to have a good idea with more competitors than a bad one without. You don't need to worry about entering a "crowded market" so long as you have a thesis about what everyone else in it is overlooking. Google wasn&#8217;t the first to market, but it didn&#8217;t keep them from dominating and being the best! A crowded market is actually a good sign, because it means both that there's demand and that none of the existing solutions are good enough.</p></li><li><p>Turn off your &#8220;schlep&#8221; (avoidance of tedious tasks) and &#8220;unsexy&#8221; (avoidance of unglamorous work) filters.</p></li><li><p>When searching for ideas, look in areas where you have some expertise. If you're a UI expert, don't build a database app.</p></li><li><p>One good trick is to ask yourself whether in your previous job you ever found yourself saying "Why doesn't someone make x? If someone made x we'd buy it in a second."</p></li><li><p>Talk to other people about their unmet needs. Find the gaps that they believe exist in the world. What's missing? What would they like to do that they can't? What's tedious or annoying, particularly in their work?</p></li></ul><h4><strong><a href="https://www.youtube.com/watch?v=M6Oxl5dAnR0&amp;t=4253s">#6: Excerpt from Steve Jobs&#8217;s 1995 interview with Computerworld&#8217;s Oral History Project</a>:</strong></h4><ul><li><p>Many people approach the world with a &#8216;fixed&#8217; mindset (thus lacking imagination and a lack of propensity to dream of how things &#8216;could&#8217; be).</p></li><li><p>The world needs death: to get rid of the people who are satisfied with the current ways of doing things and produces new people who see the potential to improve things and dream of new things.</p></li><li><p>Large companies suck. The people at the top of the company tend to not notice what many people notice at the lower levels of the company &#8211; and even when they do tend to notice, it tends to be too late (think IBM). Big companies move too slowly.</p></li><li><p>As long as new humans keep getting born &#8211; there will be many new opportunities for young people to come in and come up with new ideas and for young people to come in an innovate.</p></li><li><p>What advice would you give to young entrepreneurs?</p><ul><li><p>Find something you&#8217;re really passionate about instead of thinking of &#8216;ideas.&#8217; Ideas are useless. Work on something and find your ideas through work rather than fishing for the next idea or big thing.</p></li><li><p>More than half of what separates the successful entrepreneurs from the non-successful ones is <strong>pure perseverance. Most people give up and it&#8217;s a hard road to take.</strong></p></li><li><p>You have to have passion for the idea that you&#8217;re bringing about.</p></li></ul></li><li><p>We&#8217;re all going to be dead soon. Live each day on earth like it&#8217;s going to be your last. You never know when you&#8217;re gonna go. Look to leave something great behind.</p></li><li><p>Talent attracts talent. Ambitious and bright people tend to attract each other and work in groups (which thus explains the great success within the Bay area).</p></li></ul><h4><strong><a href="https://www.wsj.com/articles/BL-232B-2715">#8: Why Startups Need to Focus on Sales, Not Marketing (by Jessica Livingston</a>):</strong></h4><ul><li><p>You should not be doing any &#8216;marketing&#8217; at your start up. Instead, your focus should be on sales (narrow and deep) rather than marketing (broad and shallow).</p></li><li><p>Talk to a small number of users using your product and focus on that. You need to talk individually to early adopters to make a really good product, so engage with the early birds and don&#8217;t be scared of getting your hands dirty and being really involved.</p></li><li><p>Successful startups almost always start narrow and deep.</p></li><li><p>Get a small number of users initially, and focus in on them.</p></li><li><p>How to measure if your efforts are effective? Focus on growth rather than absolute numbers.</p></li><li><p>Make a really good product and go out and find users for it manually.</p></li></ul><h4><strong>#9: Chapter 3-5 of Zero to One (by Peter Thiel):</strong></h4><ul><li><p>If you want to create and capture lasting value, don&#8217;t build an undifferentiated commodity business and <strong>avoid markets which have destructive competition </strong>(like the airline or restaurant industries). Look to build differentiated products and a monopoly (like Google).</p></li><li><p>Both monopolies and non-monopolies try to bend the truth. Monopolies don&#8217;t want governments getting in the way, so they up-sell their own competition. Non-monopolies want investors, so they overstate their own differentiation and talk down their competition.</p></li><li><p>Competition pushes people towards ruthlessness or death. Monopolies have the freedom to do what they want and focus on what&#8217;s important without prioritizing money.</p></li><li><p>Not all monopolies are bad: creative monopolists give customers more choices by adding entirely new categories of abundance to the world. Creative monopoly profits provide an <strong>incentive to innovate. </strong>Monopolies can funnel their profits into long-term thinking and various research projects which non-monopolies don&#8217;t have the ability to do.</p></li><li><p>Old school economics is outdated and no longer relevant. Businesses are not static. Static = death. Monopolies are dynamic and usually creative. Monopolies are actually good for the world.</p></li><li><p><strong>So why do we value competition?</strong></p><ul><li><p>Our education system brainwashes us into valuing and believing in competition.</p></li><li><p>Managers never tire of comparing business to war.</p></li><li><p>Our society hero-worships competition and what it represents, when reality shows the opposite: competition and extremely competitive markets simply suck.</p></li><li><p>It&#8217;s better to merge with competitors than to fight them. Thiel goes on to describe PayPal&#8217;s merger with X.com and how it benefited both companies and equipped them to survive the dot-com crash.</p></li><li><p>Simply put: competition is a force of destruction, so avoid it at all costs.</p></li></ul></li><li><p><strong>So &#8211; how do you build a monopoly business?</strong></p><ul><li><p>Why is Twitter valued so much more than the New York Times? The New York times was profitable while Twitter wasn&#8217;t. Simply put: cash flow. Great business is valued by the cash flow its able to produce in the future rather than today. Investors expect that Twitter will be able to capture monopoly profits over the next few decades, so the newspaper monopoly days are over.</p></li><li><p>Most of the value in low-growth businesses (like nightclubs and restaurants) is focused on the near term: they trade in profits which they make today for its future profits (which get eaten away by substitutes and competitors). Technology companies follow the opposite trajectory: they sacrifice today&#8217;s profits (and lose) to build something which will generate great value 10 to 15 years into the future.</p></li><li><p>PayPal and LinkedIn are excellent examples of these sorts of companies: the valuations might seem insane on the surface, but the future cash flows and compound growth tell a good story.</p></li><li><p>If you focus on near term growth too much, you&#8217;ll miss out on the most important question which you should be asking yourself: <strong>will this business still be around a decade from now? </strong></p></li><li><p>Every monopoly is unique, but they usually share some combination of the following characteristics: proprietary technology, network effects, economies of scale, and branding.</p></li><li><p><strong>Proprietary technology: </strong>Think Google: it&#8217;s search algorithm dominated (fast results combined with incredible quality). As a good rule of thumb, the technology should be 10 times better than its substitutes. The best way to make something 10x better is to invest something completely new. Or you can radically improve an existing solution: once you&#8217;re 10x better, you escape competition. Amazon made its first 10x improvement in a particularly visible way: they offered at least 10 times as many books as any other bookstore. Apple made a tablet that went from unusable to something that was beautiful and useful.</p></li><li><p><strong>Network Effects: </strong>Network effects make a product more useful as more people use it. For example, if all your friends are on Facebook which draws even more people towards using Facebook. Paradoxically, then, network effects businesses must start with especially small markets. Facebook started with just Harvard students.</p></li><li><p><strong>Economies of Scale: </strong>A monopoly gets stronger as it gets bigger: the fixed costs of creating a product (like employee costs or office space) can be spread our over greater quantities / sales. Software can enjoy incredible economies of scale due to marginal costs of making more copies being close to zero. Many business gain only limited advantages from scaling (like service businesses). A good startup should have the potential for great scale built into its first design.</p></li><li><p><strong>Branding: </strong>today&#8217;s strongest brand is Apple. Apple offers products so good as to constitute a category of their own. Apple has a complex suite of proprietary technologies, both in hardware (like superior touchscreen materials) and software (like touchscreen interfaces purpose-designed for specific materials). It manufactures products at a scale large enough to dominate pricing for the materials it buys. And it enjoys strong network effects from its content ecosystem: thousands of developers write software for Apple devices because that&#8217;s where hundreds of millions of users are, and those users stay on the platform because it&#8217;s where the apps are. These other monopolistic advantages are less obvious than Apple&#8217;s sparkling brand, but they are the fundamentals that let the branding effectively reinforce Apple&#8217;s monopoly.</p></li></ul></li><li><p><strong>Building a Monopoly:</strong></p><ul><li><p>Every startup is small at the start. Every monopoly dominates a large share of its market. Therefore, every startup should start with a very small market.</p></li><li><p>Always err on focusing on a small market. The reason? A small market is easier to dominate than a large one.</p></li><li><p>The perfect target market for a startup is a small group of particular people concentrated together and served by few or no competitors. Any big market is a bad choice, and a big market already served by competing companies is even worse.</p></li><li><p>Once you dominate a niche market &#8211; your focus should be on expanding into related broader markets. Amazon as an example started with books and then moved into other areas.</p></li><li><p>Don&#8217;t disrupt: avoid competition as much as possible. Build a monopoly in a niche market and &#8220;study the endgame before everything else.&#8221; Also &#8211; forget about the &#8216;first mover advantage.&#8217; Usually, you want to be the last mover &#8211; make the last great development in a specific market and enjoy years or even decades of monopoly profits.</p></li></ul></li></ul><h4><strong><a href="https://www.youtube.com/watch?v=raIUQP71SBU">#10: How we put Facebook on the path to 1 billion users (by Chamath Palihapitiya)</a>:</strong></h4><ul><li><p>Most people and most companies are mostly shit (learned this at AOL).</p></li><li><p>Spent most of his time investing and playing poker.</p></li><li><p>Many people try to mask themselves in a &#8216;veneer of complexity&#8217; but it&#8217;s fairly simply: measure some shit, try some shit, test some more shit, throw out some more shit and it&#8217;s really not that complicated.</p></li><li><p>It&#8217;s unbelievable the lack of &#8216;dog-fooding&#8217; that happens in the real world (where dog-fooding refers to people using their own product or the product which they produce).</p></li><li><p>People in general think of growth in completely wrong way.</p></li><li><p>Three of the most important questions in regards to consumer products that are asked:</p><ul><li><p>How do you get people into the front door?</p></li><li><p>How do you get to an &#8216;aha&#8217; moment as quickly as possible?</p></li><li><p>How do you deliver the core-product value and engagement?</p></li></ul></li><li><p>Only after you address these questions can you focus on growth.</p></li><li><p>Eliminate ego. Be comfortable with not being rewarded in the short term.</p></li><li><p>Don&#8217;t live on gut-feeling. Most people can&#8217;t predict things correctly.</p></li><li><p>Be honest. Don&#8217;t allow bullshit to permeate your culture.</p></li><li><p>Do you really know what you&#8217;re building and why?</p></li><li><p>Key thing which Facebook focused on: how do we provide value to as many users as possible. They didn&#8217;t focus on growth or anything else. Focus was on delivering the core product value to as many users as possible.</p></li></ul><h4><strong><a href="https://genius.com/Joel-spolsky-does-slow-growth-equal-slow-death-annotated">#11: Does Slow Growth Equal Slow Death? (by Joel Spolsky)</a>:</strong></h4><ul><li><p>Speed to market often involves a trade-off with quality: if you need high quality code, it takes time and Joel usually takes the time to do things right. This has also slowed Fog Creek (his company) down a lot.</p></li><li><p>He&#8217;s OK with reasonable and steady growth over explosive growth (Fog Creek had grown 56% annually for 10 years).</p></li><li><p>Joel is happy with this growth rate: the company is profitable, their customers love their products and their sales are rising.</p></li><li><p>But, in the book &#8216;Crossing the Chasm,&#8217; Moore writes about the battle between Oracle and Ingres in the 1980s: Oracle drove for 100 percent growth while Ingres accepted 50 percent growth. According to executives at Ingres, the company could not grow any faster than 50 percent and still adequately serve their customers. They said that Oracle was over-promising and under-delivering and that their customers hated them. They ended up being wrong and Oracle won the war.</p></li><li><p>This concerned Joel. Moore also said &#8220;Once the apparent leader-to-be emerges, pragmatists will support that company, virtually regardless of how arrogant, unresponsive, or overpriced it is."</p></li><li><p>This is entirely possible and you can think of it this way: &#8220;If you're growing at 50 percent a year, and your competitor is growing at 100 percent a year, it takes only eight years before your competitor is 10 times bigger than you. And when it's 10 times bigger than you, it can buy 10 times as much advertising and do 10 times as many projects and have meetings with 10 times as many customers. And you begin to disappear.&#8221;</p></li><li><p>Many software companies have gone away because they simply didn&#8217;t grow fast enough and were over-taken by the market leader (look at Word Perfect or Word Star) - but expanding a business faster than its natural rate is also risky. You have to hire quickly and borrow money from investors as well as rely on outside partnerships.</p></li><li><p><strong>Key point: If you want to win, you need to be OK with focusing on growth taking risks. </strong>If you aren&#8217;t, someone else will be and they will take your market share.</p></li><li><p>At Fog Creek, they plan to take more risks in the future by:</p><ul><li><p>Focusing on delivering a product that can square off with their competitors; often, they lose a customer because the don&#8217;t have X and the competitor does. They plan to address this by adding features to their already excellent product.</p></li><li><p>Focusing on building up a sales force. Word of mouth isn&#8217;t enough and Fog Creek could use a bigger sales team which they plan on delivering soon.</p></li></ul></li></ul><h4><strong><a href="https://a16z.com/a-recipe-for-growth-adding-layers-to-the-cake/">#12: A Recipe for Growth - Adding Layers to the Cake (by Jeff Jordan)</a>:</strong></h4><ul><li><p>Businesses don&#8217;t grow themselves. One of the most important jobs of a CEO is to aggressively define and pursue a growth agenda for his or her business.</p></li><li><p>When he joined e-bay, he noticed that month over month growth wasn&#8217;t there for one month and needed a plan to prioritize growth. Rather than using more marketing (which they were already utilizing) or attempting to acquire a company (it felt desperate to acquire a company), they decided to focus on focusing on <strong>product innovation</strong>.</p></li><li><p>Decided to look into buying formats: at the time, they only allowed buying through auctions, but research showed that non-male users may not have loved auctions and preferred fixed-price formats. The buy-now option that they added now represents 62% of eBay&#8217;s revenue.</p></li><li><p>He came to call this process of layering in new innovations on top of the core business &#8220;adding layers to the cake.&#8221; eBay within the U.S. was the company&#8217;s original business but the team focused on adding more &#8216;growth layers&#8217; &#8211; the first one being international expansion, followed by payments and finally by acquiring PayPal which all took place between 1996-2005.</p></li><li><p>At PayPal &#8211; they added further layers through international expansion, improving offerings for merchants (who sold outside of eBay) and starting to offer credit on top of payments business.</p></li><li><p>His earlier success at OpenTable also used the &#8216;layer on the cake&#8217; growth strategy, and other public companies like Apple and Amazon utilized it heavily during this time (Apple by expanding its product like and Amazon by expanding into other non-merchandise businesses). The key to the success here almost always lied in <strong>brilliant innovation.</strong></p></li><li><p>These winning Net companies are incredibly strong at <strong>product innovation. </strong>The best innovations improve and compliment the core business of a company, taking advantage of and enhancing its most valuable assets.</p></li></ul><h4><strong><a href="https://allthingsd.com/20121020/mark-zuckerberg-on-facebooks-early-days-go-hard-or-go-home/">#13: Mark Zuckerberg on Facebook&#8217;s Early Days: Go Hard or Go Home (by Mike Isaac)</a>:</strong></h4><ul><li><p>Like most other start-ups, Facebook didn&#8217;t have many resources in its early days. Its very first server back in 2004 cost $85 to rent. They didn&#8217;t spend much and were small, tight and had a lot to prove.</p></li><li><p>They first went to schools that were hardest to succeed in. Zuckerberg figured that if they had a product that was better than all others, it would be worth investing in.</p></li><li><p>After first growing Facebook inside of Harvard, the plan was essentially to go hard or go home &#8212; to launch at universities that already had a really well integrated social network (like Columbia, Stanford and Yale). The thinking was that if Facebook succeeded there, scaling to less integrated schools would be a downhill and easier battle.</p></li><li><p>Some other great advice which Zuckerberg offered to the crowd: <strong>listen to your users, stay simple, be reliable.</strong></p></li></ul><h4><strong><a href="https://allthingsd.com/20121020/the-secret-behind-pinterests-growth-was-marketing-not-engineering-says-ceo-ben-silbermann/">#14: The Secret Behind Pinterest&#8217;s Growth Was Marketing, Not Engineering (by Liz Gannes)</a>:</strong></h4><ul><li><p>The way Pinterest grew had little to do with wisdom and more to do with regular grassroots marketing.</p></li><li><p>Initially had a small number of users (3000) who really loved the product.</p></li><li><p>Instead of changing the product (to accelerate growth) &#8211; they focused on finding more &#8216;core users&#8217; who could love the product and what it offered, and it worked.</p></li><li><p>General advice: don&#8217;t simply follow the herd or follow Venture Capitalist advice. Fundamentally, the future isn&#8217;t written.</p></li></ul><h4><strong><a href="https://www.paulgraham.com/growth.html">#16: Startup = Growth (by Paul Graham)</a>:</strong></h4><ul><li><p>A startup is a company designed to grow fast. If you want to start one, it's important to understand that. Millions of companies are started every year in the US. Only a tiny fraction are startups.</p></li><li><p>Most startups fail. To grow rapidly, you need to make something you can sell to a big market. To do this, you have to 1) make something lots of people want and 2) reach and serve all those people. Writing software is a great way to solve 2, but you&#8217;re stilled constrained with 1.</p></li><li><p>Most successful startups are started by founders who notice ideas that most other people overlook. In other words, the founders are different and able to notice a blind spot the market has ignored.</p></li><li><p>The growth of a successful startup usually has three phases:</p><ul><li><p>Initial period of slow growth while startup figures out what it&#8217;s doing.</p></li><li><p>The startup figures out how to make something lots of people want and how to reach them, they go through rapid growth.</p></li><li><p>Eventually, startup grows into a big company and growth declines again.</p></li></ul></li><li><p>Y-Combinator measures growth rate per week. A good growth rate during YC is 5-7% a week. If you can hit 10% a week you're doing exceptionally well. The best thing to measure here is revenue; the next best thing is active users.</p></li><li><p>It's hard to find something that grows consistently at several percent a week, but if you do you may have found something surprisingly valuable. (1% weekly growth = 1.7x yearly multiple; 5% weekly growth = 12.6x yearly multiple; 7% =33.7x; 10% = 142x).</p></li><li><p>Why are VCs interested only in high-growth companies? The reason is that they get paid by getting their capital back, ideally after the startup IPOs, or failing that when it's acquired. Many startups fail, but the ones which do make it are growth focused and return a huge multiple of the initial investment.</p></li><li><p>A lot of startups are acquisition targets. Rapidly growing companies can bring great value (PayPal brought great value to eBay as an example).</p></li><li><p>If you want to understand startups, understand growth. When you start a start-up, you&#8217;re committing yourself to <strong>finding growth.</strong></p></li></ul><h4><strong><a href="https://www.bloomberg.com/news/articles/2012-07-25/chasing-facebooks-next-billion-users">#17: Chasing Facebook's Next Billion Users (by Douglas MacMillan)</a>:</strong></h4><ul><li><p>Talks about Facebook&#8217;s growth team and its early days (went from 5 people to 150+). Early focus was on expanding market from universities to general population.</p></li><li><p>Some of their growth strategies focused on:</p><ul><li><p>Partnering with Google and adding Facebook profiles to their search results.</p></li><li><p>Adding &#8216;People You May Know&#8217; feature that let others discover more connections.</p></li><li><p>Making site available in other languages.</p></li></ul></li><li><p>The team views a dashboard every morning which shows a running tally of monthly active users.</p></li><li><p>Next focus is on emerging international markets and Facebook use on mobile phones.</p></li><li><p>Other companies are also copying Facebook and now have their own growth teams.</p></li></ul><h4><strong><a href="https://businessofsoftware.org/2023/09/kathy-sierra-your-app-makes-me-fat/">#19: Your App Makes Me Fat (by Kathy Sierra)</a>:</strong></h4><ul><li><p>In 1999, a study was done asking one group of students to memorize a 7-digit number while another group was asked to memorize only 2 digits. The group that memorized 7 digits were 50% more likely to take cake when being offered cake vs. fruit after the study.</p></li><li><p>Key finding: Willpower and cognitive processing draw from the same pool of resources.</p></li><li><p>Same type of study was done but with dogs, and the findings were similar: dogs which exercised more control over their cognitive resources (by waiting) were more likely to give up on solving a toy puzzle than dogs who didn&#8217;t need to wait patiently.</p></li><li><p>Cognitive resources are easily depleted: if you had to spend all day at work exercising self-control dealing with angry customers and co-workers, you&#8217;ll have less resources when you get back home.</p></li><li><p>Think about what this means for your users:</p><ul><li><p>If your app asks users to make choices, you&#8217;re draining resources.</p></li><li><p>If your app is confusing, once again &#8211; draining cognitive resources.</p></li><li><p>Adding new features: yup, you&#8217;re taking more cognitive resources.</p></li></ul></li><li><p>At each design meeting, ask: &#8216;Is this a fruit-choosing feature or cake-choosing feature?&#8217; If you&#8217;re adding content-marketing to the site, will your users really use it or pay attention to it? Are you draining their resources by making them use your app? How can you make it easy to use and do the best possible job of not taking away from your users&#8217; precious and easily depleted cognitive resources?</p></li></ul><h4><strong><a href="https://articles.centercentre.com/design_intuitive/">#20: What Makes a Design Intuitive (by Jared Spool)</a>:</strong></h4><ul><li><p>The whole article talks about what makes a design &#8216;intuitive&#8217; &#8211; and explains that what&#8217;s intuitive to one person may not be intuitive to another. The difference is outlined by a &#8216;knowledge gap.&#8217;</p></li><li><p>In the grand scheme &#8211; there are going to be many users of a design. They can all be lined up on a spectrum ranging from &#8216;no knowledge&#8217; to &#8216;all knowledge&#8217;. In other words &#8211; the knowledge of the interface ranges from knowing everything there is to know about it to knowing nothing about it.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!EIWW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a03b672-d603-48cf-849f-7dc2d633b156_419x171.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!EIWW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a03b672-d603-48cf-849f-7dc2d633b156_419x171.png 424w, https://substackcdn.com/image/fetch/$s_!EIWW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a03b672-d603-48cf-849f-7dc2d633b156_419x171.png 848w, https://substackcdn.com/image/fetch/$s_!EIWW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a03b672-d603-48cf-849f-7dc2d633b156_419x171.png 1272w, https://substackcdn.com/image/fetch/$s_!EIWW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a03b672-d603-48cf-849f-7dc2d633b156_419x171.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!EIWW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a03b672-d603-48cf-849f-7dc2d633b156_419x171.png" width="537" height="219.15751789976133" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0a03b672-d603-48cf-849f-7dc2d633b156_419x171.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:171,&quot;width&quot;:419,&quot;resizeWidth&quot;:537,&quot;bytes&quot;:19791,&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;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!EIWW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a03b672-d603-48cf-849f-7dc2d633b156_419x171.png 424w, https://substackcdn.com/image/fetch/$s_!EIWW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a03b672-d603-48cf-849f-7dc2d633b156_419x171.png 848w, https://substackcdn.com/image/fetch/$s_!EIWW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a03b672-d603-48cf-849f-7dc2d633b156_419x171.png 1272w, https://substackcdn.com/image/fetch/$s_!EIWW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a03b672-d603-48cf-849f-7dc2d633b156_419x171.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p></li></ul><ul><li><p>Current Knowledge represents the knowledge the user has when they first approach the interface to complete the task. Target Knowledge is the knowledge the user needs to accomplish the task. Every user will have a different &#8216;current knowledge point.&#8217;</p></li><li><p>The difference between the target point and current point is normally referred to as &#8220;the knowledge gap&#8221;. Users can complete the task when their current knowledge = the target knowledge.</p></li><li><p>Two conditions are needed to bridge the gap:</p><ul><li><p>Both the current knowledge point and target knowledge point are identical (i.e. the design is simple enough so that most users approaching it already are familiar with the elements needed in order to use it).</p></li><li><p>The points aren&#8217;t identical, but the current design helps them &#8216;bridge&#8217; this gap by supplying enough information on how to use it.</p></li></ul></li><li><p>To identify a user&#8217;s current knowledge point, it&#8217;s valuable to do field studies.</p></li><li><p>To identify the target knowledge for important tasks, perform user and usability testing.</p></li><li><p>Sometimes, making something intuitive doesn&#8217;t make sense for a company. As an example, Amazon doesn&#8217;t make it easy to find its customer service phone #. Instead, it makes return products very intuitive and easy (and uses a simple wizard interface to do so).</p></li></ul><h4><strong><a href="https://vimeo.com/34081566">#21: [video] Creative mornings with Ben Chestnut</a>:</strong></h4><ul><li><p>Embrace chaos. Managers love controlling things. Creatives don&#8217;t and nature needs entropy. Without entropy there is no creation (i.e. no work) so you need to embrace creativity and chaos.</p></li><li><p>Let people have time to work on stuff and avoid meetings.</p></li><li><p>Tells people to make small things and keep working on building small prototypes. He believes big ideas come from combining little things from lots of different parts / pieces.</p></li><li><p>Encourages employees to continually work on and build new things (but tries to put a timeline on it of 2 weeks). Idea: build lots of small things and keep working on new ideas.</p></li><li><p>Likes going around asking employees what they&#8217;re working on &#8211; if they&#8217;re not working on anything, likes to connect them to employees who are building or working on something and encourages them to help them out.</p></li><li><p>Doesn&#8217;t focus on &#8216;happiness&#8217; when it comes to running a business. Knows that the job of a business is to generate money so tries to encourage the exploration of many new ideas and building new things which they could use to generate income or deliver to customers.</p></li></ul><h4><strong><a href="https://www.dropbox.com/s/cit2axfhdsqbr5q/ThePressIsATool.pdf?dl=0">#23: The Press is a Tool (by Alexia Tsotsis)</a>:</strong></h4><ul><li><p>From a startup&#8217;s perspective the press is a tool. Dealing with press is part of the job of building a successful tech company.</p></li><li><p>At its most basic level, press is about telling stories.</p></li><li><p>Building great relationships with press people early on can pay great dividends.</p></li><li><p>Some companies that have used the hype cycle successfully are Uber, Twitter and</p><p>Airbnb. When a company reaches a peak, hype-wise, it&#8217;s time to start bearing fruit.</p></li><li><p>While everyone hopes for a Cinderella story, truth is that over 90% of startups fail. 74% percent of these startups fail because of premature scaling (i.e. the hype overwhelming product capabilities).</p></li><li><p>Hype is still the currency of Silicon Valley. People think Silicon Valley is a magical place filled with amazing technologies, but it also has some of the best marketers in the world.</p></li><li><p>When you&#8217;ve got nothing, hype, manufactured by blog posts and marketing gimmicks actually can help raise VC and capture the imagination of early adopters. Sometimes this works out for startups.</p></li><li><p>Hype may help companies get investments faster, but at the same time may scare away investors (at too high of a valuation).</p></li><li><p>For the past five years, the mythological desired outcome is such: Get your</p><p>TechCrunch post, get 1 million users, raise a huge round, sell to Google for $100</p><p>million. Now that narrative is changing &#8212; Get your Product Hunt link, TechCrunch post, Re/Code post, WSJ post, blog on Tech-meme and Hacker News, sell. But the average experience, even when you do sparkle, is fade. In other words, you might not need as much press as you think you might need.</p></li><li><p>So what&#8217;s the best media/hype strategy through all the risk and randomness? Go with Warren Buffet: "Markets are risky, good businesses are not."</p></li><li><p>In other words, have a positive attitude and design your business intelligently. Always ask:</p><ul><li><p>What problem am I solving for customers?</p></li><li><p>Does my startup have a reason to exist?</p></li><li><p>How can I make my service even better?</p></li><li><p>Am I improving things for the economy or society at large?</p></li></ul></li><li><p>Another 3 questions to ask founders:</p><ul><li><p>Who is your closest competitor and what do you do differently?</p></li><li><p>What are the challenges of doing this?</p></li><li><p>What are your future plans?</p></li></ul></li><li><p>Avoid over-promising and under-delivering.</p></li></ul><h4><strong><a href="https://a16z.com/why-software-is-eating-the-world/">#24: Why Software is Eating the World (by Marc Andreessen written in 2011)</a>:</strong></h4><ul><li><p>Many people believe that we have a software bubble, but Marc Andreessen argues the opposite: companies like Apple were trading at around 15 P/E even though they had a highly differentiated product with huge margins.</p></li><li><p>Believes that we are in a middle of a broad technological and economic shift where software companies will take over large swatches of the economy (which did come true).</p></li><li><p>More businesses are being run through software delivered online.</p></li><li><p>The costs to run a tech company have gone down tremendously (used to cost him 150K a month to run Loud-cloud but now it costs 1.5K to run through Amazon&#8217;s web services).</p></li><li><p>With lower start-up costs and vastly expanded market for online services, the global economy will be digitally integrated. Look at the world&#8217;s largest bookseller, Amazon as an example. Today&#8217;s largest video service is Netflix. Music companies are becoming software companies too (iTunes, Spotify, etc...). Video-game industry and video-game makers are also growing fast. Pixar used to be a software company as well. Mobile phones have replaced cameras. The largest marketing platform today is Google. The fastest growing Telecom company is Skype. LinkedIn is today&#8217;s fastest growing recruiting company.</p></li><li><p>Software is also disrupting value-chains in physical based products (like autos). Modern cars have built-in entertainment systems, maps for guidance, etc...</p></li><li><p>Walmart uses software to power its logistics and distribution capabilities.</p></li><li><p>Oil and gas exploration uses software based solutions.</p></li><li><p>Health care is the next industry to be transformed (along with national defense industry as well).</p></li><li><p>We should be proud of this development within America!! Still, we face several challenges:</p><ul><li><p>First, every new company is being built in the face of economic headwinds (side note: I totally disagree. Interest rates were at around 0% for a very very very long time).</p></li><li><p>Secondly, many people in the US and around the world lack the level of education and skills needed in order to benefit from this oncoming software revolution. There&#8217;s no solution to this other than to increase education, and we have a long way to go.</p></li></ul></li><li><p>The new companies need to prove their worth: they need to build strong cultures, delight their customers, establish a competitive advantage and justify their rising valuations. No one should expect to build such companies easily: it&#8217;s brutally difficult to do so.</p></li><li><p>Instead of questioning valuations, people should seek to understand this new generation of companies and seek to expand them.</p></li></ul><h4><strong><a href="https://paulgraham.com/convince.html">#25: How to Convince Investors (by Paul Graham)</a>:</strong></h4><ul><li><p>Most founders try to convince others to invest into them through a pitch, which is a mistake: instead of making a pitch, let the startup do the work. Explain to investors why the start up is worth investing in and explain it clearly and simply.</p></li><li><p>Investors are looking for start-ups that are going to be very successful, but many aren&#8217;t and only a few make it through. Out of the ones that make it through, a few become giants (distribution follows power law). Most investors want to know if you have a chance of becoming one of the big 15 successes.</p></li><li><p>How do you convince them that you will be a big success? You need three things:</p><ul><li><p>Formidable founders.</p></li><li><p>A promising market.</p></li><li><p>Some evidence of success so far.</p></li></ul></li><li><p>How can you be formidable? A formidable person is one who seems like they'll get what they want, regardless of whatever obstacles are in the way. Formidable also equates to being confident as well.</p></li><li><p>Truth: the way to seem most formidable as an inexperience founder is to speak the truth. Convince yourself that your startup is worth investing in and then learn how to explain it to others.</p></li><li><p>To evaluate whether your startup is worth investing in, you have to be a domain expert. Know everything about your market.</p></li><li><p>The time to raise money is not when you need it, or when you reach some artificial deadline, it's when you can convince investors.</p></li><li><p>Market: you need a plausible path to owning a big piece of a big market. Founders think of startups as ideas, but investors think of them as markets.</p></li><li><p>If there are x number of customers who'd pay an average of $y per year for what you're making, then the total addressable market, or TAM, of your company is $xy. Make xy big enough and you&#8217;ll get interest.</p></li><li><p>You don&#8217;t have to start with targeting a large market: many times it&#8217;s often better starting off with a small one that <strong>can </strong>turn into a big one.</p></li><li><p>One big question: if this is such a great idea, why hasn&#8217;t anyone else done it. Key: most start ups notice something other people miss or they ride a trend, and also: most companies seem like only pretty good ideas (including Microsoft) in the first few months after they&#8217;re started. A huge element of &#8216;luck&#8217; plays a role in other words.</p></li><li><p>Rejection: don&#8217;t lie to investors. Also, it's not uncommon for a startup to be rejected by all the VCs except the best ones. That's what happened to Dropbox.</p></li><li><p>Different: don&#8217;t use bullshit language or &#8216;try&#8217; to convince investors. Believe in your idea and show them it&#8217;s worth investing it.</p></li><li><p>In other words, make something worth investing in, understand why it&#8217;s worth investing it and explain it clearly.</p></li></ul><h4><strong><a href="https://paulgraham.com/fr.html">#26: How to Raise Money (by Paul Graham)</a>:</strong></h4><ul><li><p>Most startups that raise money do it more than once. A typical trajectory might be (1) to get started with a few tens of thousands from something like Y-Combinator or individual angels, then (2) raise a few hundred thousand to a few million to build the company, and then (3) once the company is clearly succeeding, raise one or more later rounds to accelerate growth. This essay is focused on #2.</p></li><li><p>What makes a company a start up? Rapid growth. If taking on money makes you grow faster then take it on, and if not, don&#8217;t raise money.</p></li><li><p>If you do decide to raise money: do it as quickly as possible so you can focus your attention to getting back to work (of building your company).</p></li><li><p>Most investors have 2 main fears: the fear of missing out or the fear of investing in a flop. To mitigate investing in flops, normal investors try to wait as long as possible to gain information about the company prior to investing (in order to minimize risk).</p></li><li><p>If you&#8217;re not fundraising and an investor wants to meet with you, don&#8217;t accept the invitation.</p></li><li><p>The best type of intro is from a well-known investor who has just invested in you. So when you get an investor to commit, ask them to introduce you to other investors they respect. The next best type of intro is from a founder of a company they've funded.</p></li><li><p>When searching for investors, talk to many in parallel and do it through breadth-first search weighed by expected value (where expected value = amount willing to invest * chances of investing).</p></li><li><p>Never leave a meeting with an investor without asking what happens next. What more do they need in order to decide? Don't be too pushy, but know where you stand.</p></li><li><p>Getting the first investor to invest in your company is usually the hardest. Once you have one, the rest follow more easily.</p></li><li><p>Once an investor commits, find out when you will get the money. Don&#8217;t say you raised money until the money is in the bank.</p></li><li><p>When an investor tells you "I want to invest in you, but I don't lead," translate that in your mind to "No, except yes if you turn out to be a hot deal."</p></li><li><p>If you need to estimate the upper limit on what you should raise, a good rule of thumb is to multiply the number of people you want to hire times $15k times 18 months. In most startups, nearly all the costs are a function of the number of people. If you have additional expenses, like manufacturing, add in those at the end.</p></li><li><p>Underestimate how much you want: err on underestimating how much you want to raise. Also keep your expenses low.</p></li><li><p>Be profitable if you can: it will give you a much stronger position in raising money. You want to tell investors that you&#8217;ll succeed no matter what, but raising money will help you do it faster.</p></li><li><p>Don&#8217;t try to maximize your company valuation. Y-Combinators best 2 investments had really low valuations when they raised (Dropbox and Airbnb). Beware of &#8216;valuation sensitive&#8217; investors (investors who won&#8217;t invest unless they know your current valuation).</p></li><li><p>If you're surprised by a low-ball offer, treat it as a backup offer and delay responding to it.</p></li><li><p>Accept offers greedily: If someone makes you an acceptable offer, take it. If you have multiple incompatible offers, take the best.</p></li><li><p>Don't sell more than 25% in phase 2: Our rule of thumb is not to sell more than 25% in phase 2, on top of whatever you sold in phase 1, which should be less than 15%.</p></li><li><p>Have one person handle fundraising (if you have 2 founders, the other one can focus on working on the company). The person who handles this should be the CEO.</p></li><li><p>You'll need an executive summary (one-page paper describing in simple language what you plan to do) and (maybe) a deck.</p></li><li><p>Don&#8217;t get addicted to fundraising: you should be listening to your users, not focusing on raising money. Also, don&#8217;t raise too much money.</p></li></ul><p>This ends part 1 of this series. You can find part 2 below:</p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;c6cbe3bf-75c5-47e5-a14e-50562ba6c7fd&quot;,&quot;caption&quot;:&quot;Let&#8217;s continue on with exploring the recommended readings / material available in Sam Altman&#8217;s how to start a startup notes available here. You can find part 1 of this series below.Thanks for reading Photon-Lines Substack! Subscribe for free to receive new posts and support my work.&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;md&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Sam Altman's Startup Advice (Part 2)&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:120792961,&quot;name&quot;:&quot;Nick M&quot;,&quot;bio&quot;:&quot;I'm a software engineer who loves explaining complex topics in an intuitive and simple manner. Some of my favorite subjects are software, applied mathematics, and particle physics. &quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/83a4601e-abc1-4dae-9417-4b0461a758cc_600x408.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2024-02-02T16:32:13.767Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/vimeo/w_728,c_limit,d_video_placeholder.png/34081566&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://photonlines.substack.com/p/sam-altmans-startup-advice-part-2&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:141241745,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:0,&quot;comment_count&quot;:0,&quot;publication_id&quot;:null,&quot;publication_name&quot;:&quot;Photon-Lines Substack&quot;,&quot;publication_logo_url&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%2Fd23c96bd-e136-4004-96c4-318b52a9538f_408x408.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://photonlines.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Photon-Lines Substack! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item></channel></rss>