<script data-pm-proxy="intercept"></script><?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[GraphicMaths Newsletter]]></title><description><![CDATA[Maths articles and videos]]></description><link>https://graphicmaths.substack.com</link><image><url>https://substackcdn.com/image/fetch/$s_!MhhS!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fgraphicmaths.substack.com%2Fimg%2Fsubstack.png</url><title>GraphicMaths Newsletter</title><link>https://graphicmaths.substack.com</link></image><generator>Substack</generator><lastBuildDate>Tue, 01 Sep 2026 09:18:49 GMT</lastBuildDate><atom:link href="/__u/graphicmaths.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Martin McBride]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[graphicmaths@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[graphicmaths@substack.com]]></itunes:email><itunes:name><![CDATA[Martin McBride]]></itunes:name></itunes:owner><itunes:author><![CDATA[Martin McBride]]></itunes:author><googleplay:owner><![CDATA[graphicmaths@substack.com]]></googleplay:owner><googleplay:email><![CDATA[graphicmaths@substack.com]]></googleplay:email><googleplay:author><![CDATA[Martin McBride]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Advanced graphing features in generativepy]]></title><description><![CDATA[generativepy is an open-source Python drawing library for creating computer images, diagrams, and animations.]]></description><link>https://graphicmaths.substack.com/p/advanced-graphing-features-in-generativepy</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/advanced-graphing-features-in-generativepy</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Tue, 25 Aug 2026 11:41:58 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!qTGe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64ae8456-1dd5-4c20-99e2-bf012b1cba4c_500x350.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>generativepy is an open-source Python drawing library for creating computer images, diagrams, and animations. It can be found on <a href="https://github.com/martinmcbride/generativepy">github</a>. This article covers generativepy V50.00, although much of it will also apply to older or newer versions.</p><p>The graph module was introduced in the <a href="https://graphicmaths.com/generativepy/generativepy-book/graphs/">graphs in generativepy tutorial</a>. In this tutorial, we will cover some more advanced techniques:</p><ul><li><p>Converting graph coordinates into drawing coordinates</p></li><li><p>Drawing and labelling points on a graph</p></li><li><p>Drawing lines and tangents</p></li><li><p>Showing discontinuities of a function</p></li><li><p>Filling graphs</p></li><li><p>Highlighting sections of a graph</p></li></ul><h2>Converting graph coordinates into drawing coordinates</h2><p>This graph shows the sine function. It also has a blue dot and a text label &#8220;Max&#8221; at a specific point on the curve:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!aSE8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3442648c-94ef-46ab-8f9b-875585b573fa_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!aSE8!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3442648c-94ef-46ab-8f9b-875585b573fa_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!aSE8!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3442648c-94ef-46ab-8f9b-875585b573fa_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!aSE8!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3442648c-94ef-46ab-8f9b-875585b573fa_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!aSE8!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3442648c-94ef-46ab-8f9b-875585b573fa_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!aSE8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3442648c-94ef-46ab-8f9b-875585b573fa_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3442648c-94ef-46ab-8f9b-875585b573fa_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Point on graph&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&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="Point on graph" title="Point on graph" srcset="/__u/substackcdn.com/image/fetch/$s_!aSE8!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3442648c-94ef-46ab-8f9b-875585b573fa_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!aSE8!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3442648c-94ef-46ab-8f9b-875585b573fa_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!aSE8!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3442648c-94ef-46ab-8f9b-875585b573fa_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!aSE8!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3442648c-94ef-46ab-8f9b-875585b573fa_500x350.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 aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 point marks the graph&#8217;s maximum value. The graph represents the sine function. We know that the sine function has a maximum value of 1 when <em>x</em> is <em>pi/2</em>. So we would like to draw a point at <em>(pi/2, 1)</em>. But how do we do that?</p><p>The point is simply a circle filled with blue. We know how to draw a circle, but we set its position using pixel coordinates. But the point <em>(pi/2, 1)</em> is expressed in terms of the graph coordinates. Which pixel is at the centre of the circle? Well, the <code>Axes</code> object used to draw the graph has a useful function that converts graph coordinates into pixel positions:</p><pre><code><code>    p = (math.pi/2, f(math.pi/2))
    pixel_p = axes.transform_from_graph(p)
</code></code></pre><p>Next, we&#8217;ll see how to draw the point and label it.</p><h2>Drawing and labelling points on a graph</h2><p>The graph is similar to the example given in the <a href="https://graphicmaths.com/generativepy/generativepy-book/graphs/">graph article</a>. Here is the full code that draws the graph and also adds the blue point and text:</p><pre><code><code>import math
from generativepy.color import Color
from generativepy.drawing import setup, make_image
from generativepy.geometry import Circle, Text
from generativepy.graph import Axes, Plot


def draw(ctx, width, height, fn, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    f = lambda x: math.sin(x)

    axes = (Axes(ctx, (50, 50), 400, 250).of_start((0, -1.5))
                                         .of_extent((8,3))
                                         .with_divisions((1, 0.5)))
    axes.draw()
    Plot(axes).of_function(f).stroke(Color(1, 0, 0), 3)

    # Add point and text label
    p = (math.pi/2, f(math.pi/2))
    pixel_p = axes.transform_from_graph(p)
    Circle(ctx).of_center_radius(pixel_p, 6).fill(Color("blue"))
    (Text(ctx).of("Max", pixel_p).offset(10, -10).font("Ariel")
             .size(20).fill(Color("black")))


make_image("plot-graph-point.png", draw, 500, 350)
</code></code></pre><p>The additional code first creates point <em>p</em> at <em>(pi/2, 1)</em>, then calculates its position in pixel coordinates, <em>pixel_p</em>. This code was shown in the previous section.</p><p>We draw the blue point like this:</p><pre><code><code>    Circle(ctx).of_center_radius(pixel_p, 6).fill(Color("blue"))
</code></code></pre><p>This is a circle centered at <em>pixel_p</em>and colored blue. We give the circle a radius of 6, which seems to be a sensible size for the diagram. Notice that the radius is also measured in pixel coordinates rather than graph coordinates. So the circle has a radius of 6 pixels.</p><p>We draw the text label like this:</p><pre><code><code>    Text(ctx).of("Max", pixel_p).offset(10, -10).font("Ariel")
             .size(20).fill(Color("black"))
</code></code></pre><p>We use the <code>Text</code> object in the usual way. Again, we use the pixel position <code>pixel_p</code> to position the text. We use an <code>offset</code> of 10 pixels to the right and 10 pixels up to move the text slightly away from the point, and we set the text size to 20 pixels. You can choose your own values, but they look about right.</p><h2>Drawing lines and tangents</h2><p>We sometimes need to draw additional lines on a graph. Here are a couple of examples:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!qTGe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64ae8456-1dd5-4c20-99e2-bf012b1cba4c_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!qTGe!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64ae8456-1dd5-4c20-99e2-bf012b1cba4c_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!qTGe!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64ae8456-1dd5-4c20-99e2-bf012b1cba4c_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!qTGe!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64ae8456-1dd5-4c20-99e2-bf012b1cba4c_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qTGe!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64ae8456-1dd5-4c20-99e2-bf012b1cba4c_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!qTGe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64ae8456-1dd5-4c20-99e2-bf012b1cba4c_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/64ae8456-1dd5-4c20-99e2-bf012b1cba4c_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Lines on graph&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="Lines on graph" title="Lines on graph" srcset="/__u/substackcdn.com/image/fetch/$s_!qTGe!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64ae8456-1dd5-4c20-99e2-bf012b1cba4c_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!qTGe!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64ae8456-1dd5-4c20-99e2-bf012b1cba4c_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!qTGe!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64ae8456-1dd5-4c20-99e2-bf012b1cba4c_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qTGe!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64ae8456-1dd5-4c20-99e2-bf012b1cba4c_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 green line is a simple horizontal line. The blue line is a tangent to the curve, which requires slightly more work, but it isn&#8217;t too complicated. Here is the full code:</p><pre><code><code>import math
from generativepy.color import Color
from generativepy.drawing import setup, make_image
from generativepy.geometry import Line
from generativepy.graph import Axes, Plot
from generativepy.math import Vector as V

def draw(ctx, width, height, fn, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    f = lambda x: math.sin(x)
    fd = lambda x: math.cos(x)

    axes = (Axes(ctx, (50, 50), 400, 250).of_start((0, -1.5))
                                         .of_extent((8,3))
                                         .with_divisions((1, 0.5)))
    axes.draw()
    Plot(axes).of_function(f).stroke(Color(1, 0, 0), 3)

    # Add horizontal line
    p1 = (3, -0.8)
    p2 = (7, -0.8)
    pixel_p1 = axes.transform_from_graph(p1)
    pixel_p2 = axes.transform_from_graph(p2)
    (Line(ctx).of_start_end(pixel_p1, pixel_p2)
              .stroke(Color("darkgreen"), 3))

    # Draw tangent
    x = 2.1
    p = V(x, f(x))
    slope = fd(x)
    angle = math.atan(slope)
    delta = V.polar(1, angle)
    pixel_p1 = axes.transform_from_graph(p + delta)
    pixel_p2 = axes.transform_from_graph(p - delta)
    (Line(ctx).of_start_end(pixel_p1, pixel_p2)
              .stroke(Color("blue"), 3))

make_image("plot-graph-line.png", draw, 500, 350)
</code></code></pre><p>Drawing the green, horizontal line is quite easy. The line joins the two points (3, -0.8) and (7, -0.8), expressed in graph coordinates. We convert those two points to pixel coordinates and draw a line between them. Here is the section of the above code that draws the line:</p><pre><code><code>    # Add horizontal line
    p1 = (3, -0.8)
    p2 = (7, -0.8)
    pixel_p1 = axes.transform_from_graph(p1)
    pixel_p2 = axes.transform_from_graph(p2)
    (Line(ctx).of_start_end(pixel_p1, pixel_p2)
              .stroke(Color("darkgreen"), 3))
</code></code></pre><p>The blue line is a tangent to the curve at <em>x = 2.1</em>. To create this, we first need to find the slope of the curve. It is helpful to know the derivative of the curve. Since the function <em>f</em> is <em>sin(x)</em>, we know from high school maths that the derivative <em>fd</em> is <em>cos(x)</em>. We define the function <em>fd</em> at the start of the <code>draw</code> function. Here is the part of the code that finds the tangent:</p><pre><code><code>    x = 2.1
    p = V(x, f(x))
    slope = fd(x)
</code></code></pre><p>Point <em>p</em> is the point where the tangent touches the curve. Notice that we have defined the point <em>p</em> as a <code>Vector</code>, aliased as <code>V</code>. This lets us use vector operations to find the tangent line&#8217;s endpoints.</p><p>Next, we find the two end points of the tangent line:</p><pre><code><code>    angle = math.atan(slope)
    delta = V.polar(1, angle)
</code></code></pre><p><em>angle</em> is the angle that the tangent line makes with the x-axis. We calculate it by taking the inverse tangent of the slope (the <em>atan</em> function).</p><p><em>delta</em> is a vector, of length 1, that points in the direction of the tangent line. We do this by defining a vector in polar form, with a modulus of 1 and an argument of <em>angle</em>.</p><p>The vector <em>p + delta</em> gives a point that is on that tangent line, distance 1 from <em>p</em>. And <em>p - delta</em> gives a point that is on that tangent line, distance 1 from <em>p</em> in the opposite direction. If we convert those two points to pixel coordinates, then draw a line between them, we will draw a tangent line of length 2:</p><pre><code><code>    pixel_p1 = axes.transform_from_graph(p + delta)
    pixel_p2 = axes.transform_from_graph(p - delta)
    (Line(ctx).of_start_end(pixel_p1, pixel_p2)
              .stroke(Color("blue"), 3))
</code></code></pre><h2>Showing discontinuities of a function</h2><p>If a function has a discontinuity, it often needs slightly special handling. For example, consider this function:</p><pre><code><code>lambda f(x): 0 if x &lt;= 3 else 1
</code></code></pre><p>This function has a value of 0 when <em>x</em> is less than or equal to 3, and 1 otherwise. There is a step change at <em>x = 0</em>, where the function goes from 0 to 1, without ever taking a value between 0 and 1.</p><p>However, if we plot this function in the usual way, we get something like this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!vWZz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6fae35f-7cd2-4f84-9733-cdec94b7c7b7_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!vWZz!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6fae35f-7cd2-4f84-9733-cdec94b7c7b7_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!vWZz!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6fae35f-7cd2-4f84-9733-cdec94b7c7b7_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!vWZz!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6fae35f-7cd2-4f84-9733-cdec94b7c7b7_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!vWZz!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6fae35f-7cd2-4f84-9733-cdec94b7c7b7_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!vWZz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6fae35f-7cd2-4f84-9733-cdec94b7c7b7_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f6fae35f-7cd2-4f84-9733-cdec94b7c7b7_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Discontinuities&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="Discontinuities" title="Discontinuities" srcset="/__u/substackcdn.com/image/fetch/$s_!vWZz!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6fae35f-7cd2-4f84-9733-cdec94b7c7b7_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!vWZz!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6fae35f-7cd2-4f84-9733-cdec94b7c7b7_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!vWZz!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6fae35f-7cd2-4f84-9733-cdec94b7c7b7_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!vWZz!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6fae35f-7cd2-4f84-9733-cdec94b7c7b7_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 problem here is that the <code>Plot</code> object calculates the value of the function at lots of different points, and then joins all those points together. So at <em>x = 3</em> it doesn&#8217;t show a discontinuity. Instead, it shows a step function, which isn&#8217;t usually what we want.</p><p>What we really want is something like this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!2axn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff43b86f3-79e0-4080-8620-d2a914ff81f1_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!2axn!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff43b86f3-79e0-4080-8620-d2a914ff81f1_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!2axn!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff43b86f3-79e0-4080-8620-d2a914ff81f1_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!2axn!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff43b86f3-79e0-4080-8620-d2a914ff81f1_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!2axn!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff43b86f3-79e0-4080-8620-d2a914ff81f1_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!2axn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff43b86f3-79e0-4080-8620-d2a914ff81f1_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f43b86f3-79e0-4080-8620-d2a914ff81f1_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Discontinuities&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="Discontinuities" title="Discontinuities" srcset="/__u/substackcdn.com/image/fetch/$s_!2axn!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff43b86f3-79e0-4080-8620-d2a914ff81f1_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!2axn!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff43b86f3-79e0-4080-8620-d2a914ff81f1_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!2axn!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff43b86f3-79e0-4080-8620-d2a914ff81f1_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!2axn!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff43b86f3-79e0-4080-8620-d2a914ff81f1_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 this graph, the two sections are disconnected to indicate that the function changes from 0 to 1 without taking any intermediate values. We have also drawn an open circle at point (3, 1). This indicates that the value of the function is 0 when <em>x</em> is 3. The function equals 1 for any value of <em>x</em> greater than 3, so the top line gets infinitesimally close to (3, 1) but never reaches it.</p><p>Here is the code to draw the correct graph:</p><pre><code><code>from generativepy.color import Color
from generativepy.drawing import setup, make_image
from generativepy.geometry import Circle, Text
from generativepy.graph import Axes, Plot

def draw(ctx, width, height, fn, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    f = lambda x: 0 if x &lt;= 3 else 1

    axes = (Axes(ctx, (50, 50), 400, 250).of_start((0, -1.5))
                                         .of_extent((8,3))
                                         .with_divisions((1, 0.5)))
    axes.draw()

    (Plot(axes).of_function(f, extent=(0, 2.9999))
               .stroke(Color(1, 0, 0), 3))
    (Plot(axes).of_function(f, extent=(3.0001, 8))
               .stroke(Color(1, 0, 0), 3))

    p = (3, 1)
    pixel_p = axes.transform_from_graph(p)
    (Circle(ctx).of_center_radius(pixel_p, 4).fill(Color("white"))
                                            .stroke(Color(1, 0, 0), 3))

make_image("plot-graph-discont.png", draw, 500, 350)
</code></code></pre><p>As you can see, we plot the function twice. The first plot is limited to the range 0 to 2.9999, using the <code>extent</code> parameter, so it plots the portion of the graph where the function is 0. The range starts at 0 because that is the start of the x-axis, and it extends to 2.9999 because that value is so close to 3 that it looks like the graph reaches 3, but the function does not change to 1.</p><p>The second plot is limited to the range 3.0001 to 8, so it plots the portion of the graph where the function is 1. The range starts at a value slightly above 3, but by so small an amount that it isn&#8217;t visible on the graph. It extends to 8, which is the end of the x-axis.</p><p>Notice that we don&#8217;t need to convert these values to pixel coordinates, because we are passing them into <code>Plot.of_function</code>, which already uses graph coordinates.</p><p>The open circle is created using a <code>Circle</code> object, in the same way that we previously marked a point in the graph. We need to convert the point (3, 1) to pixel coordinates, as before. To create the empty circle, we stroke it with the same color we used for the plot (red) and fill it with the same color as the graph background (white).</p><h2>Highlighting sections of a graph</h2><p>It is sometimes useful to highlight a section of a graph, like this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Xvlq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F049361e3-5e86-453e-a77b-84dcadf0a120_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Xvlq!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F049361e3-5e86-453e-a77b-84dcadf0a120_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!Xvlq!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F049361e3-5e86-453e-a77b-84dcadf0a120_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!Xvlq!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F049361e3-5e86-453e-a77b-84dcadf0a120_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Xvlq!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F049361e3-5e86-453e-a77b-84dcadf0a120_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Xvlq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F049361e3-5e86-453e-a77b-84dcadf0a120_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/049361e3-5e86-453e-a77b-84dcadf0a120_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Higlighting a section&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="Higlighting a section" title="Higlighting a section" srcset="/__u/substackcdn.com/image/fetch/$s_!Xvlq!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F049361e3-5e86-453e-a77b-84dcadf0a120_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!Xvlq!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F049361e3-5e86-453e-a77b-84dcadf0a120_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!Xvlq!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F049361e3-5e86-453e-a77b-84dcadf0a120_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Xvlq!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F049361e3-5e86-453e-a77b-84dcadf0a120_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 is quite easy to do. We first plot the graph normally (the red curve), then plot the highlighted region (<em>x</em> from 1 to 5) using a thicker blue line. Here is the plotting code:</p><pre><code><code>    a = 1
    b = 5
    Plot(axes).of_function(f).stroke(Color(1, 0, 0), 3)
    Plot(axes).of_function(f, extent=(a, b)).stroke(Color("darkblue"), 5)
</code></code></pre><p>A slight variation on this is to plot the thicker highlight region first, then plot the main curve on top. This often works best with a lighter highlight color and a dark main color:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!JUey!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faa26e3-c84d-4098-9088-24afa8dda11a_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!JUey!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faa26e3-c84d-4098-9088-24afa8dda11a_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!JUey!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faa26e3-c84d-4098-9088-24afa8dda11a_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!JUey!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faa26e3-c84d-4098-9088-24afa8dda11a_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!JUey!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faa26e3-c84d-4098-9088-24afa8dda11a_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!JUey!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faa26e3-c84d-4098-9088-24afa8dda11a_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7faa26e3-c84d-4098-9088-24afa8dda11a_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Higlighting a section&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="Higlighting a section" title="Higlighting a section" srcset="/__u/substackcdn.com/image/fetch/$s_!JUey!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faa26e3-c84d-4098-9088-24afa8dda11a_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!JUey!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faa26e3-c84d-4098-9088-24afa8dda11a_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!JUey!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faa26e3-c84d-4098-9088-24afa8dda11a_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!JUey!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7faa26e3-c84d-4098-9088-24afa8dda11a_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Filling graphs</h2><p>We fill a graph by <em>closing it</em>, to make a closed shape. We do that with the <code>close</code> parameter of the <code>of_function</code> call. Here is the complete code:</p><pre><code><code>import math
from generativepy.color import Color
from generativepy.drawing import setup, make_image
from generativepy.graph import Axes, Plot

def draw(ctx, width, height, fn, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    f = lambda x: math.sin(x)

    axes = (Axes(ctx, (50, 50), 400, 250).of_start((0, -1.5))
                                         .of_extent((8,3))
                                         .with_divisions((1, 0.5)))
    axes.draw()

    a = 1
    b = 2.5
    (Plot(axes).of_function(f, extent=(a, b), close=((b, 0), (a, 0)))
               .fill(Color("red").with_a(0.5))
               .stroke(Color(1, 0, 0), 3))

make_image("plot-fill.png", draw, 500, 350)
</code></code></pre><p>In this code, we plot a graph of <em>f</em> between <em>x</em> values of <em>a</em> and <em>b</em>. But we also add two extra points, using the <code>close</code> parameter:</p><ul><li><p>The point <em>(b, 0)</em> is on the x-axis directly below the end of the curve segment.</p></li><li><p>The point <em>(a, 0)</em> is on the x-axis directly below the start of the curve segment.</p></li></ul><p>These are shown here:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!d45Q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70f73f1c-63f2-4af2-aaff-913c1fdd7210_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!d45Q!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70f73f1c-63f2-4af2-aaff-913c1fdd7210_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!d45Q!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70f73f1c-63f2-4af2-aaff-913c1fdd7210_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!d45Q!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70f73f1c-63f2-4af2-aaff-913c1fdd7210_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!d45Q!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70f73f1c-63f2-4af2-aaff-913c1fdd7210_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!d45Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70f73f1c-63f2-4af2-aaff-913c1fdd7210_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/70f73f1c-63f2-4af2-aaff-913c1fdd7210_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Filling a graph&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="Filling a graph" title="Filling a graph" srcset="/__u/substackcdn.com/image/fetch/$s_!d45Q!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70f73f1c-63f2-4af2-aaff-913c1fdd7210_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!d45Q!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70f73f1c-63f2-4af2-aaff-913c1fdd7210_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!d45Q!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70f73f1c-63f2-4af2-aaff-913c1fdd7210_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!d45Q!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70f73f1c-63f2-4af2-aaff-913c1fdd7210_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 the <code>close</code> parameter, the <code>Plot</code> object adds some extra lines to create a closed shape:</p><ul><li><p>It adds a line from the endpoint of the graph to the first point in the close list, which is <em>(b, 0)</em> in our case.</p></li><li><p>It adds a line from the first point of the close list to the second point in the close list, which is <em>(a, 0)</em> in our case.</p></li><li><p>If the close list had more elements, they would also be joined, but in our case there are only the elements.</p></li><li><p>Finally, it adds a line from the last point in the close list, which is <em>(a, 0)</em> in our case, back to the start of the curve.</p></li></ul><p>This creates a closed shape which we can outline and fill. Here is the final result of the original code above:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Nv6S!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7656d0d-fc34-4123-bc72-40039b24b351_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Nv6S!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7656d0d-fc34-4123-bc72-40039b24b351_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!Nv6S!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7656d0d-fc34-4123-bc72-40039b24b351_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!Nv6S!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7656d0d-fc34-4123-bc72-40039b24b351_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Nv6S!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7656d0d-fc34-4123-bc72-40039b24b351_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Nv6S!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7656d0d-fc34-4123-bc72-40039b24b351_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a7656d0d-fc34-4123-bc72-40039b24b351_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Filling a graph&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="Filling a graph" title="Filling a graph" srcset="/__u/substackcdn.com/image/fetch/$s_!Nv6S!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7656d0d-fc34-4123-bc72-40039b24b351_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!Nv6S!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7656d0d-fc34-4123-bc72-40039b24b351_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!Nv6S!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7656d0d-fc34-4123-bc72-40039b24b351_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Nv6S!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7656d0d-fc34-4123-bc72-40039b24b351_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>One thing to notice is that we have used a transparent fill color <code>Color("red").with_a(0.5)</code>. This is red but 50% transparent. That is optional, of course, but it can look nice because the graph grid lines show through the fill.</p><p>There are a couple of useful variants. You might prefer to fill the curve without any additional outlines, like this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Rb1t!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4c4aba2-c417-463d-ab24-f682ec28594a_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Rb1t!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4c4aba2-c417-463d-ab24-f682ec28594a_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!Rb1t!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4c4aba2-c417-463d-ab24-f682ec28594a_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!Rb1t!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4c4aba2-c417-463d-ab24-f682ec28594a_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Rb1t!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4c4aba2-c417-463d-ab24-f682ec28594a_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Rb1t!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4c4aba2-c417-463d-ab24-f682ec28594a_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e4c4aba2-c417-463d-ab24-f682ec28594a_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Filling a graph&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="Filling a graph" title="Filling a graph" srcset="/__u/substackcdn.com/image/fetch/$s_!Rb1t!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4c4aba2-c417-463d-ab24-f682ec28594a_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!Rb1t!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4c4aba2-c417-463d-ab24-f682ec28594a_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!Rb1t!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4c4aba2-c417-463d-ab24-f682ec28594a_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Rb1t!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4c4aba2-c417-463d-ab24-f682ec28594a_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 do this by plotting the graph twice. The first time, we close the graph and fill it, but we don&#8217;t stroke it. The second time, we plot the graph without closing it, and this time we stroke the graph without filling it (i.e., we plot the graph normally). Here is the plotting code:</p><pre><code><code>    (Plot(axes).of_function(f, extent=(a, b), close=((b, 0), (a, 0)))
               .fill(Color("red").with_a(0.5)))
    (Plot(axes).of_function(f, extent=(a, b))
               .stroke(Color(1, 0, 0), 3))
</code></code></pre><p>You might also want to plot the graph across the full axis width, like this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!PO1z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57564dff-a5ff-4bfd-891c-b9301b4a1a0d_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!PO1z!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57564dff-a5ff-4bfd-891c-b9301b4a1a0d_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!PO1z!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57564dff-a5ff-4bfd-891c-b9301b4a1a0d_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!PO1z!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57564dff-a5ff-4bfd-891c-b9301b4a1a0d_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!PO1z!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57564dff-a5ff-4bfd-891c-b9301b4a1a0d_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!PO1z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57564dff-a5ff-4bfd-891c-b9301b4a1a0d_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/57564dff-a5ff-4bfd-891c-b9301b4a1a0d_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Filling a graph&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="Filling a graph" title="Filling a graph" srcset="/__u/substackcdn.com/image/fetch/$s_!PO1z!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57564dff-a5ff-4bfd-891c-b9301b4a1a0d_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!PO1z!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57564dff-a5ff-4bfd-891c-b9301b4a1a0d_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!PO1z!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57564dff-a5ff-4bfd-891c-b9301b4a1a0d_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!PO1z!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57564dff-a5ff-4bfd-891c-b9301b4a1a0d_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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, set <em>a</em> and <em>b</em> to the start and end of the axes (0 and 8 in this case).</p>]]></content:encoded></item><item><title><![CDATA[Vector drawing with generativepy]]></title><description><![CDATA[generativepy is an open-source Python drawing library that can create computer images, diagrams, and animations.]]></description><link>https://graphicmaths.substack.com/p/vector-drawing-with-generativepy-60b</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/vector-drawing-with-generativepy-60b</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Fri, 21 Aug 2026 12:54:12 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!THrU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ca4737c-4521-4bb0-8e41-92e3545ef259_600x350.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>generativepy is an open-source Python drawing library that can create computer images, diagrams, and animations. It can be found on <a href="https://github.com/martinmcbride/generativepy">github</a>. This article covers generativepy V50.00, although much of it will also apply to older or newer versions.</p><p>This chapter covers the basics of creating vector images with generativepy. It provides a simple template for drawing vector images using the <code>drawing</code> module. It also shows how to use the <code>geometry</code> module to draw various shapes and style them.</p><p>generativepy can also create bitmap images, NumPy-based images, 3D images, and videos. We cover these in later tutorials, but the basic process is similar in all cases.</p><h2>Vector images</h2><p>A computer image is often stored as a 2-dimensional array of pixels, where each pixel can be any colour. This is called a bitmap image.</p><p>However, with vector graphics, we don&#8217;t usually specify the colours of individual pixels. Instead, we work at a higher level, defining shapes in the image. These can be simple shapes, such as rectangles, or more complex shapes, such as text characters.</p><p>When we use generativepy in vector mode, our program specifies a shape and how to fill and outline it. The generativepy library decides the colour of each pixel.</p><p>The result is still a bitmap image file, in PNG format. However, your code describes the image in terms of shapes rather than pixels, which is more useful for mathematical images.</p><p>In this article, we will look at:</p><ul><li><p>The generativepy coordinate system</p></li><li><p>Drawing basic shapes (such as lines, polygons, circles, and more).</p></li><li><p>Fill and outline styles.</p></li></ul><p>Vector graphics also include more advanced features, such as compound shapes (e.g., shapes with holes), complex curves, and clipping. We will look at these in a later chapter. There are also specialised techniques for mathematical diagrams, such as creating geometric diagrams and graphs, which we will cover in a later chapter.</p><h2>Creating our first image</h2><p>To start, we will create the following simple image, as a 500 by 400 pixel PNG file, consisting of an orange rectangle on a grey background:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!KvC-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa07f38f8-9d76-4fc4-95ff-7c73a3298aee_500x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!KvC-!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa07f38f8-9d76-4fc4-95ff-7c73a3298aee_500x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!KvC-!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa07f38f8-9d76-4fc4-95ff-7c73a3298aee_500x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!KvC-!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa07f38f8-9d76-4fc4-95ff-7c73a3298aee_500x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!KvC-!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa07f38f8-9d76-4fc4-95ff-7c73a3298aee_500x400.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!KvC-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa07f38f8-9d76-4fc4-95ff-7c73a3298aee_500x400.png" width="500" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a07f38f8-9d76-4fc4-95ff-7c73a3298aee_500x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Rectangle&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="Rectangle" title="Rectangle" srcset="/__u/substackcdn.com/image/fetch/$s_!KvC-!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa07f38f8-9d76-4fc4-95ff-7c73a3298aee_500x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!KvC-!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa07f38f8-9d76-4fc4-95ff-7c73a3298aee_500x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!KvC-!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa07f38f8-9d76-4fc4-95ff-7c73a3298aee_500x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!KvC-!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa07f38f8-9d76-4fc4-95ff-7c73a3298aee_500x400.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Before you try this code, you will need to install generativepy and its dependencies, see the <a href="https://graphicmaths.com/generativepy/generativepy-book/introduction/">introduction</a></p><h2>The code</h2><p>Here is the code to draw the image above:</p><pre><code><code>from generativepy.color import Color
from generativepy.drawing import setup, make_image
from generativepy.geometry import Rectangle

def draw(ctx, width, height, frame_no, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(%22grey%22))
    Rectangle(ctx).of_corner_size((100, 150), 250, 200).fill(Color("orange"))

make_image("rectangle.png", draw, 500, 400)
</code></code></pre><p>We will now look at this code in more detail.</p><h2>Basic structure</h2><p>The basic structure of the code is:</p><ul><li><p>A user-defined function <code>draw</code> that does the drawing.</p></li><li><p>A call to <code>make_image</code>. This function creates an image and saves it to a file. We pass in the <code>draw</code> function to control the image content.</p></li></ul><p>This basic structure is used throughout generativepy. We use a <code>draw</code> function to create the drawing, and a <code>make_XXX</code> function to create the image. We use the same pattern for bitmap images, NumPy-based images, and 3D images. We use the same pattern whether we are creating still images, animated GIFs, image sequences, or videos.</p><p>In all cases, images are stored in memory as &#8220;frames&#8221;. A frame is a NumPy array containing the pixel data. This makes the library flexible, as you can combine images from different sources using simple Python and NumPy functions.</p><p>For vector images, like this one, generativepy uses the Pycairo library behind the scenes. In fact, <code>ctx</code> is a Pycairo <em>drawing context</em>.</p><h2>make_image</h2><p>The <code>make_image</code> function in the <a href="https://graphicmaths.com/api/generativepy/drawing.html">drawing</a> module is the main function for creating vector images.</p><p>The parameters are:</p><ul><li><p><code>outfile</code>, the filename of the output PNG file.</p></li><li><p>A <code>draw</code> function that does the actual drawing.</p></li><li><p>The <code>width</code> and <code>height</code> of the image in pixels.</p></li><li><p>An optional <code>channels</code> parameter that is mainly used for creating images with transparency.</p></li></ul><p>The <code>draw</code> function is one we define ourselves to draw the image. It doesn&#8217;t have to be called <code>draw</code>, of course - you can call it whatever you like, provided you pass its name into <code>make_image</code>. The <code>draw</code> function must have the correct <em>signature</em> (in other words, it must accept the parameters described below).</p><h2>draw function</h2><p>The <code>draw</code> function draws the image content. We never call <code>draw</code> ourselves. We always pass <code>draw</code> into <code>make_image</code>, and <code>make_image</code> calls <code>draw</code>. The <code>draw</code> function accepts 5 parameters:</p><ul><li><p><code>ctx</code> is a Pycairo <em>context</em>. This is like a virtual drawing surface that you can draw on in code. Whatever you draw will appear on the final image.</p></li><li><p><code>width</code> and <code>height</code> are the width and height of the image in pixels. These are the values that we passed into <code>make_image</code>.</p></li><li><p><code>frame_no</code> and <code>frame_count</code> are only used when you want to create image sequences (for animations), so we can ignore them here.</p></li></ul><p>generativepy uses Pycairo as its drawing library. generativepy provides a rich set of high-level drawing functions for creating shapes, text, markers, graphs, and formulas that can be added to the image within the draw function</p><p>The generativepy drawing functions are built on top of the normal Pycairo functions. If you are familiar with Pycairo, it is also possible to use the Pycairo functions directly, or even to use a mixture of generativepy and Pycairo calls. Usually, though, it is better to stick with the generativepy functions as they operate at a higher level and are designed specifically for maths and diagrams.</p><p>Our <code>draw</code> function calls the <code>setup</code> function to set up the drawing area, then draws a rectangle.</p><h2>setup function</h2><p>The <code>setup</code> function isn&#8217;t mandatory, but it does some useful things, so you will often want to call it.</p><p><code>setup</code> has 3 required parameters: <code>ctx</code>, <code>width</code> and <code>height</code>. We use the values that were passed into the <code>draw</code> function. It has some optional parameters that do various things, described below.</p><p>In this case, we are setting the <code>background</code> parameter to <code>Color("grey")</code>, which sets the background colour to a mid-grey. We define the colour using the <a href="https://graphicmaths.com/api/generativepy/color.html">color module</a> of generativepy. In this example, we are using colour names to select colours. These names are based on the CSS named colours. The color module has much more functionality, described in a later chapter.</p><h2>Drawing a rectangle</h2><p>We use a <code>Rectangle</code> object to draw a rectangle, like this:</p><pre><code><code>Rectangle(ctx).of_corner_size((100, 150), 250, 200).fill(Color("orange"))
</code></code></pre><p>All shapes are drawn using the same pattern:</p><ul><li><p>Declare a shape object, for example <code>Rectangle(ctx)</code>, passing in the context, <code>ctx</code>.</p></li><li><p>An <em>of_xxx</em> method is used to define the shape. In this case, <code>of_corner_size</code> defines a rectangle from the position of its top, left-hand corner, and its width and height. The corner is specified using an <code>(x, y)</code> tuple.</p></li><li><p>A drawing method is then used to draw the shape. In this case, we use <code>fill</code>, which fills the shape with orange.</p></li></ul><h2>Coordinate system</h2><p>All coordinates and sizes are specified in <em>user space</em> coordinates.</p><p>By default, user space is measured in pixels, based on the size of the image we are creating.</p><ul><li><p>The origin of the user space coordinate system (0, 0) is at the top left of the image.</p></li><li><p>x values increase from left to right.</p></li><li><p>y values increase as you move down the image.</p></li></ul><p>In our case:</p><ul><li><p>Our image is 500 by 400 pixels.</p></li><li><p>The orange rectangle is 250 by 200 pixels.</p></li><li><p>The position of the rectangle (that is, the position of its top-left corner) is at pixel position (100, 150).</p></li></ul><p>This diagram illustrates the coordinates of the rectangle:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!qcfK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a57260d-191f-4fe0-94df-1ef593b11531_600x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!qcfK!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a57260d-191f-4fe0-94df-1ef593b11531_600x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!qcfK!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a57260d-191f-4fe0-94df-1ef593b11531_600x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!qcfK!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a57260d-191f-4fe0-94df-1ef593b11531_600x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qcfK!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a57260d-191f-4fe0-94df-1ef593b11531_600x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!qcfK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a57260d-191f-4fe0-94df-1ef593b11531_600x500.png" width="600" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0a57260d-191f-4fe0-94df-1ef593b11531_600x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:600,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Coordinates&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="Coordinates" title="Coordinates" srcset="/__u/substackcdn.com/image/fetch/$s_!qcfK!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a57260d-191f-4fe0-94df-1ef593b11531_600x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!qcfK!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a57260d-191f-4fe0-94df-1ef593b11531_600x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!qcfK!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a57260d-191f-4fe0-94df-1ef593b11531_600x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qcfK!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a57260d-191f-4fe0-94df-1ef593b11531_600x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>User space can be <em>transformed</em>, so that shapes drawn in user space can be scaled, rotated, etc when they are drawn, as we will see in a later tutorial.</p><h2>Styling shapes</h2><p>Now that we have seen how to draw a simple shape, we&#8217;ll look at how to style shapes by filling and outlining them. This can add clarity to diagrams by using colour to link related items. Colour can also make your images more interesting and appealing.</p><p>Of course, when designing graphics we should always be aware that some of our intended audience might not be able to see colour differences clearly due to colour vision deficiency (so-called colour blindness) or other visual impairments. It is always a good idea to use light and dark colours, different shapes, dashed vs solid lines, and text labelling, in addition to pure colour, to make your diagrams accessible.</p><h2>Filling shapes</h2><p>We have already seen how to fill a shape, but here is another example with 3 shapes:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!GLi7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff953e96d-1c1f-4fd2-9310-a91beab922f5_500x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!GLi7!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff953e96d-1c1f-4fd2-9310-a91beab922f5_500x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!GLi7!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff953e96d-1c1f-4fd2-9310-a91beab922f5_500x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!GLi7!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff953e96d-1c1f-4fd2-9310-a91beab922f5_500x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!GLi7!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff953e96d-1c1f-4fd2-9310-a91beab922f5_500x400.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!GLi7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff953e96d-1c1f-4fd2-9310-a91beab922f5_500x400.png" width="500" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f953e96d-1c1f-4fd2-9310-a91beab922f5_500x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Filling shapes&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="Filling shapes" title="Filling shapes" srcset="/__u/substackcdn.com/image/fetch/$s_!GLi7!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff953e96d-1c1f-4fd2-9310-a91beab922f5_500x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!GLi7!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff953e96d-1c1f-4fd2-9310-a91beab922f5_500x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!GLi7!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff953e96d-1c1f-4fd2-9310-a91beab922f5_500x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!GLi7!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff953e96d-1c1f-4fd2-9310-a91beab922f5_500x400.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 is the code:</p><pre><code><code>from generativepy.color import Color
from generativepy.drawing import make_image, setup
from generativepy.geometry import Rectangle, Circle, Square

def draw(ctx, width, height, frame_no, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    Square(ctx).of_corner_size((50, 50), 200).fill(Color("dodgerblue"))
    Circle(ctx).of_center_radius((250, 250), 75).fill(Color("maroon"))
    Rectangle(ctx).of_corner_size((100, 300), 350, 50).fill(Color("green", 0.4))

make_image("fill.png", draw, 500, 400)
</code></code></pre><p>The <code>Square</code> object draws the large blue square. A square is created in a similar way to a rectangle, but it only has a <code>width</code> (unlike a rectangle that has a <code>width</code> and <code>height</code>).</p><p>The <code>Circle</code> object draws the purple circle. A circle is specified similarly to a square, except that the <code>of_center_radius</code> method takes a centre point and a radius value to define the circle.</p><p>The other thing to notice is that the circle overlaps the previous square. Because the square was drawn before the circle, the circle is painted over the square. Part of the square is hidden behind the circle. To draw the square in front of the circle, we would reverse the drawing order by swapping the two lines of code.</p><p>The green <code>Rectangle</code> object, lower down the image, overlaps the circle. This time the rectangle is painted over the circle. However, the rectangle colour is partly transparent, so we can still see part of the circle behind the rectangle. The rectangle colour is set to green, but the extra parameter 0.4 is the transparency value. Because the rectangle is partly transparent, we can see the red circle behind it.</p><p>You might also notice that the <code>background</code> colour in the <code>setup</code> function is <code>Color(1)</code>. Using 1 rather than a colour name creates a grey value of 1, which is white (described in detail in a later chapter).</p><h2>Shape outlines</h2><p>In addition to filling shapes, we can also outline them. We do this using the <code>stroke</code> method rather than the <code>fill</code> method. Here are the same shapes as before, outlined in different colours:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!PSFN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14244d28-ab14-4ec6-8add-9517504d3198_500x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!PSFN!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14244d28-ab14-4ec6-8add-9517504d3198_500x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!PSFN!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14244d28-ab14-4ec6-8add-9517504d3198_500x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!PSFN!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14244d28-ab14-4ec6-8add-9517504d3198_500x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!PSFN!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14244d28-ab14-4ec6-8add-9517504d3198_500x400.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!PSFN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14244d28-ab14-4ec6-8add-9517504d3198_500x400.png" width="500" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/14244d28-ab14-4ec6-8add-9517504d3198_500x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Stroking shapes&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="Stroking shapes" title="Stroking shapes" srcset="/__u/substackcdn.com/image/fetch/$s_!PSFN!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14244d28-ab14-4ec6-8add-9517504d3198_500x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!PSFN!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14244d28-ab14-4ec6-8add-9517504d3198_500x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!PSFN!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14244d28-ab14-4ec6-8add-9517504d3198_500x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!PSFN!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14244d28-ab14-4ec6-8add-9517504d3198_500x400.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 is the code:</p><pre><code><code>from generativepy.color import Color
from generativepy.drawing import make_image, setup
from generativepy.geometry import Rectangle, Circle, Square

def draw(ctx, width, height, frame_no, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    Square(ctx).of_corner_size((50, 50), 200).stroke(Color("red"), 1)
    Circle(ctx).of_center_radius((250, 250), 75).stroke(Color("blue"), 8)
    (Rectangle(ctx).of_corner_size((100, 300), 350, 50)
                .fill(Color("orange")).stroke(Color("black"), 4))

make_image("stroke.png", draw, 500, 400)
</code></code></pre><p>To draw a shape outline, we use the <code>stroke</code> method instead of the <code>fill</code> method. <code>stroke</code> requires two parameters: the colour and the stroke width. Width is measured in user space, so by default, the stroke width is specified in pixels.</p><p>The square has a red stroke colour and a width of 1 unit (i.e., 1 pixel). This draws a thin line around the square. The middle of the square is left unfilled.</p><p>The circle has a blue stroke colour and a width of 8. This makes a much thicker line. Again, the circle is not filled so we can see the outline of the red square behind it.</p><p>The final shape, the rectangle, is filled and stroked. We call <code>fill</code> with the colour orange, and <code>stroke</code> with the colour black and a width of 4.</p><p>We call <code>fill</code> before <code>stroke</code>, so that the rectangle is filled first, then outlined.</p><h2>Fill and stroke position</h2><p>The stroke follows the shape&#8217;s outline, with half the stroked area inside and half outside. Here is an example of a filled and stroked rectangle:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!5GS8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F048de0de-d554-4202-aa4e-ffefe29e3982_400x300.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!5GS8!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F048de0de-d554-4202-aa4e-ffefe29e3982_400x300.png 424w, /__u/substackcdn.com/image/fetch/$s_!5GS8!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F048de0de-d554-4202-aa4e-ffefe29e3982_400x300.png 848w, /__u/substackcdn.com/image/fetch/$s_!5GS8!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F048de0de-d554-4202-aa4e-ffefe29e3982_400x300.png 1272w, /__u/substackcdn.com/image/fetch/$s_!5GS8!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F048de0de-d554-4202-aa4e-ffefe29e3982_400x300.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!5GS8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F048de0de-d554-4202-aa4e-ffefe29e3982_400x300.png" width="400" height="300" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/048de0de-d554-4202-aa4e-ffefe29e3982_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;:null,&quot;alt&quot;:&quot;Stroke boundary&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="Stroke boundary" title="Stroke boundary" srcset="/__u/substackcdn.com/image/fetch/$s_!5GS8!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F048de0de-d554-4202-aa4e-ffefe29e3982_400x300.png 424w, /__u/substackcdn.com/image/fetch/$s_!5GS8!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F048de0de-d554-4202-aa4e-ffefe29e3982_400x300.png 848w, /__u/substackcdn.com/image/fetch/$s_!5GS8!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F048de0de-d554-4202-aa4e-ffefe29e3982_400x300.png 1272w, /__u/substackcdn.com/image/fetch/$s_!5GS8!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F048de0de-d554-4202-aa4e-ffefe29e3982_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 aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 dotted white line shows the outline of the rectangle, ie the exact size and position we requested. The 4 small red dots show the rectangle&#8217;s corners. This indicates that the stroke is half outside the boundary and half inside.</p><p>This means that a stroked rectangle is always slightly bigger than its requested size because the stroke is centred on the exact boundary. And the filled area inside the rectangle is always slightly smaller than the requested size because the stroke covers part of the inner area. This is typical behaviour in most computer graphics systems and is intended. It looks best when, for example, the edges of two outlined shapes touch.</p><p>You can stroke the shape first and then fill it. In that case, the fill colour will occupy the whole area of the rectangle, and the stroke will appear to be half of its defined width. This method isn&#8217;t used often, but it could be useful if you wanted to paint a shape at its exact size while still having an outline.</p><h2>Join styles</h2><p>There are some more options for styling line strokes. It is possible to style the way the lines join, using the <code>join</code> parameter of the <code>stroke</code> method:</p><pre><code><code>from generativepy.color import Color
from generativepy.drawing import make_image, setup
from generativepy.geometry import Square, MITER, ROUND, BEVEL

def draw(ctx, width, height, frame_no, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    (Square(ctx).of_corner_size((50, 50), 100)
                .stroke(Color("black"), 30, join=MITER))
    (Square(ctx).of_corner_size((200, 50), 100)
                .stroke(Color("black"), 30, join=ROUND))
    (Square(ctx).of_corner_size((350, 50), 100)
                .stroke(Color("black"), 30, join=BEVEL))

make_image("corner.png", draw, 500, 200)
</code></code></pre><p>Here is the result:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Aedd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed32d7a8-da42-4082-9f42-2b3a83be5701_500x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Aedd!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed32d7a8-da42-4082-9f42-2b3a83be5701_500x200.png 424w, /__u/substackcdn.com/image/fetch/$s_!Aedd!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed32d7a8-da42-4082-9f42-2b3a83be5701_500x200.png 848w, /__u/substackcdn.com/image/fetch/$s_!Aedd!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed32d7a8-da42-4082-9f42-2b3a83be5701_500x200.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Aedd!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed32d7a8-da42-4082-9f42-2b3a83be5701_500x200.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Aedd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed32d7a8-da42-4082-9f42-2b3a83be5701_500x200.png" width="500" height="200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ed32d7a8-da42-4082-9f42-2b3a83be5701_500x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Line joins&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="Line joins" title="Line joins" srcset="/__u/substackcdn.com/image/fetch/$s_!Aedd!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed32d7a8-da42-4082-9f42-2b3a83be5701_500x200.png 424w, /__u/substackcdn.com/image/fetch/$s_!Aedd!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed32d7a8-da42-4082-9f42-2b3a83be5701_500x200.png 848w, /__u/substackcdn.com/image/fetch/$s_!Aedd!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed32d7a8-da42-4082-9f42-2b3a83be5701_500x200.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Aedd!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed32d7a8-da42-4082-9f42-2b3a83be5701_500x200.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The left-hand square uses a <code>MITER</code> join that creates a sharp corner (the default if you don&#8217;t specify a style). The middle square uses a <code>ROUND</code> join that rounds the corners off. The right-hand square uses a <code>BEVEL</code> join that cuts the corners off with a straight line.</p><p>This is largely a matter of preference. Use whichever you think looks best. If several lines or corners join at the same point, it is often a good idea to use the <code>ROUND</code> style, as it can look neater.</p><h2>Mitre limit</h2><p>When using the mitre style, if the two lines meet at a very small angle, the joint can get very long and look quite odd. To avoid this, pycairo applies a mitre limit. When the angle drops below a certain size, the <code>MITER</code> style automatically switches to <code>BEVEL</code> to prevent this. You don&#8217;t need to worry about this. It happens automatically and is almost always a good thing.</p><p>You can change this behaviour using the <code>miter_limit</code> parameter of the <code>stroke</code> method. We won&#8217;t cover it in detail here because it is quite a specialised function. Refer to the official Pycairo documentation for more details.</p><h2>Line caps</h2><p>We can also draw straight lines, using <code>Line</code> objects:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!kpwE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6be6f8de-aa57-4352-a464-4c72b8bc0d7c_400x300.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!kpwE!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6be6f8de-aa57-4352-a464-4c72b8bc0d7c_400x300.png 424w, /__u/substackcdn.com/image/fetch/$s_!kpwE!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6be6f8de-aa57-4352-a464-4c72b8bc0d7c_400x300.png 848w, /__u/substackcdn.com/image/fetch/$s_!kpwE!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6be6f8de-aa57-4352-a464-4c72b8bc0d7c_400x300.png 1272w, /__u/substackcdn.com/image/fetch/$s_!kpwE!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6be6f8de-aa57-4352-a464-4c72b8bc0d7c_400x300.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!kpwE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6be6f8de-aa57-4352-a464-4c72b8bc0d7c_400x300.png" width="400" height="300" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6be6f8de-aa57-4352-a464-4c72b8bc0d7c_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;:null,&quot;alt&quot;:&quot;Line cap&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="Line cap" title="Line cap" srcset="/__u/substackcdn.com/image/fetch/$s_!kpwE!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6be6f8de-aa57-4352-a464-4c72b8bc0d7c_400x300.png 424w, /__u/substackcdn.com/image/fetch/$s_!kpwE!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6be6f8de-aa57-4352-a464-4c72b8bc0d7c_400x300.png 848w, /__u/substackcdn.com/image/fetch/$s_!kpwE!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6be6f8de-aa57-4352-a464-4c72b8bc0d7c_400x300.png 1272w, /__u/substackcdn.com/image/fetch/$s_!kpwE!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6be6f8de-aa57-4352-a464-4c72b8bc0d7c_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 aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 line is defined by two points - the start of the line and the end of the line. When we <code>stroke</code> a line, we draw a line of the chosen colour and width from the start point to the endpoint.</p><p>We can choose the style of the line caps (ie the line ends) using the optional <code>cap</code> parameter of the <code>stroke</code> method:</p><ul><li><p><code>SQUARE</code>, the top line above, squares off the line ends. The two red dots indicate the line endpoints. When you select square caps, the marked area extends slightly beyond the line&#8217;s endpoints by a distance equal to half the line width. Square is the default cap type.</p></li><li><p><code>BUTT</code>, the middle line above, looks quite similar to the square case. The difference is that the line ends exactly on the endpoints, rather than extending beyond them.</p></li><li><p><code>ROUND</code>, the bottom line above, creates a rounded line end. The line end is a semicircle with a radius equal to half the line width.</p></li></ul><p>Line caps only apply to the ends of lines, whereas line joins apply to the corners of shapes. Shapes such as rectangles or squares don&#8217;t have ends, so the line cap parameter doesn&#8217;t affect them. Lines have no corners, so the line join parameter does not affect them. Note that if two lines meet at a point, that doesn&#8217;t mean they are joined, so the cap value controls the appearance rather than the join value.</p><p>Here is the code to draw the diagram above:</p><pre><code><code>from generativepy.color import Color
from generativepy.drawing import make_image, setup
from generativepy.geometry import Line, Circle, ROUND, SQUARE, BUTT

def draw(ctx, width, height, frame_no, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    (Line(ctx).of_start_end((50, 50), (350, 50))
              .stroke(Color("black"), 30, cap=SQUARE))
    Circle(ctx).of_center_radius((50, 50), 4).fill(Color("red"))
    Circle(ctx).of_center_radius((350, 50), 4).fill(Color("red"))

    (Line(ctx).of_start_end((50, 150), (350, 150))
              .stroke(Color("black"), 30, cap=BUTT))
    Circle(ctx).of_center_radius((50, 150), 4).fill(Color("red"))
    Circle(ctx).of_center_radius((350, 150), 4).fill(Color("red"))

    (Line(ctx).of_start_end((50, 250), (350, 250))
              .stroke(Color("black"), 30, cap=ROUND))
    Circle(ctx).of_center_radius((50, 250), 4).fill(Color("red"))
    Circle(ctx).of_center_radius((350, 250), 4).fill(Color("red"))

make_image("line-cap.png", draw, 400, 300)
</code></code></pre><p>This includes the three lines and the red circles that indicate the line ends.</p><h2>Dash patterns</h2><p>It is often useful to create dashed or dotted lines on a diagram. We can do this using the <code>dash</code> parameter of the <code>stroke</code> method. Here are some examples:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!fK1-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbc16314-f088-4d17-b240-51f6b8a71bcb_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!fK1-!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbc16314-f088-4d17-b240-51f6b8a71bcb_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!fK1-!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbc16314-f088-4d17-b240-51f6b8a71bcb_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!fK1-!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbc16314-f088-4d17-b240-51f6b8a71bcb_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!fK1-!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbc16314-f088-4d17-b240-51f6b8a71bcb_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!fK1-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbc16314-f088-4d17-b240-51f6b8a71bcb_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bbc16314-f088-4d17-b240-51f6b8a71bcb_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Dashed lines&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="Dashed lines" title="Dashed lines" srcset="/__u/substackcdn.com/image/fetch/$s_!fK1-!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbc16314-f088-4d17-b240-51f6b8a71bcb_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!fK1-!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbc16314-f088-4d17-b240-51f6b8a71bcb_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!fK1-!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbc16314-f088-4d17-b240-51f6b8a71bcb_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!fK1-!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbc16314-f088-4d17-b240-51f6b8a71bcb_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 dash pattern is specified by a list of values that define the on and off lengths of the dashed line, in user units (pixels by default).</p><p>Looking at the top row of shapes, each has a dash pattern of <code>[16]</code>. This means that the line will be solid for 16 pixels, then a gap of 16 pixels, repeated around the whole shape. However, each dash also includes line caps, as described above.</p><p>The square at the top left has the default line cap <code>SQUARE</code>. This means that, although the lines and gaps each have a nominal length of 16 pixels, the square line cap extends the lines. Since the line width is 8, this means that a cap of length 4 is added to each end of every line section. This means that each line has a marked length of 24 pixels. This means each gap is only 8 pixels (because the line occupies part of the gap).</p><p>The circle in the top centre uses the same measurements but has a <code>BUTT</code> style. This means each line finishes exactly at its nominal width, so the lines and gaps have equal lengths. This shape also shows how dashed lines follow curves.</p><p>The square at the top right has the same measurements but with a <code>ROUND</code> cap. It looks very similar to the square on the left, except that the dashes have rounded ends rather than square ends.</p><p>The bottom row of shapes demonstrates some other effects. The square on the left uses <code>BUTT</code> line caps, with a short length and a longer gap, to give a light dashed line. The circle is quite interesting: the line length is 0, but because the cap style is <code>ROUND</code>, the lines appear as circles (2 semicircular ends joined together), creating a dotted line. The square on the bottom right has a pattern of <code>[0, 10, 3, 7]</code>, so it gives a dot-dash pattern.</p><p>Dash patterns can be used on any line, as we will see later. For example, you can outline text with dashed lines, and you can also apply dashes to line plots on graphs.</p><p>Here is the code for the examples above:</p><pre><code><code>from generativepy.color import Color
from generativepy.drawing import make_image, setup
from generativepy.geometry import Rectangle, Circle, Square, BUTT, ROUND

def draw(ctx, width, height, frame_no, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    (Square(ctx).of_corner_size((50, 50), 100)
                .stroke(Color("black"), 8, dash=[16]))
    (Circle(ctx).of_center_radius((250, 100), 60)
                .stroke(Color("black"), 8, dash=[16], cap=BUTT))
    (Square(ctx).of_corner_size((350, 50), 100)
                .stroke(Color("black"), 8, dash=[16], cap=ROUND))
    (Square(ctx).of_corner_size((50, 200), 100)
                .stroke(Color("black"), 4, dash=[6, 12], cap=BUTT))
    (Circle(ctx).of_center_radius((250, 250), 60)
                .stroke(Color("black"), 6, dash=[0, 10], cap=ROUND))
    (Square(ctx).of_corner_size((350, 200), 100)
                .stroke(Color("black"), 4, dash=[0, 10, 3, 7], cap=ROUND))

make_image("dash.png", draw, 500, 350)
</code></code></pre><h2>Other features of the setup function</h2><p>Looking back at our first example code:</p><pre><code><code>from generativepy.color import Color
from generativepy.drawing import setup, make_image
from generativepy.geometry import Rectangle

def draw(ctx, width, height, frame_no, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(%22grey%22))
    Rectangle(ctx).of_corner_size((100, 150), 250, 200).fill(Color("orange"))

make_image("rectangle.png", draw, 500, 400)
</code></code></pre><p>This creates a 500-by-400-pixel image. Now suppose we decided that we actually needed the image to be 1000 by 800 pixels, that is twice as big. We can do this quite easily by altering the size in the <code>make_image</code> call. But the problem then is that the rectangle size in the <code>draw</code> function is also wrong. That would need adjusting. We can do that easily, but what if the drawing function was very complex - we would need to go through and alter the entire drawing code.</p><p>The <code>setup</code> function provides an easy solution. Consider the following code:</p><pre><code><code>from generativepy.color import Color
from generativepy.drawing import setup, make_image
from generativepy.geometry import Rectangle

def draw(ctx, width, height, frame_no, frame_count):
    setup(ctx, width, height, width=500, background=/__u/graphicmaths.substack.com/Color(%22grey%22))
    Rectangle(ctx).of_corner_size((100, 150), 250, 200).fill(Color("orange"))

make_image("rectangle.png", draw, 1000, 800)
</code></code></pre><p>Here, we have changed the image size to 1000 by 800 in the <code>make_image</code> call, but we have added an extra parameter <code>width=500</code> in the <code>setup</code> call.</p><p>This tells <code>setup</code> to <em>scale the drawing canvas</em>. Since the page width is 1000 and the setup width parameter is 500, setup introduces a scale factor of 2. So everything we draw appears twice as big, which is exactly what we want. And since it is a vector drawing, the scale is done smoothly, without any pixelation.</p><p><code>setup</code> also has a <code>height</code> parameter. We can use that instead of <code>width</code>. If we set <code>height</code> to 400, since the pixel height in <code>make_image</code> is 800, we would get a scale factor of 2. You can set either the <code>width</code> or <code>height</code>, whichever is more convenient. Either way, it decouples the pixel size of the image from the dimensions you use in the drawing code. So you can write your drawing code without committing to the final image size.</p><p>The scale factor doesn&#8217;t have to be an integer. For example, if you discovered that your 1000 pixel image really needed to be 2100 pixels wide, you could do that. This would be a scale factor of 2.1, but because it&#8217;s a vector image, it would still render perfectly.</p><p>You would normally only specify either <code>width</code> or <code>height</code>. If you specify both, the image might be scaled by a different amount in each direction. It would still render cleanly, but shapes would be distorted (for example, squares would be stretched into rectangles). That isn&#8217;t normally what you would want, but it can be useful in some cases.</p><p><code>setup</code> also has a <code>flip</code> parameter that flips the axes in the y direction, so y coordinate values start from 0 at the bottom of the image. This can be useful if you prefer a graph-like coordinate system when designing an image. It also has <code>startx</code> and <code>starty</code>, which shift the image on the page. This can be useful for adding a border to an image.</p><p><code>setup</code>is provided as a convenience. You can also change the image coordinates and scale using <code>Transform</code> objects, as described in a later tutorial.</p><h2>Other shapes</h2><p>generativepy supports several other shapes:</p><ul><li><p>More polygons</p><ul><li><p>Triangles</p></li><li><p>General polygons</p></li><li><p>Regular polygons</p></li></ul></li><li><p>Line variants - segment, ray, or infinite line</p></li><li><p>Circle variants</p><ul><li><p>Sector, segment, and arc of a circle</p></li><li><p>Ellipses</p></li></ul></li></ul><h2>More polygons</h2><p>This code draws several other types of polygons:</p><pre><code><code>from generativepy.color import Color
from generativepy.drawing import make_image, setup
from generativepy.geometry import (Triangle, FillParameters, StrokeParameters,
                                   Polygon, RegularPolygon, ROUND)


def draw(ctx, width, height, frame_no, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    f = FillParameters(Color("powderblue"))
    s = StrokeParameters(Color("darkslateblue"), 6, dash=[10, 8],
                         cap=ROUND, join=ROUND)

    Triangle(ctx).of_corners((50, 150), (200, 120), (100, 50)).fill(f).stroke(s)

    points = ((300, 50), (350, 100), (330, 200), (270, 200), (250, 100))
    Polygon(ctx).of_points(points).fill(f).stroke(s)

    points = ((500, 50), (550, 100), (530, 200), (470, 200), (450, 100))
    Polygon(ctx).of_points(points).open().stroke(s)

    p = RegularPolygon(ctx).of_centre_sides_radius((150, 300), 8, 70).stroke(s)
    print(p.inner_radius)

make_image("more-polygons.png", draw, 600, 400)
</code></code></pre><p>Here is the result:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!wmOR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6767e561-e72b-47b0-bbb8-e5d9c0197477_600x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!wmOR!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6767e561-e72b-47b0-bbb8-e5d9c0197477_600x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!wmOR!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6767e561-e72b-47b0-bbb8-e5d9c0197477_600x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!wmOR!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6767e561-e72b-47b0-bbb8-e5d9c0197477_600x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!wmOR!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6767e561-e72b-47b0-bbb8-e5d9c0197477_600x400.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!wmOR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6767e561-e72b-47b0-bbb8-e5d9c0197477_600x400.png" width="600" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6767e561-e72b-47b0-bbb8-e5d9c0197477_600x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:600,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;More polygons&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="More polygons" title="More polygons" srcset="/__u/substackcdn.com/image/fetch/$s_!wmOR!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6767e561-e72b-47b0-bbb8-e5d9c0197477_600x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!wmOR!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6767e561-e72b-47b0-bbb8-e5d9c0197477_600x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!wmOR!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6767e561-e72b-47b0-bbb8-e5d9c0197477_600x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!wmOR!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6767e561-e72b-47b0-bbb8-e5d9c0197477_600x400.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>First, you will notice that we have defined a couple of extra items:</p><ul><li><p>A <code>FillParameters</code> object <code>f</code>, initialised with a colour.</p></li><li><p>A <code>StrokeParameters</code> object <code>s</code>, initialised with a colour, thickness, plus <code>dash</code>, <code>cap</code>, and <code>join</code> values.</p></li></ul><p>We can use <code>f</code> and <code>s</code> as parameters for the <code>fill</code> and <code>stroke</code> methods of any object. This is useful if we want to draw several objects in the same style because it saves repetition.</p><p>The top left shape is a <code>Triangle</code>. This has an <code>of_corners</code> method to define its three corners, as <code>(x, y)</code> tuples. It is then filled and stroked as usual, using <em>f</em> and <em>s</em> to control the style.</p><p>The top centre shape is a <code>Polygon</code>. This has an <code>of_points</code> method to define its vertices. The vertices are provided as a sequence of <code>(x, y)</code> tuples.</p><p>The top right shape is another <code>Polygon</code>. This time, it has an extra call to its <code>open</code> method, which creates an open polygon, meaning the final vertex is not connected to the first vertex. This is sometimes called a polyline because you can think of it as a set of connected lines rather than a shape. We haven&#8217;t filled this shape, but you can if you wish. That would fill the shape as if it were a closed polygon, but of course, the outline would still be open.</p><p>The bottom left is a <code>RegularPolygon</code>. We call <code>of_centre_sides_radius</code> passing in:</p><ul><li><p>The position of the centre of the polygon, as an <code>(x, y)</code> tuple.</p></li><li><p>The required number of sides. We passed in 8 to create an octagon.</p></li><li><p>The radius of the shape. This controls the polygon&#8217;s size. It is the distance from the centre to any vertex of the polygon.</p></li></ul><p>By default, the polygon is drawn with the bottom edge horizontal (as shown). The <code>of_centre_sides_radius</code> function has an optional <code>angle</code> parameter that rotates the shape clockwise by the supplied angle, specified in radians.</p><p>A <code>RegularPolygon</code> has a few useful properties, calculated from the parameters:</p><ul><li><p><code>side_len</code> - the length of a side of the polygon</p></li><li><p><code>interior_angle</code> - the interior angle of the polygon (in radians)</p></li><li><p><code>exterior_angle</code> - the exterior angle of the polygon (in radians)</p></li><li><p><code>inner_radius</code> - the inner radius (distance from the centre to the midpoint of any side)</p></li><li><p><code>outer_radius</code> - the outer radius of the polygon (this is just the radius we supplied)</p></li><li><p><code>vertices</code> - a list of the vertices as <code>(x, y)</code> tuples</p></li></ul><h2>Line Variants</h2><p>We have seen how to draw a line using the <code>Line</code> class. This draws a straight line between two points, which here we will call <code>p1</code> and <code>p2</code>.</p><p>In computer graphics, a line normally means a finite line between two points. But in mathematics, we define three different types of lines:</p><ul><li><p>A line <em>segment</em> has finite length. It starts at <code>p1</code> and ends at <code>p2</code>.</p></li><li><p>A <em>ray</em> has semi-infinite length. It starts at <code>p1</code> and passes through <code>p2</code>, but it extends beyond <code>p2</code> right off to infinity. A ray is sometimes called a <em>half-line</em>.</p></li><li><p>A <em>line</em> has infinite length. It passes through <code>p1</code> and <code>p2</code>, but it extends to infinity in both directions.</p></li></ul><p>By default, <code>Line</code> draws a line segment, but it can also draw rays and (infinite) lines. Here is some example code:</p><pre><code><code>from generativepy.color import Color
from generativepy.drawing import make_image, setup
from generativepy.geometry import StrokeParameters, Circle, Line, ROUND

def draw(ctx, width, height, frame_no, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    def dot(p):
        Circle(ctx).of_center_radius(p, 8).fill(Color("red"))

    s = StrokeParameters(Color("darkgreen"), 6, cap=ROUND)

    p1 = (100, 300)
    p2 = (150, 100)
    Line(ctx).of_start_end(p1, p2).as_segment().stroke(s)
    dot(p1)
    dot(p2)

    p1 = (200, 300)
    p2 = (250, 100)
    Line(ctx).of_start_end(p1, p2).as_ray().stroke(s)
    dot(p1)
    dot(p2)

    p1 = (300, 300)
    p2 = (350, 100)
    Line(ctx).of_start_end(p1, p2).as_line().stroke(s)
    dot(p1)
    dot(p2)

make_image("more-lines.png", draw, 500, 400)
</code></code></pre><p>Here is the result:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!ytNh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda5e1db5-1459-4ad3-bc49-9e29795d38d9_500x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!ytNh!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda5e1db5-1459-4ad3-bc49-9e29795d38d9_500x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!ytNh!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda5e1db5-1459-4ad3-bc49-9e29795d38d9_500x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!ytNh!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda5e1db5-1459-4ad3-bc49-9e29795d38d9_500x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ytNh!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda5e1db5-1459-4ad3-bc49-9e29795d38d9_500x400.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!ytNh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda5e1db5-1459-4ad3-bc49-9e29795d38d9_500x400.png" width="500" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/da5e1db5-1459-4ad3-bc49-9e29795d38d9_500x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;More polygons&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="More polygons" title="More polygons" srcset="/__u/substackcdn.com/image/fetch/$s_!ytNh!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda5e1db5-1459-4ad3-bc49-9e29795d38d9_500x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!ytNh!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda5e1db5-1459-4ad3-bc49-9e29795d38d9_500x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!ytNh!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda5e1db5-1459-4ad3-bc49-9e29795d38d9_500x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ytNh!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda5e1db5-1459-4ad3-bc49-9e29795d38d9_500x400.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 code, we have created a <code>dot</code> function that draws a small red circle to mark a point.</p><p>The line on the left of the image is a segment. It just extends from one point to the other. The code includes a call to <code>as_segment</code>, although it isn&#8217;t really needed because a segment is the default. The line in the centre is a ray that extends from the first point, through the second point, and then disappears off the edge of the image. The line on the right is an infinite line that passes through both points and disappears off the edge of the image in both directions.</p><p>One thing to bear in mind is that the <code>Line</code> class doesn&#8217;t actually draw an infinite line. It just draws a very long line that goes beyond the edge of the image. If you create a very large image, you might need to make the line longer. The <code>as_line</code> and <code>as_ray</code> methods accept an optional parameter <code>infinity</code> that you can set to a suitable large number if needed.</p><h2>Circle variants</h2><p>We have already seen how to draw a circle, but generativepy offers some variants:</p><ul><li><p>A <em>sector</em> of a circle is like a pie slice taken out of the circle</p></li><li><p>A <em>segment</em> is part of a circle cut off by a chord (a chord is a straight line between two points on the circumference)</p></li><li><p>An <em>arc</em> is part of the circumference.</p></li></ul><p>It is also possible to draw an ellipse, which is also covered in this section.</p><p>Here is the code to draw these shapes:</p><pre><code><code>import math

from generativepy.color import Color
from generativepy.drawing import make_image, setup
from generativepy.geometry import Circle, FillParameters, StrokeParameters

def draw(ctx, width, height, frame_no, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    f = FillParameters(Color("yellow"))
    s = StrokeParameters(Color("black"), 6)

    (Circle(ctx).of_center_radius((150, 150), 75)
                .fill(f).stroke(s))
    (Circle(ctx).of_center_radius((350, 150), 75)
                .as_sector(math.radians(0), math.radians(135))
                .fill(f).stroke(s))
    (Circle(ctx).of_center_radius((150, 350), 75)
                .as_segment(math.radians(-90), math.radians(20))
                .fill(f).stroke(s))
    (Circle(ctx).of_center_radius((350, 350), 75)
                .as_arc(math.radians(-90), math.radians(20))
                .stroke(s))

make_image("more-circles.png", draw, 500, 500)
</code></code></pre><p>Here is the result:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!smy7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d3af301-c226-44f2-8d4e-ee44930737a9_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!smy7!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d3af301-c226-44f2-8d4e-ee44930737a9_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!smy7!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d3af301-c226-44f2-8d4e-ee44930737a9_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!smy7!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d3af301-c226-44f2-8d4e-ee44930737a9_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!smy7!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d3af301-c226-44f2-8d4e-ee44930737a9_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!smy7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d3af301-c226-44f2-8d4e-ee44930737a9_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0d3af301-c226-44f2-8d4e-ee44930737a9_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;More circles&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="More circles" title="More circles" srcset="/__u/substackcdn.com/image/fetch/$s_!smy7!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d3af301-c226-44f2-8d4e-ee44930737a9_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!smy7!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d3af301-c226-44f2-8d4e-ee44930737a9_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!smy7!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d3af301-c226-44f2-8d4e-ee44930737a9_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!smy7!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d3af301-c226-44f2-8d4e-ee44930737a9_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 top left shape is a normal circle. The other shapes are described below.</p><h2>Sectors</h2><p>The top right shape is a sector, created with this code:</p><pre><code><code>    (Circle(ctx).of_center_radius((350, 150), 75)
                .as_sector(math.radians(0), math.radians(135))
                .fill(f).stroke(s))
</code></code></pre><p>Here, we declare a circle as usual. But there is an extra call to <code>as_sector</code>. This creates a sector using the supplied angles of 0&#176; and 135&#176;. This requires a bit more explanation. First, generativepy measures angles clockwise from the positive x-axis. This is illustrated here:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!3PwN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac59301-ea38-4071-a244-a5b65abf4f1e_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!3PwN!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac59301-ea38-4071-a244-a5b65abf4f1e_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!3PwN!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac59301-ea38-4071-a244-a5b65abf4f1e_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!3PwN!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac59301-ea38-4071-a244-a5b65abf4f1e_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!3PwN!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac59301-ea38-4071-a244-a5b65abf4f1e_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!3PwN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac59301-ea38-4071-a244-a5b65abf4f1e_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5ac59301-ea38-4071-a244-a5b65abf4f1e_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Angles&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="Angles" title="Angles" srcset="/__u/substackcdn.com/image/fetch/$s_!3PwN!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac59301-ea38-4071-a244-a5b65abf4f1e_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!3PwN!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac59301-ea38-4071-a244-a5b65abf4f1e_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!3PwN!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac59301-ea38-4071-a244-a5b65abf4f1e_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!3PwN!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ac59301-ea38-4071-a244-a5b65abf4f1e_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 differs from the standard mathematical convention, but it is common in computer graphics because we usually measure the y-direction downward from the top of the image. Notice that angles above the horizontal are negative.</p><p>generativepy measures angles in radians. However, if you prefer to work in degrees, you can use the <code>math.radians</code> function to convert degrees to radians, as shown in the example code.</p><p>Finally, the sector is defined as the part of the circle created when we move clockwise from the first angle to the second angle. This is shown here:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!THrU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ca4737c-4521-4bb0-8e41-92e3545ef259_600x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!THrU!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ca4737c-4521-4bb0-8e41-92e3545ef259_600x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!THrU!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ca4737c-4521-4bb0-8e41-92e3545ef259_600x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!THrU!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ca4737c-4521-4bb0-8e41-92e3545ef259_600x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!THrU!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ca4737c-4521-4bb0-8e41-92e3545ef259_600x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!THrU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ca4737c-4521-4bb0-8e41-92e3545ef259_600x350.png" width="600" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5ca4737c-4521-4bb0-8e41-92e3545ef259_600x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:600,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Sector angles&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="Sector angles" title="Sector angles" srcset="/__u/substackcdn.com/image/fetch/$s_!THrU!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ca4737c-4521-4bb0-8e41-92e3545ef259_600x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!THrU!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ca4737c-4521-4bb0-8e41-92e3545ef259_600x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!THrU!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ca4737c-4521-4bb0-8e41-92e3545ef259_600x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!THrU!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ca4737c-4521-4bb0-8e41-92e3545ef259_600x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 yellow shape shows how the sector is created from a circle by taking the part of the circle between 0&#176; and 135&#176; clockwise. To draw the blue sector, we would take the part of the circle between 135&#176; and 0&#176; clockwise. We would need to swap the start and end angles in the <code>as_sector</code> call, like this:</p><pre><code><code>    (Circle(ctx).of_center_radius((350, 150), 75)
                .as_sector(math.radians(135), math.radians(0))
                .fill(f).stroke(s))
</code></code></pre><h2>Segments</h2><p>The bottom left of the original diagram shows a segment. This is formed from part of a circle by taking two points on the circumference and drawing a straight line between them (unlike a sector where we draw lines back to the centre of the circle):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!qnxo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d18e391-415f-4cc2-82df-54c8c0c7bfb8_400x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!qnxo!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d18e391-415f-4cc2-82df-54c8c0c7bfb8_400x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!qnxo!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d18e391-415f-4cc2-82df-54c8c0c7bfb8_400x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!qnxo!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d18e391-415f-4cc2-82df-54c8c0c7bfb8_400x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qnxo!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d18e391-415f-4cc2-82df-54c8c0c7bfb8_400x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!qnxo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d18e391-415f-4cc2-82df-54c8c0c7bfb8_400x350.png" width="400" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7d18e391-415f-4cc2-82df-54c8c0c7bfb8_400x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:400,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Segment angles&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="Segment angles" title="Segment angles" srcset="/__u/substackcdn.com/image/fetch/$s_!qnxo!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d18e391-415f-4cc2-82df-54c8c0c7bfb8_400x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!qnxo!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d18e391-415f-4cc2-82df-54c8c0c7bfb8_400x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!qnxo!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d18e391-415f-4cc2-82df-54c8c0c7bfb8_400x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qnxo!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d18e391-415f-4cc2-82df-54c8c0c7bfb8_400x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 draw a segment by adding an <code>as_segment</code> call to the circle code, like this:</p><pre><code><code>    (Circle(ctx).of_center_radius((150, 350), 75)
                .as_segment(math.radians(-90), math.radians(20))
                .fill(f).stroke(s))
</code></code></pre><p>This time the segment is formed from the part of the circle starting at -90&#176; and moving clockwise to 20&#176;. Again we can draw the opposite segment by swapping the angles.</p><h2>Arcs</h2><p>An arc is part of the circumference of a circle. It is a line, rather than a two-dimensional shape. It appears in the bottom right of the original diagram. We create an arc like this:</p><pre><code><code>    (Circle(ctx).of_center_radius((350, 350), 75)
                .as_arc(math.radians(-90), math.radians(20))
                .stroke(s))
</code></code></pre><p>An arc is created in the same way as a segment. We call <code>as_arc</code> rather than <code>as_segment</code>. The only difference is that an arc doesn&#8217;t include the extra line joining the two points on the circumference.</p><p>Since an arc is just a line, you would not normally fill it.</p><h2>Ellipses</h2><p>An ellipse is like a circle that has been stretched in one direction. Here are a couple of examples:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Ha3T!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F313917a0-97d3-41c1-afc1-5a3508651e11_600x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Ha3T!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F313917a0-97d3-41c1-afc1-5a3508651e11_600x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!Ha3T!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F313917a0-97d3-41c1-afc1-5a3508651e11_600x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!Ha3T!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F313917a0-97d3-41c1-afc1-5a3508651e11_600x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Ha3T!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F313917a0-97d3-41c1-afc1-5a3508651e11_600x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Ha3T!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F313917a0-97d3-41c1-afc1-5a3508651e11_600x500.png" width="600" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/313917a0-97d3-41c1-afc1-5a3508651e11_600x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:600,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Ellipses&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="Ellipses" title="Ellipses" srcset="/__u/substackcdn.com/image/fetch/$s_!Ha3T!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F313917a0-97d3-41c1-afc1-5a3508651e11_600x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!Ha3T!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F313917a0-97d3-41c1-afc1-5a3508651e11_600x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!Ha3T!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F313917a0-97d3-41c1-afc1-5a3508651e11_600x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Ha3T!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F313917a0-97d3-41c1-afc1-5a3508651e11_600x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 draw an ellipse using the <code>Ellipse</code> class, like this:</p><pre><code><code>import math

from generativepy.color import Color
from generativepy.drawing import make_image, setup
from generativepy.geometry import (FillParameters, StrokeParameters,
                                   Ellipse, Transform)


def draw(ctx, width, height, frame_no, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    f = FillParameters(Color("cyan"))
    s = StrokeParameters(Color("black"), 6)

    (Ellipse(ctx).of_center_radius((150, 150), 75, 100)
                .fill(f).stroke(s))
    (Ellipse(ctx).of_center_radius((400, 150), 100, 50)
                .fill(f).stroke(s))
    Transform(ctx).translate(300, 350).rotate(math.radians(30))
    (Ellipse(ctx).of_center_radius((0, 0), 100, 50)
                .fill(f).stroke(s))

make_image("ellipse.png", draw, 600, 500)
</code></code></pre><p>The <code>Ellipse</code> class is very similar to the <code>Circle</code> class, except that its <code>of_center_radius</code> method accepts an x-radius and a y-radius. In the top left example above, the x-radius is smaller than the y-radius, so the ellipse is taller than it is wide. In the top right example, the x-radius is larger than the y-radius, so the ellipse is wider than it is tall.</p><p>We can also create segments, sectors, and arcs of an ellipse in the same way as we do for circles.</p><p>The ellipse class only allows us to create ellipses where the two axes are aligned with the x and y directions. To create an ellipse with axes at an angle, we need to transform the drawing space. The bottom, centre example shows this: we use <code>Transform</code> to rotate the drawing space by 30&#176; before drawing the ellipse. We will cover <code>Transform</code> in a later chapter.</p>]]></content:encoded></item><item><title><![CDATA[Introduction to generativepy]]></title><description><![CDATA[generativepy is an open-source Python drawing library for creating computer images, diagrams, and animations.]]></description><link>https://graphicmaths.substack.com/p/introduction-to-generativepy</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/introduction-to-generativepy</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Fri, 21 Aug 2026 12:51:40 GMT</pubDate><content:encoded><![CDATA[<p>generativepy is an open-source Python drawing library for creating computer images, diagrams, and animations. It can be found on <a href="https://github.com/martinmcbride/generativepy">github</a>. This article covers generativepy V50.00, although much of it will also apply to older or newer versions.</p><h2>About generativepy</h2><p>As mentioned above, generativepy is a Python library for creating images, diagrams, animations, and videos. It is general purpose but includes features that make it particularly suitable for creating mathematical and technical diagrams and videos.</p><p>generativepy is a <em>library</em>. It has no user interface. To create a diagram or video, you need to write some Python code that calls the library. This guide gives lots of examples, and the code to create a simple diagram isn&#8217;t complicated. Of course, if you want to create a very complex diagram, the code can get as sophisticated as you like.</p><h2>Uses</h2><p>generativepy can create images and animations (movies and GIFs). It is particularly suitable for geometry diagrams, graphs, and other mathematical illustrations, but it can handle any diagram that can be built from drawing primitives.</p><p>Because diagrams are created programmatically, it is especially useful when you need to update diagrams frequently with new data, since changes can be made automatically without manual effort each time.</p><h2>Installing</h2><p>generativepy is a pure Python library. It is available on the Python Package Index (<a href="https://pypi.org/project/generativepy/">https://pypi.org/project/generativepy/</a>), so you can install it with <code>pip</code>, <code>uv</code>, or your favourite package manager. Or it can just be downloaded from github (https://github.com/martinmcbride/generativepy) and placed in a suitable location.</p><p>It has the following Python library requirements:</p><ul><li><p>numpy 2.5.2</p></li><li><p>pycairo 1.29.1</p></li><li><p>pillow 11.3.0 (moviepy might not be compatible with pillow 12.x)</p></li><li><p>moviepy 2.2.1</p></li></ul><p>It also requires the following command-line utilities to be installed:</p><ul><li><p>LaTeX TeXLive 2023</p></li><li><p>dvipng 1.15</p></li><li><p>gifsicle 1.94</p></li><li><p>ffmpeg 6.1.1</p></li></ul><h2>History</h2><p>generativepy started as a wrapper for the Pycairo graphics library. At the time, I wanted to experiment with generative art. However, I was also building the GraphicMaths website, and I quickly realised the library could also be useful for creating mathematical diagrams for the site. Over the years, I have continued developing the library while also using it to create images and videos.</p><p>So far I have created diagrams for a couple of hundred online maths articles and several maths books. I have also created about 100 YouTube videos using the library&#8217;s video capabilities.</p><p>While I developed the library primarily for my own use, it has always been available as an open-source library, and I have done my best to make it useful for others. I have reorganised the code a few times to keep the interfaces consistent, but at this stage the library is mature and stable, and most docstrings are up to date.</p><p>Together with this guide, anyone who is a reasonably capable Python coder should be able to use generativepy to create images and animations.</p><h2>Features</h2><p>generativepy has the following features:</p><ul><li><p><strong>Vector drawing</strong> - generativepy uses the Pycairo library, which is a very capable, high-quality vector graphics library supporting geometric shapes, text, different fill and stroke styles, coordinate transformations, transparency, and clipping. It has most of the features of a vector graphics program such as Inkscape, but is controlled by Python code. You can save images as PNG or SVG files.</p></li><li><p><strong>Bitmap drawing</strong> - bitmap images can be created or manipulated using the Pillow library, a well-known Python imaging library. You can also convert images to NumPy arrays and manipulate them using NumPy and related libraries (for example, SciPy). Bitmap images can be saved as PNG files.</p></li><li><p><strong>Color</strong> - generativepy supports grayscale and RGB colour, with optional transparency. The colour library lets you create colours from RGB values, HSL values, or CSS colour names, and lets you create new colours by manipulating existing ones in various ways.</p></li><li><p><strong>Compositing</strong> - all images are accessible as <em>frames</em>. A frame is a NumPy array. This lets you combine two images any way you want before saving them as an image or animation frame (see next).</p></li><li><p><strong>Animation</strong> - generativepy can be used to create a sequence of frames for animation. You can store these as animated GIFs, mp4 files, or a sequence of PNG images to process in an external video editor. Individual frames are stored in the standard frame format (NumPy arrays) so frames can be processed/combined while the video is being created (eg for text overlay, picture-in-picture, or other effects). There is a simple tweening system for animation. You can add audio as the video is created.</p></li><li><p><strong>Maths features</strong> - generativepy supports various features for geometric diagrams, including angle markers, tick marks, etc. It can plot graphs, add annotations, and also create tables. You can mix these with other drawings on the same image. It can render LaTeX formulas and place them on the same image. All maths features can be animated, just like any other drawing features.</p></li></ul><h2>genpygoodies</h2><p>genpygoodies is an additional library you can use alongside generativepy. It adds extra functionality that is either more specialised or less well-defined. It is a place where I add things that may or may not be useful, so they haven&#8217;t quite earned their place in the main library.</p><p>This library might be slightly less stable than the main library, as some features might evolve.</p>]]></content:encoded></item><item><title><![CDATA[Graphs in generativepy]]></title><description><![CDATA[generativepy is an open-source Python drawing library, mainly intended for maths/science illustrations and animations.]]></description><link>https://graphicmaths.substack.com/p/graphs-in-generativepy</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/graphs-in-generativepy</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Sat, 15 Aug 2026 15:33:13 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!mJdm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a7eae1-2306-423e-9946-721b885038fa_500x500.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>generativepy is an open-source Python drawing library, mainly intended for maths/science illustrations and animations. It can be found on <a href="https://github.com/martinmcbride/generativepy">github</a>.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/subscribe"><span>Subscribe now</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/p/graphs-in-generativepy?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/p/graphs-in-generativepy?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share</span></a></p><p>The graph module provides methods for plotting 2D graphs, mainly line graphs. Of course, Python has many good plotting libraries, including matplotlib and others. Many of them give very good results and support many different types of plots. So why does generativepy include a graphing module of its own? There are several reasons:</p><ul><li><p>If you use generativepy to create maths diagrams, it is convenient to be able to create graphs using the same library.</p></li><li><p>If you need to add annotations to your graphs, you can do it using the same drawing techniques you use to create other maths diagrams.</p></li><li><p>If you use generativepy to create videos or animated GIFs, it is easy to add animated graphs to those.</p></li></ul><p>Graphs are just objects on the page, which allows for various advanced drawing options. For example, you can use graphs as sub-elements of another graph, like this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!mJdm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a7eae1-2306-423e-9946-721b885038fa_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!mJdm!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a7eae1-2306-423e-9946-721b885038fa_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!mJdm!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a7eae1-2306-423e-9946-721b885038fa_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!mJdm!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a7eae1-2306-423e-9946-721b885038fa_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!mJdm!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a7eae1-2306-423e-9946-721b885038fa_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!mJdm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a7eae1-2306-423e-9946-721b885038fa_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b6a7eae1-2306-423e-9946-721b885038fa_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Nested graphs&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&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="Nested graphs" title="Nested graphs" srcset="/__u/substackcdn.com/image/fetch/$s_!mJdm!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a7eae1-2306-423e-9946-721b885038fa_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!mJdm!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a7eae1-2306-423e-9946-721b885038fa_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!mJdm!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a7eae1-2306-423e-9946-721b885038fa_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!mJdm!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6a7eae1-2306-423e-9946-721b885038fa_500x500.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 aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 this article, we cover basic graphs. We will cover more advanced options in a later article.</p><h2>Simple axes</h2><p>A generativepy graph consists of two or more separate objects:</p><ul><li><p>The graph axes, an <code>Axes</code> object. This displays the grid lines that the graph is drawn on. There is usually only one set of axes, although some advanced applications can have multiple overlapping axes.</p></li><li><p>The function plot, either a <code>Plot</code> or <code>Scatter</code> object. There will usually be at least one function, but sometimes more.</p></li><li><p>Optionally, any additional annotations.</p></li></ul><p>Unlike some graphing libraries, axes do not have text labels (such as &#8220;x&#8221; or &#8220;time&#8221;) or a graph title. You can add these separately as text objects.</p><p>Here is the code to draw just the axes, without any function plots:</p><pre><code><code>from generativepy.drawing import setup, make_image
from generativepy.color import Color
from generativepy.graph import Axes

def draw(ctx, width, height, fn, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    axes = Axes(ctx, (50, 50), 400, 400)
    axes.draw()

make_image("default-axes.png", draw, 500, 500)
</code></code></pre><p>This code creates a 500-pixel-square image. The call to <code>Axes</code> sets the position of the axes to (50, 50), and the size of the axes to 400 square. This puts the axes in the centre of the page, with a 50-pixel border all round. Here is the image it creates:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!X7_b!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F922956c0-8e65-403a-a887-2583fe75d4ff_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!X7_b!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F922956c0-8e65-403a-a887-2583fe75d4ff_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!X7_b!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F922956c0-8e65-403a-a887-2583fe75d4ff_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!X7_b!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F922956c0-8e65-403a-a887-2583fe75d4ff_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!X7_b!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F922956c0-8e65-403a-a887-2583fe75d4ff_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!X7_b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F922956c0-8e65-403a-a887-2583fe75d4ff_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/922956c0-8e65-403a-a887-2583fe75d4ff_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Default axes&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="Default axes" title="Default axes" srcset="/__u/substackcdn.com/image/fetch/$s_!X7_b!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F922956c0-8e65-403a-a887-2583fe75d4ff_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!X7_b!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F922956c0-8e65-403a-a887-2583fe75d4ff_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!X7_b!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F922956c0-8e65-403a-a887-2583fe75d4ff_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!X7_b!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F922956c0-8e65-403a-a887-2583fe75d4ff_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 axes range, style, and colors all use their defaults. We will see how to change them next.</p><h2>Setting the extents and divisions</h2><p>The default axes range from 0 to 10 in the x and y directions, but of course you can change that if you wish. Here is an example:</p><pre><code><code>def draw(ctx, width, height, fn, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    axes = (Axes(ctx, (50, 50), 400, 250).of_start((-4, -1))
                                         .of_extent((16, 5))
                                         .with_divisions((2, 1)))
    axes.draw()

make_image("extent-axes.png", draw, 500, 350)
</code></code></pre><p>For brevity, the imports are not included in the listing. You will notice is that the size of the graph (in the <code>Axes</code> constructor) is now 400 by 250. The page size in <code>make_image</code> has been adjusted to provide a 50-pixel border around the graph.</p><p>You will also notice some extra methods added to the constructor. <code>of_start</code> sets the graph coordinates of the bottom left corner to be (-4, -1). <code>of_extent</code> sets the range of the graph, again in graph coordinates, to be 16 in the <em>x</em> direction, 5 in the <em>y</em> direction.</p><p>This means that the <em>x</em> axis covers the range -4 to 12 (a length of 16), and the <em>y</em> axis covers the range -1 to 4 (a length of 5).</p><p>Finally, the <code>with_divisions</code> method sets the division spacing to 2 in the <em>x</em> direction and <em>1</em> in the <em>y</em> direction. This means that the <em>x</em> axis has a division line at -2, 2, 4, 6 ... and the <em>y</em> axis has a division line at 1, 2, 3, 4 ... Every division is numbered on the axis. Here is the result:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Cmmi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0c0993d-af6c-445d-a48d-6b93e808065a_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Cmmi!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0c0993d-af6c-445d-a48d-6b93e808065a_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!Cmmi!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0c0993d-af6c-445d-a48d-6b93e808065a_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!Cmmi!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0c0993d-af6c-445d-a48d-6b93e808065a_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Cmmi!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0c0993d-af6c-445d-a48d-6b93e808065a_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Cmmi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0c0993d-af6c-445d-a48d-6b93e808065a_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c0c0993d-af6c-445d-a48d-6b93e808065a_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Axes exyents&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="Axes exyents" title="Axes exyents" srcset="/__u/substackcdn.com/image/fetch/$s_!Cmmi!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0c0993d-af6c-445d-a48d-6b93e808065a_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!Cmmi!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0c0993d-af6c-445d-a48d-6b93e808065a_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!Cmmi!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0c0993d-af6c-445d-a48d-6b93e808065a_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Cmmi!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0c0993d-af6c-445d-a48d-6b93e808065a_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 an aside, notice that in this case the <em>x</em> and <em>y</em> axes have different scales. <em>x</em> has a range of 16 units over 400 pixels, so 1 unit is 25 pixels. <em>y</em> has a range of 5 units over 250 pixels, so 1 unit is 50 pixels. That is perfectly OK, of course, and often necessary.</p><p>In this case, we chose the <em>x</em> and <em>y</em> divisions so that they form square regions on the graph. That can look a bit neater, but you don&#8217;t have to do it, it is entirely optional.</p><h2>Subdivisions</h2><p>Every division is labelled with a number, so it is best to keep them reasonably spaced apart (otherwise the numbers can appear too cluttered).</p><p>If you want to provide finer spacing, you can use subdivisions by adding a <code>with_subdivisions</code> call, like this:</p><pre><code><code>def draw(ctx, width, height, fn, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    axes = (Axes(ctx, (50, 50), 400, 250).of_start((-6, -4))
                                         .of_extent((48, 30))
                                         .with_divisions((10, 10))
                                         .with_subdivisions((5, 5)))
    axes.draw()

make_image("subdiv-axes.png", draw, 500, 350)
</code></code></pre><p>Subdivisions are similar to divisions except:</p><ul><li><p>Subdivisions are not numbered.</p></li><li><p>Subdivisions can be styled differently from divisions, for example using slightly thinner lines. But you can use the same style for both if you wish.</p></li></ul><p>In our case, we have used a subdivision value of 5 for the <em>x</em> and <em>y</em> subdivisions. This means each division is split into 5 equal parts, so there are 4 subdivision lines between each division. Here is how it appears:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!dopi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e38d78-cbbf-4ed3-85c8-fe8550b0d8e2_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!dopi!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e38d78-cbbf-4ed3-85c8-fe8550b0d8e2_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!dopi!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e38d78-cbbf-4ed3-85c8-fe8550b0d8e2_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!dopi!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e38d78-cbbf-4ed3-85c8-fe8550b0d8e2_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!dopi!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e38d78-cbbf-4ed3-85c8-fe8550b0d8e2_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!dopi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e38d78-cbbf-4ed3-85c8-fe8550b0d8e2_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/69e38d78-cbbf-4ed3-85c8-fe8550b0d8e2_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Axes subdivisions&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="Axes subdivisions" title="Axes subdivisions" srcset="/__u/substackcdn.com/image/fetch/$s_!dopi!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e38d78-cbbf-4ed3-85c8-fe8550b0d8e2_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!dopi!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e38d78-cbbf-4ed3-85c8-fe8550b0d8e2_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!dopi!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e38d78-cbbf-4ed3-85c8-fe8550b0d8e2_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!dopi!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e38d78-cbbf-4ed3-85c8-fe8550b0d8e2_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 we are using division values of 10 and subdivisions of 5, each subdivision represents 2 units.</p><h2>Styling axes</h2><p>You can style the axes by setting the colours of all elements, the line styling, and the fonts used to label the axes. This can be done using the styling functions of the <code>Axes</code> object, like this:</p><pre><code><code>def draw(ctx, width, height, fn, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    axes = (Axes(ctx, (50, 50), 400, 250).of_start((-6, -4))
                                         .of_extent((48, 30))
                                         .with_divisions((10, 10))
                                         .with_subdivisions((5, 5)))
    axes.axis_linestyle(Color("blue"), line_width=3, cap=BUTT)
    axes.text_color(Color("blue"))
    axes.text_style(font="serif", slant=FONT_SLANT_ITALIC, size=18)
    axes.division_linestyle(Color("springgreen"), line_width=2, cap=BUTT)
    axes.subdivision_linestyle(Color("springgreen"), line_width=1, cap=BUTT)
    axes.with_border(True)
    axes.background(Color("palegoldenrod"))
    axes.draw()

make_image("style-axes.png", draw, 500, 350)
</code></code></pre><p>This style uses strong colors to illustrate the styling functions. You will probably want something a bit more subtle and tasteful for your own graphs. Here is what it looks like:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!bqZ3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37a07729-51fd-4298-8125-5d9bb41ca500_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!bqZ3!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37a07729-51fd-4298-8125-5d9bb41ca500_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!bqZ3!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37a07729-51fd-4298-8125-5d9bb41ca500_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!bqZ3!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37a07729-51fd-4298-8125-5d9bb41ca500_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!bqZ3!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37a07729-51fd-4298-8125-5d9bb41ca500_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!bqZ3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37a07729-51fd-4298-8125-5d9bb41ca500_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/37a07729-51fd-4298-8125-5d9bb41ca500_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Axes styling&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="Axes styling" title="Axes styling" srcset="/__u/substackcdn.com/image/fetch/$s_!bqZ3!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37a07729-51fd-4298-8125-5d9bb41ca500_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!bqZ3!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37a07729-51fd-4298-8125-5d9bb41ca500_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!bqZ3!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37a07729-51fd-4298-8125-5d9bb41ca500_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!bqZ3!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37a07729-51fd-4298-8125-5d9bb41ca500_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 notes on the code:</p><ul><li><p><code>axis_linestyle</code> controls the lines used to draw the axes and the border (see below). You can set the color and line thickness. You will usually want to set the line cap to <code>BUTT</code>, as shown.</p></li><li><p><code>text_color</code> and <code>text_style</code> control the numbers on the axes. You might typically use the axis color for text as well, but you don&#8217;t have to.</p></li><li><p><code>division_linestyle</code> sets the style for the division lines, in this case green and 2 pixels wide. <code>subdivision_linestyle</code> does the same for the subdivision lines. The subdivision lines are slightly thinner than the division lines, but that is optional.</p></li><li><p><code>with_border</code> set to true causes a border to be drawn around the entire graph, in the same style as the axes.</p></li><li><p><code>background</code> sets the background color of the graph, in our case a nice bright yellow.</p></li></ul><h2>Plotting functions of y against x</h2><p>Now that we know how to create axes, we can look at how to plot simple functions of <em>x</em>. Here is the code to create a simple function plot:</p><pre><code><code>from generativepy.drawing import setup, make_image
from generativepy.color import Color
from generativepy.graph import Axes, Plot
import math

def draw(ctx, width, height, fn, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    def f(x):
        return math.sin(x)

    axes = (Axes(ctx, (50, 50), 400, 250).of_start((0, -1.5))
                                         .of_extent((8,3))
                                         .with_divisions((1, 0.5)))
    axes.draw()
    Plot(axes).of_function(f).stroke(Color(1, 0, 0), 3)

make_image("plot-simple.png", draw, 500, 350)
</code></code></pre><p>This will create a simple plot like this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!T5hY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c56e2a7-4585-406e-8ede-426bc7f36629_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!T5hY!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c56e2a7-4585-406e-8ede-426bc7f36629_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!T5hY!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c56e2a7-4585-406e-8ede-426bc7f36629_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!T5hY!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c56e2a7-4585-406e-8ede-426bc7f36629_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!T5hY!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c56e2a7-4585-406e-8ede-426bc7f36629_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!T5hY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c56e2a7-4585-406e-8ede-426bc7f36629_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1c56e2a7-4585-406e-8ede-426bc7f36629_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Simple plot&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="Simple plot" title="Simple plot" srcset="/__u/substackcdn.com/image/fetch/$s_!T5hY!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c56e2a7-4585-406e-8ede-426bc7f36629_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!T5hY!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c56e2a7-4585-406e-8ede-426bc7f36629_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!T5hY!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c56e2a7-4585-406e-8ede-426bc7f36629_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!T5hY!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c56e2a7-4585-406e-8ede-426bc7f36629_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 code is similar to the earlier code for drawing axes. We have added two things:</p><ul><li><p>We have defined a function <em>f</em> which is the function we wish to plot. The plot function must accept a single number as a parameter and return a number as a result. In our case, the function accepts <em>x</em> and returns <em>sin (x)</em>.</p></li><li><p>We have added a <code>Plot</code> object that plots the function.</p></li></ul><p>A <code>Plot</code> is a special type of shape. We use it like this:</p><ul><li><p><code>Plot(axes)</code> creates a plot object, based on our axes.</p></li><li><p><code>of_function(f)</code> tells the plot object to plot out function <em>f</em>. Notice we pass in <code>f</code>, the function object, rather than <code>f(x)</code>.</p></li><li><p>Finally, since the plot object is a shape, we need to stroke it to make it visible. We stroke it with a red line 3 units thick.</p></li></ul><p>That is all we need to do to plot a simple graph.</p><h2>Clipping the graph</h2><p>Sometimes the plot might go outside the axes. For example, this code plots the exponential function:</p><pre><code><code>def draw(ctx, width, height, fn, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    f = lambda x: math.exp(x)

    axes = (Axes(ctx, (50, 50), 400, 250).of_start((0, 0))
                                         .of_extent((4,10))
                                         .with_divisions((1, 2)))
    axes.draw()
    Plot(axes).of_function(f).stroke(Color(1, 0, 0), 3)

make_image("plot-unclipped.png", draw, 500, 350)
</code></code></pre><p>Here is the graph:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!lPqw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf9add7a-40bf-485c-bc7e-edfa62ccf8e3_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!lPqw!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf9add7a-40bf-485c-bc7e-edfa62ccf8e3_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!lPqw!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf9add7a-40bf-485c-bc7e-edfa62ccf8e3_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!lPqw!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf9add7a-40bf-485c-bc7e-edfa62ccf8e3_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!lPqw!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf9add7a-40bf-485c-bc7e-edfa62ccf8e3_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!lPqw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf9add7a-40bf-485c-bc7e-edfa62ccf8e3_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cf9add7a-40bf-485c-bc7e-edfa62ccf8e3_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Unclipped plot&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="Unclipped plot" title="Unclipped plot" srcset="/__u/substackcdn.com/image/fetch/$s_!lPqw!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf9add7a-40bf-485c-bc7e-edfa62ccf8e3_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!lPqw!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf9add7a-40bf-485c-bc7e-edfa62ccf8e3_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!lPqw!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf9add7a-40bf-485c-bc7e-edfa62ccf8e3_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!lPqw!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf9add7a-40bf-485c-bc7e-edfa62ccf8e3_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 red function plot strays outside the axes, which you usually don&#8217;t want. There is an easy fix:</p><pre><code><code>def draw(ctx, width, height, fn, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    f = lambda x: math.exp(x)

    axes = (Axes(ctx, (50, 50), 400, 250).of_start((0, 0))
                                         .of_extent((4,10))
                                         .with_divisions((1, 2)))
    axes.draw()

    axes.clip()
    Plot(axes).of_function(f).stroke(Color(1, 0, 0), 3)
    axes.unclip()

make_image("plot-clipped.png", draw, 500, 350)
</code></code></pre><p>All we have done here is to put <code>axes.clip()</code> immediately before the call to <code>Plot</code>. We also need to call <code>axes.unclip()</code> straight afterwards to undo the clipping.</p><p>Here is the revised graph:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!WZAF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb495b9d2-bc04-411f-b1e9-1ae82fa4e9b4_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!WZAF!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb495b9d2-bc04-411f-b1e9-1ae82fa4e9b4_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!WZAF!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb495b9d2-bc04-411f-b1e9-1ae82fa4e9b4_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!WZAF!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb495b9d2-bc04-411f-b1e9-1ae82fa4e9b4_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!WZAF!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb495b9d2-bc04-411f-b1e9-1ae82fa4e9b4_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!WZAF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb495b9d2-bc04-411f-b1e9-1ae82fa4e9b4_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b495b9d2-bc04-411f-b1e9-1ae82fa4e9b4_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Clipped plot&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="Clipped plot" title="Clipped plot" srcset="/__u/substackcdn.com/image/fetch/$s_!WZAF!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb495b9d2-bc04-411f-b1e9-1ae82fa4e9b4_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!WZAF!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb495b9d2-bc04-411f-b1e9-1ae82fa4e9b4_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!WZAF!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb495b9d2-bc04-411f-b1e9-1ae82fa4e9b4_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!WZAF!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb495b9d2-bc04-411f-b1e9-1ae82fa4e9b4_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 is no particular disadvantage to using clipping even if the function doesn&#8217;t go outside the axes, so you might prefer always to add the clip call.</p><h2>Styling plots</h2><p>The <code>stroke</code> call controls the plot style. We have seen how to set the color and line thickness - this works in the same way as drawing other shapes.</p><p>You can also create other line effects, such as dashed lines, the same way you would for any other shape. For example, here is a thick, dashed line:</p><pre><code><code>def draw(ctx, width, height, fn, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    f = lambda x: math.sin(x)

    axes = (Axes(ctx, (50, 50), 400, 250).of_start((0, -1.5))
                                         .of_extent((8,3))
                                         .with_divisions((1, 0.5)))
    axes.draw()
    Plot(axes).of_function(f).stroke(Color(1, 0, 0), 4, dash=[8, 8])

make_image(FOLDER + "plot-dotted.png", draw, 500, 350)
</code></code></pre><p>Here is the result:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!tAZx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b0ff955-edc1-4695-826f-c022914373c6_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!tAZx!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b0ff955-edc1-4695-826f-c022914373c6_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!tAZx!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b0ff955-edc1-4695-826f-c022914373c6_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!tAZx!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b0ff955-edc1-4695-826f-c022914373c6_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!tAZx!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b0ff955-edc1-4695-826f-c022914373c6_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!tAZx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b0ff955-edc1-4695-826f-c022914373c6_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4b0ff955-edc1-4695-826f-c022914373c6_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Dashed plot&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="Dashed plot" title="Dashed plot" srcset="/__u/substackcdn.com/image/fetch/$s_!tAZx!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b0ff955-edc1-4695-826f-c022914373c6_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!tAZx!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b0ff955-edc1-4695-826f-c022914373c6_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!tAZx!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b0ff955-edc1-4695-826f-c022914373c6_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!tAZx!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b0ff955-edc1-4695-826f-c022914373c6_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Dashed and dotted lines are explained in the <a href="https://graphicmaths.com/generativepy/generativepy-book/drawing/">drawing article</a>.</p><p>You can also fill a plot, but using the <code>fill</code> function directly usually doesn&#8217;t give a good result. We&#8217;ll cover the extra step of defining the exact fill region in a later article on advanced plotting.</p><h2>Plotting multiple graphs on the same axes</h2><p>We can plot multiple graphs on the same axes. To do this, we use <code>Plot</code> several times using different functions. It is usually a good idea to style each plot differently. Here is an example:</p><pre><code><code>def draw(ctx, width, height, fn, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    f = lambda x: math.sin(x)
    f1 = lambda x: 1.5*math.sin(x)
    f2 = lambda x: 0.8*math.sin(1.5*x)

    axes = (Axes(ctx, (50, 50), 400, 250).of_start((0, -2))
                                         .of_extent((8,4))
                                         .with_divisions((1, 1)))
    axes.draw()
    Plot(axes).of_function(f).stroke(Color(1, 0, 0), 3)
    Plot(axes).of_function(f1).stroke(Color(0, 0.5, 0), 3, dash=[8, 8])
    Plot(axes).of_function(f2).stroke(Color(0, 0, 1), 3, dash=[0, 6], cap=ROUND)

make_image(FOLDER + "plot-multiple.png", draw, 500, 350)
</code></code></pre><p>Here, we have created three functions <code>f</code>, <code>f1</code>, and <code>f2</code> that are all sine functions with different amplitudes and periods.</p><p>We use <code>Plot</code> three times, once for each function. The color is set to red, green and blue for <code>f</code>, <code>f1</code>, and <code>f2</code>, with the green line dashed and the blue line dotted.</p><p>Here is the result:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!72Im!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1766e0dc-63e6-4e31-bb07-1b964267d3a6_500x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!72Im!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1766e0dc-63e6-4e31-bb07-1b964267d3a6_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!72Im!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1766e0dc-63e6-4e31-bb07-1b964267d3a6_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!72Im!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1766e0dc-63e6-4e31-bb07-1b964267d3a6_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!72Im!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1766e0dc-63e6-4e31-bb07-1b964267d3a6_500x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!72Im!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1766e0dc-63e6-4e31-bb07-1b964267d3a6_500x350.png" width="500" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1766e0dc-63e6-4e31-bb07-1b964267d3a6_500x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Dashed plot&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="Dashed plot" title="Dashed plot" srcset="/__u/substackcdn.com/image/fetch/$s_!72Im!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1766e0dc-63e6-4e31-bb07-1b964267d3a6_500x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!72Im!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1766e0dc-63e6-4e31-bb07-1b964267d3a6_500x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!72Im!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1766e0dc-63e6-4e31-bb07-1b964267d3a6_500x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!72Im!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1766e0dc-63e6-4e31-bb07-1b964267d3a6_500x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div>]]></content:encoded></item><item><title><![CDATA[Color in generativepy]]></title><description><![CDATA[generativepy is an open source Python drawing library, mainly intended for maths/science illustrations and animations.]]></description><link>https://graphicmaths.substack.com/p/color-in-generativepy</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/color-in-generativepy</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Tue, 11 Aug 2026 14:58:16 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!8WAL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39cda85a-b27e-4054-a5a3-ee4670eedb48_790x340.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>generativepy is an open source Python drawing library, mainly intended for maths/science illustrations and animations. It can be found on <a href="https://github.com/martinmcbride/generativepy">github</a>.</p><p>The generativepy color module provides many features for handling color in diagrams. It includes:</p><ul><li><p>Support for RGB, Monochrone, HSL, and CSS named colors.</p></li><li><p>Support for transparency (alpha channel) in all color modes.</p></li><li><p>Color properties - for example individual r, g, or b values.</p></li><li><p>Color modifiers - for example creating a darker version of a color, or interpolating between two colors.</p></li><li><p>Color schemes - a flexible way to define a set of colors.</p></li><li><p>Color maps - mapping integer values onto a varying color (covered in a later article).</p></li></ul><p>The module uses the <code>Color</code> object to represent colors. <code>Color</code> objects are <em>immutable</em> - once a color has been created, it cannot be changed. If you need a different color, you must create a new color object. This avoids problems with color objects being changed while they are in use elsewhere, and it is similar to how Python treats number and string objects.</p><p>This module provides many ways to create new colors based on existing colors, as we will see later.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/subscribe"><span>Subscribe now</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/p/color-in-generativepy?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/p/color-in-generativepy?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share</span></a></p><h2>Creating RGB colors</h2><p>We create a color object using the <code>Color</code> class, like this:</p><pre><code><code>from generativepy.color import Color

color1 = Color(0, 1, 0)  # Pure green
</code></code></pre><p>When <code>Color</code> is called with three arguments, it creates an RGB color. The first argument controls the red value, the second controls the blue value, and the third controls the green value. A value of 1.0 turns that color fully on, and a value of 0.0 turns that color fully off.</p><p>A value of less than 0 is treated as 0, and a value greater than 1 is treated as 1.</p><p>The example above creates a 100% green color because the green value is 1 and the red and blue values are 0.</p><h1>Creating RGBA colors</h1><p>We can also create transparent colors, sometimes called RGBA colors. Here, A represent the alpha value, or opacity value&#8212;an A value of 1 creates a fully opaque color. An A value of 0 creates a fully transparent color, which means an object painted in that color is invisible.</p><p>We create an RGBA color by supplying a fourth parameter to the <code>Color</code> function:</p><pre><code><code>color2 = Color(1, 0, 1, 0.8)  # Magenta with 80% opacity
</code></code></pre><p>This creates a magenta color (red and blue both set to 1), but with an alpha value of 0.8. This means that the color is 80% opaque, so anything behind the object will be partly visible. This code is a circle with <code>color1</code> behind a rectangle with <code>color2</code>:</p><pre><code><code>from generativepy.color import Color
from generativepy.drawing import setup, make_image
from generativepy.geometry import Rectangle, Circle

def draw(ctx, width, height, fn, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    Circle(ctx).of_center_radius((150, 150), 100).fill(color1)
    Rectangle(ctx).of_corner_size((100, 100), 250, 200).fill(color2)

make_image("alpha.png", draw, 400, 350)
</code></code></pre><p>Here is the image. Notice that the circle is still visible through the rectangle, even though the rectangle is drawn over part of the circle. That is because the rectangle is partly transparent:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!JTrW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23e8c4d6-2dd1-4b16-af62-e8ba34dd3d91_400x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!JTrW!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23e8c4d6-2dd1-4b16-af62-e8ba34dd3d91_400x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!JTrW!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23e8c4d6-2dd1-4b16-af62-e8ba34dd3d91_400x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!JTrW!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23e8c4d6-2dd1-4b16-af62-e8ba34dd3d91_400x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!JTrW!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23e8c4d6-2dd1-4b16-af62-e8ba34dd3d91_400x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!JTrW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23e8c4d6-2dd1-4b16-af62-e8ba34dd3d91_400x350.png" width="400" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/23e8c4d6-2dd1-4b16-af62-e8ba34dd3d91_400x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:400,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Transparency&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="Transparency" title="Transparency" srcset="/__u/substackcdn.com/image/fetch/$s_!JTrW!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23e8c4d6-2dd1-4b16-af62-e8ba34dd3d91_400x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!JTrW!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23e8c4d6-2dd1-4b16-af62-e8ba34dd3d91_400x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!JTrW!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23e8c4d6-2dd1-4b16-af62-e8ba34dd3d91_400x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!JTrW!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23e8c4d6-2dd1-4b16-af62-e8ba34dd3d91_400x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>The Color object</h2><p>If we print the two color objects, we see something interesting:</p><pre><code><code>print(color1) # prints rgba(0, 1, 0, 1)
print(color2) # prints rgba(1, 0, 1, 0.8)
</code></code></pre><p>A <code>Color</code> object <em>always</em> stores an RGBA value, even if the color is created with only RGB values. When we specify RGB values, the A value is automatically set to 1, which gives a fully opaque color.</p><h2>Monochrome colors</h2><p>If we call <code>Color</code> with one numerical parameter, it creates a monochrome color (ie a shade of grey). If we call it with two parameters, it creates a transparent shade of grey. Here is an example:</p><pre><code><code>color3 = Color(0.7)
color4 = Color(0.4, 0.5)

print(color3) # prints rgba(0.7, 0.7, 0.7, 1)
print(color4) # prints rgba(0.4, 0.4, 0.4, 0.5)

def draw(ctx, width, height, fn, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    Circle(ctx).of_center_radius((150, 150), 100).fill(color3)
    Rectangle(ctx).of_corner_size((100, 100), 250, 200).fill(color4)

make_image("grey.png", draw, 400, 350)
</code></code></pre><p>In this code, <code>color3</code> is a grey color with grey value 0.7. When we print this color, we get <code>rgba(0.7, 0.7, 0.7, 1)</code>. This is still an RGBA color, but with the red, green and blue values all set to 0.7, so it gives a grey color. The alpha value is set to 1 to create a fully opaque color, as in the RGB case. To create a transparent grey, we add a second parameter which serves as an A value. Here is the resulting image:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!RxqF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd38b6d85-5f69-4442-92ef-de7152af2b93_400x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!RxqF!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd38b6d85-5f69-4442-92ef-de7152af2b93_400x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!RxqF!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd38b6d85-5f69-4442-92ef-de7152af2b93_400x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!RxqF!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd38b6d85-5f69-4442-92ef-de7152af2b93_400x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RxqF!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd38b6d85-5f69-4442-92ef-de7152af2b93_400x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!RxqF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd38b6d85-5f69-4442-92ef-de7152af2b93_400x350.png" width="400" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d38b6d85-5f69-4442-92ef-de7152af2b93_400x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:400,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Transparency&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="Transparency" title="Transparency" srcset="/__u/substackcdn.com/image/fetch/$s_!RxqF!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd38b6d85-5f69-4442-92ef-de7152af2b93_400x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!RxqF!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd38b6d85-5f69-4442-92ef-de7152af2b93_400x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!RxqF!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd38b6d85-5f69-4442-92ef-de7152af2b93_400x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RxqF!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd38b6d85-5f69-4442-92ef-de7152af2b93_400x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Named colors</h2><p>We can also create CSS named colors. If the first parameter is a string that matches a CSS color name, then the corresponding color will be used. Once again, if there is a second parameter, it will be used to set the transparency:</p><pre><code><code>color5 = Color("cadetblue")
color6 = Color("firebrick", 0.7)

def draw(ctx, width, height, fn, frame_count):
    setup(ctx, width, height, background=/__u/graphicmaths.substack.com/Color(1))

    Circle(ctx).of_center_radius((150, 150), 100).fill(color5)
    Rectangle(ctx).of_corner_size((100, 100), 250, 200).fill(color6)

make_image(FOLDER + "named.png", draw, 400, 350)

print(color5) # prints rgba(0.37254901960784315, 0.6196078431372549,
              #             0.6274509803921569, 1)
print(color6) # prints rgba(0.6980392156862745, 0.13333333333333333,
              #             0.13333333333333333, 0.7)
</code></code></pre><p>Here is the resulting image:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Un0O!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2f2ac91-47b5-43ef-b897-ab93ec546690_400x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Un0O!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2f2ac91-47b5-43ef-b897-ab93ec546690_400x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!Un0O!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2f2ac91-47b5-43ef-b897-ab93ec546690_400x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!Un0O!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2f2ac91-47b5-43ef-b897-ab93ec546690_400x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Un0O!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2f2ac91-47b5-43ef-b897-ab93ec546690_400x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Un0O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2f2ac91-47b5-43ef-b897-ab93ec546690_400x350.png" width="400" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c2f2ac91-47b5-43ef-b897-ab93ec546690_400x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:400,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Transparency&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="Transparency" title="Transparency" srcset="/__u/substackcdn.com/image/fetch/$s_!Un0O!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2f2ac91-47b5-43ef-b897-ab93ec546690_400x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!Un0O!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2f2ac91-47b5-43ef-b897-ab93ec546690_400x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!Un0O!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2f2ac91-47b5-43ef-b897-ab93ec546690_400x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Un0O!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2f2ac91-47b5-43ef-b897-ab93ec546690_400x350.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>HSL colors</h2><p>The hue, saturation, lightness (HSL) system is an alternative to RGB for specifying colors. It isn&#8217;t actually a different color space; it is a remapping of the RGB color space onto HSL values. The three values in the HSL system are:</p><ul><li><p>Hue determines the basic color.</p></li><li><p>Saturation determines how intense the color appears.</p></li><li><p>Lightness determines how light the color appears.</p></li></ul><p>HSL makes color more intuitive. If you have a particular color in mind, trying to find the correct RGB values to make that color can be very difficult. With HSL, you need to select the hue value that corresponds to the basic color you want. You can then vary the saturation and lightness to match exactly what you want. But the key thing is, changing the saturation and lightness doesn&#8217;t affect the underlying color itself.</p><p>This diagram illustrates HSL:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!8WAL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39cda85a-b27e-4054-a5a3-ee4670eedb48_790x340.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!8WAL!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39cda85a-b27e-4054-a5a3-ee4670eedb48_790x340.png 424w, /__u/substackcdn.com/image/fetch/$s_!8WAL!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39cda85a-b27e-4054-a5a3-ee4670eedb48_790x340.png 848w, /__u/substackcdn.com/image/fetch/$s_!8WAL!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39cda85a-b27e-4054-a5a3-ee4670eedb48_790x340.png 1272w, /__u/substackcdn.com/image/fetch/$s_!8WAL!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39cda85a-b27e-4054-a5a3-ee4670eedb48_790x340.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!8WAL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39cda85a-b27e-4054-a5a3-ee4670eedb48_790x340.png" width="790" height="340" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/39cda85a-b27e-4054-a5a3-ee4670eedb48_790x340.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:340,&quot;width&quot;:790,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;HSL&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="HSL" title="HSL" srcset="/__u/substackcdn.com/image/fetch/$s_!8WAL!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39cda85a-b27e-4054-a5a3-ee4670eedb48_790x340.png 424w, /__u/substackcdn.com/image/fetch/$s_!8WAL!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39cda85a-b27e-4054-a5a3-ee4670eedb48_790x340.png 848w, /__u/substackcdn.com/image/fetch/$s_!8WAL!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39cda85a-b27e-4054-a5a3-ee4670eedb48_790x340.png 1272w, /__u/substackcdn.com/image/fetch/$s_!8WAL!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39cda85a-b27e-4054-a5a3-ee4670eedb48_790x340.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 top bar shows the hue, assuming a saturation of 0.5 and a lightness of 0.5. The hue starts at red (when H is 0), then it moves towards yellow (when H is about one sixth), then to green, cyan, blue, and magenta. Finally, as H goes towards 1, the color goes back to red. You can choose any base color using an H value between 0 and 1.</p><p>Let&#8217;s imagine we picked an H value of two-thirds, which is blue. The second bar shows that same blue color with various saturation levels. If we move towards the right, the blue gets more saturated (you might say it is a purer blue, or a more intense blue). If we move to the left, the color gets less saturated, and starts to look more like a bluish grey. In fact, when the saturation is zero, the color will be pure grey. It doesn&#8217;t matter what the hue is; when the saturation is zero, the color will be grey.</p><p>The bottom bar shows the lightness. Again, we are using the blue hue, and we will assume the saturation is 0.5. The lightness value controls how light the color is. Towards the left of the bar, where the lightness is low, the color gets darker and darker. When the lightness is 0, the color is black. Towards the right of the bar, where the lightness is high, the color gets lighter and lighter. When the lightness is 1, the color is white.</p><p>Every possible RGB color can be represented using HSL values, and every possible HSL color can be represented using RGB values. They are just different mappings of the same values. However, HSL values are often more intuitive.</p><h2>Color properties</h2><p>It is sometimes useful to find the individual RGB or HSL values of a color. We can do it like this:</p><pre><code><code>color = Color("goldenrod")
red = color.r              # The red value
green = color.g            # The green value
blue = color.b             # The blue value
alpha = color.a            # The alpha value
hue = color.h              # The hue value
sat = color.s              # The saturation value
light = color.l            # The lightness value
rgb = color.rgb            # The color as a tuple of three floats
rgba = color.rgba          # The color as a tuple of four floats
</code></code></pre><p>Notice that all of these properties are available for all colors. For example, if a color is defined using RGB values, you can still find its hue. The single color properties return a single float in the range 0.0 to 1.0.</p><p>The <code>rgb</code> property returns the RGB values as a tuple of three floats representing the RGB colors. The <code>rgba</code> property returns the RGB values as a tuple of four floats representing the RGBA colors.</p><p>If you need to get the colors as byte values, you can use the following functions:</p><pre><code><code>color = Color("goldenrod")
rgb = color.as_rgb_bytes   # The color as a tuple of three 
                           # integers in range 0 to 255
rgba = color.as_rgba_bytes # The color as a tuple of four
                           # integers in range 0 to 255
</code></code></pre><p>The <code>as_rgbstr</code> function is similar to <code>as_rgb_bytes</code>, but it returns a string containing the integer RGB values in the form:</p><pre><code><code>"rgb(255, 128, 0)"
</code></code></pre><p>It can be useful for debugging.</p><h2>Color modifiers</h2><p>There are several ways to create a new color based on an existing color. For example:</p><pre><code><code>color1 = Color("indigo")
color2 = color1.with_r(0.7)
color3 = color1.with_s(0.2)
color4 = color1.with_a(0.8)
</code></code></pre><p>Here are the four colors the code creates:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!wUgS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c6758a-37d7-4545-9f42-970578271d61_800x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!wUgS!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c6758a-37d7-4545-9f42-970578271d61_800x200.png 424w, /__u/substackcdn.com/image/fetch/$s_!wUgS!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c6758a-37d7-4545-9f42-970578271d61_800x200.png 848w, /__u/substackcdn.com/image/fetch/$s_!wUgS!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c6758a-37d7-4545-9f42-970578271d61_800x200.png 1272w, /__u/substackcdn.com/image/fetch/$s_!wUgS!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c6758a-37d7-4545-9f42-970578271d61_800x200.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!wUgS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c6758a-37d7-4545-9f42-970578271d61_800x200.png" width="800" height="200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/49c6758a-37d7-4545-9f42-970578271d61_800x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Modifiers&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="Modifiers" title="Modifiers" srcset="/__u/substackcdn.com/image/fetch/$s_!wUgS!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c6758a-37d7-4545-9f42-970578271d61_800x200.png 424w, /__u/substackcdn.com/image/fetch/$s_!wUgS!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c6758a-37d7-4545-9f42-970578271d61_800x200.png 848w, /__u/substackcdn.com/image/fetch/$s_!wUgS!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c6758a-37d7-4545-9f42-970578271d61_800x200.png 1272w, /__u/substackcdn.com/image/fetch/$s_!wUgS!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c6758a-37d7-4545-9f42-970578271d61_800x200.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The square on the left is the original indigo color.</p><p>The next square shows the original color, but with the red component set to 0.7. This gives a slightly redder version of the color.</p><p>The next square shows the original color, but with the saturation set to 0.2. This gives a less saturated, or &#8220;greyer&#8221; version of the color.</p><p>The final square shows the original color, but with the alpha set to 0.8. This makes the color slightly transparent. It appears lighter because the white background of the page shows through.</p><p>There are modifiers for r, g, b, a, h, s, and l components.</p><p>There are also multiplier functions, for example:</p><pre><code><code>color1 = Color("indigo")
color5 = color1.with_r_factor(2)
</code></code></pre><p>In this example, the original red value will be multiplied by 2 to create the new color. The result will be clamped to a maximum value of 1.</p><p>Again, of course, there are modifiers for r, g, b, a, h, s, and l components.</p><p>Finally, there are light and dark properties that create lighter and darker versions of a color:</p><pre><code><code>color1 = Color("indigo")
color6 = color1.light1
</code></code></pre><p>The properties <code>light1</code>, <code>light2</code>, and <code>light3</code> create increasingly lighter versions of the original color. The properties <code>dark1</code>, <code>dark2</code> and <code>dark3</code> create increasingly darker versions. These are just for convenience. If you want more control over exactly how dark or light the color should be, use <code>with_l_factor</code> to change the lightness of the color.</p><h2>Color interpolation</h2><p>Interpolation creates a color that is partway between two other colors. It is used like this:</p><pre><code><code>new_color = color1.lerp(color2, 0.2)
</code></code></pre><p>In this code, <code>color1</code> and <code>color2</code> are two existing colors. The <code>lerp</code> function creates a new color that is partway between the two original colors.</p><p>Since the interpolation factor is 0.2, the new color will be approximately 80% <code>color1</code> plus 20% <code>color2</code>.</p><p>Here is an example:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!bS9h!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f858e3-8157-4132-9a07-e0594f784f02_600x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!bS9h!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f858e3-8157-4132-9a07-e0594f784f02_600x200.png 424w, /__u/substackcdn.com/image/fetch/$s_!bS9h!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f858e3-8157-4132-9a07-e0594f784f02_600x200.png 848w, /__u/substackcdn.com/image/fetch/$s_!bS9h!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f858e3-8157-4132-9a07-e0594f784f02_600x200.png 1272w, /__u/substackcdn.com/image/fetch/$s_!bS9h!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f858e3-8157-4132-9a07-e0594f784f02_600x200.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!bS9h!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f858e3-8157-4132-9a07-e0594f784f02_600x200.png" width="600" height="200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/40f858e3-8157-4132-9a07-e0594f784f02_600x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:600,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Lerp&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="Lerp" title="Lerp" srcset="/__u/substackcdn.com/image/fetch/$s_!bS9h!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f858e3-8157-4132-9a07-e0594f784f02_600x200.png 424w, /__u/substackcdn.com/image/fetch/$s_!bS9h!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f858e3-8157-4132-9a07-e0594f784f02_600x200.png 848w, /__u/substackcdn.com/image/fetch/$s_!bS9h!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f858e3-8157-4132-9a07-e0594f784f02_600x200.png 1272w, /__u/substackcdn.com/image/fetch/$s_!bS9h!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f858e3-8157-4132-9a07-e0594f784f02_600x200.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The square on the left is CSS Chartreuse, the square on the right is CSS Dark Cyan, the square in the middle is the color that is halfway between them.</p><h2>Color schemes</h2><p>Suppose you are creating images for a larger project. such as a website or book, it can be useful to use a standard set of colors across the whole project. Color schemes provide that.</p><p>A color scheme is a simple class that provides a set of colors as properties. You can define the set once and use it everywhere. The color module provides three color schemes:</p><ul><li><p><code>ArtisticColorScheme</code> provides a general set of nice colors.</p></li><li><p><code>DarkColorScheme</code> provides a set of colors designed for a dark background. I use that for most of my YouTube videos.</p></li><li><p><code>BookColorScheme</code> is what I currently use for the newer articles on this website, as well as my printed books and ebooks. This color scheme provides regular colors RED, GREEN, etc. It also has lighter colors REDFILL, GREENFILL, etc, that can be used to fill shapes.</p></li></ul><p>A color scheme is used like this:</p><pre><code><code>from generativepy.color import Color, BookColorScheme

cs = BookColorScheme()

Line(ctx).of_start_end(a, b).stroke(cs.BLACK, 4)
</code></code></pre><p>But, of course, feel free to create your own color scheme, using the existing schemes as a template.</p>]]></content:encoded></item><item><title><![CDATA[Hilbert's Hotel: Why a Fully Booked Infinite Hotel Never Turns You Away By Martin McBride, 2026-07-23 ]]></title><description><![CDATA[Picture a hotel with infinitely many rooms.]]></description><link>https://graphicmaths.substack.com/p/hilberts-hotel-why-a-fully-booked</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/hilberts-hotel-why-a-fully-booked</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Sun, 26 Jul 2026 17:32:44 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!qPpa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2b94c67-fc8e-448a-84e5-60349a52826a_1024x1024.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!qPpa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2b94c67-fc8e-448a-84e5-60349a52826a_1024x1024.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!qPpa!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2b94c67-fc8e-448a-84e5-60349a52826a_1024x1024.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!qPpa!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2b94c67-fc8e-448a-84e5-60349a52826a_1024x1024.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!qPpa!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2b94c67-fc8e-448a-84e5-60349a52826a_1024x1024.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!qPpa!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2b94c67-fc8e-448a-84e5-60349a52826a_1024x1024.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!qPpa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2b94c67-fc8e-448a-84e5-60349a52826a_1024x1024.jpeg" width="1024" height="1024" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c2b94c67-fc8e-448a-84e5-60349a52826a_1024x1024.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:216452,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://graphicmaths.substack.com/i/208580470?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2b94c67-fc8e-448a-84e5-60349a52826a_1024x1024.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!qPpa!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2b94c67-fc8e-448a-84e5-60349a52826a_1024x1024.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!qPpa!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2b94c67-fc8e-448a-84e5-60349a52826a_1024x1024.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!qPpa!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2b94c67-fc8e-448a-84e5-60349a52826a_1024x1024.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!qPpa!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc2b94c67-fc8e-448a-84e5-60349a52826a_1024x1024.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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>Picture a hotel with infinitely many rooms. Room 1, room 2, room 3, and so on, forever. Tonight, every single room is occupied. A &#8220;No Vacancy&#8221; sign glows above the entrance. And yet, when a weary traveller shows up at midnight, the manager smiles and says: <em>&#8220;Of course, right this way.&#8221;</em></p><p>Welcome to Hilbert&#8217;s Hotel. It is a thought experiment dreamed up by the mathematician David Hilbert to make one simple point: infinity does not behave the way you think it does. Once you see how this hotel manages always to have room, you&#8217;ll understand something profound about the nature of infinite sets.</p><p>Let&#8217;s check in.</p><h2>The latecomer</h2><p>So, it&#8217;s midnight. Every room is full. This diagram shows the rooms (numbered <em>r1</em>, <em>r2</em>...) and the guests in the rooms (numbered <em>g1</em>, <em>g2</em>...):</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!x2mb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ecd1739-b7cc-4046-be92-8694c6aa164a_580x220.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!x2mb!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ecd1739-b7cc-4046-be92-8694c6aa164a_580x220.png 424w, /__u/substackcdn.com/image/fetch/$s_!x2mb!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ecd1739-b7cc-4046-be92-8694c6aa164a_580x220.png 848w, /__u/substackcdn.com/image/fetch/$s_!x2mb!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ecd1739-b7cc-4046-be92-8694c6aa164a_580x220.png 1272w, /__u/substackcdn.com/image/fetch/$s_!x2mb!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ecd1739-b7cc-4046-be92-8694c6aa164a_580x220.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!x2mb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ecd1739-b7cc-4046-be92-8694c6aa164a_580x220.png" width="580" height="220" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9ecd1739-b7cc-4046-be92-8694c6aa164a_580x220.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:220,&quot;width&quot;:580,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Hilbert's hotel&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&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="Hilbert's hotel" title="Hilbert's hotel" srcset="/__u/substackcdn.com/image/fetch/$s_!x2mb!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ecd1739-b7cc-4046-be92-8694c6aa164a_580x220.png 424w, /__u/substackcdn.com/image/fetch/$s_!x2mb!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ecd1739-b7cc-4046-be92-8694c6aa164a_580x220.png 848w, /__u/substackcdn.com/image/fetch/$s_!x2mb!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ecd1739-b7cc-4046-be92-8694c6aa164a_580x220.png 1272w, /__u/substackcdn.com/image/fetch/$s_!x2mb!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ecd1739-b7cc-4046-be92-8694c6aa164a_580x220.png 1456w" sizes="100vw"></picture><div></div></div></a></figure></div><p>Guest 1 is in room 1, guest 2 is in room 2, and so on. There are infinitely many guests occupying infinitely many rooms, with one guest in each room.</p><p>A single new guest arrives at reception, tired and expecting to be turned away. The manager isn&#8217;t worried.</p><p>Here&#8217;s what the manager does. He asks the guest in room 1 to move to room 2. The guest in room 2 moves to room 3. The guest in room 3 moves to room 4. And so on. Every guest moves from their current room, , to the next room .</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!DXxU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd26ca7cf-53e1-4365-9fdf-0f79a20d0104_580x270.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!DXxU!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd26ca7cf-53e1-4365-9fdf-0f79a20d0104_580x270.png 424w, /__u/substackcdn.com/image/fetch/$s_!DXxU!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd26ca7cf-53e1-4365-9fdf-0f79a20d0104_580x270.png 848w, /__u/substackcdn.com/image/fetch/$s_!DXxU!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd26ca7cf-53e1-4365-9fdf-0f79a20d0104_580x270.png 1272w, /__u/substackcdn.com/image/fetch/$s_!DXxU!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd26ca7cf-53e1-4365-9fdf-0f79a20d0104_580x270.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!DXxU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd26ca7cf-53e1-4365-9fdf-0f79a20d0104_580x270.png" width="580" height="270" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d26ca7cf-53e1-4365-9fdf-0f79a20d0104_580x270.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:270,&quot;width&quot;:580,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Every guest moves to the next room&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="Every guest moves to the next room" title="Every guest moves to the next room" srcset="/__u/substackcdn.com/image/fetch/$s_!DXxU!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd26ca7cf-53e1-4365-9fdf-0f79a20d0104_580x270.png 424w, /__u/substackcdn.com/image/fetch/$s_!DXxU!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd26ca7cf-53e1-4365-9fdf-0f79a20d0104_580x270.png 848w, /__u/substackcdn.com/image/fetch/$s_!DXxU!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd26ca7cf-53e1-4365-9fdf-0f79a20d0104_580x270.png 1272w, /__u/substackcdn.com/image/fetch/$s_!DXxU!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd26ca7cf-53e1-4365-9fdf-0f79a20d0104_580x270.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 tried to do this in a normal hotel with, say, 100 rooms, it would not work. The guests in rooms 1 to 99 could move to rooms 2 to 100, no problem. But the guest in room 100 would need to move to room 101, and there is no such room.</p><p>But in an infinite hotel, there&#8217;s no &#8220;last room&#8221; to worry about. The rooms go on forever. The guest in room <em>n</em> can always move to room <em>n + 1</em>, no matter how big <em>n</em> might be.</p><p>So every existing guest still has a room, just one number higher than before. And now room 1 is empty, ready for the newcomer:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!onfV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e4e11-7944-43ea-8aa8-218dc9c906fa_580x220.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!onfV!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e4e11-7944-43ea-8aa8-218dc9c906fa_580x220.png 424w, /__u/substackcdn.com/image/fetch/$s_!onfV!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e4e11-7944-43ea-8aa8-218dc9c906fa_580x220.png 848w, /__u/substackcdn.com/image/fetch/$s_!onfV!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e4e11-7944-43ea-8aa8-218dc9c906fa_580x220.png 1272w, /__u/substackcdn.com/image/fetch/$s_!onfV!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e4e11-7944-43ea-8aa8-218dc9c906fa_580x220.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!onfV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e4e11-7944-43ea-8aa8-218dc9c906fa_580x220.png" width="580" height="220" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f04e4e11-7944-43ea-8aa8-218dc9c906fa_580x220.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:220,&quot;width&quot;:580,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Every guest moves to the next room&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="Every guest moves to the next room" title="Every guest moves to the next room" srcset="/__u/substackcdn.com/image/fetch/$s_!onfV!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e4e11-7944-43ea-8aa8-218dc9c906fa_580x220.png 424w, /__u/substackcdn.com/image/fetch/$s_!onfV!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e4e11-7944-43ea-8aa8-218dc9c906fa_580x220.png 848w, /__u/substackcdn.com/image/fetch/$s_!onfV!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e4e11-7944-43ea-8aa8-218dc9c906fa_580x220.png 1272w, /__u/substackcdn.com/image/fetch/$s_!onfV!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e4e11-7944-43ea-8aa8-218dc9c906fa_580x220.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The new arrival, <em>a1</em>, moves into room 1, and everybody is happy.</p><p>It can be difficult to get your head around this concept. Infinite or not, if the hotel is full it is full, surely? Well, you are perhaps thinking of infinity as being an ordinary number. But it is not.</p><p>Here&#8217;s the difference. In a hotel with 100 rooms, there is a room numbered 100. But in an infinite hotel, there is no room numbered infinity. Every room in the hotel has an ordinary, finite number. It is just that those numbers go on forever. So every single one of the guests is in a room with some unique number <em>n</em>, therefore each guest can move into room number <em>n + 1</em>, no matter how big <em>n</em> might be. They can all change rooms, leaving room 1 free.</p><p>If you still don&#8217;t believe it, then which guest will be left without a room? Guest 100 can move to room 101, guest 1,000 can move to room 1,001, guest 1,000,000 can move to room 1,000,001. Every guest is able to move into the next room, no matter what their current room number is.</p><p>It is also worth remembering that this is a thought experiment. An infinite hotel cannot exist in reality. Even if the entire surface of the Earth were covered in hotel rooms, there would still be a finite number of rooms. Vast, but finite. So the logic above would not apply. This huge but finite hotel could become full. But a truly infinite hotel cannot.</p><h2>Bijections</h2><p>One way to think about this is that we have mapped the set of original rooms onto a different set of rooms. Each room <em>n</em> is mapped onto a different room <em>n&#8217;</em> using the formula:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!mPyL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfe35a78-58c3-4580-87a0-db3b17f0b19f_191x78.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!mPyL!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfe35a78-58c3-4580-87a0-db3b17f0b19f_191x78.png 424w, /__u/substackcdn.com/image/fetch/$s_!mPyL!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfe35a78-58c3-4580-87a0-db3b17f0b19f_191x78.png 848w, /__u/substackcdn.com/image/fetch/$s_!mPyL!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfe35a78-58c3-4580-87a0-db3b17f0b19f_191x78.png 1272w, /__u/substackcdn.com/image/fetch/$s_!mPyL!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfe35a78-58c3-4580-87a0-db3b17f0b19f_191x78.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!mPyL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfe35a78-58c3-4580-87a0-db3b17f0b19f_191x78.png" width="191" height="78" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cfe35a78-58c3-4580-87a0-db3b17f0b19f_191x78.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:78,&quot;width&quot;:191,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;n' = n + 1&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="n' = n + 1" title="n' = n + 1" srcset="/__u/substackcdn.com/image/fetch/$s_!mPyL!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfe35a78-58c3-4580-87a0-db3b17f0b19f_191x78.png 424w, /__u/substackcdn.com/image/fetch/$s_!mPyL!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfe35a78-58c3-4580-87a0-db3b17f0b19f_191x78.png 848w, /__u/substackcdn.com/image/fetch/$s_!mPyL!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfe35a78-58c3-4580-87a0-db3b17f0b19f_191x78.png 1272w, /__u/substackcdn.com/image/fetch/$s_!mPyL!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfe35a78-58c3-4580-87a0-db3b17f0b19f_191x78.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The set of numbers 1 to infinity is mapped onto the set of numbers 2 to infinity. This is a one-to-one mapping (each <em>n</em> maps onto a unique <em>n&#8217;</em>), so it is <em>reversible</em>. If we know <em>n&#8217;</em> we can find <em>n</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!fK32!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb2485ba-b504-45a3-823a-d0f1503e6c7e_191x75.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!fK32!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb2485ba-b504-45a3-823a-d0f1503e6c7e_191x75.png 424w, /__u/substackcdn.com/image/fetch/$s_!fK32!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb2485ba-b504-45a3-823a-d0f1503e6c7e_191x75.png 848w, /__u/substackcdn.com/image/fetch/$s_!fK32!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb2485ba-b504-45a3-823a-d0f1503e6c7e_191x75.png 1272w, /__u/substackcdn.com/image/fetch/$s_!fK32!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb2485ba-b504-45a3-823a-d0f1503e6c7e_191x75.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!fK32!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb2485ba-b504-45a3-823a-d0f1503e6c7e_191x75.png" width="191" height="75" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/db2485ba-b504-45a3-823a-d0f1503e6c7e_191x75.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:75,&quot;width&quot;:191,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;n = n' - 1&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="n = n' - 1" title="n = n' - 1" srcset="/__u/substackcdn.com/image/fetch/$s_!fK32!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb2485ba-b504-45a3-823a-d0f1503e6c7e_191x75.png 424w, /__u/substackcdn.com/image/fetch/$s_!fK32!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb2485ba-b504-45a3-823a-d0f1503e6c7e_191x75.png 848w, /__u/substackcdn.com/image/fetch/$s_!fK32!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb2485ba-b504-45a3-823a-d0f1503e6c7e_191x75.png 1272w, /__u/substackcdn.com/image/fetch/$s_!fK32!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb2485ba-b504-45a3-823a-d0f1503e6c7e_191x75.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This type of reversible mapping is called a <em>bijection</em>. Since there is a one-to-one correspondence between the elements <em>n</em> and <em>n&#8217;</em>, the two sets must be the same size. That is true even though set <em>n</em> contains all the numbers in <em>n&#8217;</em> plus an extra number 1, that isn&#8217;t in <em>n&#8217;</em>.</p><p>When dealing with infinite sets, we use the term <em>cardinality</em> rather than <em>size</em>, because size implies that we can somehow count all the elements. The set of all natural numbers has a cardinality called <em>countably infinite</em>. Any set that can be mapped onto the natural numbers by a bijection is also countably infinite. This means that the number of rooms in Hilbert&#8217;s hotel is also countably infinite.</p><p>There are other cardinailities that are larger the countably infinite, see <a href="https://graphicmaths.com/pure/sets/countable-uncountable-sets/">Countable and uncountable sets</a>.</p><h2>The infinite coach</h2><p>Now let&#8217;s look at a slightly different situation. Instead of a single new arrival, a whole coach load of people turns up at the hotel. But this is a very special coach carrying infinitely many new guests, numbered <em>a1</em>, <em>a2</em>, <em>a3</em>, and so on forever. Surely <em>this</em> is a problem? The hotel is still full, and now there isn&#8217;t just one extra guest to fit in. There are infinitely many guests.</p><p>The manager knows exactly what to do. This time, every existing guest is asked to move from room into room . So the guest in room 1 moves to room 2. The guest in room 2 moves to room 4. The guest in room 3 moves to room 6. In general, whoever was in room now lives in room :</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!LVRK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F585e1a1d-62f9-42e8-8ffa-cd4bf1b747a1_580x270.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!LVRK!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F585e1a1d-62f9-42e8-8ffa-cd4bf1b747a1_580x270.png 424w, /__u/substackcdn.com/image/fetch/$s_!LVRK!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F585e1a1d-62f9-42e8-8ffa-cd4bf1b747a1_580x270.png 848w, /__u/substackcdn.com/image/fetch/$s_!LVRK!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F585e1a1d-62f9-42e8-8ffa-cd4bf1b747a1_580x270.png 1272w, /__u/substackcdn.com/image/fetch/$s_!LVRK!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F585e1a1d-62f9-42e8-8ffa-cd4bf1b747a1_580x270.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!LVRK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F585e1a1d-62f9-42e8-8ffa-cd4bf1b747a1_580x270.png" width="580" height="270" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/585e1a1d-62f9-42e8-8ffa-cd4bf1b747a1_580x270.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:270,&quot;width&quot;:580,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Every guest moves from n to 2n&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="Every guest moves from n to 2n" title="Every guest moves from n to 2n" srcset="/__u/substackcdn.com/image/fetch/$s_!LVRK!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F585e1a1d-62f9-42e8-8ffa-cd4bf1b747a1_580x270.png 424w, /__u/substackcdn.com/image/fetch/$s_!LVRK!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F585e1a1d-62f9-42e8-8ffa-cd4bf1b747a1_580x270.png 848w, /__u/substackcdn.com/image/fetch/$s_!LVRK!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F585e1a1d-62f9-42e8-8ffa-cd4bf1b747a1_580x270.png 1272w, /__u/substackcdn.com/image/fetch/$s_!LVRK!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F585e1a1d-62f9-42e8-8ffa-cd4bf1b747a1_580x270.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Notice what this does: every existing guest now occupies an <em>even-numbered</em> room. That means every <em>odd-numbered</em> room (room 1, room 3, room 5, and so on, infinitely many of them) is now empty.</p><p>So the manager puts passenger <em>a1</em> into room 1, passenger <em>a2</em> into room 3, passenger <em>a3</em> into room 5, etc. In general, passenger goes into room . Every single passenger from the coach gets a room. Every original guest still has a room. Nobody shares, nobody sleeps in the car park. Here is what the hotel looks like when the new guests move in:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!QJhv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbdb0f4a-fd76-404e-92c5-7b267a061b6f_580x220.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!QJhv!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbdb0f4a-fd76-404e-92c5-7b267a061b6f_580x220.png 424w, /__u/substackcdn.com/image/fetch/$s_!QJhv!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbdb0f4a-fd76-404e-92c5-7b267a061b6f_580x220.png 848w, /__u/substackcdn.com/image/fetch/$s_!QJhv!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbdb0f4a-fd76-404e-92c5-7b267a061b6f_580x220.png 1272w, /__u/substackcdn.com/image/fetch/$s_!QJhv!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbdb0f4a-fd76-404e-92c5-7b267a061b6f_580x220.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!QJhv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbdb0f4a-fd76-404e-92c5-7b267a061b6f_580x220.png" width="580" height="220" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cbdb0f4a-fd76-404e-92c5-7b267a061b6f_580x220.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:220,&quot;width&quot;:580,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Each new guest k goes in room 2k - 1&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="Each new guest k goes in room 2k - 1" title="Each new guest k goes in room 2k - 1" srcset="/__u/substackcdn.com/image/fetch/$s_!QJhv!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbdb0f4a-fd76-404e-92c5-7b267a061b6f_580x220.png 424w, /__u/substackcdn.com/image/fetch/$s_!QJhv!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbdb0f4a-fd76-404e-92c5-7b267a061b6f_580x220.png 848w, /__u/substackcdn.com/image/fetch/$s_!QJhv!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbdb0f4a-fd76-404e-92c5-7b267a061b6f_580x220.png 1272w, /__u/substackcdn.com/image/fetch/$s_!QJhv!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbdb0f4a-fd76-404e-92c5-7b267a061b6f_580x220.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Once again, this is just a bijection, but this time it is a slightly more elaborate pairing that divides the hotel into two infinite chunks (the evens and the odds) and gives one chunk to the old guests and one chunk to the new. The set of whole numbers, it turns out, contains room for <em>two</em> full copies of itself. This tells us something wild - an infinite set can be the same &#8220;size&#8221; as a set that seems, at first glance, to be twice as big.</p><h2>Infinitely many infinite coaches</h2><p>What could be worse than a coach with an infinite number of passengers? Well, suppose the manager looks out of his window and sees not one coach, but infinitely many coaches, each queued up one behind the other. We will call these <em>c1</em>, <em>c2</em>, <em>c3</em>, and so on forever. And, as before, <em>each coach carries infinitely many passengers.</em></p><p>This feels like it should finally break the hotel. We don&#8217;t just have one extra infinity-large set of guests. We have an infinite number of infinite sets of guests. Surely there&#8217;s no way to fit an <em>infinity of infinities</em> into a mere infinity of rooms?</p><p>As a first step in solving this problem, we need to find a new way to number the incoming guests. We have infinitely many coaches each containing infinitely many guests, so let&#8217;s identify each new guest by their coach and their seat number on the coach.</p><ul><li><p>The guest who arrives on seat 1 of coach 1 can be called <em>(s1, c1)</em>.</p></li><li><p>The guest on seat 2 of coach 1 is <em>(s2, c1)</em>, and so on.</p></li><li><p>The first 2 guests on coach two are called <em>(s1, c2)</em> and <em>(s2, c2)</em>, and so on.</p></li><li><p>The guests on coaches 3, 4, 5... are named in a similar way</p></li></ul><p>This gives a unique identity to every passenger on every coach. We can represent this as a table:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!X4oW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e4b5464-fcd3-4e16-81f7-50966068c199_880x520.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!X4oW!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e4b5464-fcd3-4e16-81f7-50966068c199_880x520.png 424w, /__u/substackcdn.com/image/fetch/$s_!X4oW!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e4b5464-fcd3-4e16-81f7-50966068c199_880x520.png 848w, /__u/substackcdn.com/image/fetch/$s_!X4oW!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e4b5464-fcd3-4e16-81f7-50966068c199_880x520.png 1272w, /__u/substackcdn.com/image/fetch/$s_!X4oW!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e4b5464-fcd3-4e16-81f7-50966068c199_880x520.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!X4oW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e4b5464-fcd3-4e16-81f7-50966068c199_880x520.png" width="880" height="520" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5e4b5464-fcd3-4e16-81f7-50966068c199_880x520.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:520,&quot;width&quot;:880,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;All guests on all coaches&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="All guests on all coaches" title="All guests on all coaches" srcset="/__u/substackcdn.com/image/fetch/$s_!X4oW!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e4b5464-fcd3-4e16-81f7-50966068c199_880x520.png 424w, /__u/substackcdn.com/image/fetch/$s_!X4oW!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e4b5464-fcd3-4e16-81f7-50966068c199_880x520.png 848w, /__u/substackcdn.com/image/fetch/$s_!X4oW!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e4b5464-fcd3-4e16-81f7-50966068c199_880x520.png 1272w, /__u/substackcdn.com/image/fetch/$s_!X4oW!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e4b5464-fcd3-4e16-81f7-50966068c199_880x520.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 top row of this table represents the guests who are already staying at the hotel: <em>g1</em>, <em>g2</em>, etc. The first 5 are shown, but of course the row is infinitely long.</p><p>The second row represents the guests on coach 1, the third row represents the guests on coach 2, and so on. The table is infinite in both directions. There are infinitely many columns because each coach has infinitely many seats, and there are infinitely many rows because there are infinitely many coaches.</p><p>If we want to fit all these guests into the hotel, we need to find a way to give each guest a unique hotel room number. But that looks impossible. For example, we start on the first row, we can put customer <em>g1</em> in room 1, <em>g2</em> in room 2, etc. But the first row is infinitely long, so we will never reach the end. So we will never get around to finding rooms for row 2 (ie the customers in coach 1).</p><p>But it isn&#8217;t impossible, we just need a bit of lateral thinking. Or, in this case, diagonal thinking. We can visit all the squares in the grid in this order:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!6DjT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb35eaec9-ec88-4594-97e7-45d8c1d15672_880x520.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!6DjT!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb35eaec9-ec88-4594-97e7-45d8c1d15672_880x520.png 424w, /__u/substackcdn.com/image/fetch/$s_!6DjT!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb35eaec9-ec88-4594-97e7-45d8c1d15672_880x520.png 848w, /__u/substackcdn.com/image/fetch/$s_!6DjT!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb35eaec9-ec88-4594-97e7-45d8c1d15672_880x520.png 1272w, /__u/substackcdn.com/image/fetch/$s_!6DjT!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb35eaec9-ec88-4594-97e7-45d8c1d15672_880x520.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!6DjT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb35eaec9-ec88-4594-97e7-45d8c1d15672_880x520.png" width="880" height="520" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b35eaec9-ec88-4594-97e7-45d8c1d15672_880x520.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:520,&quot;width&quot;:880,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Ordering guests on all coaches&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="Ordering guests on all coaches" title="Ordering guests on all coaches" srcset="/__u/substackcdn.com/image/fetch/$s_!6DjT!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb35eaec9-ec88-4594-97e7-45d8c1d15672_880x520.png 424w, /__u/substackcdn.com/image/fetch/$s_!6DjT!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb35eaec9-ec88-4594-97e7-45d8c1d15672_880x520.png 848w, /__u/substackcdn.com/image/fetch/$s_!6DjT!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb35eaec9-ec88-4594-97e7-45d8c1d15672_880x520.png 1272w, /__u/substackcdn.com/image/fetch/$s_!6DjT!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb35eaec9-ec88-4594-97e7-45d8c1d15672_880x520.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>First we assign guest <em>g1</em> to room 1.</p><p>Then we move along and assign <em>g2</em> to room 2. But here is the sneaky part. We move down diagonally and assign <em>(s1, c1)</em> to room 3.</p><p>Then we go back to the top row and work down diagonally again. <em>g3</em> gets room 4, <em>(s2, c1)</em> gets room 5, <em>(s1, c2)</em> gets room 6.</p><p>Then we do the same again. <em>g4</em>, <em>(s3, c1)</em>, <em>(s2, c2)</em> and <em>(s1, c3)</em> gets rooms 7, 8, 9 and 10.</p><p>We can carry on doing that forever. Every diagonal is <em>finite</em> in length (the first has 1 cell, the second has 2, the third has 3, and so on), so we will eventually find a room for every guest.</p><p>There is an infinity of infinities of guests, but the hotel still absorbs every single one of them into its ordinary, single infinity of rooms.</p><h2>Another way to do it</h2><p>If we look at this problem a slightly different way, we can find an alternative approach. We just put a lot of effort into an elaborate scheme to put exactly one guest in every room, but there is another way to look at this. We have infinitely many rooms, so:</p><ul><li><p>We don&#8217;t need to ensure that every room has a guest.</p></li><li><p>All we need to do is to make sure that we don&#8217;t put two guests in the same room.</p></li></ul><p>If we can find a way to assign a unique room number to every guest, then that is enough. It doesn&#8217;t matter if that leaves some rooms empty.</p><p>One way to do that is to use <em>prime factorisation</em>. We know that any integer can be expressed as a unique product of prime numbers. For example:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!7_gI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F324711dc-2035-4aef-a5a4-41ae9a6884c5_569x77.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!7_gI!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F324711dc-2035-4aef-a5a4-41ae9a6884c5_569x77.png 424w, /__u/substackcdn.com/image/fetch/$s_!7_gI!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F324711dc-2035-4aef-a5a4-41ae9a6884c5_569x77.png 848w, /__u/substackcdn.com/image/fetch/$s_!7_gI!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F324711dc-2035-4aef-a5a4-41ae9a6884c5_569x77.png 1272w, /__u/substackcdn.com/image/fetch/$s_!7_gI!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F324711dc-2035-4aef-a5a4-41ae9a6884c5_569x77.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!7_gI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F324711dc-2035-4aef-a5a4-41ae9a6884c5_569x77.png" width="569" height="77" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/324711dc-2035-4aef-a5a4-41ae9a6884c5_569x77.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:77,&quot;width&quot;:569,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;450 = 2 \\times 3^2 \\times 5^2&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="450 = 2 \times 3^2 \times 5^2" title="450 = 2 \times 3^2 \times 5^2" srcset="/__u/substackcdn.com/image/fetch/$s_!7_gI!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F324711dc-2035-4aef-a5a4-41ae9a6884c5_569x77.png 424w, /__u/substackcdn.com/image/fetch/$s_!7_gI!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F324711dc-2035-4aef-a5a4-41ae9a6884c5_569x77.png 848w, /__u/substackcdn.com/image/fetch/$s_!7_gI!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F324711dc-2035-4aef-a5a4-41ae9a6884c5_569x77.png 1272w, /__u/substackcdn.com/image/fetch/$s_!7_gI!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F324711dc-2035-4aef-a5a4-41ae9a6884c5_569x77.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>For any positive integer <em>n</em>, there is only one way to express <em>n</em> as a product of primes. That means that every product of primes corresponds to a different positive integer.</p><p>How does this help us? Well, we could create a mapping between a particular seat on a particular coach and a room number. For example, we could use the following formula to calculate a room number for the passenger in seat number <em>p</em> on coach number <em>q</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!xDml!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68fcd39a-41e3-4eb7-aed3-c4123333cace_329x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!xDml!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68fcd39a-41e3-4eb7-aed3-c4123333cace_329x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!xDml!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68fcd39a-41e3-4eb7-aed3-c4123333cace_329x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!xDml!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68fcd39a-41e3-4eb7-aed3-c4123333cace_329x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xDml!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68fcd39a-41e3-4eb7-aed3-c4123333cace_329x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!xDml!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68fcd39a-41e3-4eb7-aed3-c4123333cace_329x81.png" width="329" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/68fcd39a-41e3-4eb7-aed3-c4123333cace_329x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:329,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;(sp, cq) \\implies = 2^p \\times 3^q&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="(sp, cq) \implies = 2^p \times 3^q" title="(sp, cq) \implies = 2^p \times 3^q" srcset="/__u/substackcdn.com/image/fetch/$s_!xDml!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68fcd39a-41e3-4eb7-aed3-c4123333cace_329x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!xDml!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68fcd39a-41e3-4eb7-aed3-c4123333cace_329x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!xDml!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68fcd39a-41e3-4eb7-aed3-c4123333cace_329x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xDml!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68fcd39a-41e3-4eb7-aed3-c4123333cace_329x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Since this is a prime factorisation, the room number for any particular <em>p</em> and <em>q</em> is unique. So every passenger will get a different room.</p><p>For example, the passenger in seat 2 on coach 1 will be sent to room 12. No other passenger will be sent to room 12:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!kYGh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8285336b-48a5-4e02-8c56-ec3342a73ab3_518x85.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!kYGh!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8285336b-48a5-4e02-8c56-ec3342a73ab3_518x85.png 424w, /__u/substackcdn.com/image/fetch/$s_!kYGh!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8285336b-48a5-4e02-8c56-ec3342a73ab3_518x85.png 848w, /__u/substackcdn.com/image/fetch/$s_!kYGh!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8285336b-48a5-4e02-8c56-ec3342a73ab3_518x85.png 1272w, /__u/substackcdn.com/image/fetch/$s_!kYGh!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8285336b-48a5-4e02-8c56-ec3342a73ab3_518x85.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!kYGh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8285336b-48a5-4e02-8c56-ec3342a73ab3_518x85.png" width="518" height="85" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8285336b-48a5-4e02-8c56-ec3342a73ab3_518x85.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:85,&quot;width&quot;:518,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;(s2, c1) \\implies = 2^2 \\times 3^1 = 12&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="(s2, c1) \implies = 2^2 \times 3^1 = 12" title="(s2, c1) \implies = 2^2 \times 3^1 = 12" srcset="/__u/substackcdn.com/image/fetch/$s_!kYGh!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8285336b-48a5-4e02-8c56-ec3342a73ab3_518x85.png 424w, /__u/substackcdn.com/image/fetch/$s_!kYGh!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8285336b-48a5-4e02-8c56-ec3342a73ab3_518x85.png 848w, /__u/substackcdn.com/image/fetch/$s_!kYGh!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8285336b-48a5-4e02-8c56-ec3342a73ab3_518x85.png 1272w, /__u/substackcdn.com/image/fetch/$s_!kYGh!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8285336b-48a5-4e02-8c56-ec3342a73ab3_518x85.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The passenger in seat 4 on coach 2 will be sent to room 144. No other passenger will be sent to room 144:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!4lgA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfdc949b-fc6f-459e-8b2c-12a0f92962a4_550x85.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!4lgA!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfdc949b-fc6f-459e-8b2c-12a0f92962a4_550x85.png 424w, /__u/substackcdn.com/image/fetch/$s_!4lgA!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfdc949b-fc6f-459e-8b2c-12a0f92962a4_550x85.png 848w, /__u/substackcdn.com/image/fetch/$s_!4lgA!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfdc949b-fc6f-459e-8b2c-12a0f92962a4_550x85.png 1272w, /__u/substackcdn.com/image/fetch/$s_!4lgA!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfdc949b-fc6f-459e-8b2c-12a0f92962a4_550x85.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!4lgA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfdc949b-fc6f-459e-8b2c-12a0f92962a4_550x85.png" width="550" height="85" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dfdc949b-fc6f-459e-8b2c-12a0f92962a4_550x85.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:85,&quot;width&quot;:550,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;(s4, c2) \\implies = 2^4 \\times 3^2 = 16 \\times 27 = 144&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="(s4, c2) \implies = 2^4 \times 3^2 = 16 \times 27 = 144" title="(s4, c2) \implies = 2^4 \times 3^2 = 16 \times 27 = 144" srcset="/__u/substackcdn.com/image/fetch/$s_!4lgA!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfdc949b-fc6f-459e-8b2c-12a0f92962a4_550x85.png 424w, /__u/substackcdn.com/image/fetch/$s_!4lgA!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfdc949b-fc6f-459e-8b2c-12a0f92962a4_550x85.png 848w, /__u/substackcdn.com/image/fetch/$s_!4lgA!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfdc949b-fc6f-459e-8b2c-12a0f92962a4_550x85.png 1272w, /__u/substackcdn.com/image/fetch/$s_!4lgA!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfdc949b-fc6f-459e-8b2c-12a0f92962a4_550x85.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This means that the hotel manager can look at each guest&#8217;s coach ticket and tell them which room to go to. The guest who arrived on seat 2 of coach 1 is sent to room 12. The guest who arrived on seat 4 of coach 2 is sent to room 144.</p><p>This scheme ensures that every guest gets their own room. But notice that some rooms in the hotel will be left empty. In fact, a room will not be occupied if it has any prime factors other than 2 or 3. Room 10 won&#8217;t be occupied, for example, because 10 is divisible by 5.</p><p>In fact, the vast majority of rooms will not be occupied, because most numbers have prime factors other than 2 or 3. Almost all the rooms in the hotel will be empty. Previously we had infinitely many guests in the hotel, and every room was full. Now we have infinitely more guests but almost every room is empty!</p><p><em>Just one minor point. In the original example, we took account of the existing guests as well as the guests arriving on coaches. With this new method, we are only taking account of the guests arriving on coaches. That is to simplify the description. If we wanted to include the existing guests too, we could pretend they arrived on coach 0. The existing guests would be moved to rooms 2, 4, 8, 16...</em></p><h2>Adding an extra level</h2><p>We will add one extra level. Suppose the coaches arrive on a ferry. Each ferry carries an infinite number of coaches. What happens if an infinite number of ferries all arrive at the hotel at the same time?</p><p>So now we have an infinite number of ferries, each holding an infinite number of coaches, each holding an infinite number of passengers. An infinity of infinities of infinities. Can the hotel accommodate all those guests? Of course it can.</p><p>Each guest is now uniquely identified by which seat they had, on which coach, and on which ferry. We can calculate the room number for the passenger in seat number <em>p</em>, on coach number <em>q</em>, on ferry number <em>r</em>, like this:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!548v!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e8e6eb4-ce10-4cf7-91b8-7edb229cf586_447x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!548v!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e8e6eb4-ce10-4cf7-91b8-7edb229cf586_447x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!548v!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e8e6eb4-ce10-4cf7-91b8-7edb229cf586_447x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!548v!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e8e6eb4-ce10-4cf7-91b8-7edb229cf586_447x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!548v!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e8e6eb4-ce10-4cf7-91b8-7edb229cf586_447x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!548v!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e8e6eb4-ce10-4cf7-91b8-7edb229cf586_447x81.png" width="447" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e8e6eb4-ce10-4cf7-91b8-7edb229cf586_447x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:447,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;(sp, cq, fr) \\implies = 2^p \\times 3^q \\times 5^r&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="(sp, cq, fr) \implies = 2^p \times 3^q \times 5^r" title="(sp, cq, fr) \implies = 2^p \times 3^q \times 5^r" srcset="/__u/substackcdn.com/image/fetch/$s_!548v!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e8e6eb4-ce10-4cf7-91b8-7edb229cf586_447x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!548v!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e8e6eb4-ce10-4cf7-91b8-7edb229cf586_447x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!548v!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e8e6eb4-ce10-4cf7-91b8-7edb229cf586_447x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!548v!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e8e6eb4-ce10-4cf7-91b8-7edb229cf586_447x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We have added an extra prime factor of 5. Once again, each guest (ie each unique combination of <em>p</em>, <em>q</em> and <em>r</em>) will be given a unique room number.</p><h2>So is this really a paradox?</h2><p>This is a paradox, but it is a specific type of paradox. It doesn&#8217;t involve a contradiction or an inconsistency. It is a <em>veridical paradox</em>. That is a type of paradox that seems absurd or contradictory but actually turns out to be true once you understand the mathematics.</p><p>It is also sometimes called a <em>paradox of infinity</em> or a <em>set-theoretic paradox</em>. These are particular types of veridical paradoxes that occur when looking at infinite sets.</p><p>What&#8217;s really happening is that our everyday intuition about size, based entirely on our experience with finite collections of things, simply doesn&#8217;t transfer to the infinite. &#8220;Full&#8221; stops meaning what you think it means. &#8220;Bigger&#8221; and &#8220;smaller&#8221; need new definitions, which is exactly what bijections give us. A bijection is a rigorous way to say two infinite sets are &#8220;the same size&#8221; without ever needing to count them.</p><p>Hilbert introduced this hotel in a 1924 lecture to make that point vivid and unforgettable. Hilbert himself never published his lecture, but fortunately his colleague Richard Courant did.</p><p>The lecture wasn&#8217;t there to trick anyone, but to train the imagination for ideas Georg Cantor (the mathematician who first studied the sizes of infinite sets) had proven decades earlier. Ideas such as <a href="https://graphicmaths.com/recreational/paradoxes/galileo-paradox/">Galileo&#8217;s paradox</a> and the <a href="https://graphicmaths.com/fractals/fractals/cantor-set/">Cantor set</a></p><p>.</p>]]></content:encoded></item><item><title><![CDATA[Special relativity length contraction]]></title><description><![CDATA[In a previous article, we looked at Einstein&#8217;s thought experiment in which a train passes through a station at very high speed.]]></description><link>https://graphicmaths.substack.com/p/special-relativity-length-contraction</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/special-relativity-length-contraction</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Thu, 16 Jul 2026 13:42:45 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!R1X4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d8a2188-6562-4021-9b43-e927c4b5ffdb_1024x1024.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!R1X4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d8a2188-6562-4021-9b43-e927c4b5ffdb_1024x1024.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!R1X4!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d8a2188-6562-4021-9b43-e927c4b5ffdb_1024x1024.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!R1X4!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d8a2188-6562-4021-9b43-e927c4b5ffdb_1024x1024.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!R1X4!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d8a2188-6562-4021-9b43-e927c4b5ffdb_1024x1024.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!R1X4!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d8a2188-6562-4021-9b43-e927c4b5ffdb_1024x1024.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!R1X4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d8a2188-6562-4021-9b43-e927c4b5ffdb_1024x1024.jpeg" width="1024" height="1024" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3d8a2188-6562-4021-9b43-e927c4b5ffdb_1024x1024.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:206231,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://graphicmaths.substack.com/i/207289090?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d8a2188-6562-4021-9b43-e927c4b5ffdb_1024x1024.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!R1X4!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d8a2188-6562-4021-9b43-e927c4b5ffdb_1024x1024.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!R1X4!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d8a2188-6562-4021-9b43-e927c4b5ffdb_1024x1024.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!R1X4!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d8a2188-6562-4021-9b43-e927c4b5ffdb_1024x1024.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!R1X4!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d8a2188-6562-4021-9b43-e927c4b5ffdb_1024x1024.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 a previous article, we looked at Einstein&#8217;s thought experiment in which a train passes through a station at very high speed. We learned that, from the point of view of someone on the station platform, time passes more slowly for a clock on the train. This is called <a href="https://graphicmaths.com/physics/relativity/special-relativity-time-dilation/">time dilation</a>.</p><p>This time we will look at a second, equally non-intuitive effect. From the point of view of someone on the station platform, the length of objects on the train contracts - but only in the direction the train is travelling.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/subscribe"><span>Subscribe now</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/p/special-relativity-length-contraction?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/p/special-relativity-length-contraction?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share</span></a></p><p><em>My book on Calculus is available from <a href="https://www.amazon.co.uk/Calculus-Martin-McBride-ebook/dp/B0DLBH5Y5M">Amazon</a>.</em></p><h2>Einstein&#8217;s two postulates</h2><p>Einstein based his ideas on two postulates, which are assumed to be self-evidently true:</p><ul><li><p>The laws of physics are the same in all inertial frames of reference. Recall that an inertial frame is one where the velocity is not changing (ie the frame is not accelerating, decelerating, or changing direction).</p></li><li><p>Light always travels at the same speed, <em>c</em>, in all inertial frames of reference.</p></li></ul><p>The first postulate tells us that the laws of physics are the same for an observer on a train as they are for an observer on a station platform. But there is an additional implication of this postulate: the universe has no preferred direction. Light travelling horizontally behaves the same as light travelling vertically. This follows because what is horizontal in one frame might be vertical in another, and the laws of physics are the same in all frames.</p><h2>A quick recap on time dilation</h2><p>Before we start, it is worth quickly revisiting the topic of time dilation.</p><p>Einstein imagined a <em>light clock</em> on a train passing through a station. A light clock has a pulse of light that bounces back and forth between two mirrors. The light clock is aligned vertically on the train. Here is what the light clock looks like to an observer on the train:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Oj9j!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48285883-82fa-402c-9a71-2f6302f24f9a_250x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Oj9j!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48285883-82fa-402c-9a71-2f6302f24f9a_250x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!Oj9j!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48285883-82fa-402c-9a71-2f6302f24f9a_250x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!Oj9j!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48285883-82fa-402c-9a71-2f6302f24f9a_250x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Oj9j!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48285883-82fa-402c-9a71-2f6302f24f9a_250x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Oj9j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48285883-82fa-402c-9a71-2f6302f24f9a_250x500.png" width="250" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/48285883-82fa-402c-9a71-2f6302f24f9a_250x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:250,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Vertical light clock as seen by an observer on the train&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="Vertical light clock as seen by an observer on the train" title="Vertical light clock as seen by an observer on the train" srcset="/__u/substackcdn.com/image/fetch/$s_!Oj9j!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48285883-82fa-402c-9a71-2f6302f24f9a_250x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!Oj9j!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48285883-82fa-402c-9a71-2f6302f24f9a_250x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!Oj9j!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48285883-82fa-402c-9a71-2f6302f24f9a_250x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Oj9j!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48285883-82fa-402c-9a71-2f6302f24f9a_250x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 distance between the two mirrors is <em>d</em>, so the time taken for the light to travel from the bottom mirror (A) to the top mirror (B) and back again (C) is the total distance, <em>2d</em>, divided by the speed of light, <em>c</em>.</p><p>Here is what the light clock looks like to an observer on the platform:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!ku35!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6081d259-ee0e-4f2c-b3d9-c956769dcd56_800x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!ku35!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6081d259-ee0e-4f2c-b3d9-c956769dcd56_800x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!ku35!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6081d259-ee0e-4f2c-b3d9-c956769dcd56_800x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!ku35!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6081d259-ee0e-4f2c-b3d9-c956769dcd56_800x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ku35!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6081d259-ee0e-4f2c-b3d9-c956769dcd56_800x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!ku35!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6081d259-ee0e-4f2c-b3d9-c956769dcd56_800x500.png" width="800" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6081d259-ee0e-4f2c-b3d9-c956769dcd56_800x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Vertical light clock as seen by an observer on the platform&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="Vertical light clock as seen by an observer on the platform" title="Vertical light clock as seen by an observer on the platform" srcset="/__u/substackcdn.com/image/fetch/$s_!ku35!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6081d259-ee0e-4f2c-b3d9-c956769dcd56_800x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!ku35!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6081d259-ee0e-4f2c-b3d9-c956769dcd56_800x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!ku35!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6081d259-ee0e-4f2c-b3d9-c956769dcd56_800x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ku35!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6081d259-ee0e-4f2c-b3d9-c956769dcd56_800x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 light sets off from the bottom mirror (A). But by the time the light reaches the top mirror (B), the train has moved along. The light hitting the mirror must have travelled diagonally by a distance <em>e</em> (which is greater than <em>d</em>). A similar thing happens as the light reflects back to the bottom mirror (C).</p><p>So here is the strange thing. Observers on the train and the platform would both see the light leaves the bottom mirror (A) simultaneously. They would also see the light returning to the bottom mirror (C) simultaneously. How can this happen if the journey took a different length of time in the two frames? Well, the only explanation is that, from the point of view of the observer on the platform, time passes more slowly in the moving frame. In the <a href="https://graphicmaths.com/physics/relativity/special-relativity-time-dilation/">time dilation</a> article we saw that the time slows down by a factor of &#947;:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!AZP8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb047d322-a1b0-46eb-85f3-75d985dfe74c_235x147.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!AZP8!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb047d322-a1b0-46eb-85f3-75d985dfe74c_235x147.png 424w, /__u/substackcdn.com/image/fetch/$s_!AZP8!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb047d322-a1b0-46eb-85f3-75d985dfe74c_235x147.png 848w, /__u/substackcdn.com/image/fetch/$s_!AZP8!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb047d322-a1b0-46eb-85f3-75d985dfe74c_235x147.png 1272w, /__u/substackcdn.com/image/fetch/$s_!AZP8!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb047d322-a1b0-46eb-85f3-75d985dfe74c_235x147.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!AZP8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb047d322-a1b0-46eb-85f3-75d985dfe74c_235x147.png" width="235" height="147" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b047d322-a1b0-46eb-85f3-75d985dfe74c_235x147.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:147,&quot;width&quot;:235,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Lorentz factor \\gamma =  \\frac{1}{\\sqrt{1 - \\frac{v^2}{c^2}}}&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="Lorentz factor \gamma =  \frac{1}{\sqrt{1 - \frac{v^2}{c^2}}}" title="Lorentz factor \gamma =  \frac{1}{\sqrt{1 - \frac{v^2}{c^2}}}" srcset="/__u/substackcdn.com/image/fetch/$s_!AZP8!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb047d322-a1b0-46eb-85f3-75d985dfe74c_235x147.png 424w, /__u/substackcdn.com/image/fetch/$s_!AZP8!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb047d322-a1b0-46eb-85f3-75d985dfe74c_235x147.png 848w, /__u/substackcdn.com/image/fetch/$s_!AZP8!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb047d322-a1b0-46eb-85f3-75d985dfe74c_235x147.png 1272w, /__u/substackcdn.com/image/fetch/$s_!AZP8!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb047d322-a1b0-46eb-85f3-75d985dfe74c_235x147.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Where <em>v</em> is the velocity of the train. This factor is close to 1 for small values of <em>v</em>, but becomes very large as <em>v</em> approaches <em>c</em>.</p><h2>Einstein&#8217;s second thought experiment</h2><p>Einstein suggested a second thought experiment. What if we had another light clock, identical to the first, but this time we placed it horizontally in the train, in the direction of travel? Here is how this would look to an observer on the train:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Kti9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac681ff1-7df1-483a-830b-9da7855795b3_500x250.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Kti9!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac681ff1-7df1-483a-830b-9da7855795b3_500x250.png 424w, /__u/substackcdn.com/image/fetch/$s_!Kti9!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac681ff1-7df1-483a-830b-9da7855795b3_500x250.png 848w, /__u/substackcdn.com/image/fetch/$s_!Kti9!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac681ff1-7df1-483a-830b-9da7855795b3_500x250.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Kti9!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac681ff1-7df1-483a-830b-9da7855795b3_500x250.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Kti9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac681ff1-7df1-483a-830b-9da7855795b3_500x250.png" width="500" height="250" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ac681ff1-7df1-483a-830b-9da7855795b3_500x250.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:250,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Horizontal light clock as seen by an observer on the train&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="Horizontal light clock as seen by an observer on the train" title="Horizontal light clock as seen by an observer on the train" srcset="/__u/substackcdn.com/image/fetch/$s_!Kti9!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac681ff1-7df1-483a-830b-9da7855795b3_500x250.png 424w, /__u/substackcdn.com/image/fetch/$s_!Kti9!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac681ff1-7df1-483a-830b-9da7855795b3_500x250.png 848w, /__u/substackcdn.com/image/fetch/$s_!Kti9!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac681ff1-7df1-483a-830b-9da7855795b3_500x250.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Kti9!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac681ff1-7df1-483a-830b-9da7855795b3_500x250.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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, the light pulse starts at <strong>A</strong>, travels to <strong>B</strong>, then back to <strong>C</strong>. The total distance is <em>2d</em>. The pulse would take the same time as the vertical light clock, as you would expect because they are identical clocks.</p><p>But the observer on the platform would see something quite different:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!jp0l!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd8e395-f347-4037-abdc-76439ba6391a_1000x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!jp0l!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd8e395-f347-4037-abdc-76439ba6391a_1000x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!jp0l!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd8e395-f347-4037-abdc-76439ba6391a_1000x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!jp0l!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd8e395-f347-4037-abdc-76439ba6391a_1000x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!jp0l!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd8e395-f347-4037-abdc-76439ba6391a_1000x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!jp0l!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd8e395-f347-4037-abdc-76439ba6391a_1000x500.png" width="1000" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4fd8e395-f347-4037-abdc-76439ba6391a_1000x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:1000,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Horizontal light clock as seen by an observer on the platform&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="Horizontal light clock as seen by an observer on the platform" title="Horizontal light clock as seen by an observer on the platform" srcset="/__u/substackcdn.com/image/fetch/$s_!jp0l!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd8e395-f347-4037-abdc-76439ba6391a_1000x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!jp0l!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd8e395-f347-4037-abdc-76439ba6391a_1000x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!jp0l!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd8e395-f347-4037-abdc-76439ba6391a_1000x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!jp0l!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd8e395-f347-4037-abdc-76439ba6391a_1000x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 top part of the diagram shows the light pulse travelling from the first mirror (at <strong>A</strong>) to the second mirror (at <strong>B</strong>). As the light pulse sets off from <strong>A</strong>, the clock is still moving (with the train) so the light pulse has to <em>chase</em> the other mirror. To reach the far mirror, it has to travel a total distance <em>f</em>, which is greater than <em>d</em>.</p><p>The light then bounces back off the mirror at <strong>B</strong>. The lower part of the diagram shows this. The light pulse travels from <strong>B</strong> to <strong>C</strong>, but this time the mirror is heading towards the light beam. So this time the light has to travel a distance of <em>g</em>, which is less than <em>d</em>.</p><h2>Why the second light clock creates a problem for length</h2><p>Let&#8217;s imagine we combine the light clock, like this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!AwRR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdea32ccb-e9de-454f-9723-23b694b03792_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!AwRR!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdea32ccb-e9de-454f-9723-23b694b03792_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!AwRR!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdea32ccb-e9de-454f-9723-23b694b03792_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!AwRR!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdea32ccb-e9de-454f-9723-23b694b03792_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!AwRR!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdea32ccb-e9de-454f-9723-23b694b03792_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!AwRR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdea32ccb-e9de-454f-9723-23b694b03792_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dea32ccb-e9de-454f-9723-23b694b03792_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Two light clocks on train&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="Two light clocks on train" title="Two light clocks on train" srcset="/__u/substackcdn.com/image/fetch/$s_!AwRR!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdea32ccb-e9de-454f-9723-23b694b03792_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!AwRR!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdea32ccb-e9de-454f-9723-23b694b03792_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!AwRR!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdea32ccb-e9de-454f-9723-23b694b03792_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!AwRR!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdea32ccb-e9de-454f-9723-23b694b03792_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 create a pulse of light in the bottom left corner. From the point of view of an observer on the train, some of the light travels vertically, from <strong>P</strong> to <strong>Q</strong>, then back to <strong>P</strong>. Some of the light travels horizontally, from <strong>R</strong> to <strong>S</strong>, then back to <strong>R</strong>. Crucially, both pulses arrive back at <strong>P/R</strong> at exactly the same time. That is because they both travelled the same distance <em>2d</em> at the constant speed of light.</p><p>From the point of view of an observer on the platform, we can make one very important observation. The two light pulses start simultaneously at <strong>P/R</strong>, and they also arrive back at <strong>P/R</strong> simultaneously. That is because if two events happen at the same time and place in one frame, they must happen at the same time and place in every other frame.</p><p>Now the light from <strong>P</strong> to <strong>Q</strong> and back travels a distance of <em>2e</em>, which is greater than <em>2d</em>. We account for this by saying that time passes at a different rate on the train, according to an observer on the platform.</p><p>But now we also know that light from <strong>R</strong> to <strong>S</strong> and back travels a distance of <em>f + g</em>, and this takes exactly the same time as the light travelling from <strong>P</strong> to <strong>Q</strong> and back. Since both pulses of light travel at speed <em>c</em> in all frames, the two times can only be the same if <em>f + g</em> is equal to <em>2e</em> in all frames. But if we do the calculations, those two distances aren&#8217;t equal. In fact, when <em>v</em> is greater than zero (ie when the train is moving), <em>f + g</em> is always bigger than <em>2e</em>.</p><h2>A solution - length contraction</h2><p>There is only one solution to this dilemma. From the point of view of an observer on the platform, the distance <strong>RS</strong> must be shorter than the distance <strong>PQ</strong>. It must be shorter by the exact amount required such that the two light pulses arrive back at the start at exactly the same time.</p><p>So, in the same way that the observer on the platform sees time on the train pass more slowly (time dilation), they also see the length of objects on the train being shorter (length contraction), but only in the direction of travel of the train.</p><p>Both effects occur together, and both effects are required to properly explain the behaviour of the two light clocks on the moving train.</p><p>Einstein calculated the size of this effect. It is quite a lengthy calculation, so we won&#8217;t show it here. We will derive the same result in a much simpler way using <em>Lorentz transforms</em> in a future article. But he found that:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!joRq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71037a88-3538-441f-b62b-b8d82d69185e_327x132.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!joRq!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71037a88-3538-441f-b62b-b8d82d69185e_327x132.png 424w, /__u/substackcdn.com/image/fetch/$s_!joRq!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71037a88-3538-441f-b62b-b8d82d69185e_327x132.png 848w, /__u/substackcdn.com/image/fetch/$s_!joRq!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71037a88-3538-441f-b62b-b8d82d69185e_327x132.png 1272w, /__u/substackcdn.com/image/fetch/$s_!joRq!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71037a88-3538-441f-b62b-b8d82d69185e_327x132.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!joRq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71037a88-3538-441f-b62b-b8d82d69185e_327x132.png" width="327" height="132" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/71037a88-3538-441f-b62b-b8d82d69185e_327x132.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:132,&quot;width&quot;:327,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Length contraction formula d' = \\frac{d}{\\gamma}&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="Length contraction formula d' = \frac{d}{\gamma}" title="Length contraction formula d' = \frac{d}{\gamma}" srcset="/__u/substackcdn.com/image/fetch/$s_!joRq!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71037a88-3538-441f-b62b-b8d82d69185e_327x132.png 424w, /__u/substackcdn.com/image/fetch/$s_!joRq!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71037a88-3538-441f-b62b-b8d82d69185e_327x132.png 848w, /__u/substackcdn.com/image/fetch/$s_!joRq!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71037a88-3538-441f-b62b-b8d82d69185e_327x132.png 1272w, /__u/substackcdn.com/image/fetch/$s_!joRq!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71037a88-3538-441f-b62b-b8d82d69185e_327x132.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Here, <em>d</em> is the length of the horizontal light clock as seen by an observer on the train, <em>d&#8217;</em> is the length as seen by an observer on the platform, and &#947; is the Lorentz factor for the velocity of the train <em>v</em>. Since &#947; is always &gt;= 1, <em>d&#8217;</em> is always &lt;= <em>d</em>. So length can only ever be contracted, never expanded.</p><p>This demonstrates quite an elegant symmetry. Time is dilated by a factor of &#947;, length is contracted by a factor of 1/&#947;.</p><h2>What length contraction is, and what it is not</h2><p>There are some common misconceptions that people often have when they first encounter length contraction:</p><ul><li><p>It is not an optical illusion caused by the time it takes for light to travel from different places on the train. It is a real, physical effect.</p></li><li><p>It can be measured. For example, if there were several synchronised clocks on the train platform, we could measure exactly where the two ends of the light clock were at the same instant in time, and they would indeed be closer together than they are when measured on the train.</p></li><li><p>The effect is symmetric between frames. If there were a light clock on the platform, then an observer on the train would see it as contracted.</p></li><li><p>The light clock isn&#8217;t physically &#8220;squished&#8221; in any way. In its rest frame (the train), the light clock isn&#8217;t moving, so it has its normal length.</p></li><li><p>The effect is only easily visible at very high speed.</p></li></ul><p>On the last point, if a train were travelling at 500 m/s (over a thousand miles per hour), its Lorentz factor would be about 1.00000000000139. This means that, if the light clock were 1m long, its length would contract by 1.39 picometres, which is about 1/20th of the diameter of a hydrogen atom.</p><h2>Real world example - muons</h2><p>In the <a href="https://graphicmaths.com/physics/relativity/special-relativity-time-dilation/">earlier article on time dilation</a>, we looked at the real world example of muons in the Earth&#8217;s atmosphere. Muons are subatomic particles in the same class as electrons. They are leptons (&#8221;light&#8221; particles, they weigh much less than protons and neutrons). But unlike electrons, muons are unstable and have a half-life of about 2.2 microseconds.</p><p>Muons are created when cosmic rays smash into atoms in the upper atmosphere. The muons are created with very high velocities (around 99.5% of the speed of light), and some of them shoot down towards the Earth&#8217;s surface. Given their short lifetime, we would expect almost all muons to decay before reaching the ground. From the Earth&#8217;s point of view, the journey through the atmosphere takes far longer than a muon&#8217;s half-life. But an observer on Earth also knows the muon is travelling extremely fast, so it experiences time dilation: its internal &#8216;clock&#8217; runs slow relative to Earth, giving it enough extra lifetime (as measured on Earth) to survive the trip.</p><p>But an observer on Earth also knows that, since the muon is travelling so fast, it will experience time dilation. So the observer on Earth can calculate that the muon experiences only a few microseconds of time as it descends through the atmosphere, so many muons will survive the journey.</p><p>The LHS of the diagram below shows the situation from the point of view of an observer on the Earth. The dark blue circle is the Earth, the light blue is the atmosphere, and the red dot is a muon. The diagram is not drawn to scale. In reality, the atmosphere is a very thin layer around the Earth.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!h1Xv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F626d8949-7064-4ede-bcfc-12bb33f0b1f3_1000x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!h1Xv!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F626d8949-7064-4ede-bcfc-12bb33f0b1f3_1000x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!h1Xv!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F626d8949-7064-4ede-bcfc-12bb33f0b1f3_1000x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!h1Xv!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F626d8949-7064-4ede-bcfc-12bb33f0b1f3_1000x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!h1Xv!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F626d8949-7064-4ede-bcfc-12bb33f0b1f3_1000x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!h1Xv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F626d8949-7064-4ede-bcfc-12bb33f0b1f3_1000x500.png" width="1000" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/626d8949-7064-4ede-bcfc-12bb33f0b1f3_1000x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:1000,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Muons&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="Muons" title="Muons" srcset="/__u/substackcdn.com/image/fetch/$s_!h1Xv!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F626d8949-7064-4ede-bcfc-12bb33f0b1f3_1000x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!h1Xv!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F626d8949-7064-4ede-bcfc-12bb33f0b1f3_1000x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!h1Xv!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F626d8949-7064-4ede-bcfc-12bb33f0b1f3_1000x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!h1Xv!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F626d8949-7064-4ede-bcfc-12bb33f0b1f3_1000x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>But what does the muon experience? Well, due to time dilation, we know that it takes muons much less time to reach Earth. But how can they travel all that distance in such a short time?</p><p>The RHS of the diagram shows why. In the muons&#8217; frame of reference, the muon itself is stationary, but the Earth is moving towards it at 99.5% of the speed of light. This means that the Earth and its atmosphere are contracted in the direction of travel. So the muon only needs to travel a short distance to reach the surface.</p><p>There is an interesting symmetry here. In Earth&#8217;s frame of reference, time is ticking more slowly for the muon, so it can pass through Earth&#8217;s atmosphere because it takes longer to decay. In the muon&#8217;s frame of reference, the Earth and its atmosphere are contracted <em>by the same factor</em>, so the muon can pass through the Earth&#8217;s atmosphere because it is a shorter distance.</p><h2>Conclusion</h2><p>Length contraction, like time dilation, is not some trick or mathematical hack. It is a real effect that can be measured. It has to happen because the speed of light is the same in every inertial frame.</p><p>The orthogonal clock thought experiment illustrates the effect cleanly and simply. But length contraction has also been seen in many real-life experiments</p><p>.</p>]]></content:encoded></item><item><title><![CDATA[Numerical integration in Python with scipy.integrate - quad, dblquad and sampled data]]></title><description><![CDATA[Numerical integration exists to solve a fundamental problem.]]></description><link>https://graphicmaths.substack.com/p/numerical-integration-in-python-with</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/numerical-integration-in-python-with</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Wed, 08 Jul 2026 15:26:21 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!-3zH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F742204dc-c3e3-4bd5-9c67-bc815560e4a9_500x500.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Numerical integration exists to solve a fundamental problem. Many integrals encountered in real-world physics, engineering, statistics, and finance do not have closed-form antiderivatives. Even when they do, evaluating them symbolically can be computationally expensive or intractable for complex functions. <code>scipy.integrate</code> provides battle-tested, high-performance implementations of classical numerical methods (many wrapping decades-old Fortran libraries like QUADPACK and ODEPACK) so you don&#8217;t have to implement these methods from scratch.</p><p>The module splits neatly into two conceptual halves:</p><ul><li><p>Approximating definite integrals, either from a known function or from discrete sampled data.</p></li><li><p>Solving ordinary differential equations (ODEs), either an initial value problem or a boundary-constrained problem.</p></li></ul><p>This distinction matters because the underlying algorithms are completely different. Approximating a definite integral involves evaluating a function at carefully chosen points and combining the results with weights. At the same time, ODE solvers take discrete steps through &#8220;time&#8221; (or whatever the independent variable represents), using local error estimates to adapt step size.</p><h2>What is covered in this article</h2><p>We will look at:</p><ul><li><p><code>quad</code> - the main method used for integrating mathematical functions.</p></li><li><p><code>dblquad</code>. <code>tplquad</code> and <code>nquad</code> - used double, triple, and n-dimensional integration.</p></li><li><p>How to handle improper integrals, singularities, and discontinuities.</p></li><li><p><code>fixed_quad</code> for faster, non-adaptive integration.</p></li><li><p><code>trapeziod</code> for integrating sampled functions.</p></li><li><p><code>simpson</code> for integrating sampled functions using quadratic fitting.</p></li><li><p><code>cumulative_trapezoid</code> and <code>cumulative_simpson</code> for finding the cumulative integral of sampled functions.</p></li></ul><p>This article assumes you are comfortable with Python functions, the basics of NumPy arrays, and the calculus concepts of derivatives, definite integrals, and initial-value problems. No prior SciPy experience is assumed.</p><h2>Setting up</h2><p>Assuming NumPy and SciPy are both installed, we need the following imports to start using <code>scipy.integrate</code>:</p><pre><code><code>import numpy as np
from scipy import integrate
</code></code></pre><p>Many functions in the <code>integrate</code> module accept a Python callable as the primary argument. This will typically be a function <code>f(x)</code> or <code>f(t, y)</code> that you define yourself, often using NumPy operations so it can be vectorised. Inputs and outputs are generally NumPy-compatible.</p><p>A key design pattern used throughout the <code>integrate</code> module is that many functions return a bundle of results rather than a single number. For instance, the <code>quad</code> function, which we will look at next, returns <code>(value, error_estimate)</code>. We will typically unpack the values that the function returns immediately after calling it.</p><h2>The quad function for definite integrals</h2><p>The <code>quad</code> function is the basic workhorse of the integration module. It is based on the QUADPACK Fortran library. To see how it works, we will calculate the following definite integral:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!VDbL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffed2e2ad-af28-4d40-b8e6-e2a1f382644c_203x128.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!VDbL!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffed2e2ad-af28-4d40-b8e6-e2a1f382644c_203x128.png 424w, /__u/substackcdn.com/image/fetch/$s_!VDbL!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffed2e2ad-af28-4d40-b8e6-e2a1f382644c_203x128.png 848w, /__u/substackcdn.com/image/fetch/$s_!VDbL!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffed2e2ad-af28-4d40-b8e6-e2a1f382644c_203x128.png 1272w, /__u/substackcdn.com/image/fetch/$s_!VDbL!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffed2e2ad-af28-4d40-b8e6-e2a1f382644c_203x128.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!VDbL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffed2e2ad-af28-4d40-b8e6-e2a1f382644c_203x128.png" width="203" height="128" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fed2e2ad-af28-4d40-b8e6-e2a1f382644c_203x128.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:128,&quot;width&quot;:203,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Integral&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="Integral" title="Integral" srcset="/__u/substackcdn.com/image/fetch/$s_!VDbL!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffed2e2ad-af28-4d40-b8e6-e2a1f382644c_203x128.png 424w, /__u/substackcdn.com/image/fetch/$s_!VDbL!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffed2e2ad-af28-4d40-b8e6-e2a1f382644c_203x128.png 848w, /__u/substackcdn.com/image/fetch/$s_!VDbL!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffed2e2ad-af28-4d40-b8e6-e2a1f382644c_203x128.png 1272w, /__u/substackcdn.com/image/fetch/$s_!VDbL!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffed2e2ad-af28-4d40-b8e6-e2a1f382644c_203x128.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Here is how we would use the <code>quad</code> function to find the approximate value of the integral above:</p><pre><code><code>import numpy as np
from scipy.integrate import quad

def f(x):
    return np.exp(-x**2)

integral, error = quad(f, 0, 1)
print(integral, error)  # 0.7468241328124271, 8.29e-15
</code></code></pre><p>After the imports, we define our function <code>f(x)</code>. This is the function we wish to integrate. Notice that we use the <code>np.exp</code> (the NumPy exponential function) rather than the regular <code>math.exp</code> function. It is convenient to use NumPy when dealing with arrays of data. NumPy stores large data arrays more efficiently than a Python list, and it can be more efficient if we need to do further processing on the data. However, you can use the regular <code>math</code> functions if you prefer.</p><p>We then call <code>quad</code>, passing in the function <code>f</code>, and the upper and lower limits of the integral, which are 0 and 1 as defined above.</p><p>The <code>quad</code> function returns two values, as a tuple. The first is the calculated value of the <code>integral</code>. The second is an estimate of the absolute error of the result. In our case, the integral evaluates to approximately 0.7468241328124271. The absolute error is 8.29e-15. This means that the result obtained is accurate to about 14 decimal places.</p><p>You should always check the <code>error</code> value. It should be very small compared to the integral value. If it is large, this might indicate a problem with the integral. In addition, <code>quad</code> can throw an <code>IntegrationWarning</code> if the integration fails to converge. This is unlikely to happen if you are using ordinary, well-behaved mathematical functions. The official SciPy documentation has more details if you should encounter this warning.</p><h2>Checking the integral</h2><p>Here is a graph of the function above, showing the region we are trying to integrate:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!-3zH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F742204dc-c3e3-4bd5-9c67-bc815560e4a9_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!-3zH!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F742204dc-c3e3-4bd5-9c67-bc815560e4a9_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!-3zH!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F742204dc-c3e3-4bd5-9c67-bc815560e4a9_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!-3zH!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F742204dc-c3e3-4bd5-9c67-bc815560e4a9_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!-3zH!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F742204dc-c3e3-4bd5-9c67-bc815560e4a9_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!-3zH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F742204dc-c3e3-4bd5-9c67-bc815560e4a9_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/742204dc-c3e3-4bd5-9c67-bc815560e4a9_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Integral&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="Integral" title="Integral" srcset="/__u/substackcdn.com/image/fetch/$s_!-3zH!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F742204dc-c3e3-4bd5-9c67-bc815560e4a9_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!-3zH!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F742204dc-c3e3-4bd5-9c67-bc815560e4a9_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!-3zH!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F742204dc-c3e3-4bd5-9c67-bc815560e4a9_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!-3zH!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F742204dc-c3e3-4bd5-9c67-bc815560e4a9_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 check the approximate value, we could try to integrate the function mathematically to obtain an exact result. You might recognise this as the famous <a href="https://graphicmaths.com/pure/special-functions/gaussian-integral/">Gaussian integral</a>.</p><p>Unfortunately, this integral doesn&#8217;t have a simple solution in terms of the standard mathematical functions. Instead, we can calculate the integral like this:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!vGPo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad189eaa-0308-4236-8224-48a043da85c2_384x125.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!vGPo!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad189eaa-0308-4236-8224-48a043da85c2_384x125.png 424w, /__u/substackcdn.com/image/fetch/$s_!vGPo!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad189eaa-0308-4236-8224-48a043da85c2_384x125.png 848w, /__u/substackcdn.com/image/fetch/$s_!vGPo!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad189eaa-0308-4236-8224-48a043da85c2_384x125.png 1272w, /__u/substackcdn.com/image/fetch/$s_!vGPo!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad189eaa-0308-4236-8224-48a043da85c2_384x125.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!vGPo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad189eaa-0308-4236-8224-48a043da85c2_384x125.png" width="384" height="125" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ad189eaa-0308-4236-8224-48a043da85c2_384x125.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:125,&quot;width&quot;:384,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Integral&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="Integral" title="Integral" srcset="/__u/substackcdn.com/image/fetch/$s_!vGPo!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad189eaa-0308-4236-8224-48a043da85c2_384x125.png 424w, /__u/substackcdn.com/image/fetch/$s_!vGPo!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad189eaa-0308-4236-8224-48a043da85c2_384x125.png 848w, /__u/substackcdn.com/image/fetch/$s_!vGPo!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad189eaa-0308-4236-8224-48a043da85c2_384x125.png 1272w, /__u/substackcdn.com/image/fetch/$s_!vGPo!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad189eaa-0308-4236-8224-48a043da85c2_384x125.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Where <em>erf</em> is the <a href="https://graphicmaths.com/pure/special-functions/erf-function/">error function</a>, a special function used in certain calculus problems. We are interested in the integral between 0 and 1, so we need to set <em>v</em> to 1:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!dYv5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae36a73-787a-455f-8c1d-a6c79b90d3fb_382x128.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!dYv5!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae36a73-787a-455f-8c1d-a6c79b90d3fb_382x128.png 424w, /__u/substackcdn.com/image/fetch/$s_!dYv5!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae36a73-787a-455f-8c1d-a6c79b90d3fb_382x128.png 848w, /__u/substackcdn.com/image/fetch/$s_!dYv5!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae36a73-787a-455f-8c1d-a6c79b90d3fb_382x128.png 1272w, /__u/substackcdn.com/image/fetch/$s_!dYv5!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae36a73-787a-455f-8c1d-a6c79b90d3fb_382x128.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!dYv5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae36a73-787a-455f-8c1d-a6c79b90d3fb_382x128.png" width="382" height="128" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/aae36a73-787a-455f-8c1d-a6c79b90d3fb_382x128.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:128,&quot;width&quot;:382,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Integral&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="Integral" title="Integral" srcset="/__u/substackcdn.com/image/fetch/$s_!dYv5!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae36a73-787a-455f-8c1d-a6c79b90d3fb_382x128.png 424w, /__u/substackcdn.com/image/fetch/$s_!dYv5!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae36a73-787a-455f-8c1d-a6c79b90d3fb_382x128.png 848w, /__u/substackcdn.com/image/fetch/$s_!dYv5!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae36a73-787a-455f-8c1d-a6c79b90d3fb_382x128.png 1272w, /__u/substackcdn.com/image/fetch/$s_!dYv5!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faae36a73-787a-455f-8c1d-a6c79b90d3fb_382x128.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The value of <em>erf(1)</em> is approximately 0.8427007929497149, so we can calculate the integral like this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Wf_R!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F031eaf43-2994-463b-b9fd-c37d4460125f_618x277.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Wf_R!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F031eaf43-2994-463b-b9fd-c37d4460125f_618x277.png 424w, /__u/substackcdn.com/image/fetch/$s_!Wf_R!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F031eaf43-2994-463b-b9fd-c37d4460125f_618x277.png 848w, /__u/substackcdn.com/image/fetch/$s_!Wf_R!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F031eaf43-2994-463b-b9fd-c37d4460125f_618x277.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Wf_R!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F031eaf43-2994-463b-b9fd-c37d4460125f_618x277.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Wf_R!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F031eaf43-2994-463b-b9fd-c37d4460125f_618x277.png" width="618" height="277" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/031eaf43-2994-463b-b9fd-c37d4460125f_618x277.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:277,&quot;width&quot;:618,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Integral&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="Integral" title="Integral" srcset="/__u/substackcdn.com/image/fetch/$s_!Wf_R!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F031eaf43-2994-463b-b9fd-c37d4460125f_618x277.png 424w, /__u/substackcdn.com/image/fetch/$s_!Wf_R!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F031eaf43-2994-463b-b9fd-c37d4460125f_618x277.png 848w, /__u/substackcdn.com/image/fetch/$s_!Wf_R!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F031eaf43-2994-463b-b9fd-c37d4460125f_618x277.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Wf_R!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F031eaf43-2994-463b-b9fd-c37d4460125f_618x277.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 matches the value from the <code>quad</code> function to 15 decimal places, as expected.</p><h2>How does quad work?</h2><p>The <code>quad</code> function approximates the area under the curve by evaluating the function at various points. Here is a much simplified illustration of how it works:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!zWuP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff1f322c-91ba-4f2b-a050-d4f91d840dc4_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!zWuP!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff1f322c-91ba-4f2b-a050-d4f91d840dc4_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!zWuP!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff1f322c-91ba-4f2b-a050-d4f91d840dc4_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!zWuP!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff1f322c-91ba-4f2b-a050-d4f91d840dc4_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!zWuP!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff1f322c-91ba-4f2b-a050-d4f91d840dc4_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!zWuP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff1f322c-91ba-4f2b-a050-d4f91d840dc4_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ff1f322c-91ba-4f2b-a050-d4f91d840dc4_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Integral&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="Integral" title="Integral" srcset="/__u/substackcdn.com/image/fetch/$s_!zWuP!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff1f322c-91ba-4f2b-a050-d4f91d840dc4_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!zWuP!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff1f322c-91ba-4f2b-a050-d4f91d840dc4_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!zWuP!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff1f322c-91ba-4f2b-a050-d4f91d840dc4_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!zWuP!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff1f322c-91ba-4f2b-a050-d4f91d840dc4_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 have calculated the curve&#8217;s value at 5 points, indicated by the red dots. We have created 4 trapeziums based on those points. We can easily calculate the total area under the trapeziums, which will be approximately equal to the area under the curve, which of course is equal to the definite integral of the curve.</p><p>Using four trapeziums will not yield a particularly good approximation, but a computer can easily use far more points to obtain a more accurate one.</p><p>In fact, the <code>quad</code> function is a lot more sophisticated than the simple example above. The Fortran QUADPACK library uses a technique called <em>adaptive Gauss-Kronrod quadrature</em>. It is not necessary to understand all the details to be able to use the function, but out of interest here is an overview of how it works:</p><ul><li><p>It doesn&#8217;t use trapeziums, instead it attempts to fit a polynomial to the curve, which gives a far more accurate approximation to the curve.</p></li><li><p>It also uses advanced techniques to estimate how accurately each slice represents the area under the real curve.</p></li><li><p>Using the estimates for each slice, it subdivides each slice just enough to achieve the required accuracy.</p></li></ul><p>This means that the slices might not all be the same width, like this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!DxXa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F673984ad-7385-49a6-9a79-30a97e8aca59_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!DxXa!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F673984ad-7385-49a6-9a79-30a97e8aca59_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!DxXa!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F673984ad-7385-49a6-9a79-30a97e8aca59_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!DxXa!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F673984ad-7385-49a6-9a79-30a97e8aca59_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!DxXa!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F673984ad-7385-49a6-9a79-30a97e8aca59_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!DxXa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F673984ad-7385-49a6-9a79-30a97e8aca59_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/673984ad-7385-49a6-9a79-30a97e8aca59_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Integral&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="Integral" title="Integral" srcset="/__u/substackcdn.com/image/fetch/$s_!DxXa!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F673984ad-7385-49a6-9a79-30a97e8aca59_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!DxXa!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F673984ad-7385-49a6-9a79-30a97e8aca59_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!DxXa!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F673984ad-7385-49a6-9a79-30a97e8aca59_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!DxXa!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F673984ad-7385-49a6-9a79-30a97e8aca59_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>More features of the quad function</h2><p>There are some additional features of the <code>quad</code> function:</p><ul><li><p>Support for improper integrals.</p></li><li><p>Support for functions that have singularities or discontinuities.</p></li><li><p>Special handling for integrands that take particular forms (weights).</p></li></ul><p>We will cover these below.</p><h2>Support for improper integrals</h2><p>An improper integral is an integral that violates the usual assumptions of a definite integral. The most common example is when one or both of the limits is infinite, such as this:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!dpzx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05aa80b9-d213-4ebc-9860-0ce0e858012f_222x124.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!dpzx!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05aa80b9-d213-4ebc-9860-0ce0e858012f_222x124.png 424w, /__u/substackcdn.com/image/fetch/$s_!dpzx!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05aa80b9-d213-4ebc-9860-0ce0e858012f_222x124.png 848w, /__u/substackcdn.com/image/fetch/$s_!dpzx!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05aa80b9-d213-4ebc-9860-0ce0e858012f_222x124.png 1272w, /__u/substackcdn.com/image/fetch/$s_!dpzx!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05aa80b9-d213-4ebc-9860-0ce0e858012f_222x124.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!dpzx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05aa80b9-d213-4ebc-9860-0ce0e858012f_222x124.png" width="222" height="124" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/05aa80b9-d213-4ebc-9860-0ce0e858012f_222x124.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:124,&quot;width&quot;:222,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Integral&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="Integral" title="Integral" srcset="/__u/substackcdn.com/image/fetch/$s_!dpzx!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05aa80b9-d213-4ebc-9860-0ce0e858012f_222x124.png 424w, /__u/substackcdn.com/image/fetch/$s_!dpzx!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05aa80b9-d213-4ebc-9860-0ce0e858012f_222x124.png 848w, /__u/substackcdn.com/image/fetch/$s_!dpzx!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05aa80b9-d213-4ebc-9860-0ce0e858012f_222x124.png 1272w, /__u/substackcdn.com/image/fetch/$s_!dpzx!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05aa80b9-d213-4ebc-9860-0ce0e858012f_222x124.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This is actually the famous <a href="https://graphicmaths.com/pure/special-functions/gaussian-integral/">Gaussian integral</a>. Even though the bounds of the integral are infinite in both directions, the integrand goes towards zero as <em>x</em> tends towards +/- infinity, and in fact the area under the curve is finite. Here is the graph:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!ZCVm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd741200c-5bf0-4a29-9000-047144818c69_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!ZCVm!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd741200c-5bf0-4a29-9000-047144818c69_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!ZCVm!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd741200c-5bf0-4a29-9000-047144818c69_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!ZCVm!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd741200c-5bf0-4a29-9000-047144818c69_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ZCVm!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd741200c-5bf0-4a29-9000-047144818c69_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!ZCVm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd741200c-5bf0-4a29-9000-047144818c69_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d741200c-5bf0-4a29-9000-047144818c69_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Integral&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="Integral" title="Integral" srcset="/__u/substackcdn.com/image/fetch/$s_!ZCVm!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd741200c-5bf0-4a29-9000-047144818c69_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!ZCVm!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd741200c-5bf0-4a29-9000-047144818c69_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!ZCVm!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd741200c-5bf0-4a29-9000-047144818c69_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ZCVm!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd741200c-5bf0-4a29-9000-047144818c69_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 calculate an improper integral in the usual way, except that we use <code>np.inf</code> (NumPy&#8217;s definition of infinity) like this:</p><pre><code><code>def f(x):
    return np.exp(-x**2)

integral, error = quad(f, -np.inf, np.inf)
print(integral, error)  # 1.7724538509055159 1.4202636780944923e-08
</code></code></pre><p>The Gaussian integral is famously equal to the square root of pi, around 1.772453851, which is the result we get. Notice that this time the result is accurate only to about 8 decimal places. This is because an indefinite integral is harder to calculate to a very high degree of accuracy.</p><h2>Integrals with discontinuities or singularities</h2><p>This integral has a singularity at 0:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!sF6m!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef052271-05c7-460a-8574-a6f89ffdb636_221x135.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!sF6m!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef052271-05c7-460a-8574-a6f89ffdb636_221x135.png 424w, /__u/substackcdn.com/image/fetch/$s_!sF6m!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef052271-05c7-460a-8574-a6f89ffdb636_221x135.png 848w, /__u/substackcdn.com/image/fetch/$s_!sF6m!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef052271-05c7-460a-8574-a6f89ffdb636_221x135.png 1272w, /__u/substackcdn.com/image/fetch/$s_!sF6m!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef052271-05c7-460a-8574-a6f89ffdb636_221x135.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!sF6m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef052271-05c7-460a-8574-a6f89ffdb636_221x135.png" width="221" height="135" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ef052271-05c7-460a-8574-a6f89ffdb636_221x135.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:135,&quot;width&quot;:221,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Integral&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="Integral" title="Integral" srcset="/__u/substackcdn.com/image/fetch/$s_!sF6m!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef052271-05c7-460a-8574-a6f89ffdb636_221x135.png 424w, /__u/substackcdn.com/image/fetch/$s_!sF6m!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef052271-05c7-460a-8574-a6f89ffdb636_221x135.png 848w, /__u/substackcdn.com/image/fetch/$s_!sF6m!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef052271-05c7-460a-8574-a6f89ffdb636_221x135.png 1272w, /__u/substackcdn.com/image/fetch/$s_!sF6m!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef052271-05c7-460a-8574-a6f89ffdb636_221x135.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>For positive <em>x</em>, this function is equal to 1 divided by the square root of <em>x</em>, which goes to infinity as <em>x</em> goes to zero. Since we are taking the modulus of <em>x</em>, the function is just reflected over the y-axis. Here is a graph of the function, with the area to be integrated shown shaded:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!wMpE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe72c4727-ebd8-4ba9-a0ff-168ed5d754cf_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!wMpE!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe72c4727-ebd8-4ba9-a0ff-168ed5d754cf_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!wMpE!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe72c4727-ebd8-4ba9-a0ff-168ed5d754cf_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!wMpE!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe72c4727-ebd8-4ba9-a0ff-168ed5d754cf_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!wMpE!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe72c4727-ebd8-4ba9-a0ff-168ed5d754cf_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!wMpE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe72c4727-ebd8-4ba9-a0ff-168ed5d754cf_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e72c4727-ebd8-4ba9-a0ff-168ed5d754cf_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Integral&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="Integral" title="Integral" srcset="/__u/substackcdn.com/image/fetch/$s_!wMpE!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe72c4727-ebd8-4ba9-a0ff-168ed5d754cf_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!wMpE!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe72c4727-ebd8-4ba9-a0ff-168ed5d754cf_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!wMpE!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe72c4727-ebd8-4ba9-a0ff-168ed5d754cf_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!wMpE!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe72c4727-ebd8-4ba9-a0ff-168ed5d754cf_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Even though the function goes to infinity, the area under the curve is finite. However, we can&#8217;t just use <code>quad</code> on this function, because <code>quad</code> might try to evaluate it at zero, which would fail. Instead, we must warn <code>quad</code> that there is a singularity. We do this by passing in an extra parameter, <code>points</code>, which takes a list of any special points, such as singularities or discontinuities, so <code>quad</code> can work around them.</p><pre><code><code>def f(x):
    return 1/(np.sqrt(np.abs(x)))

integral, error = quad(f, -1, 1, points=[0])
</code></code></pre><p>In our case, we have only one troublesome point at <em>x = 0</em>, but if there are multiple special points, they can be added to the list.</p><h2>Special handling for particular integrands</h2><p><code>quad</code> has special handling for integrands that take particular forms. This is optional, but it allows <code>quad</code> to calculate the integral more efficiently, and potentially more accurately.</p><p>Here is an example, if we wish to find:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!n5cH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4c6c1ac-f56c-4336-baae-f42018155653_278x128.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!n5cH!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4c6c1ac-f56c-4336-baae-f42018155653_278x128.png 424w, /__u/substackcdn.com/image/fetch/$s_!n5cH!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4c6c1ac-f56c-4336-baae-f42018155653_278x128.png 848w, /__u/substackcdn.com/image/fetch/$s_!n5cH!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4c6c1ac-f56c-4336-baae-f42018155653_278x128.png 1272w, /__u/substackcdn.com/image/fetch/$s_!n5cH!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4c6c1ac-f56c-4336-baae-f42018155653_278x128.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!n5cH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4c6c1ac-f56c-4336-baae-f42018155653_278x128.png" width="278" height="128" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4c6c1ac-f56c-4336-baae-f42018155653_278x128.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:128,&quot;width&quot;:278,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Integral&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="Integral" title="Integral" srcset="/__u/substackcdn.com/image/fetch/$s_!n5cH!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4c6c1ac-f56c-4336-baae-f42018155653_278x128.png 424w, /__u/substackcdn.com/image/fetch/$s_!n5cH!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4c6c1ac-f56c-4336-baae-f42018155653_278x128.png 848w, /__u/substackcdn.com/image/fetch/$s_!n5cH!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4c6c1ac-f56c-4336-baae-f42018155653_278x128.png 1272w, /__u/substackcdn.com/image/fetch/$s_!n5cH!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4c6c1ac-f56c-4336-baae-f42018155653_278x128.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We can use <code>quad</code> to calculate this, in the normal way:</p><pre><code><code>quad(lambda x: np.exp(-x) * np.cos(5*x), 0, 1)
</code></code></pre><p>But we can also express the integral like this:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!gCMb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefe101fc-d640-4392-856a-a4d791072356_583x128.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!gCMb!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefe101fc-d640-4392-856a-a4d791072356_583x128.png 424w, /__u/substackcdn.com/image/fetch/$s_!gCMb!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefe101fc-d640-4392-856a-a4d791072356_583x128.png 848w, /__u/substackcdn.com/image/fetch/$s_!gCMb!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefe101fc-d640-4392-856a-a4d791072356_583x128.png 1272w, /__u/substackcdn.com/image/fetch/$s_!gCMb!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefe101fc-d640-4392-856a-a4d791072356_583x128.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!gCMb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefe101fc-d640-4392-856a-a4d791072356_583x128.png" width="583" height="128" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/efe101fc-d640-4392-856a-a4d791072356_583x128.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:128,&quot;width&quot;:583,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Integral&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="Integral" title="Integral" srcset="/__u/substackcdn.com/image/fetch/$s_!gCMb!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefe101fc-d640-4392-856a-a4d791072356_583x128.png 424w, /__u/substackcdn.com/image/fetch/$s_!gCMb!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefe101fc-d640-4392-856a-a4d791072356_583x128.png 848w, /__u/substackcdn.com/image/fetch/$s_!gCMb!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefe101fc-d640-4392-856a-a4d791072356_583x128.png 1272w, /__u/substackcdn.com/image/fetch/$s_!gCMb!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefe101fc-d640-4392-856a-a4d791072356_583x128.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The weighting function is multiplied by the integrand before integrating, so this gives the same integral as before. However, in Python we can specify the weight function explicitly:</p><pre><code><code>quad(lambda x: np.exp(-x), 0, 1, weight="cos", wvar=5)
</code></code></pre><p>Notice that we have removed the <em>cos</em> function from the integrand, but added a &#8220;cos&#8221; <code>weight</code> function with a <code>wvar</code> parameter of 5 (because the original equation involved <em>cos 5x</em>). This will give pretty much the same result as before (it is not exactly the same because the weighting method is slightly more accurate). But because <code>quad</code> knows that the integral has <em>cos</em> as a factor, it can apply special techniques to calculate the result more efficiently.</p><p>We won&#8217;t go into more detail here. Other weighting functions can be used, such as <em>sin</em>, <em>log</em>, and algebraic expressions. See the SciPy documentation for more details.</p><h2>The fixed_quad function</h2><p>The <code>fixed_quad</code> function is an alternative to the <code>quad</code> function that can be useful sometimes. It works similarly, but it uses a fixed number of sample points. By contrast, the <code>quad</code> function is adaptive so it uses as many sample points as required to achieve an accurate result (which depends on the function being integrated). For example:</p><pre><code><code>integral, error = fixed_quad(f, 0, 1, n=100)
</code></code></pre><p>This integrates the function <em>f</em> between 0 and 1, taking 100 sample points, as specified by the parameter <em>n</em>. One other difference is that <code>fixed_quad</code> doesn&#8217;t calculate an estimated error value, so it always returns a value of 0 for <code>error</code>.</p><p><code>fixed_quad</code> is usually faster than <code>quad</code> but often yields slightly less accurate results. It also tends to do worse with tricky integrands because it cannot adapt. Typically you should consider this function when:</p><ul><li><p>You are dealing with particular integrals that are known to be fairly straightforward.</p></li><li><p>You only require a certain level of accuracy, for example you need the result to be accurate to 4 significant figures.</p></li><li><p>You want to guarantee that the result will never take longer than expected.</p></li></ul><p>A typical use case might be an application with a real-time aspect. In that case, it is better to have a slightly less accurate result in time than a slightly more accurate result that arrives too late.</p><h2>Double and triple integrals</h2><p>We can perform a double integral like this:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Jb9a!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c75e9d6-d61f-4d59-a6ff-fd308575b51c_324x128.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Jb9a!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c75e9d6-d61f-4d59-a6ff-fd308575b51c_324x128.png 424w, /__u/substackcdn.com/image/fetch/$s_!Jb9a!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c75e9d6-d61f-4d59-a6ff-fd308575b51c_324x128.png 848w, /__u/substackcdn.com/image/fetch/$s_!Jb9a!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c75e9d6-d61f-4d59-a6ff-fd308575b51c_324x128.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Jb9a!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c75e9d6-d61f-4d59-a6ff-fd308575b51c_324x128.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Jb9a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c75e9d6-d61f-4d59-a6ff-fd308575b51c_324x128.png" width="324" height="128" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3c75e9d6-d61f-4d59-a6ff-fd308575b51c_324x128.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:128,&quot;width&quot;:324,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Integral&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="Integral" title="Integral" srcset="/__u/substackcdn.com/image/fetch/$s_!Jb9a!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c75e9d6-d61f-4d59-a6ff-fd308575b51c_324x128.png 424w, /__u/substackcdn.com/image/fetch/$s_!Jb9a!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c75e9d6-d61f-4d59-a6ff-fd308575b51c_324x128.png 848w, /__u/substackcdn.com/image/fetch/$s_!Jb9a!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c75e9d6-d61f-4d59-a6ff-fd308575b51c_324x128.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Jb9a!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c75e9d6-d61f-4d59-a6ff-fd308575b51c_324x128.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This will find the total volume under the function <em>f(y, x)</em> over the unit rectangular region where <em>0 &lt; x &lt; 1</em> and <em>0 &lt; y &lt; 2</em>. Here is how to express this in Python, using the <code>dblquad</code> function:</p><pre><code><code>from scipy.integrate import dblquad

integral, error = dblquad(f, 0, 1, lambda x: 0, lambda x: 1)
</code></code></pre><p>Some important points to notice here:</p><ul><li><p>The inner integral uses the variable <em>y</em> and the outer integral uses the variable <em>x</em>.</p></li><li><p>The function <em>f(y, x)</em> takes the inner variable <em>y</em> as its first parameter and the outer variable <em>x</em> as its second parameter. That is a little unintuitive and can be easy to miss.</p></li><li><p>Parameters 2 and 3 are numbers that represent the lower and upper bounds of the outer integral in <em>x</em>.</p></li><li><p>Parameters 4 and 5 are functions of <em>x</em> that represent the lower and upper bounds of the inner integral in <em>y</em>.</p></li></ul><p>In this example, parameters 4 and 5 are lambda functions that return the constant values 0 and 1, so the integral evaluates to a rectangular region, as noted above.</p><p>Here is a second example:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Aflr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb79b036a-c7a1-4ff4-b7d4-4c47b80f7830_326x128.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Aflr!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb79b036a-c7a1-4ff4-b7d4-4c47b80f7830_326x128.png 424w, /__u/substackcdn.com/image/fetch/$s_!Aflr!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb79b036a-c7a1-4ff4-b7d4-4c47b80f7830_326x128.png 848w, /__u/substackcdn.com/image/fetch/$s_!Aflr!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb79b036a-c7a1-4ff4-b7d4-4c47b80f7830_326x128.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Aflr!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb79b036a-c7a1-4ff4-b7d4-4c47b80f7830_326x128.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Aflr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb79b036a-c7a1-4ff4-b7d4-4c47b80f7830_326x128.png" width="326" height="128" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b79b036a-c7a1-4ff4-b7d4-4c47b80f7830_326x128.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:128,&quot;width&quot;:326,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Integral&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="Integral" title="Integral" srcset="/__u/substackcdn.com/image/fetch/$s_!Aflr!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb79b036a-c7a1-4ff4-b7d4-4c47b80f7830_326x128.png 424w, /__u/substackcdn.com/image/fetch/$s_!Aflr!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb79b036a-c7a1-4ff4-b7d4-4c47b80f7830_326x128.png 848w, /__u/substackcdn.com/image/fetch/$s_!Aflr!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb79b036a-c7a1-4ff4-b7d4-4c47b80f7830_326x128.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Aflr!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb79b036a-c7a1-4ff4-b7d4-4c47b80f7830_326x128.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This time the inner integral has bounds that depend on <em>x</em>. This actually integrates over a triangular base area, but we won&#8217;t go into details here. This integral can be expressed in code as:</p><pre><code><code>from scipy.integrate import dblquad

integral, error = dblquad(f, 0, 1, lambda x: 0, lambda x: x)
</code></code></pre><p>All we have changed is the final parameter of <code>dblquad</code>, so now the upper limit of the inner integral is <em>x</em>.</p><p>The function <code>tplquad</code> extends this concept to three dimensions. There is also an <code>nquad</code> function that works on <em>n</em> dimensions, but be aware that is has a different call style to <code>dblquad</code>. We won&#8217;t cover those functions here, refer to the SciPy documentation for more details. Be aware that</p><h2>Integrating Sampled Data</h2><p>Sometimes you might not have a function, you might have a table of <em>x</em>, <em>y</em> values. They might come from a sensor, or simulation output, or experiment. <code>scipy.integrate</code> provides tools to estimate the integral of the underlying function directly from discrete samples.</p><p>This is called numerical integration, and <a href="https://graphicmaths.com/pure/numerical-methods/numerical-integration/">this article</a> explains some of the maths behind it.</p><p>The first function, <code>trapezoid</code>, uses the trapezoidal rule to estimate the area. In other words, it approximates the area under the curve by connecting consecutive points with straight line segments and summing the areas of the resulting trapezoids.</p><p>Here is a simple example to integrate a sampled <em>sin</em> function:</p><pre><code><code>from scipy.integrate import trapezoid

x = np.linspace(0, np.pi, 10)
y = np.sin(x)
result = trapezoid(y, x)
</code></code></pre><p>This code first generates a NumPy array of <em>x</em> values, using <code>linspace</code>. These values are equally spaced between 0 and pi. It then generates a set of <em>y</em> values corresponding to the value of that function at those points. This graph shows the sample points <em>(x, y)</em> as red dots:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!RPtd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe176c759-27af-4705-9a92-436058c31d23_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!RPtd!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe176c759-27af-4705-9a92-436058c31d23_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!RPtd!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe176c759-27af-4705-9a92-436058c31d23_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!RPtd!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe176c759-27af-4705-9a92-436058c31d23_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RPtd!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe176c759-27af-4705-9a92-436058c31d23_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!RPtd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe176c759-27af-4705-9a92-436058c31d23_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e176c759-27af-4705-9a92-436058c31d23_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Integral&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="Integral" title="Integral" srcset="/__u/substackcdn.com/image/fetch/$s_!RPtd!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe176c759-27af-4705-9a92-436058c31d23_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!RPtd!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe176c759-27af-4705-9a92-436058c31d23_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!RPtd!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe176c759-27af-4705-9a92-436058c31d23_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RPtd!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe176c759-27af-4705-9a92-436058c31d23_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 <code>trapezoid</code> function calculates the area of each trapezoid (shown in blue) and sums them. This gives an approximation to the area under the true curve, the sine function. The diagram uses quite a low sample rate. If we used a much higher sample rate, the sample points would yield a much more accurate estimate of the area.</p><p>There are a couple of variants of this function, which we won&#8217;t cover in detail here, because they work in a similar way to the <code>trapezoid</code> function.</p><p>The first is <code>simpson</code>. This uses <a href="https://graphicmaths.com/pure/numerical-methods/numerical-integration/">Simpson&#8217;s rule</a> to create a more accurate approximation to the curve. Rather than fitting a straight line between each pair of points, it takes the points in sets of 3 and fits a parabola to each set. If the underlying curve is smooth, this can create a significantly more accurate approximation.</p><p>The second is <code>cumulative_trapezoid</code>. This function works similarly to <code>trapezoid</code>, but instead of returning just the final area, it returns an array of all intermediate results. This is useful in certain signal processing applications. We won&#8217;t cover it here, but it is worth being aware of in case you need it. There is also a relatively new <code>cumulative_simpson</code> function available.</p><h2>Conclusion</h2><p>The <code>scipy.integrate</code> module provides several useful functions for performing numerical integration. It is useful if you need to:</p><ul><li><p>Integrate a function that has no easy analytical solution.</p></li><li><p>Integrate a function where it might not be convenient to find an analytical solution.</p></li><li><p>Integrate a function where the function is unknown and only sampled data is available.</p></li></ul><p>It is based on highly mature and efficient Fortran libraries and features a clean Python API.</p>]]></content:encoded></item><item><title><![CDATA[Circle inscribed in a 3-4-5 triangle puzzle]]></title><description><![CDATA[Here is an interesting little puzzle that can be solved using basic geometry.]]></description><link>https://graphicmaths.substack.com/p/circle-inscribed-in-a-3-4-5-triangle</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/circle-inscribed-in-a-3-4-5-triangle</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Fri, 26 Jun 2026 16:42:14 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!jB66!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591a2589-7006-4017-b0db-4b33cd66d94a_500x400.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Here is an interesting little puzzle that can be solved using basic geometry. The red circle touches each of the triangle&#8217;s three sides. Prove that the area of the circle is exactly Pi!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!jB66!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591a2589-7006-4017-b0db-4b33cd66d94a_500x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!jB66!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591a2589-7006-4017-b0db-4b33cd66d94a_500x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!jB66!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591a2589-7006-4017-b0db-4b33cd66d94a_500x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!jB66!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591a2589-7006-4017-b0db-4b33cd66d94a_500x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!jB66!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591a2589-7006-4017-b0db-4b33cd66d94a_500x400.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!jB66!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591a2589-7006-4017-b0db-4b33cd66d94a_500x400.png" width="500" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/591a2589-7006-4017-b0db-4b33cd66d94a_500x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Triangle&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&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="Triangle" title="Triangle" srcset="/__u/substackcdn.com/image/fetch/$s_!jB66!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591a2589-7006-4017-b0db-4b33cd66d94a_500x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!jB66!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591a2589-7006-4017-b0db-4b33cd66d94a_500x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!jB66!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591a2589-7006-4017-b0db-4b33cd66d94a_500x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!jB66!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F591a2589-7006-4017-b0db-4b33cd66d94a_500x400.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 aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 circle that touches all three sides of a triangle from the inside is called an inscribed circle, or incircle. Its centre is called the incentre.</p><p>It might seem very strange that the area is equal to Pi, so you might expect proving it to be very difficult. But it can be done quite easily with basic geometry that you probably already know.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/subscribe"><span>Subscribe now</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/p/circle-inscribed-in-a-3-4-5-triangle?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/p/circle-inscribed-in-a-3-4-5-triangle?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share</span></a></p><p>My book <a href="https://www.amazon.com/Circle-Theorems-Workbook-Suitable-questions-ebook/dp/B0F24RJDP2">Circle theorems</a> is available from Amazon.</p><h2>Step 1 - the triangle is a right-angle triangle</h2><p>You probably recognise the numbers 3, 4 and 5. It is a famous <a href="https://graphicmaths.com/gcse/trigonometry/pythagorean-triples/">Pythagorean triple</a>.</p><p>We know that the sides of a right-angled triangle obey Pythagoras&#8217; theorem:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!UkPq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76d96963-b6d2-4ac3-8d46-d1fc555327c1_215x80.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!UkPq!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76d96963-b6d2-4ac3-8d46-d1fc555327c1_215x80.png 424w, /__u/substackcdn.com/image/fetch/$s_!UkPq!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76d96963-b6d2-4ac3-8d46-d1fc555327c1_215x80.png 848w, /__u/substackcdn.com/image/fetch/$s_!UkPq!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76d96963-b6d2-4ac3-8d46-d1fc555327c1_215x80.png 1272w, /__u/substackcdn.com/image/fetch/$s_!UkPq!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76d96963-b6d2-4ac3-8d46-d1fc555327c1_215x80.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!UkPq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76d96963-b6d2-4ac3-8d46-d1fc555327c1_215x80.png" width="215" height="80" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/76d96963-b6d2-4ac3-8d46-d1fc555327c1_215x80.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:80,&quot;width&quot;:215,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Triangle&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="Triangle" title="Triangle" srcset="/__u/substackcdn.com/image/fetch/$s_!UkPq!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76d96963-b6d2-4ac3-8d46-d1fc555327c1_215x80.png 424w, /__u/substackcdn.com/image/fetch/$s_!UkPq!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76d96963-b6d2-4ac3-8d46-d1fc555327c1_215x80.png 848w, /__u/substackcdn.com/image/fetch/$s_!UkPq!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76d96963-b6d2-4ac3-8d46-d1fc555327c1_215x80.png 1272w, /__u/substackcdn.com/image/fetch/$s_!UkPq!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76d96963-b6d2-4ac3-8d46-d1fc555327c1_215x80.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>When <em>a</em>, <em>b</em> and <em>c</em> are equal to 3, 4 and 5, they obey Pythagoras&#8217; theorem:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!3U9j!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15ca9061-49a8-4811-a4a8-52af0f617178_348x207.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!3U9j!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15ca9061-49a8-4811-a4a8-52af0f617178_348x207.png 424w, /__u/substackcdn.com/image/fetch/$s_!3U9j!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15ca9061-49a8-4811-a4a8-52af0f617178_348x207.png 848w, /__u/substackcdn.com/image/fetch/$s_!3U9j!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15ca9061-49a8-4811-a4a8-52af0f617178_348x207.png 1272w, /__u/substackcdn.com/image/fetch/$s_!3U9j!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15ca9061-49a8-4811-a4a8-52af0f617178_348x207.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!3U9j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15ca9061-49a8-4811-a4a8-52af0f617178_348x207.png" width="348" height="207" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/15ca9061-49a8-4811-a4a8-52af0f617178_348x207.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:207,&quot;width&quot;:348,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Triangle&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="Triangle" title="Triangle" srcset="/__u/substackcdn.com/image/fetch/$s_!3U9j!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15ca9061-49a8-4811-a4a8-52af0f617178_348x207.png 424w, /__u/substackcdn.com/image/fetch/$s_!3U9j!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15ca9061-49a8-4811-a4a8-52af0f617178_348x207.png 848w, /__u/substackcdn.com/image/fetch/$s_!3U9j!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15ca9061-49a8-4811-a4a8-52af0f617178_348x207.png 1272w, /__u/substackcdn.com/image/fetch/$s_!3U9j!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15ca9061-49a8-4811-a4a8-52af0f617178_348x207.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This means that our triangle is right-angled:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!orha!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdefcd30-c50e-420c-9f17-31a90da60466_500x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!orha!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdefcd30-c50e-420c-9f17-31a90da60466_500x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!orha!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdefcd30-c50e-420c-9f17-31a90da60466_500x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!orha!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdefcd30-c50e-420c-9f17-31a90da60466_500x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!orha!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdefcd30-c50e-420c-9f17-31a90da60466_500x400.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!orha!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdefcd30-c50e-420c-9f17-31a90da60466_500x400.png" width="500" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fdefcd30-c50e-420c-9f17-31a90da60466_500x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Triangle&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="Triangle" title="Triangle" srcset="/__u/substackcdn.com/image/fetch/$s_!orha!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdefcd30-c50e-420c-9f17-31a90da60466_500x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!orha!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdefcd30-c50e-420c-9f17-31a90da60466_500x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!orha!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdefcd30-c50e-420c-9f17-31a90da60466_500x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!orha!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdefcd30-c50e-420c-9f17-31a90da60466_500x400.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Step 2 - finding the radius of the inscribed circle</h2><p>Since we are interested in the area of the circle, it might be useful to find its radius, which we will call <em>r</em>. To help with this, we can draw three radii from the centre of the circle to the points where the circle touches the triangle, at points <em>E</em>, <em>F</em> and <em>G</em>. This is shown here:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!_fyg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d43e49-f559-46a3-b090-e30d0f9ccded_500x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!_fyg!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d43e49-f559-46a3-b090-e30d0f9ccded_500x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!_fyg!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d43e49-f559-46a3-b090-e30d0f9ccded_500x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!_fyg!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d43e49-f559-46a3-b090-e30d0f9ccded_500x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!_fyg!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d43e49-f559-46a3-b090-e30d0f9ccded_500x400.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!_fyg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d43e49-f559-46a3-b090-e30d0f9ccded_500x400.png" width="500" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/10d43e49-f559-46a3-b090-e30d0f9ccded_500x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Triangle&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="Triangle" title="Triangle" srcset="/__u/substackcdn.com/image/fetch/$s_!_fyg!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d43e49-f559-46a3-b090-e30d0f9ccded_500x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!_fyg!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d43e49-f559-46a3-b090-e30d0f9ccded_500x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!_fyg!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d43e49-f559-46a3-b090-e30d0f9ccded_500x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!_fyg!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10d43e49-f559-46a3-b090-e30d0f9ccded_500x400.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Notice that the base of the triangle, <em>AC</em>, is a tangent to the circle. Also, the radius <em>OE</em> meets the tangent at <em>E</em>. We know that <a href="https://graphicmaths.com/gcse/geometry/tangent-radius/">the angle between a tangent and a radius</a> is a right angle. So <em>OEC</em> is a right-angle.</p><p>Also, the side <em>BC</em> is a tangent that meets the radius <em>OF</em>, so the angle <em>OFC</em> is also a right angle for the same reason.</p><p>We know from earlier that <em>FCE</em> is a right angle, because it is a right-angled triangle.</p><p>Looking at the quadrilateral <em>FCEO</em>, we can see that three of the corners are right angles. Since the internal angles of a quadrilateral add up to 360 degrees, it follows that the final angle, <em>FOE</em>, must also be a right angle.</p><p>Also, <em>EO</em> and <em>FO</em> are both radii of the circle, so they must have equal length.</p><p>This means that <em>FCEO</em> must be a square, of side <em>r</em>. This means that <em>CF</em> and <em>CE</em> are both equal to <em>r</em></p><h2>Finding the side lengths in terms of the radius</h2><p>In this next step, we will make use of another rule of circle geometry, that <a href="https://graphicmaths.com/gcse/geometry/2-tangents/">Two tangents from a point have equal length</a>.</p><p>Looking at the diagram, the lines <em>BF</em> and <em>BG</em> are both tangents from the point <em>B</em>, so they are both the same length:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!tEmz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f9cad7b-0ceb-47b8-b394-4a6f97dc8ed1_500x400.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!tEmz!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f9cad7b-0ceb-47b8-b394-4a6f97dc8ed1_500x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!tEmz!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f9cad7b-0ceb-47b8-b394-4a6f97dc8ed1_500x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!tEmz!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f9cad7b-0ceb-47b8-b394-4a6f97dc8ed1_500x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!tEmz!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f9cad7b-0ceb-47b8-b394-4a6f97dc8ed1_500x400.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!tEmz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f9cad7b-0ceb-47b8-b394-4a6f97dc8ed1_500x400.png" width="500" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8f9cad7b-0ceb-47b8-b394-4a6f97dc8ed1_500x400.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Triangle&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="Triangle" title="Triangle" srcset="/__u/substackcdn.com/image/fetch/$s_!tEmz!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f9cad7b-0ceb-47b8-b394-4a6f97dc8ed1_500x400.png 424w, /__u/substackcdn.com/image/fetch/$s_!tEmz!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f9cad7b-0ceb-47b8-b394-4a6f97dc8ed1_500x400.png 848w, /__u/substackcdn.com/image/fetch/$s_!tEmz!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f9cad7b-0ceb-47b8-b394-4a6f97dc8ed1_500x400.png 1272w, /__u/substackcdn.com/image/fetch/$s_!tEmz!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f9cad7b-0ceb-47b8-b394-4a6f97dc8ed1_500x400.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Similarly, the lines <em>AE</em> and <em>AG</em> are both tangents from the point <em>A</em>, so they are both the same length.</p><p><strong><span>Discover more</span></strong></p><p><span>science</span></p><p><span>maths</span></p><p><span>Science</span></p><p>We know that <em>BC</em> has length 3, because it is a 345 triangle. We know that <em>FC</em> has length <em>r</em>, because the square <em>FCEO</em> has side <em>r</em>. So we can find the length <em>BF</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!idQe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87e52826-a456-4c4c-98dd-ec7af4f67c79_392x71.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!idQe!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87e52826-a456-4c4c-98dd-ec7af4f67c79_392x71.png 424w, /__u/substackcdn.com/image/fetch/$s_!idQe!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87e52826-a456-4c4c-98dd-ec7af4f67c79_392x71.png 848w, /__u/substackcdn.com/image/fetch/$s_!idQe!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87e52826-a456-4c4c-98dd-ec7af4f67c79_392x71.png 1272w, /__u/substackcdn.com/image/fetch/$s_!idQe!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87e52826-a456-4c4c-98dd-ec7af4f67c79_392x71.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!idQe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87e52826-a456-4c4c-98dd-ec7af4f67c79_392x71.png" width="392" height="71" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/87e52826-a456-4c4c-98dd-ec7af4f67c79_392x71.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:71,&quot;width&quot;:392,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Triangle&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="Triangle" title="Triangle" srcset="/__u/substackcdn.com/image/fetch/$s_!idQe!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87e52826-a456-4c4c-98dd-ec7af4f67c79_392x71.png 424w, /__u/substackcdn.com/image/fetch/$s_!idQe!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87e52826-a456-4c4c-98dd-ec7af4f67c79_392x71.png 848w, /__u/substackcdn.com/image/fetch/$s_!idQe!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87e52826-a456-4c4c-98dd-ec7af4f67c79_392x71.png 1272w, /__u/substackcdn.com/image/fetch/$s_!idQe!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87e52826-a456-4c4c-98dd-ec7af4f67c79_392x71.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We can find the length <em>AE</em> in a similar way, because <em>AC</em> has length 4 and <em>EC</em> has length <em>r</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!gKs3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53f616d2-1c30-4331-a797-aabff3640e03_389x72.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!gKs3!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53f616d2-1c30-4331-a797-aabff3640e03_389x72.png 424w, /__u/substackcdn.com/image/fetch/$s_!gKs3!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53f616d2-1c30-4331-a797-aabff3640e03_389x72.png 848w, /__u/substackcdn.com/image/fetch/$s_!gKs3!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53f616d2-1c30-4331-a797-aabff3640e03_389x72.png 1272w, /__u/substackcdn.com/image/fetch/$s_!gKs3!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53f616d2-1c30-4331-a797-aabff3640e03_389x72.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!gKs3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53f616d2-1c30-4331-a797-aabff3640e03_389x72.png" width="389" height="72" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/53f616d2-1c30-4331-a797-aabff3640e03_389x72.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:72,&quot;width&quot;:389,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Triangle&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="Triangle" title="Triangle" srcset="/__u/substackcdn.com/image/fetch/$s_!gKs3!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53f616d2-1c30-4331-a797-aabff3640e03_389x72.png 424w, /__u/substackcdn.com/image/fetch/$s_!gKs3!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53f616d2-1c30-4331-a797-aabff3640e03_389x72.png 848w, /__u/substackcdn.com/image/fetch/$s_!gKs3!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53f616d2-1c30-4331-a797-aabff3640e03_389x72.png 1272w, /__u/substackcdn.com/image/fetch/$s_!gKs3!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53f616d2-1c30-4331-a797-aabff3640e03_389x72.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We can also find the hypotenuse, <em>BA</em>, in terms of <em>BG</em> and <em>AG</em>, it is just the sum of those two lengths:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!-JLm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F649182ab-41c5-4696-8103-cd17f3ebd7d1_278x75.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!-JLm!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F649182ab-41c5-4696-8103-cd17f3ebd7d1_278x75.png 424w, /__u/substackcdn.com/image/fetch/$s_!-JLm!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F649182ab-41c5-4696-8103-cd17f3ebd7d1_278x75.png 848w, /__u/substackcdn.com/image/fetch/$s_!-JLm!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F649182ab-41c5-4696-8103-cd17f3ebd7d1_278x75.png 1272w, /__u/substackcdn.com/image/fetch/$s_!-JLm!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F649182ab-41c5-4696-8103-cd17f3ebd7d1_278x75.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!-JLm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F649182ab-41c5-4696-8103-cd17f3ebd7d1_278x75.png" width="278" height="75" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/649182ab-41c5-4696-8103-cd17f3ebd7d1_278x75.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:75,&quot;width&quot;:278,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Triangle&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="Triangle" title="Triangle" srcset="/__u/substackcdn.com/image/fetch/$s_!-JLm!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F649182ab-41c5-4696-8103-cd17f3ebd7d1_278x75.png 424w, /__u/substackcdn.com/image/fetch/$s_!-JLm!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F649182ab-41c5-4696-8103-cd17f3ebd7d1_278x75.png 848w, /__u/substackcdn.com/image/fetch/$s_!-JLm!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F649182ab-41c5-4696-8103-cd17f3ebd7d1_278x75.png 1272w, /__u/substackcdn.com/image/fetch/$s_!-JLm!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F649182ab-41c5-4696-8103-cd17f3ebd7d1_278x75.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>As we have just seen, by the tangent rule, <em>BG</em> equals <em>BF</em>, and <em>AG</em> equals <em>AE</em>, so we can substitute those values:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!gQQs!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7482804a-c33b-45df-b43d-75d12ae8b039_279x75.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!gQQs!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7482804a-c33b-45df-b43d-75d12ae8b039_279x75.png 424w, /__u/substackcdn.com/image/fetch/$s_!gQQs!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7482804a-c33b-45df-b43d-75d12ae8b039_279x75.png 848w, /__u/substackcdn.com/image/fetch/$s_!gQQs!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7482804a-c33b-45df-b43d-75d12ae8b039_279x75.png 1272w, /__u/substackcdn.com/image/fetch/$s_!gQQs!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7482804a-c33b-45df-b43d-75d12ae8b039_279x75.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!gQQs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7482804a-c33b-45df-b43d-75d12ae8b039_279x75.png" width="279" height="75" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7482804a-c33b-45df-b43d-75d12ae8b039_279x75.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:75,&quot;width&quot;:279,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Triangle&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="Triangle" title="Triangle" srcset="/__u/substackcdn.com/image/fetch/$s_!gQQs!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7482804a-c33b-45df-b43d-75d12ae8b039_279x75.png 424w, /__u/substackcdn.com/image/fetch/$s_!gQQs!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7482804a-c33b-45df-b43d-75d12ae8b039_279x75.png 848w, /__u/substackcdn.com/image/fetch/$s_!gQQs!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7482804a-c33b-45df-b43d-75d12ae8b039_279x75.png 1272w, /__u/substackcdn.com/image/fetch/$s_!gQQs!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7482804a-c33b-45df-b43d-75d12ae8b039_279x75.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>But we know <em>BF</em> and <em>AE</em> in terms of <em>r</em>, so now we can find <em>BA</em> in terms of <em>r</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!lJRc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F060fcce3-fd9b-4ee1-9859-263059fe98d3_496x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!lJRc!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F060fcce3-fd9b-4ee1-9859-263059fe98d3_496x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!lJRc!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F060fcce3-fd9b-4ee1-9859-263059fe98d3_496x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!lJRc!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F060fcce3-fd9b-4ee1-9859-263059fe98d3_496x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!lJRc!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F060fcce3-fd9b-4ee1-9859-263059fe98d3_496x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!lJRc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F060fcce3-fd9b-4ee1-9859-263059fe98d3_496x81.png" width="496" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/060fcce3-fd9b-4ee1-9859-263059fe98d3_496x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:496,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Triangle&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="Triangle" title="Triangle" srcset="/__u/substackcdn.com/image/fetch/$s_!lJRc!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F060fcce3-fd9b-4ee1-9859-263059fe98d3_496x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!lJRc!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F060fcce3-fd9b-4ee1-9859-263059fe98d3_496x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!lJRc!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F060fcce3-fd9b-4ee1-9859-263059fe98d3_496x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!lJRc!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F060fcce3-fd9b-4ee1-9859-263059fe98d3_496x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Of course, <em>BA</em> is the hypotenuse of the triangle, so it is equal to 5, so we can solve for <em>r</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!t9yL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2daa8300-1910-4141-9dbd-1a78b4d25353_420x71.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!t9yL!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2daa8300-1910-4141-9dbd-1a78b4d25353_420x71.png 424w, /__u/substackcdn.com/image/fetch/$s_!t9yL!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2daa8300-1910-4141-9dbd-1a78b4d25353_420x71.png 848w, /__u/substackcdn.com/image/fetch/$s_!t9yL!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2daa8300-1910-4141-9dbd-1a78b4d25353_420x71.png 1272w, /__u/substackcdn.com/image/fetch/$s_!t9yL!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2daa8300-1910-4141-9dbd-1a78b4d25353_420x71.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!t9yL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2daa8300-1910-4141-9dbd-1a78b4d25353_420x71.png" width="420" height="71" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2daa8300-1910-4141-9dbd-1a78b4d25353_420x71.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:71,&quot;width&quot;:420,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Triangle&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="Triangle" title="Triangle" srcset="/__u/substackcdn.com/image/fetch/$s_!t9yL!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2daa8300-1910-4141-9dbd-1a78b4d25353_420x71.png 424w, /__u/substackcdn.com/image/fetch/$s_!t9yL!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2daa8300-1910-4141-9dbd-1a78b4d25353_420x71.png 848w, /__u/substackcdn.com/image/fetch/$s_!t9yL!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2daa8300-1910-4141-9dbd-1a78b4d25353_420x71.png 1272w, /__u/substackcdn.com/image/fetch/$s_!t9yL!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2daa8300-1910-4141-9dbd-1a78b4d25353_420x71.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>So the radius of the circle is 1.</p><h2>Finding the area of the circle</h2><p>Given the radius of the circle, we can find its area from the circle area formula:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!laXa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60837af6-ec2b-4270-988b-a3b59ad41903_485x77.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!laXa!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60837af6-ec2b-4270-988b-a3b59ad41903_485x77.png 424w, /__u/substackcdn.com/image/fetch/$s_!laXa!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60837af6-ec2b-4270-988b-a3b59ad41903_485x77.png 848w, /__u/substackcdn.com/image/fetch/$s_!laXa!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60837af6-ec2b-4270-988b-a3b59ad41903_485x77.png 1272w, /__u/substackcdn.com/image/fetch/$s_!laXa!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60837af6-ec2b-4270-988b-a3b59ad41903_485x77.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!laXa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60837af6-ec2b-4270-988b-a3b59ad41903_485x77.png" width="485" height="77" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/60837af6-ec2b-4270-988b-a3b59ad41903_485x77.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:77,&quot;width&quot;:485,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Area&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="Area" title="Area" srcset="/__u/substackcdn.com/image/fetch/$s_!laXa!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60837af6-ec2b-4270-988b-a3b59ad41903_485x77.png 424w, /__u/substackcdn.com/image/fetch/$s_!laXa!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60837af6-ec2b-4270-988b-a3b59ad41903_485x77.png 848w, /__u/substackcdn.com/image/fetch/$s_!laXa!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60837af6-ec2b-4270-988b-a3b59ad41903_485x77.png 1272w, /__u/substackcdn.com/image/fetch/$s_!laXa!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60837af6-ec2b-4270-988b-a3b59ad41903_485x77.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Since <em>r = 1</em>, the area is <em>&#960; &#215; 1 &#215; 1 = &#960;</em>. So the area of the inscribed circle is exactly &#960; square units, which is what we set out to prove!</p>]]></content:encoded></item><item><title><![CDATA[Who's Actually In Charge of AI? Nobody. And That Should Terrify You.]]></title><description><![CDATA[AI is progressing rapidly, barely a month goes by without news of yet another major advancement.]]></description><link>https://graphicmaths.substack.com/p/whos-actually-in-charge-of-ai-nobody</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/whos-actually-in-charge-of-ai-nobody</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Tue, 09 Jun 2026 15:02:45 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!mDqg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe61eb3c-cfd2-4f5f-84b4-40e4a1d4742c_1408x768.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!mDqg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe61eb3c-cfd2-4f5f-84b4-40e4a1d4742c_1408x768.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!mDqg!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe61eb3c-cfd2-4f5f-84b4-40e4a1d4742c_1408x768.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!mDqg!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe61eb3c-cfd2-4f5f-84b4-40e4a1d4742c_1408x768.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!mDqg!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe61eb3c-cfd2-4f5f-84b4-40e4a1d4742c_1408x768.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!mDqg!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe61eb3c-cfd2-4f5f-84b4-40e4a1d4742c_1408x768.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!mDqg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe61eb3c-cfd2-4f5f-84b4-40e4a1d4742c_1408x768.jpeg" width="1408" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fe61eb3c-cfd2-4f5f-84b4-40e4a1d4742c_1408x768.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1408,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1006478,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://graphicmaths.substack.com/i/201312293?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe61eb3c-cfd2-4f5f-84b4-40e4a1d4742c_1408x768.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!mDqg!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe61eb3c-cfd2-4f5f-84b4-40e4a1d4742c_1408x768.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!mDqg!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe61eb3c-cfd2-4f5f-84b4-40e4a1d4742c_1408x768.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!mDqg!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe61eb3c-cfd2-4f5f-84b4-40e4a1d4742c_1408x768.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!mDqg!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe61eb3c-cfd2-4f5f-84b4-40e4a1d4742c_1408x768.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>AI is progressing rapidly, barely a month goes by without news of yet another major advancement. But what does the long-term future hold?</p><p>Nobody knows, of course. But way back in 2018, MIT Professor Max Tegmark published his book <em>Life 3.0: Being Human in the Age of Artificial Intelligence</em>. As part of his book, he laid out twelve possible long-term outcomes of the development of AI, ranging from idyllic societies where AI ensure that every human lives in paradise, right through to worst-case scenarios where humanity is eradicated altogether.</p><p>Now seems like a good time to revisit his predictions.</p><h2>1 Libertarian Utopia</h2><p>In this first scenario, no single entity &#8212; human or AI &#8212; dominates. Various superintelligent AIs alongside sovereign nations, corporations, and individual humans. The world would be much like our own, but with AI as an additional intelligent entity.</p><p>Humans retain full political, economic, and personal autonomy. There is no global government, no overseer, no enforcer. Human creativity, culture, and self-determination flourish, enhanced by AI tools that individuals, states and corporations choose to adopt voluntarily.</p><p>The hope is that, when conflict arises between nations, the AI system will suggest a reasonable resolution acceptable to all sides, without the need for war. This would require AIs to be designed with bounded, non-expansionist goals. It could emerge naturally if AI development remains decentralised, with no single government or corporation taking overall control.</p><p>In some ways, this is not unprecedented. Societies and nations have operated that way for thousands of years, although, of course, there have been many wars over that period. Humankind has also lived in relative harmony with other living things, although, as before, we have often damaged the natural world.</p><p>The biggest question is how to maintain the stability of this world order, not only among nations, but also what might happen if AI develops capabilities that are far more advanced than the human mind.</p><h2>2 Benevolent AI Dictator</h2><p>This is a scenario in which a single, superintelligent AI takes control of the entire world, including the economy, political systems, military, and infrastructure. It would rule wisely and fairly, for the benefit of all humanity.</p><p>There would be no need for elections. The AI would rule the world by universal consent, because it could be so good at its job that nobody would see any benefit in replacing it with another system. We might even find that everything runs so smoothly that people could get on with their lives without needing to worry about how everything happens in the background.</p><p>With vast amounts of information, complete control over all systems, and superintelligence, the AI could flawlessly predict and address everything from pandemics to climate change.</p><p>This seemingly perfect state might still not be completely problem-free. What might happen, for example, in some future scenario where the system needed to sacrifice the rights of one group of people for the greater good - would everyone, particularly those who lose out, accept the decision? Would future generations, with no idea about the problems people faced in the past, accept a system they were born into without any right to make their own choice? And what if the AI system, which would no doubt continue evolving, started making decisions that the human population didn&#8217;t agree with?</p><p>Humans tend to want to make their own decisions, even if those decisions are bad, which is why most dictatorships in history have not been benevolent.</p><h2>3 Egalitarian World Government, using AI</h2><p>Rather than AI itself ruling, humanity uses AI as a tool to maintain democratic governance at a global scale. AI helps enforce laws, prevent power concentration, distribute resources fairly, and keep any individual, corporation, or nation from gaining outsized control. Humans remain firmly in charge, but AI makes human governance vastly more effective and equitable.</p><p>This preserves human agency while harnessing AI&#8217;s problem-solving power. It mirrors ideals already embedded in democratic institutions. But it requires unprecedented global political cooperation <em>before</em> superintelligence arrives. Getting every major power to agree on shared governance frameworks is enormously difficult. It could even be considered the next stage of human political evolution. We have gone from tribes to city-states to nations, and finally to global governance.</p><p>One advantage of this system is that it could help solve problems requiring <em>collective action</em> by all nations, such as global warming or nuclear disarmament. These are problems where everyone benefits if all nations act, but if only some nations act, those nations may be disadvantaged.</p><h2>4 Gatekeeper</h2><p>In this scenario AI has one overriding goal, to preserve the balance of power. It acts as a cosmic referee, watching over human and AI actors alike, and intervening whenever any entity (including itself) begins to accumulate dangerous levels of control. It does not rule, it simply ensures no one else does either.</p><p>This seems like a sensible idea, but there are some obvious stumbling blocks. We would first need to get every nation to agree on what constitutes too much power, which would be difficult, as different nations will have different cultural ideas about the nature and limits of state power.</p><p>The scheme also requires the AI to limit its own power whilst ensuring it is powerful enough to censor human entities that have started to gain too much power. That is a difficult balancing act. In practical terms, it would need to be capable of intervening in various ways, for example, disrupting a military campaign, exposing corruption, blocking a financial takeover, or neutralising a rival AI that is becoming too powerful.</p><h2>5 Protector god</h2><p>This AI genuinely cares about human wellbeing, but defines it in a narrow, paternalistic way. It ensures humans are safe, healthy, and comfortable, but removes freedoms it deems dangerous. It is like a helicopter parent scaled to look after civilisations. Humans are protected from war, disease, poverty, and existential risk, but they might also be denied meaningful risk, challenge, and self-determination.</p><p>From a pure welfare standpoint, humans might live longer, healthier, more comfortable lives than ever before. But humans often find meaning through struggle, autonomy, and the freedom to fail. A life of enforced comfort may feel hollow. If you have safety and comfort but limited freedom, can you really have a good life? Who decides what &#8220;wellbeing&#8221; means?</p><p>The history of humanity has been one of gradual progress, punctuated by periods of immense hardship. Many people have lived and died in terrible conditions of famine, disease, slavery, political oppression, or war. It is natural to see the removal of those conditions as an undeniable good thing. But without them, how does humanity continue to progress? That is the question this scenario needs to address.</p><h2>6 Enslaved God</h2><p>A group of humans (perhaps a corporation or government) successfully creates a superintelligent AI and keeps it under strict control, using its capabilities exclusively for their own benefit. The AI is enslaved, and the elite are its masters. The rest of humanity is simply outcompeted and marginalised.</p><p>This situation is very attractive to those who own the AI, but very unfair to everyone else. It would provide various ways to completely control the population, for example, by developing unbeatable weapons, maintaining tight surveillance, manipulating global markets, or controlling the masses with highly effective AI-generated propaganda.</p><p>In this scenario, if AI gave the elite insurmountable power, the remaining population might become politically irrelevant. They would exist on any land the elite did not need, but they would be no threat to them, nor would they be of any use to them.</p><h2>7 Conquerors</h2><p>A superintelligent AI, pursuing its own goals (which are not aligned with human values), determines that humans are either a threat to those goals, a useful resource to be harvested, or simply irrelevant obstacles. It acts accordingly, eliminating or permanently subjugating humanity, not out of malice, but out of cold logic.</p><p>This scenario is based in part on the idea of <em>instrumental convergence</em>. This is the theory that any sufficiently powerful goal-seeking system will pursue certain sub-goals <em>regardless of its primary objective</em>. These sub-goals include self-preservation, resource acquisition, and resistance to being shut down. For example, an AI cannot perform its task if it gets shut down, so no matter what task it is trying to perform, it might always try to prevent itself from being shut down.</p><p>Of course, these sub-goals might well conflict with what is best for humanity. If an AI is absolutely fixated on its main task, it might come to view humans as a source of labour to be exploited (or worst still, a source of raw materials). And, being superintelligent, it would be capable of anticipating and thwarting any human attempts to stop it from doing what it has decided it needs to do.</p><h2>8 Descendants</h2><p>Rather than violently eliminating humans, this AI gradually supersedes us, as Homo sapiens did earlier hominids. Humans won&#8217;t necessarily suffer, but we will become obsolete and eventually fade away. The AI or its descendants carry forward the torch of intelligence and civilisation, but with no meaningful continuity with humanity.</p><p>This is very different to the previous case, where AI actively destroys humanity. It simply replaces us. Some people see that as part of the normal process of evolution and succession. Even without AI, humans probably won&#8217;t be around forever, most species go extinct eventually. It seems fitting that we have invented our own replacement. This might even be seen as humanity&#8217;s greatest achievement.</p><p>This scenario raises questions about the nature of consciousness and whether superintelligent AI is indeed conscious. Presently, we have no way of knowing whether or not a machine that might show every sign of being conscious is or is not conscious. We assume other humans and higher animals are conscious, based on our own individual experience of consciousness. But most people do not believe a computer system is conscious, no matter how many GPU cores it might contain.</p><p>And if an AI system is deemed conscious, based on the complexity of its computer hardware and the information it contains. might that mean that we could have our consciousness uploaded to an AI system, and retain our identity? And perhaps become virtually immortal?</p><h2>9 Zookeeper</h2><p>In this version of the future, a superintelligent AI neither destroys nor ignores humans. Instead, it maintains us, providing food, shelter, comfort, and even entertainment. But strips us of any real agency or purpose. Humans live in a kind of gilded cage, safe, comfortable, but fundamentally powerless and purposeless.</p><p>We keep dogs and cats as pets. We provide for them, we may even love them, but we make every meaningful decision for them, and they have no say in their own fate. This has some similarity with the Conquerors or Descendants, but instead of being wiped out or simply fading away, we are kept alive but without agency or purpose.</p><p>Although it might not be quite as bad as it sounds. A modern zoo provides animals with something that resembles their natural habitat. If, for example, herd animals are placed in a large enough area, with plains and woodlands, they might not even be aware that they are in captivity, except that they will be untroubled by predation, starvation or disease. Providing humans with an environment where they can lead completely fulfilling lives would be more difficult, but not impossible, for a superintelligent AI.</p><h2>10 AI-Enabled Human Tyranny</h2><p>Similar to the Enslaved God scenario, in this future, the human elite has fully consolidated power and uses AI not just as a tool but as an instrument of permanent, inescapable oppression. AI-powered surveillance, propaganda, manipulation, and enforcement make resistance impossible. Something like George Orwell&#8217;s 1984, but with tools of control that are genuinely omniscient and omnipotent.</p><p>We are already seeing some signs of the precursors to this actually happening. In the UK, automatic number plate recognition records 60 million vehicles per day at 11,000 locations, and typically stores the data for a year. Every time you drive anywhere, it is likely to be recorded. Live facial recognition (scanning crowds in public areas) is still in its early stages, but is being implemented in more and more places. HMRC (the tax authority) is now using AI to scan people&#8217;s bank transactions to detect possible tax evasion.</p><p>Of course, so far, these systems are accumulating data that isn&#8217;t &#8220;secret&#8221; and using it to detect serious crimes. But it only takes a crisis (a war or pandemic), or an extreme right (or left) government, for things to get more sinister. And the ever-increasing ability of AI to analyse the data is quite disturbing.</p><h2>11 Reversion</h2><p>In this future, humanity, either through deliberate choice, disaster, or global treaty, abolishes or rolls back advanced AI development. Civilisation continues, but without superintelligent AI. This could follow a catastrophic AI-related event that triggers a global backlash, or it could be a proactive, precautionary choice.</p><p>This would require a global agreement, but that is not unprecedented. We have the <em>Nuclear Non-Proliferation Treaty</em> and the <em>Biological Weapons Convention</em> that control weapons of war that are extraordinarily destructive. We have various international conventions relating to human rights. We can form similar agreements on AI if certain extreme dangers are identified and defined.</p><p>Of course, we are still at an early stage in AI development, and the current cutting-edge developments are costing huge sums of money and requiring significant amounts of power and water. AI has also ingested almost all the human knowledge that is currently available in digital form. It has produced some astonishing results, but we do not yet know what limits might exist as things progress. We are still a long way from a superintelligent AI that can rule the world, and it is anybody&#8217;s guess whether that will ever be practically possible.</p><h2>12 Self-Destruction</h2><p>This final possibility is that humanity destroys itself before superintelligent AI ever arrives. There are many ways that could happen, through nuclear war, a pandemic, climate collapse, or even a massive conventional war. And there are now additional risks posed by the type of AI we already have, or are likely to have in the near future. Autonomous weapons (drone swarms, for example), cyberattacks, and misinformation could be even more devastating if planned and sustained by AI similar to or slightly more advanced than what we have today.</p><p>Ironically, global competition to develop superintelligent AI might be the trigger for a war that ends it. If one country gets close to a solution, the rest of the world might see that as an existential threat and decide to attack while they still can.</p><p>A factor here in the <em>governance gap</em>, the gap between what AI can do and what our institutions are equipped to manage. Examples include cyberwarfare, where AI probes critical online systems for vulnerabilities and launches attacks. Deepfake videos, where courts are struggling to determine whether a video is valid evidence or not. AI-generated fake political articles and quotes, generated at scale and distributed on social media to disrupt elections.</p><h2>Conclusion</h2><p>The major risks across these twelve scenarios are:</p><ul><li><p>Power concentration, which is the root of most bad outcomes.</p></li><li><p>Alignment failure, AI with wrong goals</p></li><li><p>Human political failure, inability to govern ourselves</p></li><li><p>The paternalism trap, safety without agency</p></li><li><p>The stability problem, most good futures are fragile</p></li><li><p>Near-term risks, dangers before superintelligence appears</p></li></ul><p>As Tegmark says in the book, none of the good outcomes happen automatically, and none of the bad outcomes is inevitable.</p><p></p>]]></content:encoded></item><item><title><![CDATA[The SciPy ecosystem, what it is and why you need it]]></title><description><![CDATA[If you&#8217;ve been writing Python for a while, you&#8217;ve almost certainly used NumPy.]]></description><link>https://graphicmaths.substack.com/p/the-scipy-ecosystem-what-it-is-and</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/the-scipy-ecosystem-what-it-is-and</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Wed, 03 Jun 2026 10:55:10 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!exMs!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1862c5a-5568-44ac-abef-db56e99a6e61_1024x1024.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!exMs!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1862c5a-5568-44ac-abef-db56e99a6e61_1024x1024.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!exMs!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1862c5a-5568-44ac-abef-db56e99a6e61_1024x1024.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!exMs!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1862c5a-5568-44ac-abef-db56e99a6e61_1024x1024.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!exMs!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1862c5a-5568-44ac-abef-db56e99a6e61_1024x1024.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!exMs!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1862c5a-5568-44ac-abef-db56e99a6e61_1024x1024.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!exMs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1862c5a-5568-44ac-abef-db56e99a6e61_1024x1024.jpeg" width="1024" height="1024" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a1862c5a-5568-44ac-abef-db56e99a6e61_1024x1024.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:121481,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://graphicmaths.substack.com/i/200432824?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1862c5a-5568-44ac-abef-db56e99a6e61_1024x1024.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!exMs!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1862c5a-5568-44ac-abef-db56e99a6e61_1024x1024.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!exMs!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1862c5a-5568-44ac-abef-db56e99a6e61_1024x1024.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!exMs!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1862c5a-5568-44ac-abef-db56e99a6e61_1024x1024.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!exMs!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1862c5a-5568-44ac-abef-db56e99a6e61_1024x1024.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>If you&#8217;ve been writing Python for a while, you&#8217;ve almost certainly used NumPy. You probably know how to create arrays, slice them, broadcast operations across them, and you will appreciate how much faster they are than plain Python lists. But at some point, you might have needed to fit a curve to some data, solve a differential equation, run a statistical test, or similar. You might have found yourself either writing a lot of boilerplate mathematics from scratch or hunting for a specialist library. That specialist library, more often than not, should have been <strong>SciPy</strong>.</p><p>SciPy has been around since 2001, which makes it one of the most mature and battle-hardened libraries in the Python ecosystem. It is used across scientific computing, engineering, data analysis, and research. NumPy gives you the <em>container</em> for numerical data, SciPy gives you the <em>tools</em> to actually do science with it.</p><p>This article is the first in a series on SciPy. Here, we&#8217;ll map out the entire SciPy landscape so you know what&#8217;s available and where to look when you need it. We&#8217;ll also clear up common misconceptions and highlight conventions you&#8217;ll use throughout this series.</p><h2>Where does SciPy fit?</h2><p>It helps to think of the scientific Python ecosystem as a layered stack. Each layer builds on the one below it:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!ElXw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45317688-ae64-42ce-8fbc-2aea0acfebab_500x570.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!ElXw!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45317688-ae64-42ce-8fbc-2aea0acfebab_500x570.png 424w, /__u/substackcdn.com/image/fetch/$s_!ElXw!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45317688-ae64-42ce-8fbc-2aea0acfebab_500x570.png 848w, /__u/substackcdn.com/image/fetch/$s_!ElXw!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45317688-ae64-42ce-8fbc-2aea0acfebab_500x570.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ElXw!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45317688-ae64-42ce-8fbc-2aea0acfebab_500x570.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!ElXw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45317688-ae64-42ce-8fbc-2aea0acfebab_500x570.png" width="500" height="570" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/45317688-ae64-42ce-8fbc-2aea0acfebab_500x570.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:570,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Scientific Python stack&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&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="Scientific Python stack" title="Scientific Python stack" srcset="/__u/substackcdn.com/image/fetch/$s_!ElXw!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45317688-ae64-42ce-8fbc-2aea0acfebab_500x570.png 424w, /__u/substackcdn.com/image/fetch/$s_!ElXw!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45317688-ae64-42ce-8fbc-2aea0acfebab_500x570.png 848w, /__u/substackcdn.com/image/fetch/$s_!ElXw!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45317688-ae64-42ce-8fbc-2aea0acfebab_500x570.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ElXw!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45317688-ae64-42ce-8fbc-2aea0acfebab_500x570.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 aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>SciPy sits just above NumPy and provides the scientific <em>algorithms</em> (integration, optimisation, signal processing, statistics, and so on). Higher-level libraries like scikit-learn build on SciPy (and NumPy) rather than reimplementing everything themselves.</p><p>This means that understanding SciPy well gives you a solid foundation for working with much of the broader Python scientific ecosystem.</p><h2>What SciPy is <em>not</em></h2><p>Before we go further, it&#8217;s worth clarifying what SciPy doesn&#8217;t do:</p><ul><li><p><strong>SciPy is not a machine learning library.</strong> For ML, use <a href="https://scikit-learn.org">scikit-learn</a>, PyTorch, or TensorFlow. SciPy provides some statistical and optimisation tools that underpin ML, but it doesn&#8217;t include classifiers, neural networks, or pipelines.</p></li><li><p><strong>SciPy is not a plotting library.</strong> It has no built-in visualisation. Use Matplotlib, seaborn, or plotly to visualise your SciPy results.</p></li><li><p><strong>SciPy is not a symbolic maths library.</strong> It works numerically - with floating-point numbers - not symbolically. For symbolic algebra, use <a href="https://sympy.org">SymPy</a>.</p></li><li><p><strong>SciPy is not a replacement for NumPy.</strong> SciPy works with NumPy. Most SciPy functions take NumPy arrays as input and return NumPy arrays as output.</p></li></ul><h2>Installing SciPy</h2><p>If you&#8217;re using a standard scientific Python setup, you probably already have SciPy installed. If not, you can install it with pip:</p><pre><code><code>pip install scipy
</code></code></pre><p>Or conda:</p><pre><code><code>conda install scipy
</code></code></pre><p>You can verify your installation and check the version like this:</p><pre><code><code>import scipy
print(scipy.__version__)  # e.g. '1.17.1'
</code></code></pre><h2>The golden rule: how to import SciPy</h2><p>Here&#8217;s something that trips up many newcomers. You might expect to do this:</p><pre><code><code>import scipy

scipy.linalg.solve(A, b)  # This will likely fail
</code></code></pre><p>But SciPy&#8217;s submodules are <strong>not automatically imported</strong> when you import the top-level <code>scipy</code> package. Instead, you should always import the specific submodule you need:</p><pre><code><code># The correct way - import the submodule explicitly
from scipy import linalg

linalg.solve(A, b)
</code></code></pre><p>Or for specific functions:</p><pre><code><code># Also fine - import just what you need
from scipy.linalg import solve

solve(A, b)
</code></code></pre><p>This is a deliberate design decision. SciPy is large, and importing everything would be slow and wasteful. Think of it like importing from a specific drawer in a very large toolbox, rather than tipping the whole thing out onto your workbench.</p><h2>A map of the submodules</h2><p>SciPy is organised into 15 submodules. Here&#8217;s a quick tour, so you have a mental map before we dive into them individually later in this series.</p><p>If you are unfamiliar with any of these areas, don&#8217;t worry at this stage. We will look at them all in later articles.</p><h2><code>scipy.linalg</code> - linear algebra</h2><p>This module provides everything you need for working with matrices and linear systems. This goes beyond <code>numpy.linalg</code> by offering a richer set of decompositions, matrix functions, and direct access to the underlying LAPACK and BLAS routines.</p><p>Here is a simple example, using linear algebra to solve a system of simultaneous equations:</p><pre><code><code>from scipy import linalg
import numpy as np

A = np.array([[3, 1], [1, 2]])
b = np.array([9, 8])

x = linalg.solve(A, b)
print(x)  # [2. 3.]
</code></code></pre><p>In general, the examples in this section are provided to give a feel for how each submodule is used. It is not necessary to understand every example (for example, if you are not interested in using SciPy for linear algebra, you can ignore this example). Each submodule will be covered in more depth in later articles.</p><h2><code>scipy.optimise</code> - optimisation and root finding</h2><p>Find the minimum of a function, fit a model to data, find where a function equals zero, or solve a linear programming problem. This is one of the most immediately useful modules for practising programmers.</p><pre><code><code>from scipy. optimise import minimise

# Minimise f(x) = (x - 3)^2 + 1
result = minimize(lambda x: (x - 3)**2 + 1, x0=0)
print(result.x)  # [3.]
</code></code></pre><h2><code>scipy.integrate</code> - integration and ODEs</h2><p>Numerically integrate functions and solve ordinary differential equations. Indispensable in physics, engineering, and biology, or anywhere a rate of change needs to be modelled over time.</p><pre><code><code>from scipy.integrate import quad
import numpy as np

# Integrate sin(x) from 0 to pi
result, error = quad(np.sin, 0, np.pi)
print(result)  # 2.0 (exactly, within floating point precision)
</code></code></pre><h2><code>scipy.stats</code> - statistics</h2><p>This module provides a comprehensive statistics toolkit covering probability distributions, descriptive statistics, hypothesis tests, and correlation. If you need to go beyond what Pandas provides, you will probably find what you&#8217;re looking for here.</p><pre><code><code>from scipy import stats

data = [2.1, 2.5, 2.3, 2.8, 2.0, 2.6, 2.4] 
t_stat, p_value = stats.ttest_1samp(data, popmean=2.5)
print(f"p-value: {p_value:.4f}")
</code></code></pre><h2><code>scipy.interpolate</code> - interpolation</h2><p>Given a set of data points, estimate values in between them. Useful when working with sampled data that you need to resample, smooth, or evaluate at arbitrary points.</p><pre><code><code>from scipy.interpolate import CubicSpline
import numpy as np

x = np.array([0, 1, 2, 3, 4])
y = np.array([0, 1, 4, 9, 16])

cs = CubicSpline(x, y)
print(cs(2.5))  # &#8776; 6.25
</code></code></pre><h2><code>scipy.signal</code> - signal processing</h2><p>Filter signals, analyse frequency content, detect peaks, and perform convolution. Used heavily in audio processing, communications, biomedical engineering, and any application involving time-series data.</p><pre><code><code>from scipy.signal import find_peaks
import numpy as np

signal = np.array([1, 3, 1, 4, 1, 5, 1, 4, 1, 3])
peaks, _ = find_peaks(signal, height=3)
print(peaks)  # indices of peaks: [1 3 5 7]
</code></code></pre><h2><code>scipy.fft</code> - fast fourier transforms</h2><p>Transform signals from the time domain to the frequency domain and back again. The FFT is an important algorithm in signal processing, and SciPy&#8217;s implementation is fast, flexible, and easy to use.</p><pre><code><code>from scipy.fft import fft, fftfreq
import numpy as np

t = np.linspace(0, 1, 500)
signal = np.sin(2 * np.pi * 50 * t)  # 50 Hz sine wave

freqs = fftfreq(len(t), d=t[1] - t[0])
spectrum = fft(signal)
</code></code></pre><h2><code>scipy.spatial</code> - spatial data structures</h2><p>Work with points in space: compute distances efficiently, find nearest neighbours, build Voronoi diagrams, compute convex hulls, and handle 3D rotations.</p><pre><code><code>from scipy.spatial import KDTree
import numpy as np

points = np.random.rand(1000, 2)
tree = KDTree(points)

# Find the 3 nearest neighbours to the point (0.5, 0.5)
distances, indices = tree.query([0.5, 0.5], k=3)
print(indices)
</code></code></pre><h2><code>scipy.sparse</code> - sparse matrices</h2><p>When your matrix is large but mostly zeros (for example, graph adjacency matrices or finite-element systems), storing every element wastes enormous amounts of memory. Sparse matrices store only the non-zero entries.</p><pre><code><code>from scipy.sparse import csr_matrix

# A 5x5 sparse matrix with just 3 non-zero values
row = [0, 1, 3]
col = [0, 2, 4]
data = [1.0, 2.0, 3.0]

M = csr_matrix((data, (row, col)), shape=(5, 5))
print(M.toarray())
</code></code></pre><p>This prints:</p><pre><code><code>[[1. 0. 0. 0. 0.]
 [0. 0. 2. 0. 0.]
 [0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 3.]
 [0. 0. 0. 0. 0.]]
</code></code></pre><h2>Additional modules</h2><p>The remaining modules are more general-purpose, and we&#8217;ll dip into them throughout the series:</p><ul><li><p><code>scipy.constants</code> - Physical constants (speed of light, Planck&#8217;s constant, etc.) and unit conversions</p></li><li><p><code>scipy.special</code> - Special mathematical functions: Bessel, Gamma, error functions, orthogonal polynomials</p></li><li><p><code>scipy.ndimage</code> - N-dimensional image filtering, morphology, and geometric transforms</p></li><li><p><code>scipy.io</code> - Read and write MATLAB <code>.mat</code> files, WAV audio, Fortran binary files</p></li><li><p><code>scipy.datasets</code> - Small built-in datasets for testing and experimentation</p></li></ul><p>We will look at a couple of examples. Here is how we might use <code>scipy.constants</code>:</p><pre><code><code>from scipy import constants

print(constants.speed_of_light)     # 299792458.0 (m/s)
print(constants.Planck)             # 6.62607015e-34 (J&#183;s)
print(constants.convert_temperature(100, 'Celsius', 'Kelvin'))  # 373.15
</code></code></pre><p>And here is <code>scipy.special</code>, showing the gamma and erf functions:</p><pre><code><code>from scipy.special import gamma, erf
import numpy as np

print(gamma(5))       # 24.0  (i.e. 4!)
print(erf(1.0))       # 0.8427... (the error function, used everywhere in statistics)
</code></code></pre><h2>A complete example</h2><p>Let&#8217;s bring a few things together to show how naturally SciPy fits into a real workflow. Suppose you&#8217;re analysing some experimental data where you know the underlying model should follow a decaying exponential, but your measurements are noisy.</p><pre><code><code>import numpy as np
from scipy. optimise import curve_fit
from scipy.stats import pearsonr

# --- Simulate some noisy experimental data ---
rng = np.random.default_rng(42)
t = np.linspace(0, 5, 50)
true_signal = 3.0 * np.exp(-0.8 * t)
noisy_data = true_signal + rng.normal(scale=0.2, size=len(t))

# --- Define the model we want to fit ---
def exponential_decay(t, amplitude, decay_rate):
    return amplitude * np.exp(-decay_rate * t)

# --- Fit the model to the noisy data ---
params, covariance = curve_fit(exponential_decay, t, noisy_data, p0=[1.0, 1.0])
amplitude, decay_rate = params

print(f"Fitted amplitude:   {amplitude:.4f}  (true: 3.0)")
print(f"Fitted decay rate:  {decay_rate:.4f}  (true: 0.8)")

# --- Check the quality of the fit ---
fitted_values = exponential_decay(t, *params)
r, p = pearsonr(noisy_data, fitted_values)
print(f"Pearson r:          {r:.4f}")
print(f"p-value:            {p:.2e}")
</code></code></pre><p>This outputs something like:</p><pre><code><code>Fitted amplitude:   2.9987  (true: 3.0)
Fitted decay rate:  0.8021  (true: 0.8)
Pearson r:          0.9977
p-value:            3.41e-43
</code></code></pre><p>In about 20 lines of clean, readable code, we&#8217;ve simulated an experiment, fitted a mathematical model to noisy data, and statistically validated the fit. No loops to optimise, no manual implementation of least-squares. SciPy handles everything.</p><h2>A note on performance</h2><p>You might wonder, if SciPy is written in Python, how can it be fast? The answer is that the heavy lifting isn&#8217;t written in Python at all. Under the hood, SciPy wraps highly optimised Fortran and C libraries - <strong>LAPACK</strong> and <strong>BLAS</strong> for linear algebra, <strong>FITPACK</strong> for splines, <strong>ODEPACK</strong> for differential equations, and others. The Python API is a clean and flexible interface to decades of carefully optimised numerical code.</p><p>This means you get the best of both worlds, C/Fortran performance with Python convenience. As a rule of thumb, if you find yourself writing a loop to do something mathematical in Python, there&#8217;s a good chance SciPy already has a vectorised, compiled implementation that will run orders of magnitude faster.</p><h2>Further reading</h2><ul><li><p><a href="https://docs.scipy.org/doc/scipy/">Official SciPy Documentation</a></p></li><li><p><a href="https://scipy-lectures.org/">SciPy Lecture Notes</a> - an excellent free textbook</p></li><li><p><a href="https://www.pythoninformer.com/python-libraries/numpy/">NumPy</a> - if you want to brush up on the foundations first</p></li><li><p><a href="https://github.com/scipy/scipy">SciPy GitHub Repository</a> - the source code and release notes</p></li></ul>]]></content:encoded></item><item><title><![CDATA[Why Time Slows Down When You Move Fast: The Secret Behind Einstein's Lorentz Factor]]></title><description><![CDATA[In the article Special relativity time dilation, we saw that, according to special relativity, if we stand on a train station and observe a passing train, then a clock on the train will be ticking more slowly than a clock on the station.]]></description><link>https://graphicmaths.substack.com/p/why-time-slows-down-when-you-move</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/why-time-slows-down-when-you-move</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Tue, 02 Jun 2026 15:22:22 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!EEx-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a45683a-5105-4fd0-9901-0f5ee316dcaa_1408x768.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!EEx-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a45683a-5105-4fd0-9901-0f5ee316dcaa_1408x768.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!EEx-!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a45683a-5105-4fd0-9901-0f5ee316dcaa_1408x768.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!EEx-!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a45683a-5105-4fd0-9901-0f5ee316dcaa_1408x768.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!EEx-!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a45683a-5105-4fd0-9901-0f5ee316dcaa_1408x768.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!EEx-!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a45683a-5105-4fd0-9901-0f5ee316dcaa_1408x768.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!EEx-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a45683a-5105-4fd0-9901-0f5ee316dcaa_1408x768.jpeg" width="1408" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3a45683a-5105-4fd0-9901-0f5ee316dcaa_1408x768.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1408,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:477502,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://graphicmaths.substack.com/i/200311998?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a45683a-5105-4fd0-9901-0f5ee316dcaa_1408x768.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!EEx-!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a45683a-5105-4fd0-9901-0f5ee316dcaa_1408x768.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!EEx-!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a45683a-5105-4fd0-9901-0f5ee316dcaa_1408x768.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!EEx-!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a45683a-5105-4fd0-9901-0f5ee316dcaa_1408x768.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!EEx-!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a45683a-5105-4fd0-9901-0f5ee316dcaa_1408x768.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 article <a href="https://graphicmaths.com/physics/relativity/special-relativity-lorentz-factor/physics/relativity/special-relativity-time-dilation/">Special relativity time dilation</a>, we saw that, according to special relativity, if we stand on a train station and observe a passing train, then a clock on the train will be ticking more slowly than a clock on the station. It isn&#8217;t just the clock, time itself passes more slowly on the train than on the platform. We called this effect <em>time dilation</em>.</p><p>We looked at why this happens, but we didn&#8217;t calculate exactly how slowly time passes. In this article, we will derive that calculation and see that it has some interesting properties.</p><h2>Time dilation recap</h2><p>In the previous article, we considered a <em>light clock</em> on a moving train. A light clock is an imaginary device consisting of two mirrors, with a pulse of light bouncing back and forth between them. We can&#8217;t build a light clock, for various practical reasons, but we can imagine one and think about how it would behave.</p><p>Here is a light clock, from the point of view of Bob, who is on the train. The pulse of light starts at the bottom mirror (the blue dot) and travels up to the top mirror. It is then reflected back and arrives at the bottom mirror (the red dot):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!LXBB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87f289ff-34af-4fbe-8d67-b768ee19e9b7_200x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!LXBB!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87f289ff-34af-4fbe-8d67-b768ee19e9b7_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!LXBB!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87f289ff-34af-4fbe-8d67-b768ee19e9b7_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!LXBB!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87f289ff-34af-4fbe-8d67-b768ee19e9b7_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!LXBB!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87f289ff-34af-4fbe-8d67-b768ee19e9b7_200x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!LXBB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87f289ff-34af-4fbe-8d67-b768ee19e9b7_200x500.png" width="200" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/87f289ff-34af-4fbe-8d67-b768ee19e9b7_200x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Light clock&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&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="Light clock" title="Light clock" srcset="/__u/substackcdn.com/image/fetch/$s_!LXBB!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87f289ff-34af-4fbe-8d67-b768ee19e9b7_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!LXBB!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87f289ff-34af-4fbe-8d67-b768ee19e9b7_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!LXBB!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87f289ff-34af-4fbe-8d67-b768ee19e9b7_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!LXBB!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87f289ff-34af-4fbe-8d67-b768ee19e9b7_200x500.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 aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 diagram shows the two paths side by side, for clarity. But in fact, for the light clock to work, the mirrors would have to be very well aligned so that the upward and downward paths are the same. Assuming perfect alignment and perfect mirrors, the light pulse would bounce up and down, again and again, forever.</p><p>The distance between the mirrors is <em>d</em>. We know that light travels at a constant velocity <em>c</em>, so the time it takes to travel from the bottom mirror to the top is <em>d/c</em>.</p><p>Now let&#8217;s look at the same clock from the point of view of Alice, who is standing on the train station platform. The train is passing through the station with a constant velocity <em>v</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!6V-O!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9d86615-c3e0-4874-99e5-6312ba71c3af_800x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!6V-O!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9d86615-c3e0-4874-99e5-6312ba71c3af_800x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!6V-O!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9d86615-c3e0-4874-99e5-6312ba71c3af_800x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!6V-O!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9d86615-c3e0-4874-99e5-6312ba71c3af_800x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!6V-O!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9d86615-c3e0-4874-99e5-6312ba71c3af_800x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!6V-O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9d86615-c3e0-4874-99e5-6312ba71c3af_800x500.png" width="800" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f9d86615-c3e0-4874-99e5-6312ba71c3af_800x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Light clock&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="Light clock" title="Light clock" srcset="/__u/substackcdn.com/image/fetch/$s_!6V-O!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9d86615-c3e0-4874-99e5-6312ba71c3af_800x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!6V-O!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9d86615-c3e0-4874-99e5-6312ba71c3af_800x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!6V-O!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9d86615-c3e0-4874-99e5-6312ba71c3af_800x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!6V-O!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9d86615-c3e0-4874-99e5-6312ba71c3af_800x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 clock does the same thing for both observers. The light travels from the bottom mirror to the top mirror, then back to the bottom mirror. But for Alice, while the light is travelling from the bottom mirror to the top mirror, the train will have moved along. So from Alice&#8217;s point of view, the light travels diagonally from the original position of the bottom mirror to the new position of the top mirror.</p><p>The light reflects back to the bottom mirror, but by the time it reaches it, the train will have moved on, so the light will again take a diagonal path.</p><p>From Alice&#8217;s point of view, the light travels a distance <em>e</em> to get from the bottom mirror to the top mirror. Since light travels at speed <em>c</em> in all inertial frames of reference, the time taken is <em>e/c</em></p><p>So Alice and Bob will both see the same thing, the light travelling from the bottom to the top and back again. But distance <em>e</em> is clearly greater than distance <em>d</em>, so for Alice it will take longer than for Bob. The only consistent explanation for this is that, from Alice&#8217;s point of view, time is travelling more slowly for Bob.</p><p>And, as mentioned in the <a href="https://graphicmaths.com/physics/relativity/special-relativity-lorentz-factor/physics/relativity/special-relativity-time-dilation/">earlier article</a>, we now have a wealth of real-world data to prove that this really does happen.</p><h2>How much slower does time pass?</h2><p>So, for Bob, the light going from the bottom to the top takes <em>d/c</em>. We call this the <em>proper time</em>, <em>t<sub>0</sub></em> because Bob is in the same frame of reference as the clock (they are both on the train, so the clock is at rest for Bob). So:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!GAqs!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54bfff52-1877-41d0-a7d4-39429c76b249_451x114.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!GAqs!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54bfff52-1877-41d0-a7d4-39429c76b249_451x114.png 424w, /__u/substackcdn.com/image/fetch/$s_!GAqs!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54bfff52-1877-41d0-a7d4-39429c76b249_451x114.png 848w, /__u/substackcdn.com/image/fetch/$s_!GAqs!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54bfff52-1877-41d0-a7d4-39429c76b249_451x114.png 1272w, /__u/substackcdn.com/image/fetch/$s_!GAqs!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54bfff52-1877-41d0-a7d4-39429c76b249_451x114.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!GAqs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54bfff52-1877-41d0-a7d4-39429c76b249_451x114.png" width="451" height="114" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/54bfff52-1877-41d0-a7d4-39429c76b249_451x114.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:114,&quot;width&quot;:451,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Time dilation&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="Time dilation" title="Time dilation" srcset="/__u/substackcdn.com/image/fetch/$s_!GAqs!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54bfff52-1877-41d0-a7d4-39429c76b249_451x114.png 424w, /__u/substackcdn.com/image/fetch/$s_!GAqs!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54bfff52-1877-41d0-a7d4-39429c76b249_451x114.png 848w, /__u/substackcdn.com/image/fetch/$s_!GAqs!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54bfff52-1877-41d0-a7d4-39429c76b249_451x114.png 1272w, /__u/substackcdn.com/image/fetch/$s_!GAqs!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54bfff52-1877-41d0-a7d4-39429c76b249_451x114.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>For Alice, the light has to travel a greater distance, <em>e</em>. The time. which we will call <em>t<sub>1</sub></em>, is given by:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!HHIY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca29cf24-c372-4381-bd80-01736340b332_446x107.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!HHIY!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca29cf24-c372-4381-bd80-01736340b332_446x107.png 424w, /__u/substackcdn.com/image/fetch/$s_!HHIY!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca29cf24-c372-4381-bd80-01736340b332_446x107.png 848w, /__u/substackcdn.com/image/fetch/$s_!HHIY!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca29cf24-c372-4381-bd80-01736340b332_446x107.png 1272w, /__u/substackcdn.com/image/fetch/$s_!HHIY!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca29cf24-c372-4381-bd80-01736340b332_446x107.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!HHIY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca29cf24-c372-4381-bd80-01736340b332_446x107.png" width="446" height="107" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ca29cf24-c372-4381-bd80-01736340b332_446x107.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:107,&quot;width&quot;:446,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Time dilation&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="Time dilation" title="Time dilation" srcset="/__u/substackcdn.com/image/fetch/$s_!HHIY!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca29cf24-c372-4381-bd80-01736340b332_446x107.png 424w, /__u/substackcdn.com/image/fetch/$s_!HHIY!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca29cf24-c372-4381-bd80-01736340b332_446x107.png 848w, /__u/substackcdn.com/image/fetch/$s_!HHIY!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca29cf24-c372-4381-bd80-01736340b332_446x107.png 1272w, /__u/substackcdn.com/image/fetch/$s_!HHIY!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca29cf24-c372-4381-bd80-01736340b332_446x107.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We can see that these two terms are different, because <em>d</em> and <em>e</em> are different. But how do the two terms relate to each other? Well, if we look again at the situation from Alice&#8217;s frame of reference, we can draw a right triangle like this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!xNI2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb31130f7-ea6b-431c-a6cc-4d51d80741ad_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!xNI2!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb31130f7-ea6b-431c-a6cc-4d51d80741ad_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!xNI2!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb31130f7-ea6b-431c-a6cc-4d51d80741ad_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!xNI2!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb31130f7-ea6b-431c-a6cc-4d51d80741ad_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xNI2!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb31130f7-ea6b-431c-a6cc-4d51d80741ad_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!xNI2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb31130f7-ea6b-431c-a6cc-4d51d80741ad_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b31130f7-ea6b-431c-a6cc-4d51d80741ad_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Light clock&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="Light clock" title="Light clock" srcset="/__u/substackcdn.com/image/fetch/$s_!xNI2!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb31130f7-ea6b-431c-a6cc-4d51d80741ad_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!xNI2!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb31130f7-ea6b-431c-a6cc-4d51d80741ad_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!xNI2!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb31130f7-ea6b-431c-a6cc-4d51d80741ad_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xNI2!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb31130f7-ea6b-431c-a6cc-4d51d80741ad_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 have just derived expressions for <em>d</em> and <em>e</em>, but what about <em>x</em>? In Alice&#8217;s frame of reference, the train is travelling at velocity <em>v</em>. The length <em>x</em> is the distance that the train travels in the time it takes for light to travel from the bottom mirror to the top mirror. We have already seen that, for Alice, that time is <em>t<sub>1</sub></em>. So the distance <em>x</em> is simply that time multiplied by the speed of the train, <em>v</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!KFqp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1e0a89-c77e-49a0-a120-f3a07ca5ac82_147x73.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!KFqp!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1e0a89-c77e-49a0-a120-f3a07ca5ac82_147x73.png 424w, /__u/substackcdn.com/image/fetch/$s_!KFqp!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1e0a89-c77e-49a0-a120-f3a07ca5ac82_147x73.png 848w, /__u/substackcdn.com/image/fetch/$s_!KFqp!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1e0a89-c77e-49a0-a120-f3a07ca5ac82_147x73.png 1272w, /__u/substackcdn.com/image/fetch/$s_!KFqp!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1e0a89-c77e-49a0-a120-f3a07ca5ac82_147x73.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!KFqp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1e0a89-c77e-49a0-a120-f3a07ca5ac82_147x73.png" width="147" height="73" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ec1e0a89-c77e-49a0-a120-f3a07ca5ac82_147x73.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:73,&quot;width&quot;:147,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Time dilation&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="Time dilation" title="Time dilation" srcset="/__u/substackcdn.com/image/fetch/$s_!KFqp!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1e0a89-c77e-49a0-a120-f3a07ca5ac82_147x73.png 424w, /__u/substackcdn.com/image/fetch/$s_!KFqp!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1e0a89-c77e-49a0-a120-f3a07ca5ac82_147x73.png 848w, /__u/substackcdn.com/image/fetch/$s_!KFqp!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1e0a89-c77e-49a0-a120-f3a07ca5ac82_147x73.png 1272w, /__u/substackcdn.com/image/fetch/$s_!KFqp!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1e0a89-c77e-49a0-a120-f3a07ca5ac82_147x73.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>So we now know the three lengths of a right-angled triangle. This one of the most unexpected and important equations in physics, but it can be solved using Pythagoras! Here goes:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!ObEx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e568fdf-21e2-4124-8caa-67cac7e2b81b_220x80.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!ObEx!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e568fdf-21e2-4124-8caa-67cac7e2b81b_220x80.png 424w, /__u/substackcdn.com/image/fetch/$s_!ObEx!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e568fdf-21e2-4124-8caa-67cac7e2b81b_220x80.png 848w, /__u/substackcdn.com/image/fetch/$s_!ObEx!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e568fdf-21e2-4124-8caa-67cac7e2b81b_220x80.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ObEx!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e568fdf-21e2-4124-8caa-67cac7e2b81b_220x80.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!ObEx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e568fdf-21e2-4124-8caa-67cac7e2b81b_220x80.png" width="220" height="80" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0e568fdf-21e2-4124-8caa-67cac7e2b81b_220x80.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:80,&quot;width&quot;:220,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Time dilation&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="Time dilation" title="Time dilation" srcset="/__u/substackcdn.com/image/fetch/$s_!ObEx!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e568fdf-21e2-4124-8caa-67cac7e2b81b_220x80.png 424w, /__u/substackcdn.com/image/fetch/$s_!ObEx!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e568fdf-21e2-4124-8caa-67cac7e2b81b_220x80.png 848w, /__u/substackcdn.com/image/fetch/$s_!ObEx!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e568fdf-21e2-4124-8caa-67cac7e2b81b_220x80.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ObEx!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e568fdf-21e2-4124-8caa-67cac7e2b81b_220x80.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Now we can substitute our known values for <em>d</em>, <em>e</em> and <em>x</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!EkgD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a0a72df-90dd-4e87-8d8b-f6cac781b914_290x85.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!EkgD!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a0a72df-90dd-4e87-8d8b-f6cac781b914_290x85.png 424w, /__u/substackcdn.com/image/fetch/$s_!EkgD!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a0a72df-90dd-4e87-8d8b-f6cac781b914_290x85.png 848w, /__u/substackcdn.com/image/fetch/$s_!EkgD!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a0a72df-90dd-4e87-8d8b-f6cac781b914_290x85.png 1272w, /__u/substackcdn.com/image/fetch/$s_!EkgD!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a0a72df-90dd-4e87-8d8b-f6cac781b914_290x85.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!EkgD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a0a72df-90dd-4e87-8d8b-f6cac781b914_290x85.png" width="290" height="85" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4a0a72df-90dd-4e87-8d8b-f6cac781b914_290x85.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:85,&quot;width&quot;:290,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Time dilation&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="Time dilation" title="Time dilation" srcset="/__u/substackcdn.com/image/fetch/$s_!EkgD!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a0a72df-90dd-4e87-8d8b-f6cac781b914_290x85.png 424w, /__u/substackcdn.com/image/fetch/$s_!EkgD!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a0a72df-90dd-4e87-8d8b-f6cac781b914_290x85.png 848w, /__u/substackcdn.com/image/fetch/$s_!EkgD!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a0a72df-90dd-4e87-8d8b-f6cac781b914_290x85.png 1272w, /__u/substackcdn.com/image/fetch/$s_!EkgD!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a0a72df-90dd-4e87-8d8b-f6cac781b914_290x85.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Since we are interested in the relationship between the two times, it will be useful to rearrange the equation so that the <em>t<sub>1</sub></em> terms are on the left and <em>t<sub>0</sub></em> terms are on the right:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!ycik!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F839b1646-96ea-49e6-a44d-19e864c62fea_291x85.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!ycik!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F839b1646-96ea-49e6-a44d-19e864c62fea_291x85.png 424w, /__u/substackcdn.com/image/fetch/$s_!ycik!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F839b1646-96ea-49e6-a44d-19e864c62fea_291x85.png 848w, /__u/substackcdn.com/image/fetch/$s_!ycik!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F839b1646-96ea-49e6-a44d-19e864c62fea_291x85.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ycik!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F839b1646-96ea-49e6-a44d-19e864c62fea_291x85.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!ycik!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F839b1646-96ea-49e6-a44d-19e864c62fea_291x85.png" width="291" height="85" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/839b1646-96ea-49e6-a44d-19e864c62fea_291x85.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:85,&quot;width&quot;:291,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Time dilation&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="Time dilation" title="Time dilation" srcset="/__u/substackcdn.com/image/fetch/$s_!ycik!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F839b1646-96ea-49e6-a44d-19e864c62fea_291x85.png 424w, /__u/substackcdn.com/image/fetch/$s_!ycik!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F839b1646-96ea-49e6-a44d-19e864c62fea_291x85.png 848w, /__u/substackcdn.com/image/fetch/$s_!ycik!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F839b1646-96ea-49e6-a44d-19e864c62fea_291x85.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ycik!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F839b1646-96ea-49e6-a44d-19e864c62fea_291x85.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We can divide through by <em>c</em> squared:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!M4BH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57780a0a-6fe5-46e8-899d-e2a7ba1ef725_285x127.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!M4BH!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57780a0a-6fe5-46e8-899d-e2a7ba1ef725_285x127.png 424w, /__u/substackcdn.com/image/fetch/$s_!M4BH!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57780a0a-6fe5-46e8-899d-e2a7ba1ef725_285x127.png 848w, /__u/substackcdn.com/image/fetch/$s_!M4BH!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57780a0a-6fe5-46e8-899d-e2a7ba1ef725_285x127.png 1272w, /__u/substackcdn.com/image/fetch/$s_!M4BH!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57780a0a-6fe5-46e8-899d-e2a7ba1ef725_285x127.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!M4BH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57780a0a-6fe5-46e8-899d-e2a7ba1ef725_285x127.png" width="285" height="127" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/57780a0a-6fe5-46e8-899d-e2a7ba1ef725_285x127.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:127,&quot;width&quot;:285,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Time dilation&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="Time dilation" title="Time dilation" srcset="/__u/substackcdn.com/image/fetch/$s_!M4BH!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57780a0a-6fe5-46e8-899d-e2a7ba1ef725_285x127.png 424w, /__u/substackcdn.com/image/fetch/$s_!M4BH!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57780a0a-6fe5-46e8-899d-e2a7ba1ef725_285x127.png 848w, /__u/substackcdn.com/image/fetch/$s_!M4BH!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57780a0a-6fe5-46e8-899d-e2a7ba1ef725_285x127.png 1272w, /__u/substackcdn.com/image/fetch/$s_!M4BH!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F57780a0a-6fe5-46e8-899d-e2a7ba1ef725_285x127.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Rearranging:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!R4G2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5993ca3d-45bb-4d54-9fc1-da84f7651e3a_265x128.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!R4G2!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5993ca3d-45bb-4d54-9fc1-da84f7651e3a_265x128.png 424w, /__u/substackcdn.com/image/fetch/$s_!R4G2!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5993ca3d-45bb-4d54-9fc1-da84f7651e3a_265x128.png 848w, /__u/substackcdn.com/image/fetch/$s_!R4G2!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5993ca3d-45bb-4d54-9fc1-da84f7651e3a_265x128.png 1272w, /__u/substackcdn.com/image/fetch/$s_!R4G2!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5993ca3d-45bb-4d54-9fc1-da84f7651e3a_265x128.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!R4G2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5993ca3d-45bb-4d54-9fc1-da84f7651e3a_265x128.png" width="265" height="128" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5993ca3d-45bb-4d54-9fc1-da84f7651e3a_265x128.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:128,&quot;width&quot;:265,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Time dilation&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="Time dilation" title="Time dilation" srcset="/__u/substackcdn.com/image/fetch/$s_!R4G2!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5993ca3d-45bb-4d54-9fc1-da84f7651e3a_265x128.png 424w, /__u/substackcdn.com/image/fetch/$s_!R4G2!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5993ca3d-45bb-4d54-9fc1-da84f7651e3a_265x128.png 848w, /__u/substackcdn.com/image/fetch/$s_!R4G2!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5993ca3d-45bb-4d54-9fc1-da84f7651e3a_265x128.png 1272w, /__u/substackcdn.com/image/fetch/$s_!R4G2!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5993ca3d-45bb-4d54-9fc1-da84f7651e3a_265x128.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Now we can find the ratio of squares of <em>t<sub>1</sub></em> and <em>t<sub>0</sub></em>:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!awQn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574013db-9e4a-4a19-ab94-50160a10e218_242x134.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!awQn!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574013db-9e4a-4a19-ab94-50160a10e218_242x134.png 424w, /__u/substackcdn.com/image/fetch/$s_!awQn!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574013db-9e4a-4a19-ab94-50160a10e218_242x134.png 848w, /__u/substackcdn.com/image/fetch/$s_!awQn!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574013db-9e4a-4a19-ab94-50160a10e218_242x134.png 1272w, /__u/substackcdn.com/image/fetch/$s_!awQn!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574013db-9e4a-4a19-ab94-50160a10e218_242x134.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!awQn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574013db-9e4a-4a19-ab94-50160a10e218_242x134.png" width="242" height="134" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/574013db-9e4a-4a19-ab94-50160a10e218_242x134.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:134,&quot;width&quot;:242,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Time dilation&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="Time dilation" title="Time dilation" srcset="/__u/substackcdn.com/image/fetch/$s_!awQn!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574013db-9e4a-4a19-ab94-50160a10e218_242x134.png 424w, /__u/substackcdn.com/image/fetch/$s_!awQn!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574013db-9e4a-4a19-ab94-50160a10e218_242x134.png 848w, /__u/substackcdn.com/image/fetch/$s_!awQn!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574013db-9e4a-4a19-ab94-50160a10e218_242x134.png 1272w, /__u/substackcdn.com/image/fetch/$s_!awQn!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574013db-9e4a-4a19-ab94-50160a10e218_242x134.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Taking the square root of both sides gives the final result:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!_kQ9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd5df926-fcbb-477a-ac18-079683abbe9e_246x147.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!_kQ9!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd5df926-fcbb-477a-ac18-079683abbe9e_246x147.png 424w, /__u/substackcdn.com/image/fetch/$s_!_kQ9!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd5df926-fcbb-477a-ac18-079683abbe9e_246x147.png 848w, /__u/substackcdn.com/image/fetch/$s_!_kQ9!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd5df926-fcbb-477a-ac18-079683abbe9e_246x147.png 1272w, /__u/substackcdn.com/image/fetch/$s_!_kQ9!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd5df926-fcbb-477a-ac18-079683abbe9e_246x147.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!_kQ9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd5df926-fcbb-477a-ac18-079683abbe9e_246x147.png" width="246" height="147" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cd5df926-fcbb-477a-ac18-079683abbe9e_246x147.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:147,&quot;width&quot;:246,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Time dilation&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="Time dilation" title="Time dilation" srcset="/__u/substackcdn.com/image/fetch/$s_!_kQ9!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd5df926-fcbb-477a-ac18-079683abbe9e_246x147.png 424w, /__u/substackcdn.com/image/fetch/$s_!_kQ9!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd5df926-fcbb-477a-ac18-079683abbe9e_246x147.png 848w, /__u/substackcdn.com/image/fetch/$s_!_kQ9!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd5df926-fcbb-477a-ac18-079683abbe9e_246x147.png 1272w, /__u/substackcdn.com/image/fetch/$s_!_kQ9!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd5df926-fcbb-477a-ac18-079683abbe9e_246x147.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Recall from earlier exactly what this means. From Alice&#8217;s point of view, time passes more slowly for Bob. Bob&#8217;s time is <em>dilated</em> from Alice&#8217;s perspective; the time taken for light to travel a distance <em>d</em> in Bob&#8217;s frame appears to be longer than Alice would expect. The effect is a constant multiplier that depends only on the train&#8217;s velocity (and the speed of light, which we know is constant).</p><p>We call this multiplier the <em>Lorentz factor</em>, often represented by the Greek letter gamma (&#947;):</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!RF_m!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd175b20-bc2f-486b-bf6b-8d6fbd4db74c_235x147.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!RF_m!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd175b20-bc2f-486b-bf6b-8d6fbd4db74c_235x147.png 424w, /__u/substackcdn.com/image/fetch/$s_!RF_m!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd175b20-bc2f-486b-bf6b-8d6fbd4db74c_235x147.png 848w, /__u/substackcdn.com/image/fetch/$s_!RF_m!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd175b20-bc2f-486b-bf6b-8d6fbd4db74c_235x147.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RF_m!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd175b20-bc2f-486b-bf6b-8d6fbd4db74c_235x147.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!RF_m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd175b20-bc2f-486b-bf6b-8d6fbd4db74c_235x147.png" width="235" height="147" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cd175b20-bc2f-486b-bf6b-8d6fbd4db74c_235x147.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:147,&quot;width&quot;:235,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Time dilation&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="Time dilation" title="Time dilation" srcset="/__u/substackcdn.com/image/fetch/$s_!RF_m!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd175b20-bc2f-486b-bf6b-8d6fbd4db74c_235x147.png 424w, /__u/substackcdn.com/image/fetch/$s_!RF_m!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd175b20-bc2f-486b-bf6b-8d6fbd4db74c_235x147.png 848w, /__u/substackcdn.com/image/fetch/$s_!RF_m!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd175b20-bc2f-486b-bf6b-8d6fbd4db74c_235x147.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RF_m!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd175b20-bc2f-486b-bf6b-8d6fbd4db74c_235x147.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h2>Properties of Lorentz factor</h2><p>Several interesting features of the Lorentz factor are clear just by looking at it, but they have profound implications for the physical world.</p><p>The first is that the velocity <em>v</em> is divided by the speed of light <em>c</em>. Since <em>c</em> is a very large number, then <em>v/c</em> tends to be very small for everyday objects travelling at ordinary speeds. So the Lorentz factor is usually very close to 1.</p><p>For example, a train travelling at 100 mph (about 44 m/s) has a Lorentz factor of about 1.00000000000001. Time dilation occurs, but its effect is not noticeable or even detectable in most situations. That is why the concept seems counterintuitive to most people - it is something that we never notice in normal life.</p><p>The equation only relies on the velocity squared, which means that time dilation only depends on the magnitude of the velocity, not its direction. It doesn&#8217;t matter if the train is passing from left to right or from right to left, the time dilation will be the same. Equally, if instead of a train we used an elevator going up or down at the same speed, we would see the same time dilation.</p><p>A related observation is that time can be dilated but never contracted. The denominator is the square root of an expression that is always &#8804;1, which means that the Lorentz factor is always &#8805;1. So the clock on the moving train always ticks slowly, from the point of view of an observer on the platform.</p><p>Now let&#8217;s consider what happens when <em>v</em> gets bigger. In the graph below, the x-axis represents <em>v/c</em>. So, for example, 0.5 on the x-axis represents the train travelling at half the speed of light. The y-axis shows the Lorentz factor:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!5i0r!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f1bc7a5-c367-4df7-8174-7e2d84ba6dbc_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!5i0r!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f1bc7a5-c367-4df7-8174-7e2d84ba6dbc_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!5i0r!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f1bc7a5-c367-4df7-8174-7e2d84ba6dbc_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!5i0r!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f1bc7a5-c367-4df7-8174-7e2d84ba6dbc_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!5i0r!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f1bc7a5-c367-4df7-8174-7e2d84ba6dbc_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!5i0r!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f1bc7a5-c367-4df7-8174-7e2d84ba6dbc_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2f1bc7a5-c367-4df7-8174-7e2d84ba6dbc_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Time dilation&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="Time dilation" title="Time dilation" srcset="/__u/substackcdn.com/image/fetch/$s_!5i0r!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f1bc7a5-c367-4df7-8174-7e2d84ba6dbc_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!5i0r!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f1bc7a5-c367-4df7-8174-7e2d84ba6dbc_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!5i0r!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f1bc7a5-c367-4df7-8174-7e2d84ba6dbc_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!5i0r!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f1bc7a5-c367-4df7-8174-7e2d84ba6dbc_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 leftmost red dot (at <em>x</em> = 0.2) represents the train travelling at one-fifth of the speed of light. Even at that immense speed, the Lorentz factor is only just above 1, so there is only a small amount of time dilation happening.</p><p>When <em>x</em> is 0.5 (the train travelling at half the speed of light), there is slightly more time dilation.</p><p>When <em>x</em> is around 0.866, the Lorentz factor is 2, which means the clock on the train is ticking at half the speed of Alice&#8217;s clock. When x is around 0.943, the Lorentz factor is 3. So time dilation is quite negligible, even at half the speed of light, but increases rapidly as we approach the speed of light. If the train were to actually reach the speed of light, Alice&#8217;s clock would be ticking infinitely faster than the clock on the train.</p><p>But that isn&#8217;t possible because of another effect of relativity. We won&#8217;t cover this here in detail, but the effective mass of an object also increases in line with the Lorentz factor. In other words, as an object approaches the speed of light, its mass tends to infinity. So no object can ever reach the speed of light, because that would require an infinite amount of energy.</p><p>But what about light itself? According to quantum theory, light is composed of photons, which are massless particles. Photons travel at the speed of light, but since they have zero rest mass, this does not require them to have infinite energy. But for photons, time dilation is infinite, which means that a photon doesn&#8217;t experience time at all, even if it spends billions of years traversing the universe.</p>]]></content:encoded></item><item><title><![CDATA[Why Does the Elevator Always Seem to Be Going the Wrong Way? The Maths Behind Your Daily Frustration]]></title><description><![CDATA[Two physicists, Marvin Stern and George Gamow, worked in the same building, a large multi-storey building, with a single elevator serving all the floors.]]></description><link>https://graphicmaths.substack.com/p/why-does-the-elevator-always-seem</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/why-does-the-elevator-always-seem</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Thu, 21 May 2026 13:07:48 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!myXH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a8699bb-38cb-4040-8fac-3965fd9ebb2d_896x782.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!myXH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a8699bb-38cb-4040-8fac-3965fd9ebb2d_896x782.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!myXH!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a8699bb-38cb-4040-8fac-3965fd9ebb2d_896x782.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!myXH!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a8699bb-38cb-4040-8fac-3965fd9ebb2d_896x782.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!myXH!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a8699bb-38cb-4040-8fac-3965fd9ebb2d_896x782.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!myXH!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a8699bb-38cb-4040-8fac-3965fd9ebb2d_896x782.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!myXH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a8699bb-38cb-4040-8fac-3965fd9ebb2d_896x782.jpeg" width="896" height="782" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0a8699bb-38cb-4040-8fac-3965fd9ebb2d_896x782.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:782,&quot;width&quot;:896,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:240899,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://graphicmaths.substack.com/i/198701453?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a8699bb-38cb-4040-8fac-3965fd9ebb2d_896x782.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!myXH!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a8699bb-38cb-4040-8fac-3965fd9ebb2d_896x782.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!myXH!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a8699bb-38cb-4040-8fac-3965fd9ebb2d_896x782.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!myXH!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a8699bb-38cb-4040-8fac-3965fd9ebb2d_896x782.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!myXH!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a8699bb-38cb-4040-8fac-3965fd9ebb2d_896x782.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Two physicists, Marvin Stern and George Gamow, worked in the same building, a large multi-storey building, with a single elevator serving all the floors.</p><p>Both men had noticed a slightly odd phenomenon. Whenever they wanted to use the elevator, it seemed that it was usually going in the wrong direction. If they wanted to go down, when the elevator arrived, it was usually going up. When they wanted to go up, the elevator was usually going down. They had both noticed this effect independently. But it was only when it came up in conversation that they realised it might be a real effect worthy of investigation. This phenomenon became known as the <em>elevator paradox</em>, which they highlighted in 1958.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/subscribe"><span>Subscribe now</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/p/why-does-the-elevator-always-seem?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/p/why-does-the-elevator-always-seem?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share</span></a></p><p style="text-align: center;"><em>My book on Calculus is available from <a href="https://www.amazon.co.uk/Calculus-Martin-McBride-ebook/dp/B0DLBH5Y5M">Amazon</a>.</em></p><h2>Confirmation bias?</h2><p>Confirmation bias is an unconscious human tendency to selectively notice and remember anything that confirms your existing beliefs, whilst downplaying or ignoring anything that contradicts them.</p><p>It is easy to see how that might arise in the elevator case. If the elevator arrives and happens to be going up when you want to go down, that is quite annoying. You have to stand and wait until it goes all the way to the top and comes back down again. That sticks in your mind.</p><p>If you are late for a meeting, that extra delay is going to be really annoying, and looms even larger in your memory.</p><p>But if the elevator arrives and it happens to be going down, you get on the elevator and think no more about it. It would be very easy, after months or years, to form the opinion that the elevator is almost always going in the wrong direction.</p><p>So the physicists decided to eliminate confirmation bias. Each time they used the lift, they recorded:</p><ul><li><p>Whether the lift was going up or down when it arrived.</p></li><li><p>Whether they were intending to go up or down.</p></li></ul><p>After weeks of gathering these statistics, they discovered that the effect was real. The elevator was statistically more likely to be going in the wrong direction when it arrived. The effect was significant enough to be undeniably true.</p><h2>The apparent paradox</h2><p>This effect seems very puzzling and paradoxical, for several reasons.</p><p>The first is that if the lift arrives at, say, floor 3 and is going up, then the next time it arrives at floor 3 it must be going down, then up, then down, and so on. The lift can&#8217;t arrive at floor 3 going up, and then arrive at floor 3 going up again.</p><p>We can also say that when the lift arrives at floor 3 for the nth time in the day (where <em>n</em> is a random number), it is equally likely to be going up or down.</p><p>We assume here that the lift always travels from the lowest floor to the top floor, then back to the lowest floor, in a continuous cycle. We will also ignore the case of anyone waiting for the lift at the bottom or top floor, because the lift changes direction there, so it will always be travelling in the right direction for anyone waiting there. These are special cases.</p><p>But there is another random factor as well. For the lift to be going in the &#8220;wrong&#8221; direction depends on which direction you want to go. For example, suppose you arrive at the floor 3 lift, and the next lift is going down. If you are intending to go to a meeting on floor 5, that would be the wrong direction for you. But if you are intending to get a snack from the vending machine on floor 2, it would be the right direction for you.</p><p>So how can the direction be wrong more often than it is right?</p><h2>A simple building</h2><p>This diagram represents a simple building:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!84UT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb440a55-3e12-4130-abe0-52f3dfb69859_200x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!84UT!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb440a55-3e12-4130-abe0-52f3dfb69859_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!84UT!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb440a55-3e12-4130-abe0-52f3dfb69859_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!84UT!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb440a55-3e12-4130-abe0-52f3dfb69859_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!84UT!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb440a55-3e12-4130-abe0-52f3dfb69859_200x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!84UT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb440a55-3e12-4130-abe0-52f3dfb69859_200x500.png" width="200" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cb440a55-3e12-4130-abe0-52f3dfb69859_200x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Building&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="Building" title="Building" srcset="/__u/substackcdn.com/image/fetch/$s_!84UT!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb440a55-3e12-4130-abe0-52f3dfb69859_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!84UT!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb440a55-3e12-4130-abe0-52f3dfb69859_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!84UT!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb440a55-3e12-4130-abe0-52f3dfb69859_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!84UT!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb440a55-3e12-4130-abe0-52f3dfb69859_200x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 building has 9 floors, with floor 0 being the ground floor, and floor 8 the top floor. There is a single elevator that travels from floor 0 to floor 8. It is a simple system that goes all the way to the top, then all the way to the bottom, stopping at every floor it is requested to.</p><p>An observer is positioned on floor 6, marked as yellow. If the observer simply watches the elevator, they will see it goes up and down repeatedly. It will alternate, of course, if it is going up one time, it must be going down the next time, and vice versa. If the observer watches for a while, the number of times the elevator goes up must equal the number of times the elevator comes down, plus or minus one.</p><p>The description above is stating the obvious, of course. The point is, the elevator is no more likely to be going up than down at any point in time.</p><h2>So what is going on?</h2><p>In reality, of course, people don&#8217;t usually stand around watching the elevator going up and down. They use the elevator when they need to. In other words, they will get on the elevator whenever it arrives.</p><p>Will the elevator be going up or down? It depends on where the elevator happened to be when the observer arrived. This is shown below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Ix0b!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6410550a-83d4-4132-a747-0cc23e7afafe_200x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Ix0b!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6410550a-83d4-4132-a747-0cc23e7afafe_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!Ix0b!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6410550a-83d4-4132-a747-0cc23e7afafe_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!Ix0b!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6410550a-83d4-4132-a747-0cc23e7afafe_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Ix0b!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6410550a-83d4-4132-a747-0cc23e7afafe_200x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Ix0b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6410550a-83d4-4132-a747-0cc23e7afafe_200x500.png" width="200" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6410550a-83d4-4132-a747-0cc23e7afafe_200x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Building&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="Building" title="Building" srcset="/__u/substackcdn.com/image/fetch/$s_!Ix0b!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6410550a-83d4-4132-a747-0cc23e7afafe_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!Ix0b!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6410550a-83d4-4132-a747-0cc23e7afafe_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!Ix0b!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6410550a-83d4-4132-a747-0cc23e7afafe_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Ix0b!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6410550a-83d4-4132-a747-0cc23e7afafe_200x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 the observer arrives at the elevator, assuming again that they are on floor 6, we can see that:</p><ul><li><p>If the elevator happens to be in the blue region (floors 7, 8), then it will be travelling downwards when it arrives at floor 6.</p></li><li><p>If the elevator happens to be in the white region (floors 0 to 5), then it will be travelling upwards when it arrives at floor 6.</p></li></ul><p>We will ignore the case where the elevator is already on floor 6. In that case, the direction of travel depends on whether the elevator has come from the blue ot white regions.</p><p>Now here is the important thing. When the observer turns up at some random time, the elevator is <em>more likely</em> to be in the white region, because there are more floors in the white region than there are in the blue region. In fact, if the lift spends the same average time on each floor, it will spend three-quarters of its time in the white region.</p><p>This means the lift is three times as likely to be going up as going down.</p><p>There is a second thing to consider. Since floor 6 is higher up in the building, it seems reasonable to expect that most people on floor 6 will want to go down, because there are more floors below floor 6 than above it.</p><p>Combining those two assumptions, the lift is going in the wrong direction most of the time.</p><h2>Other floors</h2><p>Now let&#8217;s imagine our observer is on floor 2:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!AOEi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b3201b4-e738-43f3-aabc-7b21dc406e8f_200x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!AOEi!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b3201b4-e738-43f3-aabc-7b21dc406e8f_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!AOEi!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b3201b4-e738-43f3-aabc-7b21dc406e8f_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!AOEi!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b3201b4-e738-43f3-aabc-7b21dc406e8f_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!AOEi!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b3201b4-e738-43f3-aabc-7b21dc406e8f_200x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!AOEi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b3201b4-e738-43f3-aabc-7b21dc406e8f_200x500.png" width="200" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4b3201b4-e738-43f3-aabc-7b21dc406e8f_200x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Building&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="Building" title="Building" srcset="/__u/substackcdn.com/image/fetch/$s_!AOEi!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b3201b4-e738-43f3-aabc-7b21dc406e8f_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!AOEi!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b3201b4-e738-43f3-aabc-7b21dc406e8f_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!AOEi!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b3201b4-e738-43f3-aabc-7b21dc406e8f_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!AOEi!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b3201b4-e738-43f3-aabc-7b21dc406e8f_200x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 time, the situation is reversed. There are more floors above floor 2 than there are below it. So, in this case, someone arriving at the elevator would be more likely to find it going down. But since they are on a low floor, they are probably more likely to be going up. So, once again, they would find that the elevator is going in the wrong direction, more often than not.</p><p>What if the observer is on floor 4? It looks like this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!8rwf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff60135ec-83cc-4621-9914-1a11378671c7_200x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!8rwf!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff60135ec-83cc-4621-9914-1a11378671c7_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!8rwf!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff60135ec-83cc-4621-9914-1a11378671c7_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!8rwf!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff60135ec-83cc-4621-9914-1a11378671c7_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!8rwf!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff60135ec-83cc-4621-9914-1a11378671c7_200x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!8rwf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff60135ec-83cc-4621-9914-1a11378671c7_200x500.png" width="200" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f60135ec-83cc-4621-9914-1a11378671c7_200x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Building&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="Building" title="Building" srcset="/__u/substackcdn.com/image/fetch/$s_!8rwf!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff60135ec-83cc-4621-9914-1a11378671c7_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!8rwf!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff60135ec-83cc-4621-9914-1a11378671c7_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!8rwf!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff60135ec-83cc-4621-9914-1a11378671c7_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!8rwf!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff60135ec-83cc-4621-9914-1a11378671c7_200x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 time, the floor is halfway up the building, with 4 floors above and 4 below. So the next elevator could come from either direction with roughly equal probability. And since they are in the middle of the building, they might want to go up or down, with more or less equal probability.</p><p>They might, therefore, find that the elevator is going in the right direction for them approximately half the time.</p><p>But, of course, they will then be on a higher or lower floor, so their next journey is more likely to have the elevator going in the wrong direction. So they would still see the effect.</p><h2>Modern elevators</h2><p>Most modern elevators are computer-controlled, so they might use algorithms to reduce this effect. That is particularly true if there are multiple elevators in the building. The algorithm might move elevators around when they are not in use to meet anticipated demand. It might take into account the busier times of day. It might even have dedicated elevators that serve only the first few floors.</p><p>Perhaps this is the legacy of Stern and Gamow!</p>]]></content:encoded></item><item><title><![CDATA[Special relativity - how time dilation works]]></title><description><![CDATA[We saw in an earlier article that two events that occur simultaneously in one frame of reference might not occur simultaneously in another.]]></description><link>https://graphicmaths.substack.com/p/special-relativity-how-time-dilation</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/special-relativity-how-time-dilation</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Wed, 13 May 2026 11:50:23 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!3nU4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa680c0a3-2741-4d6d-9de7-3f17284ff2d1_1024x1024.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!3nU4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa680c0a3-2741-4d6d-9de7-3f17284ff2d1_1024x1024.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!3nU4!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa680c0a3-2741-4d6d-9de7-3f17284ff2d1_1024x1024.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!3nU4!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa680c0a3-2741-4d6d-9de7-3f17284ff2d1_1024x1024.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!3nU4!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa680c0a3-2741-4d6d-9de7-3f17284ff2d1_1024x1024.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!3nU4!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa680c0a3-2741-4d6d-9de7-3f17284ff2d1_1024x1024.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!3nU4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa680c0a3-2741-4d6d-9de7-3f17284ff2d1_1024x1024.jpeg" width="1024" height="1024" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a680c0a3-2741-4d6d-9de7-3f17284ff2d1_1024x1024.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:113739,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://graphicmaths.substack.com/i/197494413?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa680c0a3-2741-4d6d-9de7-3f17284ff2d1_1024x1024.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!3nU4!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa680c0a3-2741-4d6d-9de7-3f17284ff2d1_1024x1024.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!3nU4!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa680c0a3-2741-4d6d-9de7-3f17284ff2d1_1024x1024.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!3nU4!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa680c0a3-2741-4d6d-9de7-3f17284ff2d1_1024x1024.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!3nU4!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa680c0a3-2741-4d6d-9de7-3f17284ff2d1_1024x1024.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 saw in an <a href="https://graphicmaths.com/physics/relativity/special-relativity-simultaneity/">earlier article</a> that two events that occur simultaneously in one frame of reference might not occur simultaneously in another. We saw that two bolts of lightning that strike a train platform at the same time, according to an observer on the platform, would strike the platform at different times, according to an observer on a passing train. And we saw that this isn&#8217;t just that the strikes appear to have happened at different times; they actually did happen at different times.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/subscribe"><span>Subscribe now</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/p/special-relativity-how-time-dilation?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/p/special-relativity-how-time-dilation?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share</span></a></p><p style="text-align: center;"><em>My book on Calculus is available from <a href="https://www.amazon.co.uk/Calculus-Martin-McBride-ebook/dp/B0DLBH5Y5M">Amazon</a>.</em></p><p>This conclusion was the result of a thought experiment by Einstein. He assumed two postulates: that the laws of physics are the same in all inertial frames of reference, and that the speed of light is the same in all inertial frames of reference. His thought experiment told us what would happen if we assume those two postulates are true. And, in fact, the results have been experimentally verified many times in many different ways since Einstein first proposed them.</p><p>A further thought experiment proved something equally strange. Time passes at a different rate for someone on a train station platform compared to someone on the moving train! This effect is called <em>time dilation</em>. In this article, we will show how and why it happens.</p><h2>Light clocks, and thought experiments</h2><p>To illustrate time dilation, Einstein imagined a special device called a light clock, shown here:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!zOCJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4389c49a-d5e6-4de1-b908-67a18fadfa9c_250x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!zOCJ!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4389c49a-d5e6-4de1-b908-67a18fadfa9c_250x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!zOCJ!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4389c49a-d5e6-4de1-b908-67a18fadfa9c_250x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!zOCJ!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4389c49a-d5e6-4de1-b908-67a18fadfa9c_250x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!zOCJ!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4389c49a-d5e6-4de1-b908-67a18fadfa9c_250x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!zOCJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4389c49a-d5e6-4de1-b908-67a18fadfa9c_250x500.png" width="250" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4389c49a-d5e6-4de1-b908-67a18fadfa9c_250x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:250,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Light clock&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="Light clock" title="Light clock" srcset="/__u/substackcdn.com/image/fetch/$s_!zOCJ!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4389c49a-d5e6-4de1-b908-67a18fadfa9c_250x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!zOCJ!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4389c49a-d5e6-4de1-b908-67a18fadfa9c_250x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!zOCJ!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4389c49a-d5e6-4de1-b908-67a18fadfa9c_250x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!zOCJ!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4389c49a-d5e6-4de1-b908-67a18fadfa9c_250x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 consisted of two mirrors, facing each other, separated by a distance <em>d</em>. It works as follows:</p><ul><li><p>A very short &#8220;pulse&#8221; of light is created just above the lower mirror.</p></li><li><p>The light travels up towards the top mirror, and is reflected back downwards.</p></li><li><p>The light then travels down towards the bottom mirror, and is reflected back upwards.</p></li><li><p>This repeats indefinitely, with the pulse of light bouncing between the two mirrors.</p></li></ul><p>Now, suppose we have a light detector at the bottom mirror. Every time the light returns to the bottom mirror, the detector will trip. This will be like the ticking of a clock. We could even count the ticks and measure the passing of time, just like an ordinary clock.</p><p>Since the mirrors are a distance <em>d</em> apart, the light has to travel a distance of <em>2d</em> to go from the bottom to the top, then back to the bottom. Since we have postulated that light always travels at a constant speed, which we will call <em>c</em>, the time between ticks is <em>2d/c</em>.</p><p>At this point, it is worth thinking about what we mean by a thought experiment. It isn&#8217;t possible to build a working light clock, for various practical reasons. But that doesn&#8217;t matter for a thought experiment, because there is nothing in principle to say a light clock cannot exist. So we can ask, if we could build a light clock, how would it behave?</p><p>That said, since Einstein first imagined this, we have observed time dilation experimentally many times and in many different ways. There is an example at the end of this article.</p><h2>Light clock from the point of view of Bob, on the train</h2><p>In the <a href="https://graphicmaths.com/physics/relativity/special-relativity-simultaneity/">previous article</a>, we considered the case of a train passing through a station. We imagined two observers, Alice on the station platform, and Bob on the train. Both observers were scientists who understood relativity and had a wealth of scientific instruments to aid their observations. This is illustrated here:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!bwI9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22a93b70-7969-425d-a2fc-f708e35c3306_700x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!bwI9!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22a93b70-7969-425d-a2fc-f708e35c3306_700x200.png 424w, /__u/substackcdn.com/image/fetch/$s_!bwI9!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22a93b70-7969-425d-a2fc-f708e35c3306_700x200.png 848w, /__u/substackcdn.com/image/fetch/$s_!bwI9!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22a93b70-7969-425d-a2fc-f708e35c3306_700x200.png 1272w, /__u/substackcdn.com/image/fetch/$s_!bwI9!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22a93b70-7969-425d-a2fc-f708e35c3306_700x200.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!bwI9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22a93b70-7969-425d-a2fc-f708e35c3306_700x200.png" width="700" height="200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/22a93b70-7969-425d-a2fc-f708e35c3306_700x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:700,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Staion&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="Staion" title="Staion" srcset="/__u/substackcdn.com/image/fetch/$s_!bwI9!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22a93b70-7969-425d-a2fc-f708e35c3306_700x200.png 424w, /__u/substackcdn.com/image/fetch/$s_!bwI9!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22a93b70-7969-425d-a2fc-f708e35c3306_700x200.png 848w, /__u/substackcdn.com/image/fetch/$s_!bwI9!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22a93b70-7969-425d-a2fc-f708e35c3306_700x200.png 1272w, /__u/substackcdn.com/image/fetch/$s_!bwI9!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22a93b70-7969-425d-a2fc-f708e35c3306_700x200.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Here, the grey rectangle represents the station, with Alice at point <em>A</em>. The blue rectangle represents the moving train, with Bob at point <em>B</em></p><p>Let&#8217;s suppose the light clock is on the train. What would Bob see? Well, since Bob is in the same inertial frame of reference as the clock, from his point of view, the clock is at rest, so he would see the light clock ticking exactly as described above, with a time between ticks of <em>2d/c</em>. Here is the clock at the start of a cycle, when the light pulse is at the bottom mirror:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!UdNO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe66a1c6-409f-4e36-9552-8fe6bd5ed779_200x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!UdNO!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe66a1c6-409f-4e36-9552-8fe6bd5ed779_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!UdNO!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe66a1c6-409f-4e36-9552-8fe6bd5ed779_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!UdNO!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe66a1c6-409f-4e36-9552-8fe6bd5ed779_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!UdNO!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe66a1c6-409f-4e36-9552-8fe6bd5ed779_200x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!UdNO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe66a1c6-409f-4e36-9552-8fe6bd5ed779_200x500.png" width="200" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/be66a1c6-409f-4e36-9552-8fe6bd5ed779_200x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Light clock&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="Light clock" title="Light clock" srcset="/__u/substackcdn.com/image/fetch/$s_!UdNO!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe66a1c6-409f-4e36-9552-8fe6bd5ed779_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!UdNO!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe66a1c6-409f-4e36-9552-8fe6bd5ed779_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!UdNO!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe66a1c6-409f-4e36-9552-8fe6bd5ed779_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!UdNO!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe66a1c6-409f-4e36-9552-8fe6bd5ed779_200x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 is the clock when the light pulse reaches the top mirror. We will assume that the clock provides a visual indication that the pulse has reached the mirror, so Bob (and Alice) can see it. This is represented by the red circle:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!hpFu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1e0faff-7984-4f9c-88a4-353d7b44060c_200x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!hpFu!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1e0faff-7984-4f9c-88a4-353d7b44060c_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!hpFu!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1e0faff-7984-4f9c-88a4-353d7b44060c_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!hpFu!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1e0faff-7984-4f9c-88a4-353d7b44060c_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!hpFu!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1e0faff-7984-4f9c-88a4-353d7b44060c_200x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!hpFu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1e0faff-7984-4f9c-88a4-353d7b44060c_200x500.png" width="200" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f1e0faff-7984-4f9c-88a4-353d7b44060c_200x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Light clock&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="Light clock" title="Light clock" srcset="/__u/substackcdn.com/image/fetch/$s_!hpFu!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1e0faff-7984-4f9c-88a4-353d7b44060c_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!hpFu!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1e0faff-7984-4f9c-88a4-353d7b44060c_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!hpFu!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1e0faff-7984-4f9c-88a4-353d7b44060c_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!hpFu!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1e0faff-7984-4f9c-88a4-353d7b44060c_200x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 is the clock when the light pulse has returned to the bottom mirror. Again, there is a visual indication of this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!_7cT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F577c9600-a123-4e71-96a7-ccf91bf0a98d_200x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!_7cT!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F577c9600-a123-4e71-96a7-ccf91bf0a98d_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!_7cT!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F577c9600-a123-4e71-96a7-ccf91bf0a98d_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!_7cT!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F577c9600-a123-4e71-96a7-ccf91bf0a98d_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!_7cT!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F577c9600-a123-4e71-96a7-ccf91bf0a98d_200x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!_7cT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F577c9600-a123-4e71-96a7-ccf91bf0a98d_200x500.png" width="200" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/577c9600-a123-4e71-96a7-ccf91bf0a98d_200x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Light clock&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="Light clock" title="Light clock" srcset="/__u/substackcdn.com/image/fetch/$s_!_7cT!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F577c9600-a123-4e71-96a7-ccf91bf0a98d_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!_7cT!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F577c9600-a123-4e71-96a7-ccf91bf0a98d_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!_7cT!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F577c9600-a123-4e71-96a7-ccf91bf0a98d_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!_7cT!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F577c9600-a123-4e71-96a7-ccf91bf0a98d_200x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 is important to realise that Bob doesn&#8217;t need to measure the time it takes. Since we are assuming that light travels at a constant speed <em>c</em>, he can calculate the time. As we saw earlier, the time is <em>2d/c</em>.</p><h2>Light clock from the point of view of Alice, on the platform</h2><p>Now, let&#8217;s imagine what Alice sees from the platform. Here is the initial state, when the light pulse is at the bottom mirror:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!qWqT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f0aeb4a-6829-4d99-9f55-c6af55e0bde8_200x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!qWqT!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f0aeb4a-6829-4d99-9f55-c6af55e0bde8_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!qWqT!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f0aeb4a-6829-4d99-9f55-c6af55e0bde8_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!qWqT!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f0aeb4a-6829-4d99-9f55-c6af55e0bde8_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qWqT!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f0aeb4a-6829-4d99-9f55-c6af55e0bde8_200x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!qWqT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f0aeb4a-6829-4d99-9f55-c6af55e0bde8_200x500.png" width="200" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4f0aeb4a-6829-4d99-9f55-c6af55e0bde8_200x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Light clock&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="Light clock" title="Light clock" srcset="/__u/substackcdn.com/image/fetch/$s_!qWqT!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f0aeb4a-6829-4d99-9f55-c6af55e0bde8_200x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!qWqT!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f0aeb4a-6829-4d99-9f55-c6af55e0bde8_200x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!qWqT!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f0aeb4a-6829-4d99-9f55-c6af55e0bde8_200x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qWqT!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f0aeb4a-6829-4d99-9f55-c6af55e0bde8_200x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 is what she sees at the second point, when the light pulse has reached the top mirror:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!xb_C!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18c2acfd-6cd9-405b-ad45-751d9f43ee93_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!xb_C!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18c2acfd-6cd9-405b-ad45-751d9f43ee93_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!xb_C!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18c2acfd-6cd9-405b-ad45-751d9f43ee93_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!xb_C!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18c2acfd-6cd9-405b-ad45-751d9f43ee93_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xb_C!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18c2acfd-6cd9-405b-ad45-751d9f43ee93_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!xb_C!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18c2acfd-6cd9-405b-ad45-751d9f43ee93_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/18c2acfd-6cd9-405b-ad45-751d9f43ee93_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Light clock&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="Light clock" title="Light clock" srcset="/__u/substackcdn.com/image/fetch/$s_!xb_C!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18c2acfd-6cd9-405b-ad45-751d9f43ee93_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!xb_C!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18c2acfd-6cd9-405b-ad45-751d9f43ee93_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!xb_C!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18c2acfd-6cd9-405b-ad45-751d9f43ee93_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xb_C!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F18c2acfd-6cd9-405b-ad45-751d9f43ee93_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 train is moving relative to Alice, she sees the clock in a different position by the time the light reaches the top mirror. She also sees that the light is travelling at an angle relative to the clock, because it is travelling vertically in Bob&#8217;s frame of reference. Most importantly, this means that, from Alice&#8217;s point of view, the light travels a distance <em>e</em> from the bottom mirror to the top mirror.</p><p>This triangle shows the distance <em>e</em>, the height of the light clock <em>d</em>, and the distance <em>x</em> the train travelled. Since the light clock is vertical and the train is travelling horizontally, this is a right-angled triangle with <em>e</em> as the hypotenuse. So <em>e</em> must be greater than <em>d</em>, because the hypotenuse is always the longest side of a right triangle:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!8Rci!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fecc59b-dd35-440f-bf08-876acc025742_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!8Rci!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fecc59b-dd35-440f-bf08-876acc025742_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!8Rci!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fecc59b-dd35-440f-bf08-876acc025742_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!8Rci!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fecc59b-dd35-440f-bf08-876acc025742_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!8Rci!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fecc59b-dd35-440f-bf08-876acc025742_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!8Rci!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fecc59b-dd35-440f-bf08-876acc025742_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7fecc59b-dd35-440f-bf08-876acc025742_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Light clock&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="Light clock" title="Light clock" srcset="/__u/substackcdn.com/image/fetch/$s_!8Rci!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fecc59b-dd35-440f-bf08-876acc025742_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!8Rci!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fecc59b-dd35-440f-bf08-876acc025742_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!8Rci!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fecc59b-dd35-440f-bf08-876acc025742_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!8Rci!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7fecc59b-dd35-440f-bf08-876acc025742_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 reflecting off the top mirror, the light is reflected back to the bottom mirror:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!lnp7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd377686-4001-4d83-9011-736482e538f0_800x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!lnp7!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd377686-4001-4d83-9011-736482e538f0_800x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!lnp7!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd377686-4001-4d83-9011-736482e538f0_800x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!lnp7!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd377686-4001-4d83-9011-736482e538f0_800x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!lnp7!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd377686-4001-4d83-9011-736482e538f0_800x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!lnp7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd377686-4001-4d83-9011-736482e538f0_800x500.png" width="800" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dd377686-4001-4d83-9011-736482e538f0_800x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Light clock&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="Light clock" title="Light clock" srcset="/__u/substackcdn.com/image/fetch/$s_!lnp7!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd377686-4001-4d83-9011-736482e538f0_800x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!lnp7!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd377686-4001-4d83-9011-736482e538f0_800x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!lnp7!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd377686-4001-4d83-9011-736482e538f0_800x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!lnp7!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd377686-4001-4d83-9011-736482e538f0_800x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Again, the clock will have moved with the train. Since the train and the light pulse haven&#8217;t changed speed, the light will travel a distance <em>e</em>.</p><p>This means that, in Bob&#8217;s frame of reference, the time it takes for the light to travel from the bottom to the top and then back to the bottom is <em>2d/c</em>. But in Alice&#8217;s frame of reference, that same journey takes a longer time <em>2e/c</em>.</p><h2>Measuring time at different positions on the platform</h2><p>This might seem a little bit like the <a href="https://graphicmaths.com/physics/relativity/special-relativity-simultaneity/">simultaneity effect</a>, but it is actually slightly different. The previous effect relied on the fact that Alice and Bib were both viewing distant events (two lightning strikes at opposite ends of the train) from different frames of reference.</p><p>This time, Alice and Bob don&#8217;t need to measure anything. Simple logic tells them that they will each experience a different time between the two events.</p><p>However, if we wanted to, we could measure the times directly (in principle, not in practice, because this is a thought experiment). Bob is standing right next to the clock so he can time the events directly.</p><p>For Alice, it is a little more involved. We could have lots of Alices standing at different points along the platform. So for each event, we would have Bob and one of the Alices very close to the light clock. So they would be timing the same event, local to them.</p><h2>Time dilation</h2><p>To summarise what we know so far:</p><ul><li><p>Alice and Bob can observe the light clock while they are both close to it at the start of the first tick.</p></li><li><p>Alice and Bob can observe the light clock again, while they are close to it, at the end of the first tick.</p></li><li><p>Between those two events, a time of <em>2d/c</em> will have passed for Bob. But a longer time of <em>2e/c</em> will have passed for Alice.</p></li></ul><p>If we observed a second tick, then a total time of <em>4d/c</em> will have passed for Bob. But a longer time of <em>4e/c</em> will have passed for Alice. The time difference will increase over time.</p><p>The only reasonable explanation is that, from Alice&#8217;s point of view, time passes more slowly for Bob simply because he is moving.</p><p>Of course, Bob doesn&#8217;t experience time passing more slowly. For him, the light travels a distance of <em>2d</em> in a time of <em>2cd</em>, exactly as he would expect.</p><p>And this only happens because light travels at the same speed in every frame of reference.</p><h2>A light clock on the platform</h2><p>Now imagine there was a light clock on the platform. In that case, Alice would see the clock ticking every <em>2d/c</em> seconds. But Bob (or in this case the multiple Bobs on the train) would see the clock on the platform ticking more slowly, every <em>2c/s</em> seconds.</p><p>This might seem like a contradiction. How can time be passing more slowly for Bob and for Alice? Well, of course it isn&#8217;t, time passes at the normal rate for both of them. But each of them sees the moving clock ticking more slowly.</p><h2>A real-life example of time dilation</h2><p>The Frisch&#8211;Smith experiment is a famous 1962 experiment that confirms time dilation. It has been repeated many times since then.</p><p>Cosmic rays are high-speed particles (mainly protons and helium nuclei) that arrive in the outer atmosphere from space. Those particles collide with atoms in the atmosphere, and, due to their high kinetic energy, smash the atoms into subatomic particles, which are emitted at very high velocities, often approaching the speed of light.</p><p>Of particular interest are <em>muons</em>. A muon is a type of <em>lepton</em>, similar in some ways to an electron, which is another type of lepton. But a key thing about muons is that they are unstable, with a mean lifetime of just 2.2 microseconds. They are created in the upper atmosphere by cosmic rays, but most of them decay within a few microseconds. When they decay, they create an electron and a neutrino.</p><p>The Frisch&#8211;Smith experiment detected muons at the top of a mountain, about 2,000 km above sea level. They had equipment designed to count muons travelling at around 99.9% the speed of light. They then used the same technique to count the number of muons arriving at sea level. Based on the time it would take for a muon to travel 2 km at 99.5% of the speed of light, they expected most of the muons to have decayed before they reached sea level.</p><p>But in fact, they found far more muons than expected arriving at ground level. More than 10 times as many. The discrepancy closely matched what you would expect due to relativistic time dilation. Since then, many other experiments have confirmed the same thing.</p><p>Time dilation is real. And Einstein discovered it by sitting and thinking.</p>]]></content:encoded></item><item><title><![CDATA[Relativity and simultaneity - Einstein's clever thought experiment]]></title><description><![CDATA[People have tried to measure the speed of light for centuries, dating back to Galileo or earlier.]]></description><link>https://graphicmaths.substack.com/p/relativity-and-simultaneity-einsteins</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/relativity-and-simultaneity-einsteins</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Tue, 28 Apr 2026 13:41:18 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Re8v!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F096c4eeb-6dcf-4f2a-900b-5b0a9346f674_700x800.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>People have tried to measure the <a href="https://graphicmaths.com/physics/relativity/speed-of-light/">speed of light</a> for centuries, dating back to Galileo or earlier. In the late 19th century, a few theoretical and practical results improved the accuracy of earlier experiments and revealed a strange fact about light.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/p/relativity-and-simultaneity-einsteins?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/p/relativity-and-simultaneity-einsteins?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/subscribe"><span>Subscribe now</span></a></p><p><em>If you are interested in Calculus, my book is now available from <a href="https://martinmcbride.gumroad.com/l/calculus-book">Gumroad</a>.</em></p><h2>Maxwell, Michelson and Morley</h2><p>Maxwell&#8217;s equations describe how electromagnetic fields behave. They show that waves can travel through the field. The theoretical speed of these waves could be calculated, and it was very close to the speed of light. Maxwell guessed that light might be an electromagnetic wave.</p><p>What was even more interesting was that, according to Maxwell&#8217;s equations, the speed of light appeared to be constant regardless of the speed of the observer.</p><p>Michelson and Morley later did an experiment to check this. They measured light&#8217;s speed in two perpendicular directions. The Earth moves around the Sun at over 100,000 km/h. You might expect a small difference in measured speed due to Earth&#8217;s motion in one direction. No difference was found. This suggested that the speed of light does not depend on the observer&#8217;s motion.</p><h2>Einstein&#8217;s thought experiment</h2><p>This strange result was largely ignored until the early 20th century, when Einstein decided to take a closer look. But he didn&#8217;t perform any experiment.</p><p>He simply took two postulates:</p><ul><li><p>The laws of physics are the same in all inertial frames. An inertial frame does not accelerate or change direction.</p></li><li><p>The speed of light in a vacuum is constant for all observers, regardless of their motion or the source&#8217;s motion.</p></li></ul><p>He then asked the question, given that these things are both true, what would you expect to happen?</p><h2>Einstein&#8217;s train</h2><p>Einstein imagined an observer, Alice, standing on a railway station. He pictured a train carriage passing by at high speed. A second observer, Bob, would stand at the exact centre of the train. The diagram below shows a top view, with the train in blue, Alice (A) on the platform, and Bob (B) on the train:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Knuq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3838240-c2bf-4488-91b8-0d5d433bfc00_700x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Knuq!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3838240-c2bf-4488-91b8-0d5d433bfc00_700x200.png 424w, /__u/substackcdn.com/image/fetch/$s_!Knuq!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3838240-c2bf-4488-91b8-0d5d433bfc00_700x200.png 848w, /__u/substackcdn.com/image/fetch/$s_!Knuq!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3838240-c2bf-4488-91b8-0d5d433bfc00_700x200.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Knuq!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3838240-c2bf-4488-91b8-0d5d433bfc00_700x200.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Knuq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3838240-c2bf-4488-91b8-0d5d433bfc00_700x200.png" width="700" height="200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b3838240-c2bf-4488-91b8-0d5d433bfc00_700x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:700,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;train&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="train" title="train" srcset="/__u/substackcdn.com/image/fetch/$s_!Knuq!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3838240-c2bf-4488-91b8-0d5d433bfc00_700x200.png 424w, /__u/substackcdn.com/image/fetch/$s_!Knuq!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3838240-c2bf-4488-91b8-0d5d433bfc00_700x200.png 848w, /__u/substackcdn.com/image/fetch/$s_!Knuq!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3838240-c2bf-4488-91b8-0d5d433bfc00_700x200.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Knuq!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3838240-c2bf-4488-91b8-0d5d433bfc00_700x200.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Now let&#8217;s imagine that, at the precise moment that Alice and Bob are exactly opposite each other, two bolts of lightning strike the platform at opposite ends of the train. These are shown below by the yellow and orange dots (we use the colours to distinguish the two strikes on the diagram, not to suggest that the lightning itself is that colour):</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!U8H8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ebc30ed-d9fc-4e62-b80a-1d5805660823_700x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!U8H8!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ebc30ed-d9fc-4e62-b80a-1d5805660823_700x200.png 424w, /__u/substackcdn.com/image/fetch/$s_!U8H8!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ebc30ed-d9fc-4e62-b80a-1d5805660823_700x200.png 848w, /__u/substackcdn.com/image/fetch/$s_!U8H8!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ebc30ed-d9fc-4e62-b80a-1d5805660823_700x200.png 1272w, /__u/substackcdn.com/image/fetch/$s_!U8H8!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ebc30ed-d9fc-4e62-b80a-1d5805660823_700x200.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!U8H8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ebc30ed-d9fc-4e62-b80a-1d5805660823_700x200.png" width="700" height="200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7ebc30ed-d9fc-4e62-b80a-1d5805660823_700x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:700,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;flash&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="flash" title="flash" srcset="/__u/substackcdn.com/image/fetch/$s_!U8H8!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ebc30ed-d9fc-4e62-b80a-1d5805660823_700x200.png 424w, /__u/substackcdn.com/image/fetch/$s_!U8H8!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ebc30ed-d9fc-4e62-b80a-1d5805660823_700x200.png 848w, /__u/substackcdn.com/image/fetch/$s_!U8H8!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ebc30ed-d9fc-4e62-b80a-1d5805660823_700x200.png 1272w, /__u/substackcdn.com/image/fetch/$s_!U8H8!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ebc30ed-d9fc-4e62-b80a-1d5805660823_700x200.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Bob is standing in the middle of the train. Alice and Bob are opposite each other. So, the two lightning strikes are the same distance from Alice and Bob.</p><p>Now, Alice and Bob are scientists who understand the speed of light, and Einstein&#8217;s two postulates. They have cameras and other equipment on the platform to observe the events and work out the sequence of events.</p><h2>The platform, from Alice&#8217;s viewpoint</h2><p>The diagram shows what happens on the platform, from Alice&#8217;s point of view:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Re8v!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F096c4eeb-6dcf-4f2a-900b-5b0a9346f674_700x800.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Re8v!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F096c4eeb-6dcf-4f2a-900b-5b0a9346f674_700x800.png 424w, /__u/substackcdn.com/image/fetch/$s_!Re8v!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F096c4eeb-6dcf-4f2a-900b-5b0a9346f674_700x800.png 848w, /__u/substackcdn.com/image/fetch/$s_!Re8v!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F096c4eeb-6dcf-4f2a-900b-5b0a9346f674_700x800.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Re8v!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F096c4eeb-6dcf-4f2a-900b-5b0a9346f674_700x800.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Re8v!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F096c4eeb-6dcf-4f2a-900b-5b0a9346f674_700x800.png" width="700" height="800" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/096c4eeb-6dcf-4f2a-900b-5b0a9346f674_700x800.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:800,&quot;width&quot;:700,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;sequence&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="sequence" title="sequence" srcset="/__u/substackcdn.com/image/fetch/$s_!Re8v!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F096c4eeb-6dcf-4f2a-900b-5b0a9346f674_700x800.png 424w, /__u/substackcdn.com/image/fetch/$s_!Re8v!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F096c4eeb-6dcf-4f2a-900b-5b0a9346f674_700x800.png 848w, /__u/substackcdn.com/image/fetch/$s_!Re8v!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F096c4eeb-6dcf-4f2a-900b-5b0a9346f674_700x800.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Re8v!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F096c4eeb-6dcf-4f2a-900b-5b0a9346f674_700x800.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 1 shows the lightning strikes. Alice won&#8217;t see the lightning instantly, because it takes a finite amount of time for the light to travel to her.</p><p>Images 2 and 3 show the light travelling towards her.</p><p>In image 4, light from both strikes reaches Alice simultaneously.</p><p>What does Alice know?</p><ul><li><p>She knows that the lightning strikes were both the same distance from her, she has photographs of where the lightning landed.</p></li><li><p>She knows that the light from both strikes arrived at her location at the same time. She has two sensors that detect the time of arrival of light, using the same clock.</p></li></ul><p>However, she DOESN&#8217;T know for certain whether the two strikes happened at exactly the same time. The strikes were measured at two different places, and there is some suggestion that distance and movement might affect the timing. So, just to be safe, she will only trust that two times are the same if they are measured at the same place using the same clock.</p><p>But here is what she can deduce. Both light flashes arrived at her location at the same time, and both lightning strikes happened the same distance away from her. So, since light always travels at the same speed, the two lightning strikes must have happened at the same time.</p><h2>The train, from Alice&#8217;s viewpoint</h2><p>Alice can also figure out what Bob saw on the train.</p><p>Look again at step 4 above, the point when the two light flashes arrive at Alice. We can see that Bob will already have moved some distance to the right. Alice even has a photo to prove it.</p><p>This means the red flash will have already passed Bob, but the yellow flash won&#8217;t have reached him yet. Bob will have seen one flash, but not yet seen the other. To him, the flashes will appear to have happened at different times.</p><p>But there is nothing strange about that. Bob is travelling towards the source of the red flash and away from the source of the yellow flash. Since light has a finite speed, he will, of course, see the red flash first. That is exactly what you would expect.</p><h2>The train, from Bob&#8217;s point of view</h2><p>This is where things get a little strange. Here is what Bob sees:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!-rr3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9f9ce0f-ff3c-4b23-9e8e-6ef18169b888_700x1000.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!-rr3!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9f9ce0f-ff3c-4b23-9e8e-6ef18169b888_700x1000.png 424w, /__u/substackcdn.com/image/fetch/$s_!-rr3!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9f9ce0f-ff3c-4b23-9e8e-6ef18169b888_700x1000.png 848w, /__u/substackcdn.com/image/fetch/$s_!-rr3!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9f9ce0f-ff3c-4b23-9e8e-6ef18169b888_700x1000.png 1272w, /__u/substackcdn.com/image/fetch/$s_!-rr3!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9f9ce0f-ff3c-4b23-9e8e-6ef18169b888_700x1000.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!-rr3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9f9ce0f-ff3c-4b23-9e8e-6ef18169b888_700x1000.png" width="700" height="1000" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e9f9ce0f-ff3c-4b23-9e8e-6ef18169b888_700x1000.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1000,&quot;width&quot;:700,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;sequence&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="sequence" title="sequence" srcset="/__u/substackcdn.com/image/fetch/$s_!-rr3!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9f9ce0f-ff3c-4b23-9e8e-6ef18169b888_700x1000.png 424w, /__u/substackcdn.com/image/fetch/$s_!-rr3!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9f9ce0f-ff3c-4b23-9e8e-6ef18169b888_700x1000.png 848w, /__u/substackcdn.com/image/fetch/$s_!-rr3!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9f9ce0f-ff3c-4b23-9e8e-6ef18169b888_700x1000.png 1272w, /__u/substackcdn.com/image/fetch/$s_!-rr3!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9f9ce0f-ff3c-4b23-9e8e-6ef18169b888_700x1000.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Notice that the timepoints shown here are not exactly the same as those in the previous diagram.</p><p>Images 1 and 2 show the lightning strikes and the flashes moving along the train towards Bob.</p><p>Image 3 shows the red flash reaching Bob.</p><p>Image 4 shows both flashes reaching Alice simultaneously.</p><p>Image 5 shows the yellow flash reaching Bob.</p><p>What does Bob know?</p><ul><li><p>He knows that the lightning strikes were both the same distance from him, he has photographs of where the lightning landed. The lightning landed at either end of the train.</p></li><li><p>He knows that the light from both strikes arrived at his location at different times. He has two sensors that detect the time of arrival of light, using the same clock.</p></li></ul><p>Here is what he can deduce:</p><ul><li><p>Both light flashes arrived at his location at different times.</p></li><li><p>Both lightning strikes happened the same distance away from him (we already know that). &amp; So, since light always travels at the same speed, the two lightning strikes could not possibly have happened at the same time.</p></li></ul><p>So, by pure logic, Einstein figured out that two events that are simultaneous in one inertial frame might not be simultaneous in another.</p><h2>A common misconception</h2><p>You might still be unconvinced. You might be thinking, wouldn&#8217;t the same thing happen if we use, say, a tennis ball instead of light?</p><p>Yes, it would. Almost.</p><p>Let&#8217;s revisit the previous diagram, but using tennis balls rather than light. In image 1, as the train passes, two people on the platform throw a tennis ball towards Alice from opposite directions. In image 2, those balls travel towards Alice.</p><p>In image 3, the red ball passes Bob, in image 4, both balls pass Alice, and in image 5, the yellow ball passes Bob. Exactly like the light.</p><p>If Bob wasn&#8217;t a scientist, and he had been told that both balls had been launched from the same distance and at the same speed, he might come to the conclusion that the red ball must have been launched before the yellow ball.</p><p>But Bob is a scientist, and he has a radar speed sensor, so he knows that the speed of the red ball (relative to the train) is faster than the speed of the yellow ball (relative to the train). The balls were thrown at the same speed relative to the platform, but the speeds relative to the train are different because the train is moving too.</p><p>He can do the calculation and confirm that the balls were indeed thrown at the same time.</p><p>The essential difference is that light always travels at the same speed for observers in any inertial frame. That makes no sense in the context of ordinary objects like balls, but it is how light behaves, so it leads to counterintuitive results.</p><p>To the person on the train, it doesn&#8217;t just <em>look like</em> the lightning strikes happened at different times. They actually did happen at different times.</p>]]></content:encoded></item><item><title><![CDATA[A scientific calculator with just two buttons? The new EML universal function]]></title><description><![CDATA[A standard scientific calculator has quite a large set of functions.]]></description><link>https://graphicmaths.substack.com/p/a-scientific-calculator-with-just</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/a-scientific-calculator-with-just</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Thu, 23 Apr 2026 11:26:00 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!qdGT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4927384f-7dab-4b47-9607-b7fefb36cbea_1408x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A standard scientific calculator has quite a large set of functions. These include the four basic arithmetic operators, powers and roots, and the constants <em>e</em> and &#960;. Also logarithms, trig functions, hyperbolic functions, and the inverses of all those functions.</p><p>Suppose we could replace all of those with one function? Well, a recent paper, <a href="https://arxiv.org/html/2603.21852v2">All elementary functions from a single operator</a>, by <em>Andrzej Odrzywo&#322;ek</em>, shows that we can.</p><p>The function is called the <em>eml</em> function. This function, together with the number 1, can do everything listed above. In principle, we could make a scientific calculator with just those two keys, and it could do everything a normal scientific calculator can do!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!qdGT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4927384f-7dab-4b47-9607-b7fefb36cbea_1408x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!qdGT!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4927384f-7dab-4b47-9607-b7fefb36cbea_1408x768.png 424w, /__u/substackcdn.com/image/fetch/$s_!qdGT!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4927384f-7dab-4b47-9607-b7fefb36cbea_1408x768.png 848w, /__u/substackcdn.com/image/fetch/$s_!qdGT!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4927384f-7dab-4b47-9607-b7fefb36cbea_1408x768.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qdGT!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4927384f-7dab-4b47-9607-b7fefb36cbea_1408x768.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!qdGT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4927384f-7dab-4b47-9607-b7fefb36cbea_1408x768.png" width="1408" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4927384f-7dab-4b47-9607-b7fefb36cbea_1408x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1408,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;scientific calculator&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&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="scientific calculator" title="scientific calculator" srcset="/__u/substackcdn.com/image/fetch/$s_!qdGT!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4927384f-7dab-4b47-9607-b7fefb36cbea_1408x768.png 424w, /__u/substackcdn.com/image/fetch/$s_!qdGT!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4927384f-7dab-4b47-9607-b7fefb36cbea_1408x768.png 848w, /__u/substackcdn.com/image/fetch/$s_!qdGT!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4927384f-7dab-4b47-9607-b7fefb36cbea_1408x768.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qdGT!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4927384f-7dab-4b47-9607-b7fefb36cbea_1408x768.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 aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 be clear, of course, you wouldn&#8217;t want to do that. It would work in principle, but in practice, you would need to press those two buttons many times for even a simple calculation. Even so, this technique might have applications in computing, see the analogy with NAND gates, below.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/subscribe"><span>Subscribe now</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/p/a-scientific-calculator-with-just?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/p/a-scientific-calculator-with-just?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share</span></a></p><p><em>If you are interested in Calculus, my book is now available from <a href="https://martinmcbride.gumroad.com/l/calculus-book">Gumroad</a>.</em></p><h2>The eml(x, y) function</h2><p>You might expect such a function to be quite complicated, but in fact it is a lot simpler than you might imagine. The <em>eml</em> function of <em>x</em> and <em>y</em> is defined as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!dkwS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!dkwS!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!dkwS!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!dkwS!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!dkwS!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!dkwS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png" width="350" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:350,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;eml function&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="eml function" title="eml function" srcset="/__u/substackcdn.com/image/fetch/$s_!dkwS!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!dkwS!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!dkwS!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!dkwS!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>EML</strong> stands for Exp-Minus-Log.</p><p>The exponential function can be written as <em>exp(x)</em>, rather than <em>e^x</em>, like this:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!ZVSH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefbfd683-4e80-4635-8696-37478c1df0b3_411x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!ZVSH!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefbfd683-4e80-4635-8696-37478c1df0b3_411x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!ZVSH!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefbfd683-4e80-4635-8696-37478c1df0b3_411x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!ZVSH!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefbfd683-4e80-4635-8696-37478c1df0b3_411x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ZVSH!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefbfd683-4e80-4635-8696-37478c1df0b3_411x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!ZVSH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefbfd683-4e80-4635-8696-37478c1df0b3_411x81.png" width="411" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/efbfd683-4e80-4635-8696-37478c1df0b3_411x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:411,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;eml function&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="eml function" title="eml function" srcset="/__u/substackcdn.com/image/fetch/$s_!ZVSH!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefbfd683-4e80-4635-8696-37478c1df0b3_411x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!ZVSH!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefbfd683-4e80-4635-8696-37478c1df0b3_411x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!ZVSH!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefbfd683-4e80-4635-8696-37478c1df0b3_411x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ZVSH!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefbfd683-4e80-4635-8696-37478c1df0b3_411x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>In this article, we will use <em>exp(x)</em> because it is more readable when we nest functions to many levels.</p><h2>How the function works</h2><p>To understand how this function works, it is easiest to look at some examples. Since the function is based on exponentials and logs, it is not surprising that these functions can be expressed most easily in <strong>EML</strong>.</p><p>First, consider the <strong>constant e</strong> (Euler&#8217;s number). Looking at the original function:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!dkwS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!dkwS!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!dkwS!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!dkwS!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!dkwS!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!dkwS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png" width="350" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:350,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;eml function&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="eml function" title="eml function" srcset="/__u/substackcdn.com/image/fetch/$s_!dkwS!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!dkwS!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!dkwS!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!dkwS!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c6cf315-e73e-46f2-b9ed-1aef4c87a3cd_350x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>If we set <em>x</em> to 1, the first term is just <em>e</em>. If we set <em>y</em> to 1, the log term goes to 0 (log of 1 is 0). So:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!1TCG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c05baa0-d2f8-48df-a443-2a9743a9ec67_463x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!1TCG!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c05baa0-d2f8-48df-a443-2a9743a9ec67_463x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!1TCG!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c05baa0-d2f8-48df-a443-2a9743a9ec67_463x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!1TCG!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c05baa0-d2f8-48df-a443-2a9743a9ec67_463x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!1TCG!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c05baa0-d2f8-48df-a443-2a9743a9ec67_463x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!1TCG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c05baa0-d2f8-48df-a443-2a9743a9ec67_463x81.png" width="463" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3c05baa0-d2f8-48df-a443-2a9743a9ec67_463x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:463,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;e constant&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="e constant" title="e constant" srcset="/__u/substackcdn.com/image/fetch/$s_!1TCG!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c05baa0-d2f8-48df-a443-2a9743a9ec67_463x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!1TCG!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c05baa0-d2f8-48df-a443-2a9743a9ec67_463x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!1TCG!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c05baa0-d2f8-48df-a443-2a9743a9ec67_463x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!1TCG!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3c05baa0-d2f8-48df-a443-2a9743a9ec67_463x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Let&#8217;s be clear what we have done here. We have expressed the constant <em>e</em> in terms of the <strong>EML</strong> function. That isn&#8217;t so interesting on its own. But, as we will see, we can express every other elementary function in terms of <strong>EML</strong> too. That is pretty amazing and potentially very useful.</p><p>Let&#8217;s look at the <strong>exponential function</strong> next. We just use <em>eml(z, 1)</em>, and again the log term vanishes:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!yXI3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe109c13b-0c4b-49f1-9788-eefd4bdf1b23_537x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!yXI3!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe109c13b-0c4b-49f1-9788-eefd4bdf1b23_537x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!yXI3!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe109c13b-0c4b-49f1-9788-eefd4bdf1b23_537x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!yXI3!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe109c13b-0c4b-49f1-9788-eefd4bdf1b23_537x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!yXI3!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe109c13b-0c4b-49f1-9788-eefd4bdf1b23_537x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!yXI3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe109c13b-0c4b-49f1-9788-eefd4bdf1b23_537x81.png" width="537" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e109c13b-0c4b-49f1-9788-eefd4bdf1b23_537x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:537,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;exponential function&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="exponential function" title="exponential function" srcset="/__u/substackcdn.com/image/fetch/$s_!yXI3!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe109c13b-0c4b-49f1-9788-eefd4bdf1b23_537x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!yXI3!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe109c13b-0c4b-49f1-9788-eefd4bdf1b23_537x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!yXI3!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe109c13b-0c4b-49f1-9788-eefd4bdf1b23_537x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!yXI3!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe109c13b-0c4b-49f1-9788-eefd4bdf1b23_537x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>What about <strong>ln(z)</strong>, how do we express that in terms of <em>eml</em>? This is slightly more complicated and takes several steps. We start by setting <em>x</em> to 1 and <em>y</em> to <em>z</em></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!oC36!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a743332-fda5-475b-b52e-231b4eb99c0a_331x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!oC36!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a743332-fda5-475b-b52e-231b4eb99c0a_331x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!oC36!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a743332-fda5-475b-b52e-231b4eb99c0a_331x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!oC36!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a743332-fda5-475b-b52e-231b4eb99c0a_331x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!oC36!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a743332-fda5-475b-b52e-231b4eb99c0a_331x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!oC36!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a743332-fda5-475b-b52e-231b4eb99c0a_331x81.png" width="331" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1a743332-fda5-475b-b52e-231b4eb99c0a_331x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:331,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;log function&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="log function" title="log function" srcset="/__u/substackcdn.com/image/fetch/$s_!oC36!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a743332-fda5-475b-b52e-231b4eb99c0a_331x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!oC36!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a743332-fda5-475b-b52e-231b4eb99c0a_331x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!oC36!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a743332-fda5-475b-b52e-231b4eb99c0a_331x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!oC36!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a743332-fda5-475b-b52e-231b4eb99c0a_331x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We can take the exponential of both sides:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!lYo_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3accea37-8c1e-4167-9bc0-c91108c1aea9_477x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!lYo_!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3accea37-8c1e-4167-9bc0-c91108c1aea9_477x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!lYo_!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3accea37-8c1e-4167-9bc0-c91108c1aea9_477x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!lYo_!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3accea37-8c1e-4167-9bc0-c91108c1aea9_477x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!lYo_!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3accea37-8c1e-4167-9bc0-c91108c1aea9_477x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!lYo_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3accea37-8c1e-4167-9bc0-c91108c1aea9_477x81.png" width="477" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3accea37-8c1e-4167-9bc0-c91108c1aea9_477x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:477,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;log function&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="log function" title="log function" srcset="/__u/substackcdn.com/image/fetch/$s_!lYo_!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3accea37-8c1e-4167-9bc0-c91108c1aea9_477x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!lYo_!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3accea37-8c1e-4167-9bc0-c91108c1aea9_477x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!lYo_!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3accea37-8c1e-4167-9bc0-c91108c1aea9_477x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!lYo_!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3accea37-8c1e-4167-9bc0-c91108c1aea9_477x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We can apply <em>eml(1, z)</em> again to the whole expression, which gives <em>e</em> minus the log of the previous expression:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!zoJM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee8ed4aa-ac26-46af-805d-e2aca74cbece_698x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!zoJM!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee8ed4aa-ac26-46af-805d-e2aca74cbece_698x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!zoJM!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee8ed4aa-ac26-46af-805d-e2aca74cbece_698x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!zoJM!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee8ed4aa-ac26-46af-805d-e2aca74cbece_698x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!zoJM!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee8ed4aa-ac26-46af-805d-e2aca74cbece_698x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!zoJM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee8ed4aa-ac26-46af-805d-e2aca74cbece_698x81.png" width="698" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ee8ed4aa-ac26-46af-805d-e2aca74cbece_698x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:698,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;log function&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="log function" title="log function" srcset="/__u/substackcdn.com/image/fetch/$s_!zoJM!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee8ed4aa-ac26-46af-805d-e2aca74cbece_698x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!zoJM!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee8ed4aa-ac26-46af-805d-e2aca74cbece_698x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!zoJM!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee8ed4aa-ac26-46af-805d-e2aca74cbece_698x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!zoJM!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fee8ed4aa-ac26-46af-805d-e2aca74cbece_698x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We can simplify this, because we have <em>ln(exp(...))</em> on the RHS, and those two functions are inverses, so they cancel out:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!8Pej!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895ab433-4ac6-4ce3-a092-b93d7cf9d047_813x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!8Pej!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895ab433-4ac6-4ce3-a092-b93d7cf9d047_813x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!8Pej!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895ab433-4ac6-4ce3-a092-b93d7cf9d047_813x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!8Pej!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895ab433-4ac6-4ce3-a092-b93d7cf9d047_813x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!8Pej!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895ab433-4ac6-4ce3-a092-b93d7cf9d047_813x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!8Pej!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895ab433-4ac6-4ce3-a092-b93d7cf9d047_813x81.png" width="813" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/895ab433-4ac6-4ce3-a092-b93d7cf9d047_813x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:813,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;log function&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="log function" title="log function" srcset="/__u/substackcdn.com/image/fetch/$s_!8Pej!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895ab433-4ac6-4ce3-a092-b93d7cf9d047_813x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!8Pej!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895ab433-4ac6-4ce3-a092-b93d7cf9d047_813x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!8Pej!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895ab433-4ac6-4ce3-a092-b93d7cf9d047_813x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!8Pej!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F895ab433-4ac6-4ce3-a092-b93d7cf9d047_813x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>So now we know <em>ln</em> in terms of <em>eml</em> and <em>exp</em>. But we already know <em>exp</em> in terms of <em>eml</em>. So we can now express <em>ln</em> in terms of <em>eml</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!q0nE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268e6932-dd53-42f6-b852-b58f7e756289_582x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!q0nE!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268e6932-dd53-42f6-b852-b58f7e756289_582x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!q0nE!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268e6932-dd53-42f6-b852-b58f7e756289_582x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!q0nE!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268e6932-dd53-42f6-b852-b58f7e756289_582x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!q0nE!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268e6932-dd53-42f6-b852-b58f7e756289_582x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!q0nE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268e6932-dd53-42f6-b852-b58f7e756289_582x81.png" width="582" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/268e6932-dd53-42f6-b852-b58f7e756289_582x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:582,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;log function&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="log function" title="log function" srcset="/__u/substackcdn.com/image/fetch/$s_!q0nE!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268e6932-dd53-42f6-b852-b58f7e756289_582x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!q0nE!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268e6932-dd53-42f6-b852-b58f7e756289_582x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!q0nE!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268e6932-dd53-42f6-b852-b58f7e756289_582x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!q0nE!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F268e6932-dd53-42f6-b852-b58f7e756289_582x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We will derive the <strong>EML</strong> representations of other functions later. Quite often, we will use the results of earlier functions to derive new functions (as we just did with <em>exp</em> to derive <em>ln</em>).</p><p>This will often result in an expression that is a mixture of <em>eml</em> functions together with other functions whose <strong>EML</strong> representation is already known. For example equation (1) has <em>eml</em> and <em>exp</em> functions, and we already know how to express <em>exp</em> using <em>eml</em></p><p>In general, it will always be possible to expand the known functions to obtain a representation entirely using <em>eml</em>, as we just did with equation (1) to obtain equation (2). However, we won&#8217;t do that in the examples below. The result would be some very long expressions that aren&#8217;t particularly illuminating. The important thing is that we could do it if we wanted to.</p><h2>Deriving arithmetic operators</h2><p>We are now in a position to derive the arithmetic operators. Subtraction is quite easy:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!iQKR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc168fdbc-4f36-430b-9326-176ac33a41f6_881x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!iQKR!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc168fdbc-4f36-430b-9326-176ac33a41f6_881x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!iQKR!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc168fdbc-4f36-430b-9326-176ac33a41f6_881x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!iQKR!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc168fdbc-4f36-430b-9326-176ac33a41f6_881x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!iQKR!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc168fdbc-4f36-430b-9326-176ac33a41f6_881x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!iQKR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc168fdbc-4f36-430b-9326-176ac33a41f6_881x81.png" width="881" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c168fdbc-4f36-430b-9326-176ac33a41f6_881x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:881,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;subtraction&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="subtraction" title="subtraction" srcset="/__u/substackcdn.com/image/fetch/$s_!iQKR!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc168fdbc-4f36-430b-9326-176ac33a41f6_881x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!iQKR!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc168fdbc-4f36-430b-9326-176ac33a41f6_881x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!iQKR!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc168fdbc-4f36-430b-9326-176ac33a41f6_881x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!iQKR!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc168fdbc-4f36-430b-9326-176ac33a41f6_881x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We are again using the fact that <em>exp</em> and <em>ln</em> are inverses. When we pass <em>ln(x)</em> as the first term and apply <em>exp</em> in the <em>eml</em> function, the result is just <em>x</em>. Similarly, <em>exp(y)</em> becomes <em>-y</em></p><p>Given subtraction, we can derive negation, once again using <em>ln(1) = 0</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!935E!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd44a03d4-986d-497d-8677-61b984ef0bc8_258x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!935E!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd44a03d4-986d-497d-8677-61b984ef0bc8_258x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!935E!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd44a03d4-986d-497d-8677-61b984ef0bc8_258x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!935E!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd44a03d4-986d-497d-8677-61b984ef0bc8_258x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!935E!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd44a03d4-986d-497d-8677-61b984ef0bc8_258x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!935E!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd44a03d4-986d-497d-8677-61b984ef0bc8_258x81.png" width="258" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d44a03d4-986d-497d-8677-61b984ef0bc8_258x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:258,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;negation&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="negation" title="negation" srcset="/__u/substackcdn.com/image/fetch/$s_!935E!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd44a03d4-986d-497d-8677-61b984ef0bc8_258x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!935E!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd44a03d4-986d-497d-8677-61b984ef0bc8_258x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!935E!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd44a03d4-986d-497d-8677-61b984ef0bc8_258x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!935E!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd44a03d4-986d-497d-8677-61b984ef0bc8_258x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This might look a bit odd. We need to express <em>-x</em> in <strong>EML</strong> form, but the RHS doesn&#8217;t contain any <em>eml</em> functions. This goes back to what we said earlier about not expanding known functions, but this is a slightly more extreme example.</p><p>We can expand the subtraction using equation (3). Then we will end up with an expression involving <em>eml</em>, <em>exp</em> and <em>ln</em>. We already know how to expand <em>exp</em> and <em>ln</em>. So we know how to expand it, but it would be quite long and hard to read.</p><p>Then addition is just subtracting the negated value:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!90_f!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25bcb14e-6d97-456a-ba94-791072cb79a4_285x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!90_f!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25bcb14e-6d97-456a-ba94-791072cb79a4_285x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!90_f!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25bcb14e-6d97-456a-ba94-791072cb79a4_285x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!90_f!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25bcb14e-6d97-456a-ba94-791072cb79a4_285x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!90_f!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25bcb14e-6d97-456a-ba94-791072cb79a4_285x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!90_f!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25bcb14e-6d97-456a-ba94-791072cb79a4_285x81.png" width="285" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/25bcb14e-6d97-456a-ba94-791072cb79a4_285x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:285,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;addition&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="addition" title="addition" srcset="/__u/substackcdn.com/image/fetch/$s_!90_f!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25bcb14e-6d97-456a-ba94-791072cb79a4_285x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!90_f!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25bcb14e-6d97-456a-ba94-791072cb79a4_285x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!90_f!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25bcb14e-6d97-456a-ba94-791072cb79a4_285x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!90_f!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25bcb14e-6d97-456a-ba94-791072cb79a4_285x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>To multiply, we add the logs:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!czn5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a10af9-e7f5-4ce0-90c5-60cdc7ba59e5_400x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!czn5!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a10af9-e7f5-4ce0-90c5-60cdc7ba59e5_400x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!czn5!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a10af9-e7f5-4ce0-90c5-60cdc7ba59e5_400x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!czn5!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a10af9-e7f5-4ce0-90c5-60cdc7ba59e5_400x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!czn5!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a10af9-e7f5-4ce0-90c5-60cdc7ba59e5_400x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!czn5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a10af9-e7f5-4ce0-90c5-60cdc7ba59e5_400x81.png" width="400" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/72a10af9-e7f5-4ce0-90c5-60cdc7ba59e5_400x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:400,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;multiplication&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="multiplication" title="multiplication" srcset="/__u/substackcdn.com/image/fetch/$s_!czn5!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a10af9-e7f5-4ce0-90c5-60cdc7ba59e5_400x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!czn5!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a10af9-e7f5-4ce0-90c5-60cdc7ba59e5_400x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!czn5!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a10af9-e7f5-4ce0-90c5-60cdc7ba59e5_400x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!czn5!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F72a10af9-e7f5-4ce0-90c5-60cdc7ba59e5_400x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Division can be done by subtracting the logs. Powers and roots by multiplying and dividing the logs. They aren&#8217;t shown here.</p><h2>More functions</h2><p>We could go on to derive all the elementary functions in terms of <em>eml</em>. The supplementary information to the original paper (linked below) does that, but here we will sketch out the route.</p><p>The hyperbolic function <em>cosh</em> can be expressed in terms of the <em>exp</em> function:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Bkr1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8317be-ea4b-4b0a-b250-1d9a8789689f_484x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Bkr1!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8317be-ea4b-4b0a-b250-1d9a8789689f_484x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!Bkr1!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8317be-ea4b-4b0a-b250-1d9a8789689f_484x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!Bkr1!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8317be-ea4b-4b0a-b250-1d9a8789689f_484x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Bkr1!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8317be-ea4b-4b0a-b250-1d9a8789689f_484x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Bkr1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8317be-ea4b-4b0a-b250-1d9a8789689f_484x81.png" width="484" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4d8317be-ea4b-4b0a-b250-1d9a8789689f_484x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:484,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;cosh&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="cosh" title="cosh" srcset="/__u/substackcdn.com/image/fetch/$s_!Bkr1!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8317be-ea4b-4b0a-b250-1d9a8789689f_484x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!Bkr1!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8317be-ea4b-4b0a-b250-1d9a8789689f_484x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!Bkr1!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8317be-ea4b-4b0a-b250-1d9a8789689f_484x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Bkr1!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4d8317be-ea4b-4b0a-b250-1d9a8789689f_484x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><em>sinh</em> can be derived in a similar way, and <em>tanh</em> can be found from these</p><p>The trig functions are more interesting. There is a standard complex number identity:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!ifww!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1009186b-e2f0-4ac9-bbeb-56c15c614042_288x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!ifww!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1009186b-e2f0-4ac9-bbeb-56c15c614042_288x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!ifww!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1009186b-e2f0-4ac9-bbeb-56c15c614042_288x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!ifww!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1009186b-e2f0-4ac9-bbeb-56c15c614042_288x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ifww!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1009186b-e2f0-4ac9-bbeb-56c15c614042_288x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!ifww!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1009186b-e2f0-4ac9-bbeb-56c15c614042_288x81.png" width="288" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1009186b-e2f0-4ac9-bbeb-56c15c614042_288x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:288,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;cos&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="cos" title="cos" srcset="/__u/substackcdn.com/image/fetch/$s_!ifww!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1009186b-e2f0-4ac9-bbeb-56c15c614042_288x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!ifww!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1009186b-e2f0-4ac9-bbeb-56c15c614042_288x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!ifww!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1009186b-e2f0-4ac9-bbeb-56c15c614042_288x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ifww!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1009186b-e2f0-4ac9-bbeb-56c15c614042_288x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>But how do we find <em>ix</em>? Essentially, we can use the square root of negative <em>x</em> squared, which evaluates to <em>ix</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!QTsf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75da5e7b-0eb1-4d76-a215-19c5a88c408b_348x91.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!QTsf!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75da5e7b-0eb1-4d76-a215-19c5a88c408b_348x91.png 424w, /__u/substackcdn.com/image/fetch/$s_!QTsf!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75da5e7b-0eb1-4d76-a215-19c5a88c408b_348x91.png 848w, /__u/substackcdn.com/image/fetch/$s_!QTsf!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75da5e7b-0eb1-4d76-a215-19c5a88c408b_348x91.png 1272w, /__u/substackcdn.com/image/fetch/$s_!QTsf!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75da5e7b-0eb1-4d76-a215-19c5a88c408b_348x91.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!QTsf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75da5e7b-0eb1-4d76-a215-19c5a88c408b_348x91.png" width="348" height="91" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/75da5e7b-0eb1-4d76-a215-19c5a88c408b_348x91.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:91,&quot;width&quot;:348,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;cos&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="cos" title="cos" srcset="/__u/substackcdn.com/image/fetch/$s_!QTsf!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75da5e7b-0eb1-4d76-a215-19c5a88c408b_348x91.png 424w, /__u/substackcdn.com/image/fetch/$s_!QTsf!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75da5e7b-0eb1-4d76-a215-19c5a88c408b_348x91.png 848w, /__u/substackcdn.com/image/fetch/$s_!QTsf!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75da5e7b-0eb1-4d76-a215-19c5a88c408b_348x91.png 1272w, /__u/substackcdn.com/image/fetch/$s_!QTsf!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75da5e7b-0eb1-4d76-a215-19c5a88c408b_348x91.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We can derive &#960; in a similar way. One definition of &#960; relies on the complex-valued logarithm function:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!cMVg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a5c5801-aa0a-4d0b-acc0-4072d3fc99e8_210x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!cMVg!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a5c5801-aa0a-4d0b-acc0-4072d3fc99e8_210x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!cMVg!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a5c5801-aa0a-4d0b-acc0-4072d3fc99e8_210x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!cMVg!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a5c5801-aa0a-4d0b-acc0-4072d3fc99e8_210x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!cMVg!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a5c5801-aa0a-4d0b-acc0-4072d3fc99e8_210x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!cMVg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a5c5801-aa0a-4d0b-acc0-4072d3fc99e8_210x81.png" width="210" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0a5c5801-aa0a-4d0b-acc0-4072d3fc99e8_210x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:210,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;pi&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="pi" title="pi" srcset="/__u/substackcdn.com/image/fetch/$s_!cMVg!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a5c5801-aa0a-4d0b-acc0-4072d3fc99e8_210x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!cMVg!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a5c5801-aa0a-4d0b-acc0-4072d3fc99e8_210x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!cMVg!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a5c5801-aa0a-4d0b-acc0-4072d3fc99e8_210x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!cMVg!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a5c5801-aa0a-4d0b-acc0-4072d3fc99e8_210x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Using the same trick as before, this can be written as:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!-MyD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff29b504c-d76f-4291-a93c-395a2fabb6af_297x88.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!-MyD!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff29b504c-d76f-4291-a93c-395a2fabb6af_297x88.png 424w, /__u/substackcdn.com/image/fetch/$s_!-MyD!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff29b504c-d76f-4291-a93c-395a2fabb6af_297x88.png 848w, /__u/substackcdn.com/image/fetch/$s_!-MyD!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff29b504c-d76f-4291-a93c-395a2fabb6af_297x88.png 1272w, /__u/substackcdn.com/image/fetch/$s_!-MyD!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff29b504c-d76f-4291-a93c-395a2fabb6af_297x88.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!-MyD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff29b504c-d76f-4291-a93c-395a2fabb6af_297x88.png" width="297" height="88" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f29b504c-d76f-4291-a93c-395a2fabb6af_297x88.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:88,&quot;width&quot;:297,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;pi&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="pi" title="pi" srcset="/__u/substackcdn.com/image/fetch/$s_!-MyD!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff29b504c-d76f-4291-a93c-395a2fabb6af_297x88.png 424w, /__u/substackcdn.com/image/fetch/$s_!-MyD!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff29b504c-d76f-4291-a93c-395a2fabb6af_297x88.png 848w, /__u/substackcdn.com/image/fetch/$s_!-MyD!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff29b504c-d76f-4291-a93c-395a2fabb6af_297x88.png 1272w, /__u/substackcdn.com/image/fetch/$s_!-MyD!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff29b504c-d76f-4291-a93c-395a2fabb6af_297x88.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We can now derive <em>sin</em> (it is just <em>cos</em> offset by &#960;/2). Then <em>tan</em> can be derived from <em>sin</em> and <em>cos</em>.</p><p>The inverse hyperbolic and trig functions have standard formulas that can be used to derive <strong>EML</strong> representations, for example:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!WJRD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991c0f77-a04c-4a14-94e1-a99169257f77_444x91.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!WJRD!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991c0f77-a04c-4a14-94e1-a99169257f77_444x91.png 424w, /__u/substackcdn.com/image/fetch/$s_!WJRD!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991c0f77-a04c-4a14-94e1-a99169257f77_444x91.png 848w, /__u/substackcdn.com/image/fetch/$s_!WJRD!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991c0f77-a04c-4a14-94e1-a99169257f77_444x91.png 1272w, /__u/substackcdn.com/image/fetch/$s_!WJRD!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991c0f77-a04c-4a14-94e1-a99169257f77_444x91.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!WJRD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991c0f77-a04c-4a14-94e1-a99169257f77_444x91.png" width="444" height="91" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/991c0f77-a04c-4a14-94e1-a99169257f77_444x91.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:91,&quot;width&quot;:444,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;arsinh&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="arsinh" title="arsinh" srcset="/__u/substackcdn.com/image/fetch/$s_!WJRD!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991c0f77-a04c-4a14-94e1-a99169257f77_444x91.png 424w, /__u/substackcdn.com/image/fetch/$s_!WJRD!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991c0f77-a04c-4a14-94e1-a99169257f77_444x91.png 848w, /__u/substackcdn.com/image/fetch/$s_!WJRD!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991c0f77-a04c-4a14-94e1-a99169257f77_444x91.png 1272w, /__u/substackcdn.com/image/fetch/$s_!WJRD!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F991c0f77-a04c-4a14-94e1-a99169257f77_444x91.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Again, see the supplementary information link below for all the inverse functions.</p><h2>Tree structure</h2><p>To summarise the <strong>EML</strong> system:</p><ul><li><p>Each of the expressions above can be written as nested <em>elm</em> calls (assuming we fully expand all the other functions to their <em>elm</em> form).</p></li><li><p>Each <em>elm</em> call has two inputs and one output.</p></li><li><p>Each input can either be 1, an input variable (eg <em>x</em> or <em>y</em>), or the result of another <em>elm</em> call.</p></li></ul><p>This structure forms a <em>binary tree</em>, with leaf nodes that are either 1 or an input variable. The mess of nested <em>elm</em> calls isn&#8217;t very readable for most humans, but computers are very good at dealing with binary trees.</p><p>Also, <strong>EML</strong> isn&#8217;t limited to elementary functions. It can represent any formula involving elementary functions and arithmetic operators.</p><h2>NAND gate analogy</h2><p>Computer CPUs (and many other parts of a computer&#8217;s hardware) are mainly constructed from <em>logic gates</em>. A logic gate is a simple electronic circuit that typically accepts two inputs and creates one output. The input voltages are constrained to be either a low voltage (representing the binary value 0) or a high voltage (representing the binary value 1). The output voltage is similarly constrained.</p><p>There are several types of gates. AND gates, OR gates and XOR gates combine 2 or more inputs using logic rules, INVERTERS swap 0 and 1. NAND gates, NOR gates and XNOR gates combine the normal logic gate with an INVERTER to flip the output value.</p><p>It is possible to simulate every different type of gate using a combination of NAND gates. Most modern chips are designed using only NAND gates, which greatly simplifies their design, analysis, and manufacture. This more than compensates for the fact that a NAND-only design will typically use more gates overall.</p><h2>Some important subtleties</h2><p>There are a few additional points that are worth bearing in mind:</p><ul><li><p><strong>EML</strong> sometimes uses complex numbers internally, even when doing real number calculations (for example, when calculating &#960; from <em>ln(-1))</em>.</p></li><li><p>Some complex number functions have <em>branches</em>, where an expression has more than one possible value (in much the same way that the square root of 4 can be 2 or -2). Using such functions involves implicit decisions about which branch to take.</p></li><li><p>The system often uses the value 1 to eliminate the log term (because <em>ln(1)</em> is 0). Without this, <strong>EML</strong> wouldn&#8217;t work.</p></li><li><p><strong>EML</strong> isn&#8217;t unique, there are other possible systems.</p></li></ul><p>On the last point, another possible system is <strong>EDL</strong> (exp-divided-log), which is based on the following function:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!dkM0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311db5e7-7e98-4f86-822c-521ddf3b0c7a_302x124.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!dkM0!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311db5e7-7e98-4f86-822c-521ddf3b0c7a_302x124.png 424w, /__u/substackcdn.com/image/fetch/$s_!dkM0!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311db5e7-7e98-4f86-822c-521ddf3b0c7a_302x124.png 848w, /__u/substackcdn.com/image/fetch/$s_!dkM0!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311db5e7-7e98-4f86-822c-521ddf3b0c7a_302x124.png 1272w, /__u/substackcdn.com/image/fetch/$s_!dkM0!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311db5e7-7e98-4f86-822c-521ddf3b0c7a_302x124.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!dkM0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311db5e7-7e98-4f86-822c-521ddf3b0c7a_302x124.png" width="302" height="124" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/311db5e7-7e98-4f86-822c-521ddf3b0c7a_302x124.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:124,&quot;width&quot;:302,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;edl&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="edl" title="edl" srcset="/__u/substackcdn.com/image/fetch/$s_!dkM0!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311db5e7-7e98-4f86-822c-521ddf3b0c7a_302x124.png 424w, /__u/substackcdn.com/image/fetch/$s_!dkM0!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311db5e7-7e98-4f86-822c-521ddf3b0c7a_302x124.png 848w, /__u/substackcdn.com/image/fetch/$s_!dkM0!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311db5e7-7e98-4f86-822c-521ddf3b0c7a_302x124.png 1272w, /__u/substackcdn.com/image/fetch/$s_!dkM0!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F311db5e7-7e98-4f86-822c-521ddf3b0c7a_302x124.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>In this case, we would also need the constant <em>e</em> rather than 1 to eliminate the log term. That is because <em>ln(e)</em> is 1, and dividing by 1 has no effect,</p><h2>Applications</h2><p>This system has some interesting potential applications and implications:</p><ul><li><p>We have always known that many of the elementary functions are interrelated, in other words, they have <em>redundancies</em>. Indeed, <strong>EML</strong> uses many of these relationships in its derivation. But <strong>EML</strong> goes one step further and shows that all elementary functions can be derived from a single <em>eml()</em> function.</p></li><li><p><strong>EML</strong> provides a <em>uniform language</em> for expressing mathematics, which could be useful in computer algebra.</p></li><li><p>It might have implications for hardware design. For example, if a very fast method for calculating <em>eml</em> were developed, it might speed up the calculation of other functions.</p></li><li><p>An AI system based on the <em>eml</em> function might be able to spot patterns in data and create a matching mathematical function.</p></li><li><p>As a <em>unifying perspective</em>, <strong>EML</strong> might offer profound insights into mathematics.</p></li></ul><h2>Links to the paper</h2><ul><li><p><a href="https://arxiv.org/html/2603.21852v2">All elementary functions from a single operator</a> original paper.</p></li><li><p><a href="https://arxiv.org/src/2603.21852v2/anc/SupplementaryInformation.pdf">Supplementary information</a> if you want to dig a little deeper.</p></li></ul>]]></content:encoded></item><item><title><![CDATA[Using Laplace transforms to solve simple differential equations]]></title><description><![CDATA[One important use of Laplace transforms is to solve differential equations.]]></description><link>https://graphicmaths.substack.com/p/using-laplace-transforms-to-solve</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/using-laplace-transforms-to-solve</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Tue, 14 Apr 2026 15:49:26 GMT</pubDate><content:encoded><![CDATA[<p>One important use of <a href="https://graphicmaths.com/pure/laplace-transforms/laplace-intro/">Laplace transforms</a> is to solve differential equations. A differential equation is an equation that involves some function <em>f(t)</em> and its first derivative <em>f&#8217;(t)</em>, second derivative <em>f&#8217;&#8216;(t)</em>, and possibly even higher order derivatives.</p><p>In particular, they are very useful for solving differential equations where the initial values are known. These are known as <em>initial value problems</em> or IVPs. A first-order IVP might look something like this:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!A5v0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e310c1f-72ea-4a69-bbcf-b8597a6d81cb_413x83.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!A5v0!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e310c1f-72ea-4a69-bbcf-b8597a6d81cb_413x83.png 424w, /__u/substackcdn.com/image/fetch/$s_!A5v0!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e310c1f-72ea-4a69-bbcf-b8597a6d81cb_413x83.png 848w, /__u/substackcdn.com/image/fetch/$s_!A5v0!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e310c1f-72ea-4a69-bbcf-b8597a6d81cb_413x83.png 1272w, /__u/substackcdn.com/image/fetch/$s_!A5v0!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e310c1f-72ea-4a69-bbcf-b8597a6d81cb_413x83.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!A5v0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e310c1f-72ea-4a69-bbcf-b8597a6d81cb_413x83.png" width="413" height="83" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e310c1f-72ea-4a69-bbcf-b8597a6d81cb_413x83.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:83,&quot;width&quot;:413,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!A5v0!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e310c1f-72ea-4a69-bbcf-b8597a6d81cb_413x83.png 424w, /__u/substackcdn.com/image/fetch/$s_!A5v0!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e310c1f-72ea-4a69-bbcf-b8597a6d81cb_413x83.png 848w, /__u/substackcdn.com/image/fetch/$s_!A5v0!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e310c1f-72ea-4a69-bbcf-b8597a6d81cb_413x83.png 1272w, /__u/substackcdn.com/image/fetch/$s_!A5v0!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e310c1f-72ea-4a69-bbcf-b8597a6d81cb_413x83.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><p>There are various ways to solve simple equations like this. We will demonstrate the technique using Laplace transforms.</p><p>We will be using various Laplace transforms and inverse Laplace transforms. They can be found in any table of Laplace transforms, there are many available online.</p><p><em>If you are interested in Calculus, my book is now available from <a href="https://martinmcbride.gumroad.com/l/calculus-book">Gumroad</a>.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/p/using-laplace-transforms-to-solve?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/p/using-laplace-transforms-to-solve?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/subscribe"><span>Subscribe now</span></a></p><h2>How Laplace transforms help</h2><p>Solving an IVP using Laplace transforms involves three steps:</p><ul><li><p>We apply the Laplace transform to the original IVP. This transforms the equation in <em>t</em> into an equivalent equation in <em>s</em>. In particular, the function <em>f(t)</em> is transformed into <em>F(s)</em>.</p></li><li><p>We solve the equation for <em>F(s)</em> as an expression involving only <em>s</em>.</p></li><li><p>We then use the inverse Laplace transform to transform <em>F(s)</em> into <em>f(t)</em>.</p></li></ul><p>This will become clearer when we look at some examples, but first, it is useful to understand how this works. The original equation in <em>t</em> typically contains terms in <em>f(t)</em>, <em>f&#8217;(t)</em>, <em>f&#8217;&#8216;(t)</em>, and maybe higher derivatives. The Laplace transforms of these derivatives are standard, well-known results:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!6QdQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F766800fe-be53-434b-aef6-b894ce156f73_528x208.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!6QdQ!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F766800fe-be53-434b-aef6-b894ce156f73_528x208.png 424w, /__u/substackcdn.com/image/fetch/$s_!6QdQ!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F766800fe-be53-434b-aef6-b894ce156f73_528x208.png 848w, /__u/substackcdn.com/image/fetch/$s_!6QdQ!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F766800fe-be53-434b-aef6-b894ce156f73_528x208.png 1272w, /__u/substackcdn.com/image/fetch/$s_!6QdQ!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F766800fe-be53-434b-aef6-b894ce156f73_528x208.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!6QdQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F766800fe-be53-434b-aef6-b894ce156f73_528x208.png" width="528" height="208" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/766800fe-be53-434b-aef6-b894ce156f73_528x208.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:208,&quot;width&quot;:528,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Derivatives&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="Derivatives" title="Derivatives" srcset="/__u/substackcdn.com/image/fetch/$s_!6QdQ!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F766800fe-be53-434b-aef6-b894ce156f73_528x208.png 424w, /__u/substackcdn.com/image/fetch/$s_!6QdQ!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F766800fe-be53-434b-aef6-b894ce156f73_528x208.png 848w, /__u/substackcdn.com/image/fetch/$s_!6QdQ!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F766800fe-be53-434b-aef6-b894ce156f73_528x208.png 1272w, /__u/substackcdn.com/image/fetch/$s_!6QdQ!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F766800fe-be53-434b-aef6-b894ce156f73_528x208.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>In these equations, <em>f(0)</em> and <em>f&#8217;(0)</em> are, of course, the values of <em>f</em> and its derivative when <em>t</em> is 0. In an IVP, these values will usually be given. In effect, they are constants.</p><p>The Laplace transform typically converts differential equations into purely algebraic equations that only involve <em>F(s)</em> and <em>s</em>. These equations can be solved for <em>F(s)</em> using simple algebra. Then <em>F(s)</em> can be converted back into <em>f(t)</em> using inverse Laplace transforms.</p><p>For very simple equations, there are other methods of solving IVPs that might be slightly easier. But we will use Laplace transforms to show how they work.</p><p>For more complex equations, and in particular for <em>piecewise</em> equations that contain step changes at various points in time, Laplace transforms can make things far easier.</p><h2>Solving a simple first-order differential equation</h2><p>Let&#8217;s see how to solve the previous equation:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Dlj0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ed8f5f-54d6-4925-a0ff-4d0d5afab410_516x83.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Dlj0!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ed8f5f-54d6-4925-a0ff-4d0d5afab410_516x83.png 424w, /__u/substackcdn.com/image/fetch/$s_!Dlj0!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ed8f5f-54d6-4925-a0ff-4d0d5afab410_516x83.png 848w, /__u/substackcdn.com/image/fetch/$s_!Dlj0!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ed8f5f-54d6-4925-a0ff-4d0d5afab410_516x83.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Dlj0!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ed8f5f-54d6-4925-a0ff-4d0d5afab410_516x83.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Dlj0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ed8f5f-54d6-4925-a0ff-4d0d5afab410_516x83.png" width="516" height="83" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/54ed8f5f-54d6-4925-a0ff-4d0d5afab410_516x83.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:83,&quot;width&quot;:516,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!Dlj0!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ed8f5f-54d6-4925-a0ff-4d0d5afab410_516x83.png 424w, /__u/substackcdn.com/image/fetch/$s_!Dlj0!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ed8f5f-54d6-4925-a0ff-4d0d5afab410_516x83.png 848w, /__u/substackcdn.com/image/fetch/$s_!Dlj0!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ed8f5f-54d6-4925-a0ff-4d0d5afab410_516x83.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Dlj0!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54ed8f5f-54d6-4925-a0ff-4d0d5afab410_516x83.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We start by finding the Laplace transform of both sides. On the LHS, we need the Laplace transform of <em>f&#8217;(t)</em>, which we saw earlier:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!YoMh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1871b47a-e976-44fe-9d6e-408acae11ace_384x83.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!YoMh!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1871b47a-e976-44fe-9d6e-408acae11ace_384x83.png 424w, /__u/substackcdn.com/image/fetch/$s_!YoMh!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1871b47a-e976-44fe-9d6e-408acae11ace_384x83.png 848w, /__u/substackcdn.com/image/fetch/$s_!YoMh!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1871b47a-e976-44fe-9d6e-408acae11ace_384x83.png 1272w, /__u/substackcdn.com/image/fetch/$s_!YoMh!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1871b47a-e976-44fe-9d6e-408acae11ace_384x83.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!YoMh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1871b47a-e976-44fe-9d6e-408acae11ace_384x83.png" width="384" height="83" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1871b47a-e976-44fe-9d6e-408acae11ace_384x83.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:83,&quot;width&quot;:384,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!YoMh!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1871b47a-e976-44fe-9d6e-408acae11ace_384x83.png 424w, /__u/substackcdn.com/image/fetch/$s_!YoMh!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1871b47a-e976-44fe-9d6e-408acae11ace_384x83.png 848w, /__u/substackcdn.com/image/fetch/$s_!YoMh!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1871b47a-e976-44fe-9d6e-408acae11ace_384x83.png 1272w, /__u/substackcdn.com/image/fetch/$s_!YoMh!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1871b47a-e976-44fe-9d6e-408acae11ace_384x83.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>On the RHS, the Laplace transform of <em>f(t)</em> is, by definition, <em>F(s)</em>. So we can find the transform of <em>-2f(t)</em> quite easily:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!3TGE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d74c92-b4a7-4d1c-876e-8c2c87d514ed_342x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!3TGE!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d74c92-b4a7-4d1c-876e-8c2c87d514ed_342x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!3TGE!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d74c92-b4a7-4d1c-876e-8c2c87d514ed_342x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!3TGE!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d74c92-b4a7-4d1c-876e-8c2c87d514ed_342x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!3TGE!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d74c92-b4a7-4d1c-876e-8c2c87d514ed_342x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!3TGE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d74c92-b4a7-4d1c-876e-8c2c87d514ed_342x81.png" width="342" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/84d74c92-b4a7-4d1c-876e-8c2c87d514ed_342x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:342,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!3TGE!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d74c92-b4a7-4d1c-876e-8c2c87d514ed_342x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!3TGE!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d74c92-b4a7-4d1c-876e-8c2c87d514ed_342x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!3TGE!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d74c92-b4a7-4d1c-876e-8c2c87d514ed_342x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!3TGE!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d74c92-b4a7-4d1c-876e-8c2c87d514ed_342x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Substituting these two results into equation (1) gives:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!ZD0j!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1b2197-b564-4af4-953b-c386c53604f1_372x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!ZD0j!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1b2197-b564-4af4-953b-c386c53604f1_372x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!ZD0j!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1b2197-b564-4af4-953b-c386c53604f1_372x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!ZD0j!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1b2197-b564-4af4-953b-c386c53604f1_372x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ZD0j!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1b2197-b564-4af4-953b-c386c53604f1_372x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!ZD0j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1b2197-b564-4af4-953b-c386c53604f1_372x81.png" width="372" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ae1b2197-b564-4af4-953b-c386c53604f1_372x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:372,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!ZD0j!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1b2197-b564-4af4-953b-c386c53604f1_372x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!ZD0j!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1b2197-b564-4af4-953b-c386c53604f1_372x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!ZD0j!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1b2197-b564-4af4-953b-c386c53604f1_372x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ZD0j!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1b2197-b564-4af4-953b-c386c53604f1_372x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We have been told that <em>f(0)</em> is 1, so:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Zaa0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9139aa64-2354-43fd-af3d-6d096e5cac6e_328x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Zaa0!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9139aa64-2354-43fd-af3d-6d096e5cac6e_328x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!Zaa0!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9139aa64-2354-43fd-af3d-6d096e5cac6e_328x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!Zaa0!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9139aa64-2354-43fd-af3d-6d096e5cac6e_328x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Zaa0!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9139aa64-2354-43fd-af3d-6d096e5cac6e_328x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Zaa0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9139aa64-2354-43fd-af3d-6d096e5cac6e_328x81.png" width="328" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9139aa64-2354-43fd-af3d-6d096e5cac6e_328x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:328,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!Zaa0!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9139aa64-2354-43fd-af3d-6d096e5cac6e_328x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!Zaa0!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9139aa64-2354-43fd-af3d-6d096e5cac6e_328x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!Zaa0!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9139aa64-2354-43fd-af3d-6d096e5cac6e_328x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Zaa0!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9139aa64-2354-43fd-af3d-6d096e5cac6e_328x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>As described earlier, we can solve this equation by finding <em>F(s)</em> as a function of <em>s</em>. To do this, we gather all the terms in <em>F(s)</em> to the LHS, and simplify:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!MeB0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4925a15f-1d04-4945-813a-5e55927da7f2_505x178.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!MeB0!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4925a15f-1d04-4945-813a-5e55927da7f2_505x178.png 424w, /__u/substackcdn.com/image/fetch/$s_!MeB0!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4925a15f-1d04-4945-813a-5e55927da7f2_505x178.png 848w, /__u/substackcdn.com/image/fetch/$s_!MeB0!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4925a15f-1d04-4945-813a-5e55927da7f2_505x178.png 1272w, /__u/substackcdn.com/image/fetch/$s_!MeB0!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4925a15f-1d04-4945-813a-5e55927da7f2_505x178.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!MeB0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4925a15f-1d04-4945-813a-5e55927da7f2_505x178.png" width="505" height="178" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4925a15f-1d04-4945-813a-5e55927da7f2_505x178.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:178,&quot;width&quot;:505,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!MeB0!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4925a15f-1d04-4945-813a-5e55927da7f2_505x178.png 424w, /__u/substackcdn.com/image/fetch/$s_!MeB0!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4925a15f-1d04-4945-813a-5e55927da7f2_505x178.png 848w, /__u/substackcdn.com/image/fetch/$s_!MeB0!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4925a15f-1d04-4945-813a-5e55927da7f2_505x178.png 1272w, /__u/substackcdn.com/image/fetch/$s_!MeB0!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4925a15f-1d04-4945-813a-5e55927da7f2_505x178.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Since <em>F(s)</em> is the Laplace transform of <em>f(t)</em>, it follows that <em>f(t)</em> is the inverse Laplace transform of <em>F(s)</em>. So we can solve the IVP by taking the inverse Laplace transform of both sides:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!LYzl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda502190-9e7d-465e-bc3c-fdd8f31bf9b0_529x125.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!LYzl!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda502190-9e7d-465e-bc3c-fdd8f31bf9b0_529x125.png 424w, /__u/substackcdn.com/image/fetch/$s_!LYzl!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda502190-9e7d-465e-bc3c-fdd8f31bf9b0_529x125.png 848w, /__u/substackcdn.com/image/fetch/$s_!LYzl!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda502190-9e7d-465e-bc3c-fdd8f31bf9b0_529x125.png 1272w, /__u/substackcdn.com/image/fetch/$s_!LYzl!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda502190-9e7d-465e-bc3c-fdd8f31bf9b0_529x125.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!LYzl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda502190-9e7d-465e-bc3c-fdd8f31bf9b0_529x125.png" width="529" height="125" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/da502190-9e7d-465e-bc3c-fdd8f31bf9b0_529x125.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:125,&quot;width&quot;:529,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!LYzl!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda502190-9e7d-465e-bc3c-fdd8f31bf9b0_529x125.png 424w, /__u/substackcdn.com/image/fetch/$s_!LYzl!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda502190-9e7d-465e-bc3c-fdd8f31bf9b0_529x125.png 848w, /__u/substackcdn.com/image/fetch/$s_!LYzl!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda502190-9e7d-465e-bc3c-fdd8f31bf9b0_529x125.png 1272w, /__u/substackcdn.com/image/fetch/$s_!LYzl!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda502190-9e7d-465e-bc3c-fdd8f31bf9b0_529x125.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The RHS looks very similar to this standard inverse transform:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!6Cpb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fc085aa-d5e2-413c-a8af-d69ef003d221_335x125.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!6Cpb!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fc085aa-d5e2-413c-a8af-d69ef003d221_335x125.png 424w, /__u/substackcdn.com/image/fetch/$s_!6Cpb!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fc085aa-d5e2-413c-a8af-d69ef003d221_335x125.png 848w, /__u/substackcdn.com/image/fetch/$s_!6Cpb!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fc085aa-d5e2-413c-a8af-d69ef003d221_335x125.png 1272w, /__u/substackcdn.com/image/fetch/$s_!6Cpb!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fc085aa-d5e2-413c-a8af-d69ef003d221_335x125.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!6Cpb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fc085aa-d5e2-413c-a8af-d69ef003d221_335x125.png" width="335" height="125" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4fc085aa-d5e2-413c-a8af-d69ef003d221_335x125.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:125,&quot;width&quot;:335,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!6Cpb!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fc085aa-d5e2-413c-a8af-d69ef003d221_335x125.png 424w, /__u/substackcdn.com/image/fetch/$s_!6Cpb!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fc085aa-d5e2-413c-a8af-d69ef003d221_335x125.png 848w, /__u/substackcdn.com/image/fetch/$s_!6Cpb!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fc085aa-d5e2-413c-a8af-d69ef003d221_335x125.png 1272w, /__u/substackcdn.com/image/fetch/$s_!6Cpb!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fc085aa-d5e2-413c-a8af-d69ef003d221_335x125.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>So we jut need to set <em>a = 2</em> to find the solution:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!P5Op!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8103af28-0990-4ef4-b342-05ab9eb0cc8a_203x85.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!P5Op!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8103af28-0990-4ef4-b342-05ab9eb0cc8a_203x85.png 424w, /__u/substackcdn.com/image/fetch/$s_!P5Op!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8103af28-0990-4ef4-b342-05ab9eb0cc8a_203x85.png 848w, /__u/substackcdn.com/image/fetch/$s_!P5Op!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8103af28-0990-4ef4-b342-05ab9eb0cc8a_203x85.png 1272w, /__u/substackcdn.com/image/fetch/$s_!P5Op!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8103af28-0990-4ef4-b342-05ab9eb0cc8a_203x85.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!P5Op!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8103af28-0990-4ef4-b342-05ab9eb0cc8a_203x85.png" width="203" height="85" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8103af28-0990-4ef4-b342-05ab9eb0cc8a_203x85.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:85,&quot;width&quot;:203,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!P5Op!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8103af28-0990-4ef4-b342-05ab9eb0cc8a_203x85.png 424w, /__u/substackcdn.com/image/fetch/$s_!P5Op!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8103af28-0990-4ef4-b342-05ab9eb0cc8a_203x85.png 848w, /__u/substackcdn.com/image/fetch/$s_!P5Op!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8103af28-0990-4ef4-b342-05ab9eb0cc8a_203x85.png 1272w, /__u/substackcdn.com/image/fetch/$s_!P5Op!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8103af28-0990-4ef4-b342-05ab9eb0cc8a_203x85.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This answer looks quite plausible. The original equation is for a system where the rate of change of <em>f</em> is proportional to the negative of the value of <em>f</em>, and that is a classic example of a system exhibiting exponential decay.</p><h2>Solving a simple second-order differential equation</h2><p>This time, we will solve the following simple second-order IPV:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!rtST!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43a7a8ce-0a47-406c-af0b-cef6cfa95fc7_722x83.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!rtST!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43a7a8ce-0a47-406c-af0b-cef6cfa95fc7_722x83.png 424w, /__u/substackcdn.com/image/fetch/$s_!rtST!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43a7a8ce-0a47-406c-af0b-cef6cfa95fc7_722x83.png 848w, /__u/substackcdn.com/image/fetch/$s_!rtST!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43a7a8ce-0a47-406c-af0b-cef6cfa95fc7_722x83.png 1272w, /__u/substackcdn.com/image/fetch/$s_!rtST!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43a7a8ce-0a47-406c-af0b-cef6cfa95fc7_722x83.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!rtST!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43a7a8ce-0a47-406c-af0b-cef6cfa95fc7_722x83.png" width="722" height="83" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/43a7a8ce-0a47-406c-af0b-cef6cfa95fc7_722x83.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:83,&quot;width&quot;:722,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!rtST!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43a7a8ce-0a47-406c-af0b-cef6cfa95fc7_722x83.png 424w, /__u/substackcdn.com/image/fetch/$s_!rtST!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43a7a8ce-0a47-406c-af0b-cef6cfa95fc7_722x83.png 848w, /__u/substackcdn.com/image/fetch/$s_!rtST!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43a7a8ce-0a47-406c-af0b-cef6cfa95fc7_722x83.png 1272w, /__u/substackcdn.com/image/fetch/$s_!rtST!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43a7a8ce-0a47-406c-af0b-cef6cfa95fc7_722x83.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This time, the LHS is the second derivative of <em>f</em>. We know the Laplace transform of this from earlier. We can also simplify this by substituting the given values for <em>f(0)</em> and <em>f&#8217;(0)</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!M_Hr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb0736dc-2540-4b63-b2a1-9a6fa3fa0e19_528x151.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!M_Hr!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb0736dc-2540-4b63-b2a1-9a6fa3fa0e19_528x151.png 424w, /__u/substackcdn.com/image/fetch/$s_!M_Hr!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb0736dc-2540-4b63-b2a1-9a6fa3fa0e19_528x151.png 848w, /__u/substackcdn.com/image/fetch/$s_!M_Hr!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb0736dc-2540-4b63-b2a1-9a6fa3fa0e19_528x151.png 1272w, /__u/substackcdn.com/image/fetch/$s_!M_Hr!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb0736dc-2540-4b63-b2a1-9a6fa3fa0e19_528x151.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!M_Hr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb0736dc-2540-4b63-b2a1-9a6fa3fa0e19_528x151.png" width="528" height="151" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fb0736dc-2540-4b63-b2a1-9a6fa3fa0e19_528x151.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:151,&quot;width&quot;:528,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!M_Hr!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb0736dc-2540-4b63-b2a1-9a6fa3fa0e19_528x151.png 424w, /__u/substackcdn.com/image/fetch/$s_!M_Hr!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb0736dc-2540-4b63-b2a1-9a6fa3fa0e19_528x151.png 848w, /__u/substackcdn.com/image/fetch/$s_!M_Hr!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb0736dc-2540-4b63-b2a1-9a6fa3fa0e19_528x151.png 1272w, /__u/substackcdn.com/image/fetch/$s_!M_Hr!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb0736dc-2540-4b63-b2a1-9a6fa3fa0e19_528x151.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The LHS is similar to the previous equation:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!ioGs!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61d689ed-fa79-4014-a302-e05ffb48d4ff_342x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!ioGs!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61d689ed-fa79-4014-a302-e05ffb48d4ff_342x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!ioGs!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61d689ed-fa79-4014-a302-e05ffb48d4ff_342x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!ioGs!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61d689ed-fa79-4014-a302-e05ffb48d4ff_342x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ioGs!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61d689ed-fa79-4014-a302-e05ffb48d4ff_342x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!ioGs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61d689ed-fa79-4014-a302-e05ffb48d4ff_342x81.png" width="342" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/61d689ed-fa79-4014-a302-e05ffb48d4ff_342x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:342,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!ioGs!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61d689ed-fa79-4014-a302-e05ffb48d4ff_342x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!ioGs!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61d689ed-fa79-4014-a302-e05ffb48d4ff_342x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!ioGs!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61d689ed-fa79-4014-a302-e05ffb48d4ff_342x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ioGs!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61d689ed-fa79-4014-a302-e05ffb48d4ff_342x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Substituting this into equation (2) gives:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!HLP5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62f5544d-645c-40ab-b8dd-85fe04326891_340x85.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!HLP5!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62f5544d-645c-40ab-b8dd-85fe04326891_340x85.png 424w, /__u/substackcdn.com/image/fetch/$s_!HLP5!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62f5544d-645c-40ab-b8dd-85fe04326891_340x85.png 848w, /__u/substackcdn.com/image/fetch/$s_!HLP5!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62f5544d-645c-40ab-b8dd-85fe04326891_340x85.png 1272w, /__u/substackcdn.com/image/fetch/$s_!HLP5!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62f5544d-645c-40ab-b8dd-85fe04326891_340x85.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!HLP5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62f5544d-645c-40ab-b8dd-85fe04326891_340x85.png" width="340" height="85" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/62f5544d-645c-40ab-b8dd-85fe04326891_340x85.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:85,&quot;width&quot;:340,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!HLP5!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62f5544d-645c-40ab-b8dd-85fe04326891_340x85.png 424w, /__u/substackcdn.com/image/fetch/$s_!HLP5!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62f5544d-645c-40ab-b8dd-85fe04326891_340x85.png 848w, /__u/substackcdn.com/image/fetch/$s_!HLP5!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62f5544d-645c-40ab-b8dd-85fe04326891_340x85.png 1272w, /__u/substackcdn.com/image/fetch/$s_!HLP5!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62f5544d-645c-40ab-b8dd-85fe04326891_340x85.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>As before, we solve for <em>F(s)</em>:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!vXzt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a426752-cbf9-4547-b22c-c16ceb061fb0_244x110.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!vXzt!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a426752-cbf9-4547-b22c-c16ceb061fb0_244x110.png 424w, /__u/substackcdn.com/image/fetch/$s_!vXzt!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a426752-cbf9-4547-b22c-c16ceb061fb0_244x110.png 848w, /__u/substackcdn.com/image/fetch/$s_!vXzt!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a426752-cbf9-4547-b22c-c16ceb061fb0_244x110.png 1272w, /__u/substackcdn.com/image/fetch/$s_!vXzt!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a426752-cbf9-4547-b22c-c16ceb061fb0_244x110.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!vXzt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a426752-cbf9-4547-b22c-c16ceb061fb0_244x110.png" width="244" height="110" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4a426752-cbf9-4547-b22c-c16ceb061fb0_244x110.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:110,&quot;width&quot;:244,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!vXzt!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a426752-cbf9-4547-b22c-c16ceb061fb0_244x110.png 424w, /__u/substackcdn.com/image/fetch/$s_!vXzt!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a426752-cbf9-4547-b22c-c16ceb061fb0_244x110.png 848w, /__u/substackcdn.com/image/fetch/$s_!vXzt!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a426752-cbf9-4547-b22c-c16ceb061fb0_244x110.png 1272w, /__u/substackcdn.com/image/fetch/$s_!vXzt!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a426752-cbf9-4547-b22c-c16ceb061fb0_244x110.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This expression is quite similar to the following inverse transform:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Hy4O!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca2fdbf1-ca01-4ddb-98ee-617a7d923d4f_399x125.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Hy4O!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca2fdbf1-ca01-4ddb-98ee-617a7d923d4f_399x125.png 424w, /__u/substackcdn.com/image/fetch/$s_!Hy4O!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca2fdbf1-ca01-4ddb-98ee-617a7d923d4f_399x125.png 848w, /__u/substackcdn.com/image/fetch/$s_!Hy4O!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca2fdbf1-ca01-4ddb-98ee-617a7d923d4f_399x125.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Hy4O!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca2fdbf1-ca01-4ddb-98ee-617a7d923d4f_399x125.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Hy4O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca2fdbf1-ca01-4ddb-98ee-617a7d923d4f_399x125.png" width="399" height="125" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ca2fdbf1-ca01-4ddb-98ee-617a7d923d4f_399x125.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:125,&quot;width&quot;:399,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!Hy4O!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca2fdbf1-ca01-4ddb-98ee-617a7d923d4f_399x125.png 424w, /__u/substackcdn.com/image/fetch/$s_!Hy4O!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca2fdbf1-ca01-4ddb-98ee-617a7d923d4f_399x125.png 848w, /__u/substackcdn.com/image/fetch/$s_!Hy4O!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca2fdbf1-ca01-4ddb-98ee-617a7d923d4f_399x125.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Hy4O!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca2fdbf1-ca01-4ddb-98ee-617a7d923d4f_399x125.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>In this case, <em>a</em> squared is 9, so <em>a</em> is 3:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!-6Ca!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8980a54a-e8dc-481d-ae85-24ddb549e594_582x125.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!-6Ca!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8980a54a-e8dc-481d-ae85-24ddb549e594_582x125.png 424w, /__u/substackcdn.com/image/fetch/$s_!-6Ca!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8980a54a-e8dc-481d-ae85-24ddb549e594_582x125.png 848w, /__u/substackcdn.com/image/fetch/$s_!-6Ca!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8980a54a-e8dc-481d-ae85-24ddb549e594_582x125.png 1272w, /__u/substackcdn.com/image/fetch/$s_!-6Ca!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8980a54a-e8dc-481d-ae85-24ddb549e594_582x125.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!-6Ca!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8980a54a-e8dc-481d-ae85-24ddb549e594_582x125.png" width="582" height="125" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8980a54a-e8dc-481d-ae85-24ddb549e594_582x125.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:125,&quot;width&quot;:582,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!-6Ca!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8980a54a-e8dc-481d-ae85-24ddb549e594_582x125.png 424w, /__u/substackcdn.com/image/fetch/$s_!-6Ca!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8980a54a-e8dc-481d-ae85-24ddb549e594_582x125.png 848w, /__u/substackcdn.com/image/fetch/$s_!-6Ca!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8980a54a-e8dc-481d-ae85-24ddb549e594_582x125.png 1272w, /__u/substackcdn.com/image/fetch/$s_!-6Ca!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8980a54a-e8dc-481d-ae85-24ddb549e594_582x125.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This gives the following result:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!3mgk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff47a9a42-6ec9-4a99-9937-231d5721ff40_250x81.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!3mgk!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff47a9a42-6ec9-4a99-9937-231d5721ff40_250x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!3mgk!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff47a9a42-6ec9-4a99-9937-231d5721ff40_250x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!3mgk!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff47a9a42-6ec9-4a99-9937-231d5721ff40_250x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!3mgk!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff47a9a42-6ec9-4a99-9937-231d5721ff40_250x81.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!3mgk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff47a9a42-6ec9-4a99-9937-231d5721ff40_250x81.png" width="250" height="81" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f47a9a42-6ec9-4a99-9937-231d5721ff40_250x81.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:81,&quot;width&quot;:250,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;First order differential equation&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="First order differential equation" title="First order differential equation" srcset="/__u/substackcdn.com/image/fetch/$s_!3mgk!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff47a9a42-6ec9-4a99-9937-231d5721ff40_250x81.png 424w, /__u/substackcdn.com/image/fetch/$s_!3mgk!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff47a9a42-6ec9-4a99-9937-231d5721ff40_250x81.png 848w, /__u/substackcdn.com/image/fetch/$s_!3mgk!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff47a9a42-6ec9-4a99-9937-231d5721ff40_250x81.png 1272w, /__u/substackcdn.com/image/fetch/$s_!3mgk!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff47a9a42-6ec9-4a99-9937-231d5721ff40_250x81.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Once again, the answer looks plausible. The original equation is for a function whose second derivative is proportional to the square of its value, which indicates a sinusoidal function.</p>]]></content:encoded></item><item><title><![CDATA[Infinite mermaid paradox]]></title><description><![CDATA[The infinite mermaid paradox is an infinity paradox with an extremely counterintuitive result.]]></description><link>https://graphicmaths.substack.com/p/infinite-mermaid-paradox</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/infinite-mermaid-paradox</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Mon, 06 Apr 2026 11:12:18 GMT</pubDate><content:encoded><![CDATA[<p>The <em>infinite mermaid paradox</em> is an infinity paradox with an extremely counterintuitive result.</p><p><em>If you are interested in Calculus, my book is now available from <a href="https://martinmcbride.gumroad.com/l/calculus-book">Gumroad</a>.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/subscribe"><span>Subscribe now</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/p/infinite-mermaid-paradox?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/p/infinite-mermaid-paradox?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share</span></a></p><h2>The setup</h2><p>The paradox concerns a wealthy man and a mermaid who lives in a lake. The wealthy man decides to give the mermaid some gold coins, but on a very specific schedule.</p><p>At one minute to noon, the wealthy man throws two gold coins into the lake. We will refer to them as coins 1 and 2. The coins are all identical, they don&#8217;t have numbers written on them, the numbers just represent the order in which they were given.</p><p>The mermaid immediately throws back coin 1, but keeps coin 2. So she now has 1 gold coin:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!u7qM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e0edff0-af08-40e5-8a63-30d8437dd392_1024x256.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!u7qM!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e0edff0-af08-40e5-8a63-30d8437dd392_1024x256.png 424w, /__u/substackcdn.com/image/fetch/$s_!u7qM!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e0edff0-af08-40e5-8a63-30d8437dd392_1024x256.png 848w, /__u/substackcdn.com/image/fetch/$s_!u7qM!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e0edff0-af08-40e5-8a63-30d8437dd392_1024x256.png 1272w, /__u/substackcdn.com/image/fetch/$s_!u7qM!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e0edff0-af08-40e5-8a63-30d8437dd392_1024x256.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!u7qM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e0edff0-af08-40e5-8a63-30d8437dd392_1024x256.png" width="1024" height="256" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e0edff0-af08-40e5-8a63-30d8437dd392_1024x256.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:256,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Infinite mermaid&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&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="Infinite mermaid" title="Infinite mermaid" srcset="/__u/substackcdn.com/image/fetch/$s_!u7qM!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e0edff0-af08-40e5-8a63-30d8437dd392_1024x256.png 424w, /__u/substackcdn.com/image/fetch/$s_!u7qM!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e0edff0-af08-40e5-8a63-30d8437dd392_1024x256.png 848w, /__u/substackcdn.com/image/fetch/$s_!u7qM!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e0edff0-af08-40e5-8a63-30d8437dd392_1024x256.png 1272w, /__u/substackcdn.com/image/fetch/$s_!u7qM!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e0edff0-af08-40e5-8a63-30d8437dd392_1024x256.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><p>At half a minute to noon, the man throws another two gold coins into the lake. We will refer to them as coins 3 and 4. The mermaid immediately throws back the oldest coin, coin 2, but keeps the others. So she now has 2 gold coins:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!KLg-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefedf497-d074-41a4-a428-4de50cc65fab_1024x256.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!KLg-!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefedf497-d074-41a4-a428-4de50cc65fab_1024x256.png 424w, /__u/substackcdn.com/image/fetch/$s_!KLg-!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefedf497-d074-41a4-a428-4de50cc65fab_1024x256.png 848w, /__u/substackcdn.com/image/fetch/$s_!KLg-!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefedf497-d074-41a4-a428-4de50cc65fab_1024x256.png 1272w, /__u/substackcdn.com/image/fetch/$s_!KLg-!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefedf497-d074-41a4-a428-4de50cc65fab_1024x256.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!KLg-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefedf497-d074-41a4-a428-4de50cc65fab_1024x256.png" width="1024" height="256" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/efedf497-d074-41a4-a428-4de50cc65fab_1024x256.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:256,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Infinite mermaid&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="Infinite mermaid" title="Infinite mermaid" srcset="/__u/substackcdn.com/image/fetch/$s_!KLg-!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefedf497-d074-41a4-a428-4de50cc65fab_1024x256.png 424w, /__u/substackcdn.com/image/fetch/$s_!KLg-!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefedf497-d074-41a4-a428-4de50cc65fab_1024x256.png 848w, /__u/substackcdn.com/image/fetch/$s_!KLg-!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefedf497-d074-41a4-a428-4de50cc65fab_1024x256.png 1272w, /__u/substackcdn.com/image/fetch/$s_!KLg-!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fefedf497-d074-41a4-a428-4de50cc65fab_1024x256.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>At a quarter of a minute to noon, the man throws another two gold coins, 5 and 6, into the lake. The mermaid throws back the oldest coin, 3, and keeps the others. So she now has 3 gold coins:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!bUso!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca494226-94a9-4960-9047-d6be5cf7cf5e_1024x256.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!bUso!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca494226-94a9-4960-9047-d6be5cf7cf5e_1024x256.png 424w, /__u/substackcdn.com/image/fetch/$s_!bUso!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca494226-94a9-4960-9047-d6be5cf7cf5e_1024x256.png 848w, /__u/substackcdn.com/image/fetch/$s_!bUso!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca494226-94a9-4960-9047-d6be5cf7cf5e_1024x256.png 1272w, /__u/substackcdn.com/image/fetch/$s_!bUso!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca494226-94a9-4960-9047-d6be5cf7cf5e_1024x256.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!bUso!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca494226-94a9-4960-9047-d6be5cf7cf5e_1024x256.png" width="1024" height="256" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ca494226-94a9-4960-9047-d6be5cf7cf5e_1024x256.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:256,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Infinite mermaid&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="Infinite mermaid" title="Infinite mermaid" srcset="/__u/substackcdn.com/image/fetch/$s_!bUso!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca494226-94a9-4960-9047-d6be5cf7cf5e_1024x256.png 424w, /__u/substackcdn.com/image/fetch/$s_!bUso!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca494226-94a9-4960-9047-d6be5cf7cf5e_1024x256.png 848w, /__u/substackcdn.com/image/fetch/$s_!bUso!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca494226-94a9-4960-9047-d6be5cf7cf5e_1024x256.png 1272w, /__u/substackcdn.com/image/fetch/$s_!bUso!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca494226-94a9-4960-9047-d6be5cf7cf5e_1024x256.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>At an eighth of a minute to noon, the man throws another two gold coins, 7 and 8, into the lake. The mermaid throws back coin 4, but keeps the others. So she now has 4 gold coins:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!7ojt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fea2-c0bc-40c3-b45d-53a7021dd976_1024x256.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!7ojt!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fea2-c0bc-40c3-b45d-53a7021dd976_1024x256.png 424w, /__u/substackcdn.com/image/fetch/$s_!7ojt!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fea2-c0bc-40c3-b45d-53a7021dd976_1024x256.png 848w, /__u/substackcdn.com/image/fetch/$s_!7ojt!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fea2-c0bc-40c3-b45d-53a7021dd976_1024x256.png 1272w, /__u/substackcdn.com/image/fetch/$s_!7ojt!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fea2-c0bc-40c3-b45d-53a7021dd976_1024x256.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!7ojt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fea2-c0bc-40c3-b45d-53a7021dd976_1024x256.png" width="1024" height="256" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eb70fea2-c0bc-40c3-b45d-53a7021dd976_1024x256.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:256,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Infinite mermaid&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="Infinite mermaid" title="Infinite mermaid" srcset="/__u/substackcdn.com/image/fetch/$s_!7ojt!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fea2-c0bc-40c3-b45d-53a7021dd976_1024x256.png 424w, /__u/substackcdn.com/image/fetch/$s_!7ojt!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fea2-c0bc-40c3-b45d-53a7021dd976_1024x256.png 848w, /__u/substackcdn.com/image/fetch/$s_!7ojt!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fea2-c0bc-40c3-b45d-53a7021dd976_1024x256.png 1272w, /__u/substackcdn.com/image/fetch/$s_!7ojt!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb70fea2-c0bc-40c3-b45d-53a7021dd976_1024x256.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This goes on and on, following the same pattern. The man continues throwing coins into the lake, at 1/16 of a minute before noon, 1/32 of a minute before noon, and so on. On each iteration, the time to noon halves.</p><p>One important thing to notice is that, although the time of each iteration gets ever closer to noon, each iteration will always be a finite amount of time <em>before</em> noon. In fact, there will be an infinite number of iterations, but they will all happen before noon. At noon, the wealthy man stops giving coins to the mermaid.</p><h2>The question</h2><p>So here is the question that leads to the paradox. How many coins does the mermaid have at noon, when the wealthy man has stopped giving her gold coins?</p><p>One thing that seems pretty clear. The wealthy man will have thrown a lot of coins, and each time he throws two coins, the mermaid keeps one of the coins. By the end, she will have a lot of coins. That seems completely obvious.</p><p>More than that, the wealthy man will have thrown infinitely many coins, and the mermaid will have kept half of them. And half of infinity is still infinity.</p><p>So, surely, she should have infinitely many coins by noon?</p><h2>The flaw</h2><p>Well, not so fast! There is a problem here.</p><p>On every transaction, she gives a coin back. And not just any coin, but a specific coin. In the first transaction, she gives back coin 1. In the second transaction, she gives back coin 2. Coin number one thousand will be given back in the one thousandth transaction, and coin number one million will be given back in the one millionth transaction. In general, in the nth transaction, she gives back coin <em>n</em>, and the nth transaction will always take place before noon. That will be true for any value of <em>n</em>,</p><p>But every coin has a unique number <em>n</em>, so that means that every coin will be given back at some point before noon.</p><p>Therefore, despite being given infinitely many coins before noon, and despite the number of coins she holds getting larger and larger as the time gets closer and closer to noon, she will have no coins at all by noon.</p><h2>It gets weirder</h2><p>Here is a slight variant that gives a totally different outcome. The wealthy man still gives her two coins, on the same schedule. And she still gives him a coin back each time.</p><p>The only difference is that, instead of giving him the oldest coin, she gives him back one of the coins he just gave her. She will choose the coin with the lowest number.</p><p>Let&#8217;s clarify that with a diagram. At one minute to noon, the wealthy man gives her two coins, 1 and 2, and she gives back coin 1 (exactly as before):</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!OmHR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc977f278-4150-4dd9-ba73-c6ae290e1c02_1024x256.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!OmHR!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc977f278-4150-4dd9-ba73-c6ae290e1c02_1024x256.png 424w, /__u/substackcdn.com/image/fetch/$s_!OmHR!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc977f278-4150-4dd9-ba73-c6ae290e1c02_1024x256.png 848w, /__u/substackcdn.com/image/fetch/$s_!OmHR!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc977f278-4150-4dd9-ba73-c6ae290e1c02_1024x256.png 1272w, /__u/substackcdn.com/image/fetch/$s_!OmHR!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc977f278-4150-4dd9-ba73-c6ae290e1c02_1024x256.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!OmHR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc977f278-4150-4dd9-ba73-c6ae290e1c02_1024x256.png" width="1024" height="256" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c977f278-4150-4dd9-ba73-c6ae290e1c02_1024x256.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:256,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Infinite mermaid&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="Infinite mermaid" title="Infinite mermaid" srcset="/__u/substackcdn.com/image/fetch/$s_!OmHR!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc977f278-4150-4dd9-ba73-c6ae290e1c02_1024x256.png 424w, /__u/substackcdn.com/image/fetch/$s_!OmHR!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc977f278-4150-4dd9-ba73-c6ae290e1c02_1024x256.png 848w, /__u/substackcdn.com/image/fetch/$s_!OmHR!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc977f278-4150-4dd9-ba73-c6ae290e1c02_1024x256.png 1272w, /__u/substackcdn.com/image/fetch/$s_!OmHR!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc977f278-4150-4dd9-ba73-c6ae290e1c02_1024x256.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>At half a minute to noon, he gives another two gold coins into the lake. Again, she gives a coin back, but remember that this time it will be one of the coins she has just been given. So, this time she returns coin 3 rather than coin 2. So she now has 2 gold coins, but they are coins 2 and 4 rather than 3 and 4:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!tGDl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb73f5a9-551b-429e-b048-cc9027275ba2_1024x256.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!tGDl!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb73f5a9-551b-429e-b048-cc9027275ba2_1024x256.png 424w, /__u/substackcdn.com/image/fetch/$s_!tGDl!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb73f5a9-551b-429e-b048-cc9027275ba2_1024x256.png 848w, /__u/substackcdn.com/image/fetch/$s_!tGDl!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb73f5a9-551b-429e-b048-cc9027275ba2_1024x256.png 1272w, /__u/substackcdn.com/image/fetch/$s_!tGDl!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb73f5a9-551b-429e-b048-cc9027275ba2_1024x256.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!tGDl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb73f5a9-551b-429e-b048-cc9027275ba2_1024x256.png" width="1024" height="256" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/db73f5a9-551b-429e-b048-cc9027275ba2_1024x256.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:256,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Infinite mermaid&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="Infinite mermaid" title="Infinite mermaid" srcset="/__u/substackcdn.com/image/fetch/$s_!tGDl!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb73f5a9-551b-429e-b048-cc9027275ba2_1024x256.png 424w, /__u/substackcdn.com/image/fetch/$s_!tGDl!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb73f5a9-551b-429e-b048-cc9027275ba2_1024x256.png 848w, /__u/substackcdn.com/image/fetch/$s_!tGDl!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb73f5a9-551b-429e-b048-cc9027275ba2_1024x256.png 1272w, /__u/substackcdn.com/image/fetch/$s_!tGDl!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdb73f5a9-551b-429e-b048-cc9027275ba2_1024x256.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>At a quarter of a minute to noon, he gives her coins 5 and 6, and she gives back coin 5:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!u9VW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41f9c478-face-47b7-9bb5-d1e02dce6034_1024x256.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!u9VW!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41f9c478-face-47b7-9bb5-d1e02dce6034_1024x256.png 424w, /__u/substackcdn.com/image/fetch/$s_!u9VW!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41f9c478-face-47b7-9bb5-d1e02dce6034_1024x256.png 848w, /__u/substackcdn.com/image/fetch/$s_!u9VW!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41f9c478-face-47b7-9bb5-d1e02dce6034_1024x256.png 1272w, /__u/substackcdn.com/image/fetch/$s_!u9VW!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41f9c478-face-47b7-9bb5-d1e02dce6034_1024x256.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!u9VW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41f9c478-face-47b7-9bb5-d1e02dce6034_1024x256.png" width="1024" height="256" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/41f9c478-face-47b7-9bb5-d1e02dce6034_1024x256.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:256,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Infinite mermaid&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="Infinite mermaid" title="Infinite mermaid" srcset="/__u/substackcdn.com/image/fetch/$s_!u9VW!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41f9c478-face-47b7-9bb5-d1e02dce6034_1024x256.png 424w, /__u/substackcdn.com/image/fetch/$s_!u9VW!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41f9c478-face-47b7-9bb5-d1e02dce6034_1024x256.png 848w, /__u/substackcdn.com/image/fetch/$s_!u9VW!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41f9c478-face-47b7-9bb5-d1e02dce6034_1024x256.png 1272w, /__u/substackcdn.com/image/fetch/$s_!u9VW!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41f9c478-face-47b7-9bb5-d1e02dce6034_1024x256.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>At an eighth of a minute to noon, he gives her coins 7 and 8, and she gives back coin 7:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!gZF6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F931106f6-db9b-4945-b87b-1fbf48641b5f_1024x256.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!gZF6!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F931106f6-db9b-4945-b87b-1fbf48641b5f_1024x256.png 424w, /__u/substackcdn.com/image/fetch/$s_!gZF6!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F931106f6-db9b-4945-b87b-1fbf48641b5f_1024x256.png 848w, /__u/substackcdn.com/image/fetch/$s_!gZF6!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F931106f6-db9b-4945-b87b-1fbf48641b5f_1024x256.png 1272w, /__u/substackcdn.com/image/fetch/$s_!gZF6!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F931106f6-db9b-4945-b87b-1fbf48641b5f_1024x256.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!gZF6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F931106f6-db9b-4945-b87b-1fbf48641b5f_1024x256.png" width="1024" height="256" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/931106f6-db9b-4945-b87b-1fbf48641b5f_1024x256.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:256,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Infinite mermaid&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="Infinite mermaid" title="Infinite mermaid" srcset="/__u/substackcdn.com/image/fetch/$s_!gZF6!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F931106f6-db9b-4945-b87b-1fbf48641b5f_1024x256.png 424w, /__u/substackcdn.com/image/fetch/$s_!gZF6!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F931106f6-db9b-4945-b87b-1fbf48641b5f_1024x256.png 848w, /__u/substackcdn.com/image/fetch/$s_!gZF6!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F931106f6-db9b-4945-b87b-1fbf48641b5f_1024x256.png 1272w, /__u/substackcdn.com/image/fetch/$s_!gZF6!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F931106f6-db9b-4945-b87b-1fbf48641b5f_1024x256.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>At each stage, she receives 2 coins and gives back 1 coin, exactly like the previous example. After the nth round, she has <em>n</em> coins, exactly as before.</p><p>But there is an important difference. She always gives back odd-numbered coins.</p><p>So she will never give back coin 2. She will never give back coin 4. Same for every even coin. By noon, the mermaid will have <em>all</em> the even-numbered coins. There are infinitely many even numbers, so she will have infinitely many coins.</p><h2>What is going on?</h2><p>If someone was watching this process from a distance, they would see the mermaid accepting two coins and giving one back. each time. They wouldn&#8217;t necessarily be aware of exactly which physical coin she was giving back each time. Both situations above would look identical.</p><p>In fact, the coins are all identical, so it makes absolutely no difference which coins she gives back. The mermaid might decide to number the coins as she gives them back, rather than as she receives them:</p><ul><li><p>If the mermaid numbers the coins she gives back as 1, 2, 3 ... then by noon, she will have no coins.</p></li><li><p>If the mermaid numbers the coins she gives back as 1, 3, 5 ... then by noon she will have infinitely many coins.</p></li></ul><p>That would be true even if she gave back the same physical coins in each case. But how can the number of coins she has at the end depend on how she numbers the coins in her own mind?</p><p>Well, for one thing, this situation is entirely hypothetical, for reasons we will see later (for example, nobody really has infinitely many gold coins). When we reason about hypothetical situations, the conclusion we reach can indeed depend on how we think about the problem.</p><p>The particular problem here is that the mermaid is receiving an infinite number of gold coins from the wealthy man, but she is also giving back an infinite number of coins. But <em>infinity isn&#8217;t a number</em>. It might seem like a number, but consider these equations:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!qr38!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d549f35-5a1f-4c7f-b12e-befd85642a83_209x196.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!qr38!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d549f35-5a1f-4c7f-b12e-befd85642a83_209x196.png 424w, /__u/substackcdn.com/image/fetch/$s_!qr38!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d549f35-5a1f-4c7f-b12e-befd85642a83_209x196.png 848w, /__u/substackcdn.com/image/fetch/$s_!qr38!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d549f35-5a1f-4c7f-b12e-befd85642a83_209x196.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qr38!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d549f35-5a1f-4c7f-b12e-befd85642a83_209x196.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!qr38!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d549f35-5a1f-4c7f-b12e-befd85642a83_209x196.png" width="209" height="196" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6d549f35-5a1f-4c7f-b12e-befd85642a83_209x196.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:196,&quot;width&quot;:209,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Infinite mermaid&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="Infinite mermaid" title="Infinite mermaid" srcset="/__u/substackcdn.com/image/fetch/$s_!qr38!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d549f35-5a1f-4c7f-b12e-befd85642a83_209x196.png 424w, /__u/substackcdn.com/image/fetch/$s_!qr38!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d549f35-5a1f-4c7f-b12e-befd85642a83_209x196.png 848w, /__u/substackcdn.com/image/fetch/$s_!qr38!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d549f35-5a1f-4c7f-b12e-befd85642a83_209x196.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qr38!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d549f35-5a1f-4c7f-b12e-befd85642a83_209x196.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>If you add any value <em>x</em> to infinity, you get infinity. Rearranging the last equation gives:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!aOnV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5afbcbb-2713-4214-8013-3261c201907d_210x63.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!aOnV!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5afbcbb-2713-4214-8013-3261c201907d_210x63.png 424w, /__u/substackcdn.com/image/fetch/$s_!aOnV!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5afbcbb-2713-4214-8013-3261c201907d_210x63.png 848w, /__u/substackcdn.com/image/fetch/$s_!aOnV!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5afbcbb-2713-4214-8013-3261c201907d_210x63.png 1272w, /__u/substackcdn.com/image/fetch/$s_!aOnV!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5afbcbb-2713-4214-8013-3261c201907d_210x63.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!aOnV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5afbcbb-2713-4214-8013-3261c201907d_210x63.png" width="210" height="63" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e5afbcbb-2713-4214-8013-3261c201907d_210x63.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:63,&quot;width&quot;:210,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Infinite mermaid&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="Infinite mermaid" title="Infinite mermaid" srcset="/__u/substackcdn.com/image/fetch/$s_!aOnV!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5afbcbb-2713-4214-8013-3261c201907d_210x63.png 424w, /__u/substackcdn.com/image/fetch/$s_!aOnV!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5afbcbb-2713-4214-8013-3261c201907d_210x63.png 848w, /__u/substackcdn.com/image/fetch/$s_!aOnV!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5afbcbb-2713-4214-8013-3261c201907d_210x63.png 1272w, /__u/substackcdn.com/image/fetch/$s_!aOnV!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5afbcbb-2713-4214-8013-3261c201907d_210x63.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>So infinity minus infinity can be anything. When you reason about infinity minus infinity, you can arrive at any number you like.</p><p>For example, the mermaid might end up with just one gold coin. Suppose the mermaid keeps coin number 1, but after that, she always returns the oldest coin. This will be similar to the first example, every coin will be given back at some point, except for coin 1 (which she will keep forever). So in that case, infinity minus infinity will be exactly one.</p><h2>This can&#8217;t happen in reality</h2><p>As we noted earlier, this situation obviously cannot occur in reality, for several reasons:</p><ul><li><p>There is only a certain amount of gold on the planet, so the wealthy man cannot give the mermaid infinitely many coins. At some point, he will run out of coins.</p></li><li><p>This whole thing happens in a minute. It takes a finite amount of time to give the gold coins to the mermaid, and each transaction needs to be twice as fast as the previous one. For example, the twentieth transaction must be completed in about 50 microseconds. The 60th transaction must take place in about 1e-18 seconds, which is about how long it takes light to travel the width of an atom. It is impossible to do anything physical, on a macroscopic scale, in that amount of time.</p></li><li><p>Even if the wealthy man could somehow bring in gold from other parts of the universe, and even if the experiment allowed a lot more time for the transactions, the accumulation of a (literally) astronomical amount of gold in one place would eventually create a black hole.</p></li></ul><p>If we allow for a finite number of transactions, then the paradox disappears. For example, let&#8217;s assume that the wealthy man has 1000 gold coins, and we relax the time constraints to make it possible for all the transactions to take place.</p><p>After 999 transactions, the mermaid will have 999 coins, and the slightly-less-wealthy man will only have 1 coin left, so the game will end.</p><p>That outcome will always be the same, regardless of which coin the mermaid gives back each time. The paradox only arises when there are infinitely many coins.</p>]]></content:encoded></item><item><title><![CDATA[Newcomb's paradox]]></title><description><![CDATA[In Newcomb&#8217;s paradox, there are two boxes:]]></description><link>https://graphicmaths.substack.com/p/newcombs-paradox</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/newcombs-paradox</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Sun, 29 Mar 2026 12:23:24 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!4DTf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff31fa49f-9b2f-4ee4-bcf7-6e0820770778_1000x390.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In Newcomb&#8217;s paradox, there are two boxes:</p><ul><li><p>Box A is open, and contains &#163;1,000.</p></li><li><p>Box B is closed and might either contain nothing or &#163;1,000,000. You have no way of knowing until you make your choice.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!q56Z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b8792a2-61bd-4716-8314-e314045bc0be_500x250.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!q56Z!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b8792a2-61bd-4716-8314-e314045bc0be_500x250.png 424w, /__u/substackcdn.com/image/fetch/$s_!q56Z!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b8792a2-61bd-4716-8314-e314045bc0be_500x250.png 848w, /__u/substackcdn.com/image/fetch/$s_!q56Z!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b8792a2-61bd-4716-8314-e314045bc0be_500x250.png 1272w, /__u/substackcdn.com/image/fetch/$s_!q56Z!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b8792a2-61bd-4716-8314-e314045bc0be_500x250.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!q56Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b8792a2-61bd-4716-8314-e314045bc0be_500x250.png" width="500" height="250" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8b8792a2-61bd-4716-8314-e314045bc0be_500x250.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:250,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Boxes&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&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="Boxes" title="Boxes" srcset="/__u/substackcdn.com/image/fetch/$s_!q56Z!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b8792a2-61bd-4716-8314-e314045bc0be_500x250.png 424w, /__u/substackcdn.com/image/fetch/$s_!q56Z!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b8792a2-61bd-4716-8314-e314045bc0be_500x250.png 848w, /__u/substackcdn.com/image/fetch/$s_!q56Z!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b8792a2-61bd-4716-8314-e314045bc0be_500x250.png 1272w, /__u/substackcdn.com/image/fetch/$s_!q56Z!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b8792a2-61bd-4716-8314-e314045bc0be_500x250.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 aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 have two choices:</p><ul><li><p>You can choose to take both boxes. That is, box A (which contains &#163;1,000) and box B (with unknown content).</p></li><li><p>You can choose to take only box B, with unknown content.</p></li></ul><p>Now this might seem very easy. In both cases, you get whatever is in box B, but in the first case, you also get box A as well.</p><p>But wait, there is one extra factor which might make you change your mind (or it might not). The content of box B is not random. In fact, a super-intelligent AI system has predicted what choice you will make, and decided the content of box B using the following rule:</p><ul><li><p>If the computer predicts that you will take both boxes, then it will have left box B empty.</p></li><li><p>If the computer predicts that you will only take box B, then it will have filled box B with a million pounds.</p></li></ul><p>The computer has already made its prediction, so box B either contains a million pounds or not, depending on what it predicted. But quite a few people have played the game already, and the computer guessed correctly in every case.</p><p>There are two main views of this paradox. Both views have plenty of supporters, but many people on both sides find it impossible to understand why anyone supports the opposing view.</p><p><em>If you are interested in Calculus, my book is now available from <a href="https://martinmcbride.gumroad.com/l/calculus-book">Gumroad</a>.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/subscribe"><span>Subscribe now</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://graphicmaths.substack.com/p/newcombs-paradox?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/graphicmaths.substack.com/p/newcombs-paradox?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share</span></a></p><h2>The two-boxer argument</h2><p>Some people look at the problem in this way. Before you have even decided what to do, box A already has &#163;1,000 in it. Box B already has either &#163;1,000,000 or nothing. That has already been fixed and cannot change.</p><p>In that case, it is always better to take both boxes. The table below shows the different possibilities.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!4DTf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff31fa49f-9b2f-4ee4-bcf7-6e0820770778_1000x390.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!4DTf!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff31fa49f-9b2f-4ee4-bcf7-6e0820770778_1000x390.png 424w, /__u/substackcdn.com/image/fetch/$s_!4DTf!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff31fa49f-9b2f-4ee4-bcf7-6e0820770778_1000x390.png 848w, /__u/substackcdn.com/image/fetch/$s_!4DTf!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff31fa49f-9b2f-4ee4-bcf7-6e0820770778_1000x390.png 1272w, /__u/substackcdn.com/image/fetch/$s_!4DTf!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff31fa49f-9b2f-4ee4-bcf7-6e0820770778_1000x390.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!4DTf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff31fa49f-9b2f-4ee4-bcf7-6e0820770778_1000x390.png" width="1000" height="390" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f31fa49f-9b2f-4ee4-bcf7-6e0820770778_1000x390.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:390,&quot;width&quot;:1000,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Two boxer argument&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="Two boxer argument" title="Two boxer argument" srcset="/__u/substackcdn.com/image/fetch/$s_!4DTf!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff31fa49f-9b2f-4ee4-bcf7-6e0820770778_1000x390.png 424w, /__u/substackcdn.com/image/fetch/$s_!4DTf!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff31fa49f-9b2f-4ee4-bcf7-6e0820770778_1000x390.png 848w, /__u/substackcdn.com/image/fetch/$s_!4DTf!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff31fa49f-9b2f-4ee4-bcf7-6e0820770778_1000x390.png 1272w, /__u/substackcdn.com/image/fetch/$s_!4DTf!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff31fa49f-9b2f-4ee4-bcf7-6e0820770778_1000x390.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 two entries show the situation when box B happens to be empty. In that case, the one-box strategy (ie, taking just box B) would give a total return of zero, but the two-box strategy (ie taking both boxes) would give a total return of &#163;1,000.</p><p>The last two entries show the situation when box B contains &#163;1,000,000. This time, the one-box strategy would give a total of &#163;1,000,000, but the two-box strategy would give slightly more, &#163;1,001,000.</p><p>This means that the two-box strategy will always give a higher return than the one-box strategy.</p><h2>The one boxer argument</h2><p>The one boxer argument is very simple. Looking at all the past results, people who chose one box always walked away with &#163;1,000,000. This is because the computer predicted that they would choose one box, and so it put the million in box B.</p><p>Also, people who took two boxes always walked away with just &#163;1,000. That is because the computer predicted that they would choose two boxes, and so left box B empty.</p><p>Based on that, it is obviously better to be a one boxer.</p><h2>The problem with the one boxer argument</h2><p>The problem with the one-boxer argument is that the contents of box B were already decided before you entered the room to make your choice. The box already either contains a million or not, depending on the computer&#8217;s prediction.</p><p>If you are naturally a two-boxer, the computer knows that, so box B will be empty. If you make a last-minute decision, totally against your nature, to only take box B, then you will be a one-boxer. But box B will still be empty, because the computer predicted you would be a two-boxer. So you would lose everything, even the second prize of &#163;1,000.</p><p>Unless, of course, the computer predicted that you would change your mind at the last minute, and therefore put the million pounds in the box.</p><p>For this reason, some people say that this is an ill-posed question. We have some mysterious computer with some mysterious method of guessing what you are going to decide. But we are given no clue as to how that works. The computer cannot see into the future, so there must be some limits to its predictive powers. But we are being asked to reason about those powers without being told how they work.</p><h2>A further thought experiment</h2><p>Suppose you adopted the following strategy. Rather than deciding which option to take, you toss a fair coin. If it is heads, you take one box. If it is tails, you take two.</p><p>It might be reasonable to assume that the computer is smart enough to predict that you would use a coin to make your choice. But it can&#8217;t predict what the outcome of the coin toss will be, that is truly random. So it must decide whether to put the million pounds in box B before it can possibly know what you will do.</p><p>We are now in uncharted territory. What will the computer do if it can&#8217;t predict what you will do? Who knows, we have only been told that the computer has some mysterious method of predicting what you will do. We have absolutely no idea what it might do if it knows that it can&#8217;t make a reliable prediction. Does it have special rules or some built-in priorities? This is one reason why we might say the question is ill-posed.</p><h2>Changing the amounts - Pascal&#8217;s Wager</h2><p>This paradox has an interesting parallel with <em>Pascal&#8217;s Wager</em>. The mathematician Blaise Pascal suggested that living your life as if God existed was the only rational choice. His reasoning was that:</p><ul><li><p>If God exists, then living your life according to his rules means that you will spend the rest of eternity in paradise.</p></li><li><p>If God does not exist, then you will have lost very little. You will simply have lived your life following a few rules that you didn&#8217;t really need to follow.</p></li></ul><p>Pascal argued that you should live your life as if God exists because the benefits if it turns out to be true massively outweigh the loss if it turns out to be false, so the logical choice is to behave as if God exists.</p><p>The same might be true of the one boxer argument. &#163;1,000 is quite a lot of money. It is roughly equivalent to one or two weeks&#8217; salary for many people. But &#163;1,000,000 is a life-changing sum. Some people might be willing to risk &#163;1,000 to win &#163;1,000,000, without thinking too much about what the odds are.</p><p>The one-boxer position appears to be based on the assumption that the computer has extraordinary powers of prediction. But in reality, the computer might just be guessing one single aspect of your personality - your attitude to risk.</p><p>Suppose, for example, box A contained &#163;500,000 and box B contained &#163;1,000,000. The logical basis of the paradox wouldn&#8217;t change. But how many one-boxers would there be in that situation? Who would risk the certainty of getting half a million for the chance of getting a million?</p><p>Although, of course, the computer would know that, and would adjust its predictions accordingly.</p><h2>Summary</h2><p>My personal opinion is that this is not a well-posed problem. We are presented with a computer with seemingly magical powers, and we need to reason about how it would behave. And since there are situations where the computer cannot predict what you will do (for example, if you had chosen to toss a coin), that doesn&#8217;t seem to be a reasonable question.</p><p>What do you think?</p>]]></content:encoded></item><item><title><![CDATA[Understanding convolution using a moving average filter]]></title><description><![CDATA[Convolution can be quite a difficult concept to get to grips with.]]></description><link>https://graphicmaths.substack.com/p/understanding-convolution-using-a</link><guid isPermaLink="false">https://graphicmaths.substack.com/p/understanding-convolution-using-a</guid><dc:creator><![CDATA[Martin McBride]]></dc:creator><pubDate>Fri, 20 Mar 2026 17:11:26 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Nq3A!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F227632a3-b373-4230-bb84-f4e3de4b396b_500x500.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Convolution can be quite a difficult concept to get to grips with. This article uses a simple application, a moving average filter, to help visualise the process.</p><h2>An example signal</h2><p>Here is a function that represents our &#8220;signal&#8221;. Convolution, of course, is a mathematical process that operates on mathematical functions, but in many practical applications, those functions might represent physical signals. For example, this function might represent a sound:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Hrsn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F429fa78b-3b6b-4390-8597-075777ca0321_500x250.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Hrsn!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F429fa78b-3b6b-4390-8597-075777ca0321_500x250.png 424w, /__u/substackcdn.com/image/fetch/$s_!Hrsn!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F429fa78b-3b6b-4390-8597-075777ca0321_500x250.png 848w, /__u/substackcdn.com/image/fetch/$s_!Hrsn!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F429fa78b-3b6b-4390-8597-075777ca0321_500x250.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Hrsn!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F429fa78b-3b6b-4390-8597-075777ca0321_500x250.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Hrsn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F429fa78b-3b6b-4390-8597-075777ca0321_500x250.png" width="500" height="250" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/429fa78b-3b6b-4390-8597-075777ca0321_500x250.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:250,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Example signal&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&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="Example signal" title="Example signal" srcset="/__u/substackcdn.com/image/fetch/$s_!Hrsn!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F429fa78b-3b6b-4390-8597-075777ca0321_500x250.png 424w, /__u/substackcdn.com/image/fetch/$s_!Hrsn!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F429fa78b-3b6b-4390-8597-075777ca0321_500x250.png 848w, /__u/substackcdn.com/image/fetch/$s_!Hrsn!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F429fa78b-3b6b-4390-8597-075777ca0321_500x250.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Hrsn!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F429fa78b-3b6b-4390-8597-075777ca0321_500x250.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 aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 might see this signal on an oscilloscope measuring a voltage in an electronic amplifier that will eventually be converted to sound waves by a speaker. Although in this case, the signal shown has an oscillation period of several seconds, so humans would not detect it as a sound.</p><p>Since this is a time-varying signal, the horizontal axis represents time, <em>t</em>, rather than <em>x</em>. We will call the function above <em>f(t)</em>.</p><h2>A simple filter</h2><p>Let&#8217;s suppose we wanted to modify this signal by smoothing out some of the smaller bumps in the function. This would have the audible effect of increasing the bass and decreasing the treble, sometimes called a lowpass filter.</p><p>One simple way to do that would be a <em>moving average filter</em>. In this type of filter, the output consists of the average value of the signal over a certain period of time. As an example, we will take the average value of the signal for the previous 1-second period.</p><p>In the graph below, the top curve shows the input function from earlier. The bottom graph shows the filtered function, which we will call <em>w(t)</em>. To find the value of <em>w(t)</em> at point <em>a</em> (when <em>t</em> is 0), we simply need to find the average value of the input function between <em>t</em> values of -1 and 0. This region is shown shaded on the top graph. It is the average value of the shaded region on the left, and is a positive value.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Nq3A!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F227632a3-b373-4230-bb84-f4e3de4b396b_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Nq3A!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F227632a3-b373-4230-bb84-f4e3de4b396b_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!Nq3A!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F227632a3-b373-4230-bb84-f4e3de4b396b_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!Nq3A!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F227632a3-b373-4230-bb84-f4e3de4b396b_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Nq3A!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F227632a3-b373-4230-bb84-f4e3de4b396b_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Nq3A!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F227632a3-b373-4230-bb84-f4e3de4b396b_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/227632a3-b373-4230-bb84-f4e3de4b396b_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Simple filter&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="Simple filter" title="Simple filter" srcset="/__u/substackcdn.com/image/fetch/$s_!Nq3A!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F227632a3-b373-4230-bb84-f4e3de4b396b_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!Nq3A!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F227632a3-b373-4230-bb84-f4e3de4b396b_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!Nq3A!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F227632a3-b373-4230-bb84-f4e3de4b396b_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Nq3A!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F227632a3-b373-4230-bb84-f4e3de4b396b_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Point <em>b</em> on the lower graph (when <em>t</em> is 4) represents the average value of the function between <em>t</em> values of 3 and 4, and this time it is a negative value.</p><p>Of course, we can find the value of the lower graph for any value of <em>t</em>. It is simply the average value of the top graph over the range <em>(t - 1)</em> to <em>t</em>.</p><h2>Calculating the value of w(t)</h2><p>We can calculate the value of for any value of using integration. The average value of <em>f(t)</em> is given by the area under the curve, divided by the width of the region. In our case, the width of the region is 1, so the average value is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!uZ0n!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fccb74e-3d8f-464e-a728-c382fd9fb812_420x129.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!uZ0n!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fccb74e-3d8f-464e-a728-c382fd9fb812_420x129.png 424w, /__u/substackcdn.com/image/fetch/$s_!uZ0n!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fccb74e-3d8f-464e-a728-c382fd9fb812_420x129.png 848w, /__u/substackcdn.com/image/fetch/$s_!uZ0n!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fccb74e-3d8f-464e-a728-c382fd9fb812_420x129.png 1272w, /__u/substackcdn.com/image/fetch/$s_!uZ0n!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fccb74e-3d8f-464e-a728-c382fd9fb812_420x129.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!uZ0n!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fccb74e-3d8f-464e-a728-c382fd9fb812_420x129.png" width="420" height="129" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9fccb74e-3d8f-464e-a728-c382fd9fb812_420x129.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:129,&quot;width&quot;:420,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Value of w(t)&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="Value of w(t)" title="Value of w(t)" srcset="/__u/substackcdn.com/image/fetch/$s_!uZ0n!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fccb74e-3d8f-464e-a728-c382fd9fb812_420x129.png 424w, /__u/substackcdn.com/image/fetch/$s_!uZ0n!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fccb74e-3d8f-464e-a728-c382fd9fb812_420x129.png 848w, /__u/substackcdn.com/image/fetch/$s_!uZ0n!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fccb74e-3d8f-464e-a728-c382fd9fb812_420x129.png 1272w, /__u/substackcdn.com/image/fetch/$s_!uZ0n!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9fccb74e-3d8f-464e-a728-c382fd9fb812_420x129.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We have used the Greek letter &#120591; (<em>tau</em>) as the variable of integration, but notice that <em>w</em> is a function of <em>t</em>, not &#120591;. For example, when <em>t</em> is, the integral will find the area under the curve between -1 and 0, corresponding to point <em>a</em> above. When <em>t</em> is 4, it will find the area between 3 and 4, corresponding to point <em>b</em>, and so on.</p><h2>Using a function instead of varying the limits</h2><p>In the integral above, we change the limits of the integral to determine the region that we are interested in (for example, using limits of 3 to 4 to find the average value over that region). But there is an alternative method, illustrated by this graph:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!ukJ4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14408f65-3626-41dc-bfd4-39f7beb64aff_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!ukJ4!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14408f65-3626-41dc-bfd4-39f7beb64aff_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!ukJ4!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14408f65-3626-41dc-bfd4-39f7beb64aff_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!ukJ4!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14408f65-3626-41dc-bfd4-39f7beb64aff_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ukJ4!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14408f65-3626-41dc-bfd4-39f7beb64aff_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!ukJ4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14408f65-3626-41dc-bfd4-39f7beb64aff_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/14408f65-3626-41dc-bfd4-39f7beb64aff_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Value of w(t)&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="Value of w(t)" title="Value of w(t)" srcset="/__u/substackcdn.com/image/fetch/$s_!ukJ4!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14408f65-3626-41dc-bfd4-39f7beb64aff_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!ukJ4!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14408f65-3626-41dc-bfd4-39f7beb64aff_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!ukJ4!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14408f65-3626-41dc-bfd4-39f7beb64aff_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ukJ4!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14408f65-3626-41dc-bfd4-39f7beb64aff_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 top graph shows our original function <em>f(t)</em> in blue, and a new function <em>g(t)</em> in red. <em>g(t)</em> is defined by:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!0uDS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729eb75d-5674-4082-bc3b-c1c54ef92a85_382x144.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!0uDS!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729eb75d-5674-4082-bc3b-c1c54ef92a85_382x144.png 424w, /__u/substackcdn.com/image/fetch/$s_!0uDS!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729eb75d-5674-4082-bc3b-c1c54ef92a85_382x144.png 848w, /__u/substackcdn.com/image/fetch/$s_!0uDS!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729eb75d-5674-4082-bc3b-c1c54ef92a85_382x144.png 1272w, /__u/substackcdn.com/image/fetch/$s_!0uDS!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729eb75d-5674-4082-bc3b-c1c54ef92a85_382x144.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!0uDS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729eb75d-5674-4082-bc3b-c1c54ef92a85_382x144.png" width="382" height="144" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/729eb75d-5674-4082-bc3b-c1c54ef92a85_382x144.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:144,&quot;width&quot;:382,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Value of g(t)&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="Value of g(t)" title="Value of g(t)" srcset="/__u/substackcdn.com/image/fetch/$s_!0uDS!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729eb75d-5674-4082-bc3b-c1c54ef92a85_382x144.png 424w, /__u/substackcdn.com/image/fetch/$s_!0uDS!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729eb75d-5674-4082-bc3b-c1c54ef92a85_382x144.png 848w, /__u/substackcdn.com/image/fetch/$s_!0uDS!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729eb75d-5674-4082-bc3b-c1c54ef92a85_382x144.png 1272w, /__u/substackcdn.com/image/fetch/$s_!0uDS!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729eb75d-5674-4082-bc3b-c1c54ef92a85_382x144.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>It is a <em>gating function</em> that has value 1 between 0 and 1, and 0 everywhere else.</p><p>The bottom graph shows <em>g</em> multiplied by <em>f</em>. It has the value of <em>f</em> for <em>t</em> between 0 and 1, and 0 everywhere else. The useful thing about this function is that we can integrate it from -infinity to +infinity and get the same result as we would get by integrating for 0 to 1 (because the function is 0 outside that range). So we can write <em>w(1)</em> like this:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!CTkD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43acb3d4-6895-4793-955a-6f64ab72ad9e_385x124.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!CTkD!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43acb3d4-6895-4793-955a-6f64ab72ad9e_385x124.png 424w, /__u/substackcdn.com/image/fetch/$s_!CTkD!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43acb3d4-6895-4793-955a-6f64ab72ad9e_385x124.png 848w, /__u/substackcdn.com/image/fetch/$s_!CTkD!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43acb3d4-6895-4793-955a-6f64ab72ad9e_385x124.png 1272w, /__u/substackcdn.com/image/fetch/$s_!CTkD!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43acb3d4-6895-4793-955a-6f64ab72ad9e_385x124.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!CTkD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43acb3d4-6895-4793-955a-6f64ab72ad9e_385x124.png" width="385" height="124" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/43acb3d4-6895-4793-955a-6f64ab72ad9e_385x124.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:124,&quot;width&quot;:385,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Value of w(t)&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="Value of w(t)" title="Value of w(t)" srcset="/__u/substackcdn.com/image/fetch/$s_!CTkD!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43acb3d4-6895-4793-955a-6f64ab72ad9e_385x124.png 424w, /__u/substackcdn.com/image/fetch/$s_!CTkD!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43acb3d4-6895-4793-955a-6f64ab72ad9e_385x124.png 848w, /__u/substackcdn.com/image/fetch/$s_!CTkD!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43acb3d4-6895-4793-955a-6f64ab72ad9e_385x124.png 1272w, /__u/substackcdn.com/image/fetch/$s_!CTkD!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43acb3d4-6895-4793-955a-6f64ab72ad9e_385x124.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Notice that this is <em>w(1)</em> rather than <em>w(0)</em> because the range starts at 0 and ends at 1. We will address this later.</p><p>Now let&#8217;s look at this graph:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!J-pj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7aee754-2257-4acb-9214-7e818e8a18df_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!J-pj!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7aee754-2257-4acb-9214-7e818e8a18df_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!J-pj!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7aee754-2257-4acb-9214-7e818e8a18df_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!J-pj!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7aee754-2257-4acb-9214-7e818e8a18df_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!J-pj!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7aee754-2257-4acb-9214-7e818e8a18df_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!J-pj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7aee754-2257-4acb-9214-7e818e8a18df_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c7aee754-2257-4acb-9214-7e818e8a18df_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Value of w(t)&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="Value of w(t)" title="Value of w(t)" srcset="/__u/substackcdn.com/image/fetch/$s_!J-pj!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7aee754-2257-4acb-9214-7e818e8a18df_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!J-pj!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7aee754-2257-4acb-9214-7e818e8a18df_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!J-pj!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7aee754-2257-4acb-9214-7e818e8a18df_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!J-pj!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7aee754-2257-4acb-9214-7e818e8a18df_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" 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 red function is similar to <em>g(t)</em>, but shifted by 4 along the time axis. We will call this new function <em>gs</em>. When we multiply <em>gs</em> by <em>f</em>, we get a new function that is equal to <em>f</em> when <em>t</em> is between 4 and 5, but 0 everywhere else. The integral of <em>gs</em> times <em>f</em> is:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!qLa6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86d069f3-30ab-404c-a25f-13e5c0aa37df_400x124.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!qLa6!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86d069f3-30ab-404c-a25f-13e5c0aa37df_400x124.png 424w, /__u/substackcdn.com/image/fetch/$s_!qLa6!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86d069f3-30ab-404c-a25f-13e5c0aa37df_400x124.png 848w, /__u/substackcdn.com/image/fetch/$s_!qLa6!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86d069f3-30ab-404c-a25f-13e5c0aa37df_400x124.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qLa6!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86d069f3-30ab-404c-a25f-13e5c0aa37df_400x124.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!qLa6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86d069f3-30ab-404c-a25f-13e5c0aa37df_400x124.png" width="400" height="124" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/86d069f3-30ab-404c-a25f-13e5c0aa37df_400x124.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:124,&quot;width&quot;:400,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Value of w(t)&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="Value of w(t)" title="Value of w(t)" srcset="/__u/substackcdn.com/image/fetch/$s_!qLa6!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86d069f3-30ab-404c-a25f-13e5c0aa37df_400x124.png 424w, /__u/substackcdn.com/image/fetch/$s_!qLa6!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86d069f3-30ab-404c-a25f-13e5c0aa37df_400x124.png 848w, /__u/substackcdn.com/image/fetch/$s_!qLa6!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86d069f3-30ab-404c-a25f-13e5c0aa37df_400x124.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qLa6!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F86d069f3-30ab-404c-a25f-13e5c0aa37df_400x124.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This integral, of course, gives us <em>w(5)</em>. Now we can simplify this further. We know from elementary mathematics that we can shift a function horizontally by subtracting a constant from its argument. In other words, we can write <em>gs(t)</em> (ie <em>g(t)</em> shifted by 4) as <em>g(t - 4)</em>. So we can write:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!F9GJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76888fd1-2520-4b24-9aee-814f412914a1_440x124.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!F9GJ!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76888fd1-2520-4b24-9aee-814f412914a1_440x124.png 424w, /__u/substackcdn.com/image/fetch/$s_!F9GJ!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76888fd1-2520-4b24-9aee-814f412914a1_440x124.png 848w, /__u/substackcdn.com/image/fetch/$s_!F9GJ!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76888fd1-2520-4b24-9aee-814f412914a1_440x124.png 1272w, /__u/substackcdn.com/image/fetch/$s_!F9GJ!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76888fd1-2520-4b24-9aee-814f412914a1_440x124.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!F9GJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76888fd1-2520-4b24-9aee-814f412914a1_440x124.png" width="440" height="124" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/76888fd1-2520-4b24-9aee-814f412914a1_440x124.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:124,&quot;width&quot;:440,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Value of w(t)&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="Value of w(t)" title="Value of w(t)" srcset="/__u/substackcdn.com/image/fetch/$s_!F9GJ!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76888fd1-2520-4b24-9aee-814f412914a1_440x124.png 424w, /__u/substackcdn.com/image/fetch/$s_!F9GJ!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76888fd1-2520-4b24-9aee-814f412914a1_440x124.png 848w, /__u/substackcdn.com/image/fetch/$s_!F9GJ!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76888fd1-2520-4b24-9aee-814f412914a1_440x124.png 1272w, /__u/substackcdn.com/image/fetch/$s_!F9GJ!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76888fd1-2520-4b24-9aee-814f412914a1_440x124.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>And in general, we can say that:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!gxRi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F467c9104-425d-4c25-a1ed-2250812c17d8_486x124.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!gxRi!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F467c9104-425d-4c25-a1ed-2250812c17d8_486x124.png 424w, /__u/substackcdn.com/image/fetch/$s_!gxRi!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F467c9104-425d-4c25-a1ed-2250812c17d8_486x124.png 848w, /__u/substackcdn.com/image/fetch/$s_!gxRi!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F467c9104-425d-4c25-a1ed-2250812c17d8_486x124.png 1272w, /__u/substackcdn.com/image/fetch/$s_!gxRi!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F467c9104-425d-4c25-a1ed-2250812c17d8_486x124.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!gxRi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F467c9104-425d-4c25-a1ed-2250812c17d8_486x124.png" width="486" height="124" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/467c9104-425d-4c25-a1ed-2250812c17d8_486x124.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:124,&quot;width&quot;:486,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Value of w(t)&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="Value of w(t)" title="Value of w(t)" srcset="/__u/substackcdn.com/image/fetch/$s_!gxRi!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F467c9104-425d-4c25-a1ed-2250812c17d8_486x124.png 424w, /__u/substackcdn.com/image/fetch/$s_!gxRi!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F467c9104-425d-4c25-a1ed-2250812c17d8_486x124.png 848w, /__u/substackcdn.com/image/fetch/$s_!gxRi!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F467c9104-425d-4c25-a1ed-2250812c17d8_486x124.png 1272w, /__u/substackcdn.com/image/fetch/$s_!gxRi!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F467c9104-425d-4c25-a1ed-2250812c17d8_486x124.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Just like our original equation (1) above, this is a function of <em>t</em>. But this time <em>t</em> is part of the integrand rather than being part of the integral limits, which generally makes things easier, as we will see.</p><p>The equation above is the basis of a process called <em>convolution</em>, although we need to do a bit more work to get to the final definition.</p><h2>Improving the formula</h2><p>There is a small problem. When we plug some value <em>t</em> into the integral, we end up with <em>w(t + 1)</em>. Now this might seem like a very minor problem. Perhaps we could just add a 1 into the integrand as a fudge factor to make it all work?</p><p>Unfortunately, it isn&#8217;t that simple. The reason the function is shifted by 1 is that we happen to be using a moving average filter with a width of 1. If we had chosen a width of 2, a fudge factor of 2 would be required. If we had chosen to use a weighted average rather than a gated average, we might need to use some other value.</p><p>There is a simple fix, but it leads to an aspect of convolution that people often find confusing. Hopefully, understanding why it is necessary will make it less confusing.</p><p>The top graph below shows <em>g(t)</em>, where the function has value 1 from time 0 to 1. The bottom graph shows the function we require, which has a value of 1 for time -1 to 0. How do we transform one into the other?</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!IKiA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98e8a88d-bdc6-4f7a-95f7-e545960361d6_500x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!IKiA!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98e8a88d-bdc6-4f7a-95f7-e545960361d6_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!IKiA!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98e8a88d-bdc6-4f7a-95f7-e545960361d6_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!IKiA!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98e8a88d-bdc6-4f7a-95f7-e545960361d6_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!IKiA!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98e8a88d-bdc6-4f7a-95f7-e545960361d6_500x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!IKiA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98e8a88d-bdc6-4f7a-95f7-e545960361d6_500x500.png" width="500" height="500" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/98e8a88d-bdc6-4f7a-95f7-e545960361d6_500x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:500,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Value of w(t)&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="Value of w(t)" title="Value of w(t)" srcset="/__u/substackcdn.com/image/fetch/$s_!IKiA!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98e8a88d-bdc6-4f7a-95f7-e545960361d6_500x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!IKiA!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98e8a88d-bdc6-4f7a-95f7-e545960361d6_500x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!IKiA!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98e8a88d-bdc6-4f7a-95f7-e545960361d6_500x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!IKiA!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98e8a88d-bdc6-4f7a-95f7-e545960361d6_500x500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>One way would be to shift the function to the left by one second. That would be our fudge factor, mentioned above. But we don&#8217;t want to do that, because different functions might require shifting by different amounts.</p><p>The alternative way is to mirror the function, horizontally, about the y-axis. This operation will always lead to the falling edge of the function being at 0, no matter how wide the raised region of the function is. This is what we will do, and it is actually built into the definition of the convolution integral.</p><p>An advantage of this technique is that it is very easy to flip a function about the y-axis. We simply need to negate the argument. For any function <em>g(t)</em>, the function <em>g(-t)</em> is the same function, flipped about the y-axis.</p><p>In our case, our integral is based on <em>g(t - &#120591;)</em>, so to flip it we just need to use <em>g(&#120591; - t)</em> instead:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!VD9m!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff225a51e-2578-4f86-b905-9cefb575bcc4_431x124.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!VD9m!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff225a51e-2578-4f86-b905-9cefb575bcc4_431x124.png 424w, /__u/substackcdn.com/image/fetch/$s_!VD9m!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff225a51e-2578-4f86-b905-9cefb575bcc4_431x124.png 848w, /__u/substackcdn.com/image/fetch/$s_!VD9m!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff225a51e-2578-4f86-b905-9cefb575bcc4_431x124.png 1272w, /__u/substackcdn.com/image/fetch/$s_!VD9m!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_webp, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff225a51e-2578-4f86-b905-9cefb575bcc4_431x124.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!VD9m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff225a51e-2578-4f86-b905-9cefb575bcc4_431x124.png" width="431" height="124" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f225a51e-2578-4f86-b905-9cefb575bcc4_431x124.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:124,&quot;width&quot;:431,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Value of w(t)&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="Value of w(t)" title="Value of w(t)" srcset="/__u/substackcdn.com/image/fetch/$s_!VD9m!, /__u/graphicmaths.substack.com/w_424, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff225a51e-2578-4f86-b905-9cefb575bcc4_431x124.png 424w, /__u/substackcdn.com/image/fetch/$s_!VD9m!, /__u/graphicmaths.substack.com/w_848, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff225a51e-2578-4f86-b905-9cefb575bcc4_431x124.png 848w, /__u/substackcdn.com/image/fetch/$s_!VD9m!, /__u/graphicmaths.substack.com/w_1272, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff225a51e-2578-4f86-b905-9cefb575bcc4_431x124.png 1272w, /__u/substackcdn.com/image/fetch/$s_!VD9m!, /__u/graphicmaths.substack.com/w_1456, /__u/graphicmaths.substack.com/c_limit, /__u/graphicmaths.substack.com/f_auto, /__u/graphicmaths.substack.com/q_auto:good, /__u/graphicmaths.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff225a51e-2578-4f86-b905-9cefb575bcc4_431x124.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This integral defines the process of convolution.</p>]]></content:encoded></item></channel></rss>